# Don't edit Makefile!  Use conf-* for configuration.
#
# Generated by spac see http://untroubled.org/spac/

SHELL=/bin/sh

DEFAULT: all

all: libraries programs docs

auth-lib.o: compile auth-lib.c auth-lib.h ucspi-proxy.h
	./compile auth-lib.c

base64.o: compile base64.c ucspi-proxy.h
	./compile base64.c

clean: TARGETS
	rm -f `cat TARGETS`

clean-spac: clean AUTOFILES
	rm -f `cat AUTOFILES`

compile: conf-cc conf-bgincs
	( bgincs=`head -n 1 conf-bgincs`; \
	  echo '#!/bin/sh'; \
	  echo 'source=$$1; shift'; \
	  echo 'base=`echo "$$source" | sed -e s:\\\\.c$$::`'; \
	  echo exec `head -n 1 conf-cc` -I. "-I'$${bgincs}'" '-o $${base}.o -c $$source $${1+"$$@"}'; \
	) >compile
	chmod 755 compile

docs: ucspi-proxy.1.html ucspi-proxy-http-xlate.1.html

http-xlate-filter.o: compile http-xlate-filter.c ucspi-proxy.h
	./compile http-xlate-filter.c

imap-filter.o: compile imap-filter.c auth-lib.h ucspi-proxy.h
	./compile imap-filter.c

install: INSTHIER conf-bin conf-man
	bg-installer -v <INSTHIER
	bg-installer -c <INSTHIER

libraries: ucspi-proxy.a

load: conf-ld conf-bglibs
	( bglibs=`head -n 1 conf-bglibs`; \
	  echo '#!/bin/sh';\
	  echo 'main="$$1"; shift';\
	  echo exec `head -n 1 conf-ld` -L. "-L'$${bglibs}'" "-Wl,-R'$${bglibs}'" '-o "$$main" "$$main.o" $${1+"$$@"}' -lbg-sysdeps; \
	) >load
	chmod 755 load

log-filter.o: compile log-filter.c ucspi-proxy.h
	./compile log-filter.c

makelib: 
	( echo '#!/bin/sh'; \
	  echo 'lib="$$1"; shift';\
	  echo 'rm -f "$$lib"';\
	  echo 'ar cr "$$lib" $${1+"$$@"}';\
	  echo 'ranlib "$$lib"';\
	) >makelib
	chmod 755 makelib

null-filter.o: compile null-filter.c ucspi-proxy.h
	./compile null-filter.c

pop3-filter.o: compile pop3-filter.c auth-lib.h ucspi-proxy.h
	./compile pop3-filter.c

programs: ucspi-proxy-pop3 ucspi-proxy-http-xlate ucspi-proxy ucspi-proxy-log ucspi-proxy-imap

relay-filter.o: compile relay-filter.c ucspi-proxy.h
	./compile relay-filter.c

tcp-connect.o: compile tcp-connect.c ucspi-proxy.h
	./compile tcp-connect.c

ucspi-proxy: ucspi-proxy.o load null-filter.o ucspi-proxy.a
	./load ucspi-proxy null-filter.o ucspi-proxy.a -lbg 

ucspi-proxy-http-xlate: ucspi-proxy-http-xlate.o load http-xlate-filter.o ucspi-proxy.a
	./load ucspi-proxy-http-xlate http-xlate-filter.o ucspi-proxy.a -lbg 

ucspi-proxy-http-xlate.1.html: ucspi-proxy-http-xlate.1
	man2html ucspi-proxy-http-xlate.1 >ucspi-proxy-http-xlate.1.html

ucspi-proxy-http-xlate.o: compile ucspi-proxy-http-xlate.c ucspi-proxy.h
	./compile ucspi-proxy-http-xlate.c

ucspi-proxy-imap: ucspi-proxy-imap.o load imap-filter.o relay-filter.o auth-lib.o ucspi-proxy.a
	./load ucspi-proxy-imap imap-filter.o relay-filter.o auth-lib.o ucspi-proxy.a -lbg 

ucspi-proxy-imap.o: compile ucspi-proxy-imap.c ucspi-proxy.h
	./compile ucspi-proxy-imap.c

ucspi-proxy-log: ucspi-proxy-log.o load log-filter.o ucspi-proxy.a
	./load ucspi-proxy-log log-filter.o ucspi-proxy.a -lbg 

ucspi-proxy-log.o: compile ucspi-proxy-log.c ucspi-proxy.h
	./compile ucspi-proxy-log.c

ucspi-proxy-pop3: ucspi-proxy-pop3.o load pop3-filter.o relay-filter.o auth-lib.o ucspi-proxy.a
	./load ucspi-proxy-pop3 pop3-filter.o relay-filter.o auth-lib.o ucspi-proxy.a -lbg 

ucspi-proxy-pop3.o: compile ucspi-proxy-pop3.c ucspi-proxy.h
	./compile ucspi-proxy-pop3.c

ucspi-proxy.1.html: ucspi-proxy.1
	man2html ucspi-proxy.1 >ucspi-proxy.1.html

ucspi-proxy.a: makelib base64.o tcp-connect.o ucspi-proxy.o
	./makelib ucspi-proxy.a base64.o tcp-connect.o ucspi-proxy.o

ucspi-proxy.o: compile ucspi-proxy.c ucspi-proxy.h
	./compile ucspi-proxy.c

