# Makefile for sbox-fastcgi
VERSION= 1.01


CC = gcc
#CC = cc

COPTS = -O -g
#COPTS = -g -DDEBUG
#COPTS = -W -Wall -ansi -pedantic

STATIC_FLAG = -static

INSTALL_OPTS = -o root -g bin -m 4111 -s
INSTALL_DIRECTORY = /usr/lib/apache/

CFLAGS = $(COPTS) -DVERSION=$(VERSION)
INSTALL = install
LYNX    = lynx
PURIFY  = purify -chain-length="10" cc -g 

all: sbox-fastcgi env

sbox: sbox-fastcgi.o
	$(CC) $(LDOPTS) -o sbox-fastcgi sbox-fastcgi.o

sbox-fastcgi.o: sbox-fastcgi.c sbox-fastcgi.h Makefile

sbox_pure: sbox-fastcgi.o
	$(PURIFY) -o $@ sbox-fastcgi.o

env: env.o
	$(CC) $(STATIC_FLAG) -o env env.o

README.txt: README.html
	$(LYNX) -nolist -underscore -dump $< > $@

clean:
	rm -f *.o core sbox-fastcgi env

install: sbox-fastcgi
	$(INSTALL) $(INSTALL_OPTS) sbox-fastcgi $(INSTALL_DIRECTORY)

dist:	sbox-fastcgi.h sbox-fastcgi.c env.c Makefile
	-mkdir sbox-fastcgi-$(VERSION)
	cp README.txt README_FCGI.txt sbox-fastcgi.h sbox-fastcgi.c env.c Makefile sbox-fastcgi-$(VERSION)
	tar cvf - sbox-fastcgi-$(VERSION) | gzip -9c > sbox-fastcgi-$(VERSION).tgz
	rm -rf sbox-fastcgi-$(VERSION)
