# 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: bcron-exec.o load bcron.a
	./load bcron-exec bcron.a -lbg 

bcron-exec.8.html: bcron-exec.8
	man --html='cat %s' ./bcron-exec.8 > bcron-exec.8.html

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

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

bcron-sched.8.html: bcron-sched.8
	man --html='cat %s' ./bcron-sched.8 > bcron-sched.8.html

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

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

bcron-spool.8.html: bcron-spool.8
	man --html='cat %s' ./bcron-spool.8 > bcron-spool.8.html

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

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

bcron-start.8.html: bcron-start.8
	man --html='cat %s' ./bcron-start.8 > bcron-start.8.html

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

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

bcron-update.8.html: bcron-update.8
	man --html='cat %s' ./bcron-update.8 > bcron-update.8.html

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 job_dump.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 job_dump.o ministat.o sendpacket.o tempfile.o time.o timespec-next.o timespec-parse.o

bcron.html: bcron.texi
	makeinfo --html --no-split bcron.texi

bcron.info: bcron.texi
	makeinfo bcron.texi

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

bcrontab.1.html: bcrontab.1
	man --html='cat %s' ./bcrontab.1 > bcrontab.1.html

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

conf_sendmail.c: conf-sendmail
	python -c 'import shlex; line=shlex.split(open("conf-sendmail").readline().strip()); print("const char* sendmail[] = { "+",".join(["\"%s\""%a for a in line])+",NULL };")' >conf_sendmail.c

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

crontab.5.html: crontab.5
	man --html='cat %s' ./crontab.5 > crontab.5.html

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 crontab.5.html bcrontab.1.html bcron-spool.8.html bcron-sched.8.html bcron-exec.8.html bcron-start.8.html bcron-update.8.html

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

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

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

libraries: bcron.a

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

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

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

programs: bcrontab bcron-update bcron-spool bcron-start bcron-sched 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: test-sched.o load 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

