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

SHELL=/bin/sh

DEFAULT: all

all: programs installer instcheck instshow

clean: TARGETS
	rm -f `cat TARGETS`

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

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

conf_bin.c: conf-bin
	head -1 conf-bin | \
	  sed -e 's/"/\\"/g' \
	      -e 's/^/const char conf_bin[] = "/' \
	      -e 's/$$/";/' >conf_bin.c

conf_man.c: conf-man
	head -1 conf-man | \
	  sed -e 's/"/\\"/g' \
	      -e 's/^/const char conf_man[] = "/' \
	      -e 's/$$/";/' >conf_man.c

installer: load insthier.o
	./load insthier -lbg-installer
	mv insthier installer

instcheck: load insthier.o
	./load insthier -lbg-instcheck
	mv insthier instcheck

insthier.o: compile insthier.c conf_bin.c conf_man.c
	./compile insthier.c

instshow: load insthier.o
	./load insthier -lbg-instshow
	mv insthier instshow

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

main.o: compile main.c qmail-autoresponder.h
	./compile main.c

programs: qmail-autoresponder qmail-autoresponder-mysql

qmail-autoresponder: load qmail-autoresponder.o main.o
	./load qmail-autoresponder main.o -lbg-iobuf -lbg-str

qmail-autoresponder-mysql: load qmail-autoresponder-mysql.o main.o
	./load qmail-autoresponder-mysql main.o -lbg-iobuf -lbg-str -L/usr/lib/mysql -L/usr/local/lib/mysql -lmysqlclient

qmail-autoresponder-mysql.o: compile qmail-autoresponder-mysql.c qmail-autoresponder.h
	./compile qmail-autoresponder-mysql.c

qmail-autoresponder.o: compile qmail-autoresponder.c qmail-autoresponder.h
	./compile qmail-autoresponder.c

