# 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

syslogger: load syslogger.o substdio.a error.a str.a fs.a syslog.lib \
socket.lib
	./load syslogger substdio.a error.a str.a fs.a \
	 `cat syslog.lib` `cat socket.lib`

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

syslogger.o: compile \
syslogger.c \
error.h substdio.h subfd.h exit.h str.h scan.h fmt.h
	./compile syslogger.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

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

substdi.o: compile \
substdi.c \
substdio.h byte.h error.h
	./compile substdi.c

substdo.o: compile \
substdo.c \
substdio.h str.h byte.h error.h
	./compile substdo.c

subfderr.o: compile \
subfderr.c \
readwrite.h substdio.h subfd.h
	./compile subfderr.c

substdio.a: makelib substdio.o substdi.o substdo.o subfderr.o \
substdio_copy.o subfdin.o subfdout.o
	./makelib substdio.a substdio.o substdi.o substdo.o subfderr.o \
	substdio_copy.o subfdin.o subfdout.o

substdio_copy.o: compile \
substdio_copy.c \
substdio.h
	./compile substdio_copy.c

subfdin.o: compile \
subfdin.c \
readwrite.h substdio.h subfd.h
	./compile subfdin.c

subfdout.o: compile \
subfdout.c \
readwrite.h substdio.h subfd.h
	./compile subfdout.c

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

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

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

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

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

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

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

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

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

str_chr.o: compile \
str_chr.c \
str.h
	./compile str_chr.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

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

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

byte_diff.o: compile \
byte_diff.c \
byte.h
	./compile byte_diff.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_zero.o: compile \
byte_zero.c \
byte.h
	./compile byte_zero.c

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

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

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

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

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

fs.a: makelib scan_0x.o scan_8long.o scan_long.o scan_uint.o scan_ulong.o \
scan_ushort.o scan_xint.o scan_xlong.o fmt_str.o fmt_strn.o fmt_uint.o \
fmt_uint0.o fmt_ulong.o fmt_ushort.o fmt_xint.o fmt_xlong.o
	./makelib fs.a scan_0x.o scan_8long.o scan_long.o scan_uint.o \
	scan_ulong.o scan_ushort.o scan_xint.o scan_xlong.o fmt_str.o fmt_strn.o \
	fmt_uint.o fmt_uint0.o fmt_ulong.o fmt_ushort.o fmt_xint.o fmt_xlong.o

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

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

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

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

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

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

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

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

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

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

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

syslog.lib: trysyslog.c compile load
	( ( ./compile trysyslog.c && \
	./load trysyslog -lgen ) >/dev/null 2>&1 \
	&& echo -lgen || exit 0 ) > syslog.lib
	rm -f trysyslog.o trysyslog

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

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 

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

auto_home.o: compile \
auto_home.c
	./compile 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

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

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.a: makelib buffer.o buffer_get.o buffer_put.o buffer_copy.o \
buffer_2.o buffer_1.o buffer_0.o buffer_write.o buffer_read.o
	./makelib buffer.a buffer.o buffer_get.o buffer_put.o buffer_copy.o \
	buffer_2.o buffer_1.o buffer_0.o buffer_write.o buffer_read.o

it: syslogger

buffer_copy.o: compile \
buffer_copy.c \
buffer.h
	./compile buffer_copy.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 \
readwrite.h buffer.h
	./compile buffer_0.c

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

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

auto_home.c: auto-str conf-home
	./auto-str auto_home "`head -1 conf-home`" > auto_home.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

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_append.o open_excl.o open_read.o open_trunc.o \
open_write.o
	./makelib open.a open_append.o open_excl.o open_read.o open_trunc.o \
	open_write.o

man: syslogger.0

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

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

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

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

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

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

setup: it install
	./install

syslogger.0: syslogger.8
	nroff -man syslogger.8 > syslogger.0

check: it instcheck
	./instcheck

clean: TARGETS
	rm -f `cat TARGETS`
