# 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

bcron-exec: load bcron-exec.o bcron.a
	./load bcron-exec bcron.a -lbg 

bcron-exec.o: compile bcron-exec.c bcron.h
	./compile bcron-exec.c

bcron-sched: load bcron-sched.o bcron.a
	./load bcron-sched bcron.a -lbg 

bcron-sched.o: compile bcron-sched.c bcron.h
	./compile bcron-sched.c

bcron-spool: load bcron-spool.o bcron.a
	./load bcron-spool bcron.a -lbg 

bcron-spool.o: compile bcron-spool.c bcron.h
	./compile bcron-spool.c

bcron-start: load bcron-start.o bcron.a
	./load bcron-start bcron.a -lbg 

bcron-start.o: compile bcron-start.c bcron.h
	./compile bcron-start.c

bcron-update: load bcron-update.o bcron.a
	./load bcron-update bcron.a -lbg 

bcron-update.o: compile bcron-update.c bcron.h
	./compile bcron-update.c

bcron.a: makelib chdir.o connection.o crontab.o crontabs.o job.o ministat.o sendpacket.o tempfile.o time.o timespec-next.o timespec-parse.o
	./makelib bcron.a chdir.o connection.o crontab.o crontabs.o job.o ministat.o sendpacket.o tempfile.o time.o timespec-next.o timespec-parse.o

bcron.html: bcron.texi
	texi2html --toc-file=bcron.html --top-file=bcron.html bcron.texi

bcron.info: bcron.texi
	makeinfo bcron.texi

bcrontab: load bcrontab.o bcron.a
	./load bcrontab bcron.a -lbg-cli -lbg 

bcrontab.o: compile bcrontab.c bcron.h
	./compile bcrontab.c

chdir.o: compile chdir.c bcron.h
	./compile chdir.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

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

connection.o: compile connection.c bcron.h
	./compile connection.c

crontab.o: compile crontab.c bcron.h
	./compile crontab.c

crontabs.o: compile crontabs.c bcron.h
	./compile crontabs.c

docs: bcron.info bcron.html

install: installer instcheck
	./installer
	./instcheck

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

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

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

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

job.o: compile job.c bcron.h
	./compile job.c

libraries: bcron.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}'" '-o "$$main" "$$main.o" $${1+"$$@"}' -lbg-sysdeps; \
	) >load
	chmod 755 load

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

ministat.o: compile ministat.c bcron.h
	./compile ministat.c

programs: installer instcheck instshow bcron-sched bcrontab bcron-spool bcron-start bcron-update bcron-exec test-sched

sendpacket.o: compile sendpacket.c bcron.h
	./compile sendpacket.c

tempfile.o: compile tempfile.c bcron.h
	./compile tempfile.c

test-sched: load test-sched.o bcron.a
	./load test-sched bcron.a -lbg-cli -lbg 

test-sched.o: compile test-sched.c bcron.h
	./compile test-sched.c

time.o: compile time.c bcron.h
	./compile time.c

timespec-next.o: compile timespec-next.c bcron.h
	./compile timespec-next.c

timespec-parse.o: compile timespec-parse.c bcron.h
	./compile timespec-parse.c

