# 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

client.a: makelib client.o client_domain.o client_setugid.o client_setenv.o facts.o
	./makelib client.a client.o client_domain.o client_setugid.o client_setenv.o facts.o

client.o: compile client.c socket/socket.h fork.h client.h facts.h errors.h iopoll.h
	./compile client.c

client_domain.o: compile client_domain.c client.h facts.h errors.h
	./compile client_domain.c

client_setenv.o: compile client_setenv.c client.h facts.h errors.h setenv.h
	./compile client_setenv.c

client_setugid.o: compile client_setugid.c client.h facts.h errors.h
	./compile client_setugid.c

command.a: makelib module_command.o module_request.o module_output.o facts.o
	./makelib command.a module_command.o module_request.o module_output.o facts.o

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

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

cvm-benchclient: load cvm-benchclient.o client.a socket/socket.a iopoll.o setenv.o
	./load cvm-benchclient client.a socket/socket.a iopoll.o setenv.o 

cvm-benchclient.o: compile cvm-benchclient.c client.h facts.h errors.h
	./compile cvm-benchclient.c

cvm-checkpassword: load cvm-checkpassword.o client.a setenv.o socket/socket.a iopoll.o
	./load cvm-checkpassword client.a setenv.o socket/socket.a iopoll.o 

cvm-checkpassword.o: compile cvm-checkpassword.c client.h facts.h errors.h
	./compile cvm-checkpassword.c

cvm-pwfile: load cvm-pwfile.o command.a pwcmp/client.a crypt.lib
	./load cvm-pwfile command.a pwcmp/client.a `cat crypt.lib` 

cvm-pwfile-local: load cvm-pwfile-local.o local.a socket/socket.a pwcmp/client.a crypt.lib
	./load cvm-pwfile-local local.a socket/socket.a pwcmp/client.a `cat crypt.lib` 

cvm-pwfile-local.o: compile cvm-pwfile-local.c cvm-pwfile.c pwcmp/client.h module.h facts.h errors.h
	./compile cvm-pwfile-local.c

cvm-pwfile-udp: load cvm-pwfile-udp.o udp.a socket/socket.a pwcmp/client.a crypt.lib
	./load cvm-pwfile-udp udp.a socket/socket.a pwcmp/client.a `cat crypt.lib` 

cvm-pwfile-udp.o: compile cvm-pwfile-udp.c cvm-pwfile.c pwcmp/client.h module.h facts.h errors.h
	./compile cvm-pwfile-udp.c

cvm-pwfile.o: compile cvm-pwfile.c pwcmp/client.h module.h facts.h errors.h
	./compile cvm-pwfile.c

cvm-testclient: load cvm-testclient.o client.a socket/socket.a iopoll.o setenv.o
	./load cvm-testclient client.a socket/socket.a iopoll.o setenv.o 

cvm-testclient.o: compile cvm-testclient.c client.h facts.h errors.h
	./compile cvm-testclient.c

cvm-unix: load cvm-unix.o getpwnam.o command.a crypt.lib shadow.lib s.lib
	./load cvm-unix getpwnam.o command.a `cat crypt.lib` `cat shadow.lib` `cat s.lib` 

cvm-unix-local: load cvm-unix-local.o getpwnam.o local.a socket/socket.a crypt.lib shadow.lib s.lib
	./load cvm-unix-local getpwnam.o local.a socket/socket.a `cat crypt.lib` `cat shadow.lib` `cat s.lib` 

cvm-unix-local.o: compile cvm-unix-local.c cvm-unix.c hasspnam.h hasuserpw.h module.h facts.h errors.h
	./compile cvm-unix-local.c

cvm-unix-udp: load cvm-unix-udp.o getpwnam.o udp.a socket/socket.a crypt.lib shadow.lib s.lib
	./load cvm-unix-udp getpwnam.o udp.a socket/socket.a `cat crypt.lib` `cat shadow.lib` `cat s.lib` 

cvm-unix-udp.o: compile cvm-unix-udp.c cvm-unix.c hasspnam.h hasuserpw.h module.h facts.h errors.h
	./compile cvm-unix-udp.c

cvm-unix.o: compile cvm-unix.c hasspnam.h hasuserpw.h module.h facts.h errors.h
	./compile cvm-unix.c

facts.o: compile facts.c facts.h
	./compile facts.c

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

getpwnam.o: compile getpwnam.c module.h facts.h errors.h hasspnam.h hasuserpw.h
	./compile getpwnam.c

hasspnam.h: compile load tryspnam.c
	( ( ./compile tryspnam.c && ./load tryspnam ) >/dev/null 2>&1 \
	  && echo \#define HASGETSPNAM 1 || exit 0 ) > hasspnam.h
	rm -f tryspnam.o tryspnam

hasuserpw.h: s.lib compile load tryuserpw.c
	( ( ./compile tryuserpw.c && ./load tryuserpw `cat s.lib` ) >/dev/null 2>&1 \
	  && echo \#define HASGETUSERPW 1 || exit 0 ) > hasuserpw.h
	rm -f tryuserpw.o tryuserpw

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
	./compile insthier.c

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

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

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

iopoll.o: compile iopoll.c iopoll.h select.h
	./compile iopoll.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

local.a: makelib module_local.o module_request.o module_output.o module_log.o facts.o
	./makelib local.a module_local.o module_request.o module_output.o module_log.o facts.o

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

module_command.o: compile module_command.c module.h facts.h errors.h
	./compile module_command.c

module_local.o: compile module_local.c socket/socket.h module.h facts.h errors.h
	./compile module_local.c

module_log.o: compile module_log.c module.h facts.h errors.h
	./compile module_log.c

module_output.o: compile module_output.c module.h facts.h errors.h
	./compile module_output.c

module_request.o: compile module_request.c module.h facts.h errors.h
	./compile module_request.c

module_udp.o: compile module_udp.c socket/socket.h module.h facts.h errors.h
	./compile module_udp.c

programs: cvm-unix cvm-testclient cvm-pwfile-local cvm-pwfile-udp cvm-pwfile cvm-unix-udp cvm-unix-local cvm-benchclient cvm-checkpassword

pwcmp/client.a: makelib pwcmp/client.o
	./makelib pwcmp/client.a pwcmp/client.o

pwcmp/client.o: compile pwcmp/client.c fork.h client.h facts.h errors.h
	./compile pwcmp/client.c

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

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

setenv.h: choose compile load setenv.h1 setenv.h2 trysetenv.c
	./choose cl trysetenv setenv.h1 setenv.h2 > setenv.h

setenv.o: compile setenv.c setenv.h
	./compile setenv.c

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

socket/accept4.o: compile socket/accept4.c socket/socket.h
	./compile socket/accept4.c

socket/acceptu.o: compile socket/acceptu.c socket/socket.h
	./compile socket/acceptu.c

socket/bind4.o: compile socket/bind4.c socket/socket.h
	./compile socket/bind4.c

socket/bindu.o: compile socket/bindu.c socket/socket.h
	./compile socket/bindu.c

socket/broadcast.o: compile socket/broadcast.c socket/socket.h
	./compile socket/broadcast.c

socket/connect4.o: compile socket/connect4.c socket/socket.h
	./compile socket/connect4.c

socket/connectu.o: compile socket/connectu.c socket/socket.h
	./compile socket/connectu.c

socket/getaddr4.o: compile socket/getaddr4.c socket/socket.h
	./compile socket/getaddr4.c

socket/ipv4addr.o: compile socket/ipv4addr.c socket/socket.h
	./compile socket/ipv4addr.c

socket/listen.o: compile socket/listen.c socket/socket.h
	./compile socket/listen.c

socket/recv4.o: compile socket/recv4.c socket/socket.h
	./compile socket/recv4.c

socket/recvu.o: compile socket/recvu.c socket/socket.h
	./compile socket/recvu.c

socket/reuse.o: compile socket/reuse.c socket/socket.h
	./compile socket/reuse.c

socket/send4.o: compile socket/send4.c socket/socket.h
	./compile socket/send4.c

socket/sendu.o: compile socket/sendu.c socket/socket.h
	./compile socket/sendu.c

socket/shutdown.o: compile socket/shutdown.c socket/socket.h
	./compile socket/shutdown.c

socket/socket.a: makelib socket/accept4.o socket/acceptu.o socket/bind4.o socket/bindu.o socket/broadcast.o socket/connect4.o socket/connectu.o socket/getaddr4.o socket/ipv4addr.o socket/listen.o socket/recv4.o socket/recvu.o socket/reuse.o socket/send4.o socket/sendu.o socket/shutdown.o socket/tcp.o socket/udp.o socket/unixdgm.o socket/unixstr.o
	./makelib socket/socket.a socket/accept4.o socket/acceptu.o socket/bind4.o socket/bindu.o socket/broadcast.o socket/connect4.o socket/connectu.o socket/getaddr4.o socket/ipv4addr.o socket/listen.o socket/recv4.o socket/recvu.o socket/reuse.o socket/send4.o socket/sendu.o socket/shutdown.o socket/tcp.o socket/udp.o socket/unixdgm.o socket/unixstr.o

socket/tcp.o: compile socket/tcp.c socket/socket.h
	./compile socket/tcp.c

socket/udp.o: compile socket/udp.c socket/socket.h
	./compile socket/udp.c

socket/unixdgm.o: compile socket/unixdgm.c socket/socket.h
	./compile socket/unixdgm.c

socket/unixstr.o: compile socket/unixstr.c socket/socket.h
	./compile socket/unixstr.c

udp.a: makelib module_udp.o module_request.o module_output.o module_log.o facts.o
	./makelib udp.a module_udp.o module_request.o module_output.o module_log.o facts.o

