# 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

choose: warn-auto.sh choose.sh
	cat warn-auto.sh choose.sh >choose
	chmod 755 choose

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

direntry.h: compile direntry.h1 direntry.h2 trydirent.c
	( ./compile trydirent.c >/dev/null 2>&1 \
	  && cat direntry.h2 || cat direntry.h1 ) > direntry.h
	rm -f trydirent.o

fork.h: compile load fork.h1 fork.h2 tryvfork.c
	( ( ./compile tryvfork.c && ./load tryvfork ) >/dev/null 2>&1 \
	  && cat fork.h2 || cat fork.h1 ) > fork.h
	rm -f tryvfork.o tryvfork

installer: load installer.o insthier.o
	./load installer insthier.o

installer.o: compile installer.c installer.h
	./compile installer.c

instcheck: load instcheck.o insthier.o
	./load instcheck insthier.o

instcheck.o: compile instcheck.c installer.h
	./compile instcheck.c

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

instshow: load instshow.o insthier.o
	./load instshow insthier.o

instshow.o: compile instshow.c installer.h
	./compile instshow.c

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

multipipe: load multipipe.o svcfns.o
	./load multipipe svcfns.o

multipipe.o: compile multipipe.c select.h direntry.h bool.h svcfns.h
	./compile multipipe.c

multitail: load multitail.o
	./load multitail 

multitail.o: compile multitail.c systime.h bool.h
	./compile multitail.c

programs: spipe qfilelog multipipe tai2tai64n tai64n2tai teepipe multitail

qfilelog: load qfilelog.o
	./load qfilelog 

qfilelog.o: compile qfilelog.c
	./compile qfilelog.c

select.h: choose compile trysysel.c select.h1 select.h2
	./choose c trysysel select.h1 select.h2 > select.h

spipe: load spipe.o svcfns.o
	./load spipe svcfns.o

spipe.o: compile spipe.c bool.h svcfns.h
	./compile spipe.c

svcfns.o: compile svcfns.c fork.h bool.h svcfns.h
	./compile svcfns.c

systime.h: compile trysystime.c trytime.c
	( ( ./compile trysystime.c >/dev/null 2>&1 && \
	    echo '#include <sys/time.h>' ); \
	  ( ./compile trytime.c >/dev/null 2>&1 && \
	    echo '#include <time.h>' ) ) >systime.h
	rm -f trysystime.o trytime.o

tai2tai64n: load tai2tai64n.o tai_decode.o tai64n_encode.o
	./load tai2tai64n tai_decode.o tai64n_encode.o

tai2tai64n.o: compile tai2tai64n.c tai.h bool.h
	./compile tai2tai64n.c

tai64n2tai: load tai64n2tai.o tai64n_decode.o tai_encode.o
	./load tai64n2tai tai64n_decode.o tai_encode.o

tai64n2tai.o: compile tai64n2tai.c tai.h bool.h
	./compile tai64n2tai.c

tai64n_decode.o: compile tai64n_decode.c tai.h bool.h
	./compile tai64n_decode.c

tai64n_encode.o: compile tai64n_encode.c tai.h bool.h
	./compile tai64n_encode.c

tai_decode.o: compile tai_decode.c tai.h bool.h
	./compile tai_decode.c

tai_encode.o: compile tai_encode.c tai.h bool.h
	./compile tai_encode.c

teepipe: load teepipe.o
	./load teepipe 

teepipe.o: compile teepipe.c fork.h
	./compile teepipe.c

