# Don't edit Makefile!  Use conf-* for configuration.

SHELL=/bin/sh

default: it


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

compile: warn-auto.sh conf-cc
	( cat warn-auto.sh; \
	echo exec "`head -1 conf-cc`" '-c $${1+"$$@"}' \
	) > compile
	chmod 755 compile

cgi-config.o: compile \
cgi-config.c \
strerr.h exit.h auto_home.h generic-conf.h buffer.h fmt.h
	./compile cgi-config.c

auto_home.o: compile \
auto_home.c
	./compile auto_home.c

auto_home.c: auto-str conf-home
	./auto-str auto_home `head -1 conf-home` > auto_home.c

auto-str: load auto-str.o buffer.a error.a str.a
	./load auto-str buffer.a error.a str.a 

auto-str.o: compile \
auto-str.c \
buffer.h exit.h
	./compile auto-str.c

makelib: warn-auto.sh systype
	( cat warn-auto.sh; \
	echo 'main="$$1"; shift'; \
	echo 'rm -f "$$main"'; \
	echo 'ar cr "$$main" $${1+"$$@"}'; \
	case "`cat systype`" in \
	sunos-5.*) ;; \
	unix_sv*) ;; \
	irix64-*) ;; \
	irix-*) ;; \
	dgux-*) ;; \
	hp-ux-*) ;; \
	sco*) ;; \
	*) echo 'ranlib "$$main"' ;; \
	esac \
	) > makelib
	chmod 755 makelib

systype: find-systype.sh conf-cc conf-ld trycpp.c x86cpuid.c
	( cat warn-auto.sh; \
	echo CC=\'`head -1 conf-cc`\'; \
	echo LD=\'`head -1 conf-ld`\'; \
	cat find-systype.sh; \
	) | sh > systype

buffer.o: compile \
buffer.c \
buffer.h
	./compile buffer.c

buffer.a: makelib buffer.o buffer_get.o buffer_put.o buffer_copy.o \
buffer_read.o buffer_write.o buffer_2.o buffer_1.o buffer_0.o
	./makelib buffer.a buffer.o buffer_get.o buffer_put.o buffer_copy.o \
	buffer_read.o buffer_write.o buffer_2.o buffer_1.o buffer_0.o

buffer_get.o: compile \
buffer_get.c \
buffer.h byte.h error.h
	./compile buffer_get.c

buffer_put.o: compile \
buffer_put.c \
buffer.h str.h byte.h error.h
	./compile buffer_put.c

buffer_copy.o: compile \
buffer_copy.c \
buffer.h
	./compile buffer_copy.c

buffer_read.o: compile \
buffer_read.c \
buffer.h
	./compile buffer_read.c

buffer_write.o: compile \
buffer_write.c \
buffer.h
	./compile buffer_write.c

buffer_2.o: compile \
buffer_2.c \
buffer.h
	./compile buffer_2.c

buffer_1.o: compile \
buffer_1.c \
buffer.h
	./compile buffer_1.c

buffer_0.o: compile \
buffer_0.c \
buffer.h
	./compile buffer_0.c

error.o: compile \
error.c \
error.h
	./compile error.c

error_str.o: compile \
error_str.c \
error.h
	./compile error_str.c

error.a: makelib error.o error_str.o error_temp.o
	./makelib error.a error.o error_str.o error_temp.o

error_temp.o: compile \
error_temp.c \
error.h
	./compile error_temp.c

str.a: makelib byte_chr.o byte_copy.o byte_cr.o byte_diff.o byte_rchr.o \
str_chr.o str_len.o str_cpy.o str_diffn.o str_diff.o str_rchr.o \
str_start.o
	./makelib str.a byte_chr.o byte_copy.o byte_cr.o byte_diff.o byte_rchr.o \
	str_chr.o str_len.o str_cpy.o str_diffn.o str_diff.o str_rchr.o \
	str_start.o

open_read.o: compile \
open_read.c \
open.h
	./compile open_read.c

byte_chr.o: compile \
byte_chr.c \
byte.h
	./compile byte_chr.c

byte_copy.o: compile \
byte_copy.c \
byte.h
	./compile byte_copy.c

byte_cr.o: compile \
byte_cr.c \
byte.h
	./compile byte_cr.c

byte_diff.o: compile \
byte_diff.c \
byte.h
	./compile byte_diff.c

byte_rchr.o: compile \
byte_rchr.c \
byte.h
	./compile byte_rchr.c

str_chr.o: compile \
str_chr.c \
str.h
	./compile str_chr.c

str_len.o: compile \
str_len.c \
str.h
	./compile str_len.c

str_cpy.o: compile \
str_cpy.c \
str.h
	./compile str_cpy.c

str_diffn.o: compile \
str_diffn.c \
str.h
	./compile str_diffn.c

str_diff.o: compile \
str_diff.c \
str.h
	./compile str_diff.c

str_rchr.o: compile \
str_rchr.c \
str.h
	./compile str_rchr.c

str_start.o: compile \
str_start.c \
str.h
	./compile str_start.c

cgi-config: load cgi-config.o auto_home.o generic-conf.o strerr.a \
buffer.a error.a open.a str.a fs.a
	./load cgi-config auto_home.o generic-conf.o strerr.a buffer.a error.a \
	open.a str.a fs.a 

generic-conf.o: compile \
generic-conf.c \
strerr.h buffer.h open.h generic-conf.h
	./compile generic-conf.c

strerr.o: compile \
strerr.c \
stralloc.h gen_alloc.h strerr.h
	./compile strerr.c

strerr.a: makelib strerr.o strerr_sys.o strerr_die.o
	./makelib strerr.a strerr.o strerr_sys.o strerr_die.o

strerr_sys.o: compile \
strerr_sys.c \
error.h strerr.h
	./compile strerr_sys.c

strerr_die.o: compile \
strerr_die.c \
buffer.h exit.h strerr.h
	./compile strerr_die.c

open.a: makelib open_read.o open_trunc.o
	./makelib open.a open_read.o open_trunc.o

open_trunc.o: compile \
open_trunc.c \
open.h
	./compile open_trunc.c

fmt_uint.o: compile \
fmt_uint.c \
fmt.h
	./compile fmt_uint.c

fmt_ulong.o: compile \
fmt_ulong.c \
fmt.h
	./compile fmt_ulong.c

fmt_xlong.o: compile \
fmt_xlong.c \
fmt.h
	./compile fmt_xlong.c

scan_long.o: compile \
scan_long.c \
scan.h
	./compile scan_long.c

scan_sign.o: compile \
scan_sign.c \
scan.h
	./compile scan_sign.c

scan_uint.o: compile \
scan_uint.c \
scan.h
	./compile scan_uint.c

fs.a: makelib fmt_uint.o fmt_ulong.o fmt_xlong.o scan_long.o scan_sign.o \
scan_uint.o scan_ulong.o
	./makelib fs.a fmt_uint.o fmt_ulong.o fmt_xlong.o scan_long.o \
	scan_sign.o scan_uint.o scan_ulong.o

scan_ulong.o: compile \
scan_ulong.c \
scan.h
	./compile scan_ulong.c

loads: warn-auto.sh conf-lds
	( cat warn-auto.sh; \
	echo 'main="$$1"; shift'; \
	echo exec "`head -1 conf-lds`" \
	'-o "$$main" "$$main".o $${1+"$$@"}' \
	) > loads
	chmod 755 loads

choose: warn-auto.sh choose.sh conf-home
	cat warn-auto.sh choose.sh \
	| sed s}HOME}"`head -1 conf-home`"}g \
	> choose
	chmod 755 choose

uint64.h: choose compile load tryulong64.c uint64.h1 uint64.h2
	./choose clr tryulong64 uint64.h1 uint64.h2 >uint64.h

cgi-env.o: compile \
cgi-env.c \
stralloc.h gen_alloc.h sig.h exit.h fmt.h case.h str.h tai.h uint64.h \
httpdate.h timeoutwrite.h buffer.h error.h env.h
	./compile cgi-env.c

httpdate.o: compile \
httpdate.c \
caltime.h caldate.h httpdate.h stralloc.h gen_alloc.h tai.h uint64.h
	./compile httpdate.c

cgi-env: loads cgi-env.o httpdate.o timeoutwrite.o iopause.o libtai.a \
case.a stralloc.a alloc.a buffer.a error.a sig.a env.a str.a fs.a
	./loads cgi-env httpdate.o timeoutwrite.o iopause.o libtai.a case.a \
	stralloc.a alloc.a buffer.a error.a sig.a env.a str.a fs.a 

timeoutwrite.o: compile \
timeoutwrite.c \
error.h iopause.h timeoutwrite.h
	./compile timeoutwrite.c

iopause.h: choose compile load trypoll.c iopause.h1 iopause.h2
	./choose clr trypoll iopause.h1 iopause.h2 >iopause.h

iopause.o: compile \
iopause.c \
taia.h tai.h uint64.h select.h iopause.h
	./compile iopause.c

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

tai_now.o: compile \
tai_now.c \
tai.h uint64.h
	./compile tai_now.c

tai_sub.o: compile \
tai_sub.c \
tai.h uint64.h
	./compile tai_sub.c

libtai.a: makelib tai_now.o tai_sub.o tai_unpack.o taia_approx.o \
taia_add.o taia_frac.o taia_less.o taia_now.o taia_sub.o taia_uint.o \
caldate_fmjd.o caltime_tai.o caltime_utc.o leapsecs_init.o \
leapsecs_read.o leapsecs_sub.o
	./makelib libtai.a tai_now.o tai_sub.o tai_unpack.o taia_approx.o \
	taia_add.o taia_frac.o taia_less.o taia_now.o taia_sub.o taia_uint.o \
	caldate_fmjd.o caltime_tai.o caltime_utc.o leapsecs_init.o \
	leapsecs_read.o leapsecs_sub.o

tai_unpack.o: compile \
tai_unpack.c \
tai.h uint64.h
	./compile tai_unpack.c

taia_approx.o: compile \
taia_approx.c \
taia.h tai.h uint64.h
	./compile taia_approx.c

taia_add.o: compile \
taia_add.c \
taia.h tai.h uint64.h
	./compile taia_add.c

taia_frac.o: compile \
taia_frac.c \
taia.h tai.h uint64.h
	./compile taia_frac.c

taia_less.o: compile \
taia_less.c \
taia.h tai.h uint64.h
	./compile taia_less.c

taia_now.o: compile \
taia_now.c \
taia.h tai.h uint64.h
	./compile taia_now.c

taia_sub.o: compile \
taia_sub.c \
taia.h tai.h uint64.h
	./compile taia_sub.c

taia_uint.o: compile \
taia_uint.c \
taia.h tai.h uint64.h
	./compile taia_uint.c

caldate_fmjd.o: compile \
caldate_fmjd.c \
caldate.h
	./compile caldate_fmjd.c

caltime_tai.o: compile \
caltime_tai.c \
tai.h uint64.h leapsecs.h caldate.h caltime.h
	./compile caltime_tai.c

caltime_utc.o: compile \
caltime_utc.c \
tai.h uint64.h leapsecs.h caldate.h caltime.h
	./compile caltime_utc.c

leapsecs_init.o: compile \
leapsecs_init.c \
leapsecs.h
	./compile leapsecs_init.c

leapsecs_read.o: compile \
leapsecs_read.c \
tai.h uint64.h leapsecs.h
	./compile leapsecs_read.c

leapsecs_sub.o: compile \
leapsecs_sub.c \
leapsecs.h tai.h uint64.h
	./compile leapsecs_sub.c

case.a: makelib case_lowerb.o case_lowers.o case_diffb.o case_diffs.o \
case_startb.o
	./makelib case.a case_lowerb.o case_lowers.o case_diffb.o case_diffs.o \
	case_startb.o

case_lowerb.o: compile \
case_lowerb.c \
case.h
	./compile case_lowerb.c

case_lowers.o: compile \
case_lowers.c \
case.h
	./compile case_lowers.c

case_diffb.o: compile \
case_diffb.c \
case.h
	./compile case_diffb.c

case_diffs.o: compile \
case_diffs.c \
case.h
	./compile case_diffs.c

case_startb.o: compile \
case_startb.c \
case.h
	./compile case_startb.c

stralloc.a: makelib stralloc_arts.o stralloc_cat.o stralloc_catb.o \
stralloc_cats.o stralloc_copy.o stralloc_eady.o stralloc_num.o \
stralloc_opyb.o stralloc_opys.o stralloc_pend.o
	./makelib stralloc.a stralloc_arts.o stralloc_cat.o stralloc_catb.o \
	stralloc_cats.o stralloc_copy.o stralloc_eady.o stralloc_num.o \
	stralloc_opyb.o stralloc_opys.o stralloc_pend.o

stralloc_arts.o: compile \
stralloc_arts.c \
byte.h str.h stralloc.h gen_alloc.h
	./compile stralloc_arts.c

stralloc_cat.o: compile \
stralloc_cat.c \
byte.h stralloc.h gen_alloc.h
	./compile stralloc_cat.c

stralloc_catb.o: compile \
stralloc_catb.c \
stralloc.h gen_alloc.h byte.h
	./compile stralloc_catb.c

stralloc_cats.o: compile \
stralloc_cats.c \
byte.h str.h stralloc.h gen_alloc.h
	./compile stralloc_cats.c

stralloc_copy.o: compile \
stralloc_copy.c \
byte.h stralloc.h gen_alloc.h
	./compile stralloc_copy.c

stralloc_eady.o: compile \
stralloc_eady.c \
alloc.h stralloc.h gen_alloc.h gen_allocdefs.h
	./compile stralloc_eady.c

stralloc_num.o: compile \
stralloc_num.c \
stralloc.h gen_alloc.h
	./compile stralloc_num.c

stralloc_opyb.o: compile \
stralloc_opyb.c \
stralloc.h gen_alloc.h byte.h
	./compile stralloc_opyb.c

stralloc_opys.o: compile \
stralloc_opys.c \
byte.h str.h stralloc.h gen_alloc.h
	./compile stralloc_opys.c

stralloc_pend.o: compile \
stralloc_pend.c \
alloc.h stralloc.h gen_alloc.h gen_allocdefs.h
	./compile stralloc_pend.c

alloc.o: compile \
alloc.c \
alloc.h error.h
	./compile alloc.c

alloc.a: makelib alloc.o alloc_re.o
	./makelib alloc.a alloc.o alloc_re.o

alloc_re.o: compile \
alloc_re.c \
alloc.h byte.h
	./compile alloc_re.c

sig.o: compile \
sig.c \
sig.h
	./compile sig.c

sig.a: makelib sig.o sig_catch.o
	./makelib sig.a sig.o sig_catch.o

sig_catch.o: compile \
sig_catch.c \
sig.h hassgact.h
	./compile sig_catch.c

hassgact.h: choose compile trysgact.c hassgact.h1 hassgact.h2
	./choose cl trysgact hassgact.h1 hassgact.h2 > hassgact.h

env.a: makelib env.o
	./makelib env.a env.o

env.o: compile \
env.c \
str.h env.h
	./compile env.c

cgi-example: loads cgi-example.o httpdate.o timeoutwrite.o timeoutread.o \
iopause.o formdata.o percent.o libtai.a case.a pathexec.a stralloc.a \
alloc.a buffer.a error.a sig.a env.a getln.a str.a fs.a wait.a fd.a
	./loads cgi-example httpdate.o timeoutwrite.o timeoutread.o iopause.o \
	formdata.o percent.o libtai.a case.a pathexec.a stralloc.a alloc.a \
	buffer.a error.a sig.a env.a getln.a str.a fs.a wait.a fd.a 

fork.h: choose compile load tryvfork.c fork.h1 fork.h2
	./choose cl tryvfork fork.h1 fork.h2 >fork.h

cgi-example.o: compile \
cgi-example.c \
stralloc.h gen_alloc.h sig.h exit.h fmt.h case.h str.h tai.h uint64.h \
httpdate.h timeoutread.h timeoutwrite.h buffer.h error.h env.h scan.h \
formdata.h getln.h wait.h fd.h fork.h pathexec.h
	./compile cgi-example.c

timeoutread.o: compile \
timeoutread.c \
error.h iopause.h taia.h tai.h uint64.h timeoutread.h
	./compile timeoutread.c

formdata.o: compile \
formdata.c \
formdata.h stralloc.h gen_alloc.h percent.h
	./compile formdata.c

percent.o: compile \
percent.c \
percent.h stralloc.h gen_alloc.h
	./compile percent.c

pathexec.a: makelib pathexec_run.o pathexec_env.o
	./makelib pathexec.a pathexec_run.o pathexec_env.o

pathexec_run.o: compile \
pathexec_run.c \
error.h stralloc.h gen_alloc.h str.h env.h pathexec.h
	./compile pathexec_run.c

pathexec_env.o: compile \
pathexec_env.c \
stralloc.h gen_alloc.h alloc.h str.h byte.h env.h pathexec.h
	./compile pathexec_env.c

getln.o: compile \
getln.c \
byte.h getln.h buffer.h stralloc.h gen_alloc.h
	./compile getln.c

getln.a: makelib getln.o getln2.o
	./makelib getln.a getln.o getln2.o

getln2.o: compile \
getln2.c \
byte.h getln.h buffer.h stralloc.h gen_alloc.h
	./compile getln2.c

wait.a: makelib wait_pid.o
	./makelib wait.a wait_pid.o

wait_pid.o: compile \
wait_pid.c \
error.h haswaitp.h
	./compile wait_pid.c

chkshsgr.o: compile \
chkshsgr.c \
exit.h
	./compile chkshsgr.c

haswaitp.h: choose trywaitp.c haswaitp.h1 haswaitp.h2 compile load
	./choose cl trywaitp haswaitp.h1 haswaitp.h2 >haswaitp.h

fd.a: makelib fd_copy.o fd_move.o
	./makelib fd.a fd_copy.o fd_move.o

fd_copy.o: compile \
fd_copy.c \
fd.h
	./compile fd_copy.c

fd_move.o: compile \
fd_move.c \
fd.h
	./compile fd_move.c

cgi-httpd.o: compile \
cgi-httpd.c \
pathdecode.h stralloc.h gen_alloc.h percent.h sig.h exit.h fmt.h case.h \
str.h tai.h uint64.h httpdate.h timeoutread.h timeoutwrite.h buffer.h \
strerr.h error.h getln.h env.h pathexec.h droproot.h
	./compile cgi-httpd.c

pathdecode.o: compile \
pathdecode.c \
pathdecode.h stralloc.h gen_alloc.h
	./compile pathdecode.c

droproot.o: compile \
droproot.c \
env.h scan.h prot.h strerr.h
	./compile droproot.c

prot.o: compile \
prot.c \
hasshsgr.h prot.h
	./compile prot.c

cgi-httpd: load cgi-httpd.o pathdecode.o droproot.o httpdate.o percent.o \
prot.o timeoutread.o timeoutwrite.o iopause.o strerr.a libtai.a case.a \
getln.a stralloc.a alloc.a buffer.a error.a sig.a env.a pathexec.a str.a \
fs.a open.a socket.lib
	./load cgi-httpd pathdecode.o droproot.o httpdate.o percent.o prot.o \
	timeoutread.o timeoutwrite.o iopause.o strerr.a libtai.a case.a getln.a \
	stralloc.a alloc.a buffer.a error.a sig.a env.a pathexec.a str.a fs.a \
	open.a  `cat socket.lib`

hasshsgr.h: choose compile tryshsgr.c hasshsgr.h1 hasshsgr.h2 chkshsgr \
warn-shsgr
	./chkshsgr || ( cat warn-shsgr; exit 1 )
	./choose clr tryshsgr hasshsgr.h1 hasshsgr.h2 > hasshsgr.h

chkshsgr: load chkshsgr.o
	./load chkshsgr 

utime.o: compile \
utime.c \
scan.h exit.h
	./compile utime.c

socket.lib: trylsock.c compile load
	( ( ./compile trylsock.c && \
	./load trylsock -lsocket -lnsl ) >/dev/null 2>&1 \
	&& echo -lsocket -lnsl || exit 0 ) > socket.lib
	rm -f trylsock.o trylsock

cgi-success: loads cgi-success.o httpdate.o timeoutwrite.o iopause.o \
libtai.a case.a stralloc.a alloc.a buffer.a error.a sig.a env.a str.a \
fs.a
	./loads cgi-success httpdate.o timeoutwrite.o iopause.o libtai.a case.a \
	stralloc.a alloc.a buffer.a error.a sig.a env.a str.a fs.a 

cgi-success.o: compile \
cgi-success.c \
stralloc.h gen_alloc.h sig.h exit.h fmt.h case.h str.h tai.h uint64.h \
httpdate.h timeoutwrite.h buffer.h error.h env.h
	./compile cgi-success.c

cgiuser-httpd: load cgiuser-httpd.o pathdecode.o droppriv.o httpdate.o \
percent.o prot.o timeoutread.o timeoutwrite.o iopause.o strerr.a libtai.a \
case.a getln.a stralloc.a alloc.a buffer.a error.a sig.a env.a pathexec.a \
str.a fs.a open.a socket.lib
	./load cgiuser-httpd pathdecode.o droppriv.o httpdate.o percent.o prot.o \
	timeoutread.o timeoutwrite.o iopause.o strerr.a libtai.a case.a getln.a \
	stralloc.a alloc.a buffer.a error.a sig.a env.a pathexec.a str.a fs.a \
	open.a  `cat socket.lib`

cgiuser-httpd.o: compile \
cgiuser-httpd.c \
pathdecode.h stralloc.h gen_alloc.h percent.h sig.h exit.h fmt.h case.h \
str.h tai.h uint64.h httpdate.h timeoutread.h timeoutwrite.h buffer.h \
strerr.h error.h getln.h env.h pathexec.h droppriv.h
	./compile cgiuser-httpd.c

droppriv.o: compile \
droppriv.c \
env.h scan.h prot.h strerr.h
	./compile droppriv.c

cgiuser-config: load cgiuser-config.o auto_home.o generic-conf.o strerr.a \
buffer.a error.a open.a str.a fs.a
	./load cgiuser-config auto_home.o generic-conf.o strerr.a buffer.a \
	error.a open.a str.a fs.a 

cgiuser-config.o: compile \
cgiuser-config.c \
strerr.h exit.h auto_home.h generic-conf.h buffer.h fmt.h
	./compile cgiuser-config.c

cgi-dispatch: loads cgi-dispatch.o pathdecode.o httpdate.o timeoutwrite.o \
iopause.o strerr.a libtai.a pathexec.a stralloc.a alloc.a buffer.a \
error.a env.a str.a fs.a
	./loads cgi-dispatch pathdecode.o httpdate.o timeoutwrite.o iopause.o \
	strerr.a libtai.a pathexec.a stralloc.a alloc.a buffer.a error.a env.a \
	str.a fs.a 

echo-httpd: load echo-httpd.o prot.o droproot.o httpdate.o timeoutread.o \
timeoutwrite.o iopause.o strerr.a env.a fs.a libtai.a case.a getln.a \
stralloc.a alloc.a buffer.a str.a error.a sig.a socket.lib
	./load echo-httpd prot.o droproot.o httpdate.o timeoutread.o \
	timeoutwrite.o iopause.o strerr.a env.a fs.a libtai.a case.a getln.a \
	stralloc.a alloc.a buffer.a str.a error.a sig.a  `cat socket.lib`

cgi-dispatch.o: compile \
cgi-dispatch.c \
pathdecode.h stralloc.h gen_alloc.h exit.h fmt.h tai.h uint64.h \
httpdate.h timeoutwrite.h buffer.h strerr.h error.h env.h pathexec.h \
str.h
	./compile cgi-dispatch.c

echo-config: load echo-config.o auto_home.o generic-conf.o strerr.a \
buffer.a error.a open.a str.a fs.a
	./load echo-config auto_home.o generic-conf.o strerr.a buffer.a error.a \
	open.a str.a fs.a 

echo-config.o: compile \
echo-config.c \
strerr.h exit.h auto_home.h generic-conf.h buffer.h fmt.h
	./compile echo-config.c

echo-httpd.o: compile \
echo-httpd.c \
stralloc.h gen_alloc.h sig.h exit.h str.h fmt.h httpdate.h tai.h uint64.h \
timeoutread.h timeoutwrite.h buffer.h getln.h droproot.h
	./compile echo-httpd.c

constant-config: load constant-config.o auto_home.o generic-conf.o \
strerr.a buffer.a error.a open.a str.a fs.a
	./load constant-config auto_home.o generic-conf.o strerr.a buffer.a \
	error.a open.a str.a fs.a 

redir-config: load redir-config.o auto_home.o generic-conf.o strerr.a \
buffer.a error.a open.a str.a fs.a
	./load redir-config auto_home.o generic-conf.o strerr.a buffer.a error.a \
	open.a str.a fs.a 

redir-config.o: compile \
redir-config.c \
strerr.h exit.h auto_home.h generic-conf.h buffer.h fmt.h
	./compile redir-config.c

redir-httpd: load redir-httpd.o pathdecode.o file.o httpdate.o percent.o \
prot.o droproot.o timeoutread.o timeoutwrite.o iopause.o strerr.a \
libtai.a case.a getln.a stralloc.a alloc.a buffer.a error.a open.a sig.a \
env.a cdb.a str.a fs.a seek.a uint.a socket.lib
	./load redir-httpd pathdecode.o file.o httpdate.o percent.o prot.o \
	droproot.o timeoutread.o timeoutwrite.o iopause.o strerr.a libtai.a \
	case.a getln.a stralloc.a alloc.a buffer.a error.a open.a sig.a env.a \
	cdb.a str.a fs.a seek.a uint.a  `cat socket.lib`

seek.a: makelib seek_set.o
	./makelib seek.a seek_set.o

uint32.h: choose compile load tryulong32.c uint32.h1 uint32.h2
	./choose clr tryulong32 uint32.h1 uint32.h2 >uint32.h

redir-httpd.o: compile \
redir-httpd.c \
pathdecode.h stralloc.h gen_alloc.h file.h tai.h uint64.h percent.h sig.h \
exit.h fmt.h case.h str.h httpdate.h timeoutread.h timeoutwrite.h \
buffer.h error.h getln.h uint32.h cdb.h uint32.h droproot.h env.h
	./compile redir-httpd.c

file.o: compile \
file.c \
buffer.h error.h file.h tai.h uint64.h byte.h str.h env.h
	./compile file.c

cdb.o: compile \
cdb.c \
error.h seek.h byte.h cdb.h uint32.h
	./compile cdb.c

cdb.a: makelib cdb.o cdb_hash.o cdb_make.o
	./makelib cdb.a cdb.o cdb_hash.o cdb_make.o

cdb_hash.o: compile \
cdb_hash.c \
cdb.h uint32.h
	./compile cdb_hash.c

cdb_make.o: compile \
cdb_make.c \
seek.h error.h alloc.h cdb.h uint32.h cdb_make.h buffer.h
	./compile cdb_make.c

seek_set.o: compile \
seek_set.c \
seek.h
	./compile seek_set.c

uint.a: makelib uint32_unpack.o uint32_pack.o
	./makelib uint.a uint32_unpack.o uint32_pack.o

uint32_unpack.o: compile \
uint32_unpack.c \
uint32.h
	./compile uint32_unpack.c

uint32_pack.o: compile \
uint32_pack.c \
uint32.h
	./compile uint32_pack.c

redir-data: load redir-data.o cdb.a seek.a uint.a getln.a stralloc.a \
alloc.a strerr.a buffer.a error.a open.a str.a fs.a
	./load redir-data cdb.a seek.a uint.a getln.a stralloc.a alloc.a \
	strerr.a buffer.a error.a open.a str.a fs.a 

redir-data.o: compile \
redir-data.c \
byte.h fmt.h exit.h buffer.h strerr.h getln.h stralloc.h gen_alloc.h \
cdb_make.h uint32.h open.h
	./compile redir-data.c

prog: cgi-config cgi-env cgi-example cgi-httpd cgi-success cgiuser-httpd \
cgiuser-config cgi-dispatch echo-config echo-httpd redir-config \
redir-httpd redir-data constant-config constant-httpd utime

install: load install.o hier.o auto_home.o stralloc.a alloc.a strerr.a \
buffer.a open.a error.a str.a
	./load install hier.o auto_home.o stralloc.a alloc.a strerr.a buffer.a \
	open.a error.a str.a 

constant-httpd: load constant-httpd.o pathdecode.o file.o filetype.o \
httpdate.o percent.o prot.o droproot.o timeoutread.o timeoutwrite.o \
iopause.o strerr.a libtai.a case.a getln.a stralloc.a alloc.a buffer.a \
error.a open.a sig.a env.a str.a fs.a socket.lib
	./load constant-httpd pathdecode.o file.o filetype.o httpdate.o \
	percent.o prot.o droproot.o timeoutread.o timeoutwrite.o iopause.o \
	strerr.a libtai.a case.a getln.a stralloc.a alloc.a buffer.a error.a \
	open.a sig.a env.a str.a fs.a  `cat socket.lib`

constant-config.o: compile \
constant-config.c \
strerr.h exit.h auto_home.h generic-conf.h buffer.h fmt.h
	./compile constant-config.c

constant-httpd.o: compile \
constant-httpd.c \
pathdecode.h stralloc.h gen_alloc.h file.h tai.h uint64.h filetype.h \
percent.h sig.h exit.h fmt.h case.h str.h httpdate.h timeoutread.h \
timeoutwrite.h buffer.h error.h getln.h env.h
	./compile constant-httpd.c

filetype.o: compile \
filetype.c \
filetype.h stralloc.h gen_alloc.h str.h
	./compile filetype.c

utime: load utime.o fs.a
	./load utime fs.a 

install.o: compile \
install.c \
buffer.h strerr.h error.h open.h exit.h
	./compile install.c

hier.o: compile \
hier.c \
auto_home.h
	./compile hier.c

it: prog install instcheck

rts: warn-auto.sh rts.sh conf-home
	cat warn-auto.sh rts.sh \
	| sed s}HOME}"`head -1 conf-home`"}g \
	> rts
	chmod 755 rts

instcheck: load instcheck.o hier.o auto_home.o strerr.a buffer.a error.a \
str.a
	./load instcheck hier.o auto_home.o strerr.a buffer.a error.a str.a 

instcheck.o: compile \
instcheck.c \
strerr.h error.h exit.h
	./compile instcheck.c

test: prog rts rts.tests rts.exp
	./rts | cmp - rts.exp >&2

setup: it install
	./install

check: it instcheck
	./instcheck
