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

SHELL=/bin/sh

default: it

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

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

auto-str: \
load auto-str.o unix.a byte.a
	./load auto-str unix.a byte.a 

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

auto-uid: \
load auto-uid.o unix.a byte.a
	./load auto-uid unix.a byte.a 

auto-uid.o: \
compile auto-uid.c buffer.h readwrite.h exit.h fmt.h
	./compile auto-uid.c

auto-gid: \
load auto-gid.o unix.a byte.a
	./load auto-gid unix.a byte.a 

auto-gid.o: \
compile auto-gid.c buffer.h readwrite.h exit.h fmt.h
	./compile auto-gid.c

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

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

auto_qmailhome.c: \
auto-str conf-qmailhome
	./auto-str auto_qmailhome `head -1 conf-qmailhome` > auto_qmailhome.c

auto_qmailhome.o: \
compile auto_qmailhome.c
	./compile auto_qmailhome.c

auto_users.c: \
auto-str conf-realdomainowner conf-users
	(  ./auto-str auto_realdomainowner `head -1 conf-realdomainowner` \
	&& ./auto-str auto_authdb `head -1 conf-users` \
	&& ./auto-str auto_vida `head -1 conf-groups` \
	) > auto_users.c.tmp && mv auto_users.c.tmp auto_users.c

auto_users.o: \
compile auto_users.c
	./compile auto_users.c

auto_uids.c: \
auto-uid auto-gid conf-users conf-groups
	(  ./auto-uid auto_uidad `head -1 conf-users` \
	&& ./auto-uid auto_uidqu `head -2 conf-users | tail -1` \
	&& ./auto-gid auto_gidvida `head -1 conf-groups` \
	) > auto_uids.c.tmp && mv auto_uids.c.tmp auto_uids.c

auto_uids.o: \
compile auto_uids.c
	./compile auto_uids.c

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

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

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

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

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

byte.a: \
makelib byte_copy.o byte_cr.o byte_diff.o str_len.o \
str_start.o byte_chr.o fmt_ulong.o uint32_pack.o uint32_unpack.o
	./makelib byte.a byte_copy.o byte_cr.o byte_diff.o \
	str_len.o str_start.o byte_chr.o \
	fmt_ulong.o uint32_pack.o uint32_unpack.o

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

cdb.h: uint32.h

cdb_make.h: uint32.h

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

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

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

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

check: \
it instcheck
	./instcheck

chkshsgr: \
load chkshsgr.o
	./load chkshsgr 

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

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

compile: \
warn-auto.sh conf-cc systype print-cc.sh trycpp.c
	sh print-cc.sh > compile
	chmod 755 compile

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

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

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

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

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

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

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

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

install: \
load install.o hier.o auto_home.o auto_uids.o unix.a byte.a
	./load install hier.o auto_home.o auto_uids.o unix.a byte.a 

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

instcheck: \
load instcheck.o hier.o auto_home.o auto_uids.o unix.a byte.a
	./load instcheck hier.o auto_home.o auto_uids.o unix.a byte.a 

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

it: \
prog install instcheck

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

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

md5c.o: \
compile md5c.c global.h md5.h
	./compile md5c.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

prog: \
vida-pwdbinit vida-pwdbmake vida-assign vida-passwd vida-maildirmake

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

seek.a: \
makelib seek_cur.o seek_end.o seek_set.o
	./makelib seek.a seek_cur.o seek_end.o seek_set.o

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

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

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

setup: \
it install
	./install

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

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

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

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

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

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

systype: \
find-systype.sh trycpp.c x86cpuid.c
	sh find-systype.sh > systype

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

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

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

unix.a: \
makelib alloc.o alloc_re.o buffer.o buffer_0.o buffer_1.o buffer_2.o buffer_copy.o \
buffer_get.o buffer_put.o env.o error.o error_str.o getln.o getln2.o open_read.o \
open_trunc.o prot.o sgetopt.o stralloc_cat.o \
stralloc_catb.o stralloc_cats.o stralloc_copy.o stralloc_eady.o stralloc_opyb.o \
stralloc_opys.o stralloc_pend.o strerr_die.o strerr_sys.o subgetopt.o
	./makelib unix.a alloc.o alloc_re.o buffer.o buffer_1.o buffer_0.o buffer_2.o \
	buffer_copy.o buffer_get.o buffer_put.o env.o error.o getln.o getln2.o \
	error_str.o open_read.o open_trunc.o \
	prot.o sgetopt.o stralloc_cat.o stralloc_catb.o \
	stralloc_cats.o stralloc_copy.o stralloc_eady.o stralloc_opyb.o \
	stralloc_opys.o stralloc_pend.o strerr_die.o strerr_sys.o subgetopt.o

pwdb.o: \
compile pwdb.c auto_users.h auto_qmailhome.h buffer.h byte.h error.h exit.h getln.h str.h seek.h stralloc.h strerr.h
	./compile pwdb.c

vida-pwdbinit: \
load vida-pwdbinit.o auto_uids.o auto_users.o auto_qmailhome.o pwdb.o cdb.a seek.a unix.a byte.a
	./load vida-pwdbinit auto_uids.o auto_users.o auto_qmailhome.o pwdb.o cdb.a seek.a unix.a byte.a

vida-pwdbinit.o: \
compile vida-pwdbinit.c auto_uids.h auto_users.h auto_qmailhome.h pwdb.h env.h strerr.h error.h exit.h cdb_make.h
	./compile vida-pwdbinit.c

vida-pwdbmake: \
load vida-pwdbmake.o auto_users.o auto_qmailhome.o pwdb.o cdb.a seek.a unix.a byte.a
	./load vida-pwdbmake auto_users.o auto_qmailhome.o pwdb.o cdb.a seek.a unix.a byte.a 

vida-pwdbmake.o: \
compile vida-pwdbmake.c auto_users.h auto_qmailhome.h pwdb.h strerr.h stralloc.h gen_alloc.h getln.h buffer.h \
stralloc.h buffer.h exit.h byte.h cdb_make.h buffer.h uint32.h
	./compile vida-pwdbmake.c

vida-assign: \
load vida-assign.o auto_home.o auto_users.o auto_qmailhome.o seek.a unix.a byte.a
	./load vida-assign auto_home.o auto_users.o auto_qmailhome.o seek.a unix.a byte.a

vida-assign.o: \
compile vida-assign.c auto_home.h auto_users.h auto_qmailhome.h \
prot.h buffer.h env.h stralloc.h strerr.h error.h seek.h open.h fmt.h exit.h sgetopt.h
	./compile vida-assign.c

vida-passwd: \
load vida-passwd.o auto_users.o auto_qmailhome.o auto_home.o pwdb.o seek.a unix.a byte.a
	./load vida-passwd auto_users.o auto_qmailhome.o auto_home.o pwdb.o seek.a unix.a byte.a

vida-passwd.o: \
compile vida-passwd.c auto_users.h auto_qmailhome.h pwdb.h auto_home.h prot.h env.h sgetopt.h stralloc.h strerr.h subgetopt.h \
error.h seek.h open.h exit.h
	./compile vida-passwd.c

vida-maildirmake: \
load vida-maildirmake.o unix.a byte.a
	./load vida-maildirmake unix.a byte.a

vida-maildirmake.o: \
compile vida-maildirmake.c strerr.h exit.h
	./compile vida-maildirmake.c

clean:
	rm -f `cat TARGETS` *~
