VERSION=0.3.3
PACKAGE=ftpcopy
prefix=/usr/local

PACKAGE_VERSION=$(PACKAGE)-$(VERSION)
HEADERS=ftpparse.h ftplib.h urlparse.h timeoutio.h \
doconnect.h ftpcopy.h timeoutconn.h \
_buffer.h   _getln.h  _readwrite.h  _str.h \
_caldate.h  _ip4.h    _scan.h       _stralloc.h \
seek.h close.h _alloc.h strhash.h
EXTRA_HTML=install.html

DISTFILES=$(HEADERS) README NEWS ChangeLog install.list ftpcp INSTALL \
  install.html.in \
  checktype.sh fsync.sh gettimeofday.sh \
  iopause.sh replace.sh socket.sh typesize.sh
INCLUDES=-I. -DPACKAGE_VERSION=\"$(PACKAGE)-$(VERSION)\" \
   -DPACKAGE=\"$(PACKAGE)\" -DVERSION=\"$(VERSION)\"

TAR=tar
CC=gcc
L=./link.sh
C=./compile.sh
W=./compilew.sh
AR=ar
RANLIB=ranlib
GZIP=gzip --force --best
#
PACKAGE_VERSION=$(PACKAGE)-$(VERSION)
INCLUDES=-DPACKAGE_VERSION=\"$(PACKAGE)-$(VERSION)\" \
 -DPACKAGE=\"$(PACKAGE)\" -DVERSION=\"$(VERSION)\"
#
# GNU standard variables
prefix=/usr/local
exec_prefix=$(prefix)
bindir=$(exec_prefix)/bin
sbindir=$(exec_prefix)/sbin
libexecdir=$(exec_prefix)/libexec
datadir=$(prefix)/share
sysconfdir=$(prefix)/etc
sharedstatedir=$(prefix)/com
localstatedir=$(prefix)/var
libdir=$(prefix)/lib
infodir=$(prefix)/info
lispdir=$(prefix)/emacs/site-lisp
includedir=$(prefix)/include
oldincludedir=/usr/include
mandir=$(prefix)/man
man1dir=$(mandir)/man1
man2dir=$(mandir)/man2
man3dir=$(mandir)/man3
man4dir=$(mandir)/man4
man5dir=$(mandir)/man5
man6dir=$(mandir)/man6
man7dir=$(mandir)/man7
man8dir=$(mandir)/man8
man9dir=$(mandir)/man9


#!S:seek.c:seek_set seek_cur seek_end:uo_fhandle.h
#!S:fifo_make.c:fifo_make:uo_fhandle.h
#!S:open.c:open_read open_trunc open_write open_append open_create \
#  open_read_nb open_write_nb:uo_fhandle.h
#!S:close_on_exe.c:close_on_exec:uo_fhandle.h
#!E:iopause.sh
#!p:wait_pid.c:wait_pid.co:wait_pid.cp
#!p:wait_nohang.c:wait_nohang.co:wait_nohang.cp
#!p:wait.h:wait.ho:wait.hp
libuomisc_a_SOURCES= str_ulong.c str2ulong.c uogetopt.c str2long.c \
uo_wildmat.c nonblock.c str_ulong_fmt.c bailout.c 
libuomisc_a_OBJECTS=$(libuomisc_a_SOURCES:.c=.o)
 
libstrhash_a_SOURCES= strhash_look.c strhash_crea.c strhash_ente.c \
strhash_hash.c strhash_get.c 
libstrhash_a_OBJECTS=$(libstrhash_a_SOURCES:.c=.o)
 
libunix_a_SOURCES= stralloc_opyb.c stralloc_eady.c alloc.c alloc_re.c \
error.c error_str.c stralloc_opys.c stralloc_catb.c stralloc_cat.c \
stralloc_pend.c stralloc_cats.c stralloc_copy.c stralloc_free.c \
env_get.c buffer_0.c buffer_put.c buffer_1.c buffer_get.c open_read.c \
open_trunc.c buffer.c getln.c getln2.c socket_tcp.c socket_conn.c \
iopause.c socket_htons.c socket_connt.c ndelay_off.c openreadclose.c \
readclose.c socket_bind.c socket_udp.c 
libunix_a_OBJECTS=$(libunix_a_SOURCES:.c=.o)
 
libbyte_a_SOURCES= byte_copy.c str_len.c byte_chr.c byte_cr.c \
ip4_scan.c scan_ulong.c byte_zero.c fmt_ulong.c str_chr.c byte_diff.c \
case_diffb.c case_lwrtab.c uint16_unpack.c uint32_unpack.c \
uint16_pack.c str_start.c str_diff.c str_rchr.c scan_long.c \
scan_sign.c 
libbyte_a_OBJECTS=$(libbyte_a_SOURCES:.c=.o)
 
libdns_a_SOURCES= dns_ip.c dns_packet.c dns_domain.c dns_sortip.c \
dns_random.c dns_dfd.c dns_resolve.c dns_rcip.c dns_transmit.c \
dns_ipq.c dns_rcrw.c dns_name.c dns_nd.c dns_dtda.c 
libdns_a_OBJECTS=$(libdns_a_SOURCES:.c=.o)
 
libtai_a_SOURCES= taia_now.c taia_less.c taia_uint.c taia_add.c \
taia_pack.c tai_pack.c taia_sub.c taia_approx.c taia_frac.c \
taia_half.c tai_sub.c tai_now.c 
libtai_a_OBJECTS=$(libtai_a_SOURCES:.c=.o)
 
libuotime_a_SOURCES= uo_now.c uo_sec702dt.c yyyy_mm_dd.c 
libuotime_a_OBJECTS=$(libuotime_a_SOURCES:.c=.o)
 

LIBRARIES += libuomisc.a libstrhash.a libunix.a libbyte.a libdns.a \
libtai.a libuotime.a
 
MANS += 
 
EXTRA_DIST += typesize.sh gettimeofday.sh fsync.c fsync.sh utimes.c \
replace.sh checktype.sh socket.sh
 
PODFILES += ftpls.pod ftpcp.pod ftpcopy.pod
 
TARGETS += ftpcopy ftpls uoinstall ftpls.1 ftpcp.1 ftpcopy.1
 
DISTFILES += Makefile  str_ulong.c str2ulong.c uogetopt.c str2long.c \
uo_wildmat.c nonblock.c str_ulong_fmt.c bailout.c strhash_look.c \
strhash_crea.c strhash_ente.c strhash_hash.c strhash_get.c \
stralloc_opyb.c stralloc_eady.c alloc.c alloc_re.c error.c error_str.c \
stralloc_opys.c stralloc_catb.c stralloc_cat.c stralloc_pend.c \
stralloc_cats.c stralloc_copy.c stralloc_free.c env_get.c buffer_0.c \
buffer_put.c buffer_1.c buffer_get.c open_read.c open_trunc.c buffer.c \
getln.c getln2.c socket_tcp.c socket_conn.c iopause.c socket_htons.c \
socket_connt.c ndelay_off.c openreadclose.c readclose.c socket_bind.c \
socket_udp.c byte_copy.c str_len.c byte_chr.c byte_cr.c ip4_scan.c \
scan_ulong.c byte_zero.c fmt_ulong.c str_chr.c byte_diff.c \
case_diffb.c case_lwrtab.c uint16_unpack.c uint32_unpack.c \
uint16_pack.c str_start.c str_diff.c str_rchr.c scan_long.c \
scan_sign.c dns_ip.c dns_packet.c dns_domain.c dns_sortip.c \
dns_random.c dns_dfd.c dns_resolve.c dns_rcip.c dns_transmit.c \
dns_ipq.c dns_rcrw.c dns_name.c dns_nd.c dns_dtda.c taia_now.c \
taia_less.c taia_uint.c taia_add.c taia_pack.c tai_pack.c taia_sub.c \
taia_approx.c taia_frac.c taia_half.c tai_sub.c tai_now.c uo_now.c \
uo_sec702dt.c yyyy_mm_dd.c ftpcopy.c ftpparse.c ftplib.c \
ftp_read_lis.c urlparse.c doconnect.c timeoutconn.c common.c ftpls.c \
uoinstall.c str_ulong.h str2num.h uogetopt.h uo_wildmat.h nonblock.h \
bailout.h error.h strhashi.h strhash.h stralloc.h gen_allocdefs.h \
alloc.h env.h buffer.h readwrite.h open.h getln.h socket.h byte.h \
ndelay.h openreadclose.h readclose.h str.h ip4.h scan.h fmt.h case.h \
uint16.h uint32.h dns.h taia.h tai.h typesize.h uint64.h uotime.h \
gen_alloc.h typesize.sh gettimeofday.sh fsync.c fsync.sh utimes.c \
replace.sh checktype.sh socket.sh ftpls.pod ftpls.1 ftpcp.pod ftpcp.1 \
ftpcopy.pod ftpcopy.1 ftpls.html ftpcp.html ftpcopy.html
 
DISTFILES += LICENSES.LOCAL
 
DISTFILES += LICENSES
 
CLEANFILES += fsync.o fsync.lib gettimeofday.lib inet_aton.o \
inet_aton.lib socket.lib socklen_t.h socklen_t.stamp ssize_t.h \
ssize_t.stamp typesize2.h typesize2.stamp iopause.h utimes.o \
utimes.lib vfork.o vfork.lib ftpls.1.t ftpcp.1.t ftpcopy.1.t \
ftpls.html.t ftpcp.html.t ftpcopy.html.t pod2html-itemcache \
pod2html-dircache pod2htmi.x~~ pod2htmd.x~~   ftpls.1 ftpcp.1 \
ftpcopy.1
 
CLEANFILES += *.stamp
 

all: $(TARGETS)
 
iopause.h: iopause.sh compile.sh
	./iopause.sh >iopause.t && mv iopause.t $@
libuomisc.a: $(libuomisc_a_OBJECTS)
	$(AR) cru $@ $(libuomisc_a_OBJECTS)
	$(RANLIB) $@
libstrhash.a: $(libstrhash_a_OBJECTS)
	$(AR) cru $@ $(libstrhash_a_OBJECTS)
	$(RANLIB) $@
libunix.a: $(libunix_a_OBJECTS)
	$(AR) cru $@ $(libunix_a_OBJECTS)
	$(RANLIB) $@
libbyte.a: $(libbyte_a_OBJECTS)
	$(AR) cru $@ $(libbyte_a_OBJECTS)
	$(RANLIB) $@
libdns.a: $(libdns_a_OBJECTS)
	$(AR) cru $@ $(libdns_a_OBJECTS)
	$(RANLIB) $@
libtai.a: $(libtai_a_OBJECTS)
	$(AR) cru $@ $(libtai_a_OBJECTS)
	$(RANLIB) $@
libuotime.a: $(libuotime_a_OBJECTS)
	$(AR) cru $@ $(libuotime_a_OBJECTS)
	$(RANLIB) $@
ftpcopy:  ftpcopy.o ftpparse.o ftplib.o ftp_read_lis.o urlparse.o \
doconnect.o timeoutconn.o common.o libuotime.a libdns.a libstrhash.a \
libunix.a libtai.a libuomisc.a libbyte.a error_str.o socket.lib \
fsync.lib utimes.lib gettimeofday.lib link.sh
	$L ftpcopy  ftpcopy.o ftpparse.o ftplib.o ftp_read_lis.o urlparse.o \
doconnect.o timeoutconn.o common.o libuotime.a libdns.a libstrhash.a \
libunix.a libtai.a libuomisc.a libbyte.a error_str.o `cat socket.lib` \
`cat fsync.lib` `cat utimes.lib` `cat gettimeofday.lib` 
ftpls:  ftpls.o ftpparse.o ftplib.o ftp_read_lis.o urlparse.o \
doconnect.o timeoutconn.o common.o libuotime.a libdns.a libstrhash.a \
libunix.a libtai.a libuomisc.a libunix.a libbyte.a socket.lib \
gettimeofday.lib link.sh
	$L ftpls  ftpls.o ftpparse.o ftplib.o ftp_read_lis.o urlparse.o \
doconnect.o timeoutconn.o common.o libuotime.a libdns.a libstrhash.a \
libunix.a libtai.a libuomisc.a libunix.a libbyte.a `cat socket.lib` \
`cat gettimeofday.lib` 
uoinstall:  uoinstall.o libuomisc.a libunix.a libbyte.a fsync.lib \
link.sh
	$L uoinstall  uoinstall.o libuomisc.a libunix.a libbyte.a `cat \
fsync.lib` 
ftpls.1: ftpls.pod
	pod2man --center ftpcopy --release 0.3.3 ftpls.pod >$@.t && \
	mv $@.t $@
ftpcp.1: ftpcp.pod
	pod2man --center ftpcopy --release 0.3.3 ftpcp.pod >$@.t && \
	mv $@.t $@
ftpcopy.1: ftpcopy.pod
	pod2man --center ftpcopy --release 0.3.3 ftpcopy.pod >$@.t && \
	mv $@.t $@
ftpls.html: ftpls.pod
	pod2html --htmlroot=. --podpath=. --outfile $@.t --noindex --title \
"create a FTP directory listing" ftpls.pod >$@.t && mv $@.t \
$@
ftpcp.html: ftpcp.pod
	pod2html --htmlroot=. --podpath=. --outfile $@.t --noindex --title \
"copy files from an FTP server to a local directory" ftpcp.pod >$@.t \
&& mv $@.t $@
ftpcopy.html: ftpcopy.pod
	pod2html --htmlroot=. --podpath=. --outfile $@.t --noindex --title \
"mirror a FTP site" ftpcopy.pod >$@.t && mv $@.t $@
html:  ftpls.html ftpcp.html ftpcopy.html $(EXTRA_HTML)

 
docclean:
	 rm -f   ftpls.1 ftpcp.1 ftpcopy.1
 
doc:   ftpls.1 ftpcp.1 ftpcopy.1
 
openreadclose.o: openreadclose.c error.h open.h readclose.h stralloc.h \
 gen_alloc.h openreadclose.h compilew.sh
	$W -c openreadclose.c
ftpparse.o: ftpparse.c ftpparse.h compilew.sh
	$W -c ftpparse.c
ftpcopy.o: ftpcopy.c ftpparse.h _buffer.h _stralloc.h gen_alloc.h \
 _scan.h _ip4.h _alloc.h byte.h getln.h buffer.h stralloc.h socket.h \
 uint16.h typesize.h typesize2.h ftplib.h doconnect.h str2num.h \
 strhash.h uint32.h str_ulong.h uogetopt.h uotime.h uo_wildmat.h \
 urlparse.h timeoutio.h taia.h tai.h uint64.h iopause.h error.h \
 ftpcopy.h bailout.h str.h open.h compilew.sh
	$W -c ftpcopy.c
dns_random.o: dns_random.c dns.h stralloc.h gen_alloc.h iopause.h \
 taia.h tai.h uint64.h typesize.h typesize2.h uint32.h compile.sh
	$C -c dns_random.c
dns_sortip.o: dns_sortip.c byte.h dns.h stralloc.h gen_alloc.h \
 iopause.h taia.h tai.h uint64.h typesize.h typesize2.h compile.sh
	$C -c dns_sortip.c
uint32_unpack.o: uint32_unpack.c uint32.h typesize.h typesize2.h compilew.sh
	$W -c uint32_unpack.c
taia_add.o: taia_add.c taia.h tai.h uint64.h typesize.h typesize2.h compilew.sh
	$W -c taia_add.c
case_lwrtab.o: case_lwrtab.c case.h compilew.sh
	$W -c case_lwrtab.c
taia_sub.o: taia_sub.c taia.h tai.h uint64.h typesize.h typesize2.h compilew.sh
	$W -c taia_sub.c
uint16_unpack.o: uint16_unpack.c uint16.h typesize.h typesize2.h compilew.sh
	$W -c uint16_unpack.c
common.o: common.c _buffer.h _stralloc.h gen_alloc.h str.h ftplib.h \
 bailout.h ftpcopy.h error.h timeoutio.h taia.h tai.h uint64.h \
 typesize.h typesize2.h iopause.h doconnect.h _readwrite.h close.h compilew.sh
	$W -c common.c
stralloc_pend.o: stralloc_pend.c alloc.h stralloc.h gen_alloc.h \
 gen_allocdefs.h compile.sh
	$C -c stralloc_pend.c
alloc.o: alloc.c alloc.h error.h compile.sh
	$C -c alloc.c
byte_diff.o: byte_diff.c byte.h compilew.sh
	$W -c byte_diff.c
byte_copy.o: byte_copy.c byte.h compilew.sh
	$W -c byte_copy.c
byte_chr.o: byte_chr.c byte.h compilew.sh
	$W -c byte_chr.c
ip4_scan.o: ip4_scan.c scan.h ip4.h compile.sh
	$C -c ip4_scan.c
socket_udp.o: socket_udp.c nonblock.h socket.h uint16.h typesize.h \
 typesize2.h compilew.sh
	$W -c socket_udp.c
taia_now.o: taia_now.c taia.h tai.h uint64.h typesize.h typesize2.h compilew.sh
	$W -c taia_now.c
case_diffb.o: case_diffb.c case.h compilew.sh
	$W -c case_diffb.c
socket_conn.o: socket_conn.c byte.h socket.h uint16.h typesize.h \
 typesize2.h compilew.sh
	$W -c socket_conn.c
nonblock.o: nonblock.c nonblock.h compilew.sh
	$W -c nonblock.c
str_len.o: str_len.c str.h compilew.sh
	$W -c str_len.c
ndelay_off.o: ndelay_off.c ndelay.h compilew.sh
	$W -c ndelay_off.c
taia_frac.o: taia_frac.c taia.h tai.h uint64.h typesize.h typesize2.h compilew.sh
	$W -c taia_frac.c
tai_pack.o: tai_pack.c tai.h uint64.h typesize.h typesize2.h compilew.sh
	$W -c tai_pack.c
dns_domain.o: dns_domain.c error.h alloc.h case.h byte.h dns.h \
 stralloc.h gen_alloc.h iopause.h taia.h tai.h uint64.h typesize.h \
 typesize2.h compile.sh
	$C -c dns_domain.c
taia_pack.o: taia_pack.c taia.h tai.h uint64.h typesize.h typesize2.h compilew.sh
	$W -c taia_pack.c
dns_ip.o: dns_ip.c stralloc.h gen_alloc.h uint16.h typesize.h \
 typesize2.h byte.h dns.h iopause.h taia.h tai.h uint64.h compile.sh
	$C -c dns_ip.c
stralloc_catb.o: stralloc_catb.c stralloc.h gen_alloc.h byte.h compilew.sh
	$W -c stralloc_catb.c
stralloc_opyb.o: stralloc_opyb.c stralloc.h gen_alloc.h byte.h compilew.sh
	$W -c stralloc_opyb.c
stralloc_free.o: stralloc_free.c stralloc.h gen_alloc.h alloc.h compile.sh
	$C -c stralloc_free.c
str_start.o: str_start.c str.h compilew.sh
	$W -c str_start.c
stralloc_eady.o: stralloc_eady.c alloc.h stralloc.h gen_alloc.h \
 gen_allocdefs.h compile.sh
	$C -c stralloc_eady.c
tai_sub.o: tai_sub.c tai.h uint64.h typesize.h typesize2.h compilew.sh
	$W -c tai_sub.c
buffer_0.o: buffer_0.c readwrite.h buffer.h compile.sh
	$C -c buffer_0.c
error.o: error.c error.h compilew.sh
	$W -c error.c
fmt_ulong.o: fmt_ulong.c fmt.h compilew.sh
	$W -c fmt_ulong.c
socket_tcp.o: socket_tcp.c nonblock.h socket.h uint16.h typesize.h \
 typesize2.h compilew.sh
	$W -c socket_tcp.c
tai_now.o: tai_now.c tai.h uint64.h typesize.h typesize2.h compile.sh
	$C -c tai_now.c
dns_rcip.o: dns_rcip.c taia.h tai.h uint64.h typesize.h typesize2.h \
 openreadclose.h stralloc.h gen_alloc.h byte.h ip4.h env.h dns.h \
 iopause.h compile.sh
	$C -c dns_rcip.c
byte_zero.o: byte_zero.c byte.h compilew.sh
	$W -c byte_zero.c
scan_long.o: scan_long.c scan.h compilew.sh
	$W -c scan_long.c
taia_less.o: taia_less.c taia.h tai.h uint64.h typesize.h typesize2.h compilew.sh
	$W -c taia_less.c
scan_sign.o: scan_sign.c scan.h compilew.sh
	$W -c scan_sign.c
str_chr.o: str_chr.c str.h compilew.sh
	$W -c str_chr.c
taia_approx.o: taia_approx.c taia.h tai.h uint64.h typesize.h \
 typesize2.h compilew.sh
	$W -c taia_approx.c
taia_half.o: taia_half.c taia.h tai.h uint64.h typesize.h typesize2.h compile.sh
	$C -c taia_half.c
str2long.o: str2long.c str2num.h compilew.sh
	$W -c str2long.c
open_trunc.o: open_trunc.c open.h compilew.sh
	$W -c open_trunc.c
taia_uint.o: taia_uint.c taia.h tai.h uint64.h typesize.h typesize2.h compilew.sh
	$W -c taia_uint.c
dns_dtda.o: dns_dtda.c stralloc.h gen_alloc.h dns.h iopause.h taia.h \
 tai.h uint64.h typesize.h typesize2.h compile.sh
	$C -c dns_dtda.c
error_str.o: error_str.c error.h compile.sh
	$C -c error_str.c
str_ulong_fmt.o: str_ulong_fmt.c str_ulong.h compilew.sh
	$W -c str_ulong_fmt.c
uint16_pack.o: uint16_pack.c uint16.h typesize.h typesize2.h compilew.sh
	$W -c uint16_pack.c
strhash_ente.o: strhash_ente.c strhashi.h uint32.h typesize.h \
 typesize2.h strhash.h compilew.sh
	$W -c strhash_ente.c
env_get.o: env_get.c env.h compilew.sh
	$W -c env_get.c
ftpls.o: ftpls.c _stralloc.h gen_alloc.h ftpparse.h _buffer.h ftplib.h \
 str_ulong.h uogetopt.h uotime.h doconnect.h urlparse.h timeoutio.h \
 taia.h tai.h uint64.h typesize.h typesize2.h iopause.h error.h \
 getln.h buffer.h stralloc.h fmt.h _str.h ftpcopy.h bailout.h compilew.sh
	$W -c ftpls.c
socket_connt.o: socket_connt.c _readwrite.h byte.h socket.h uint16.h \
 typesize.h typesize2.h socklen_t.h compilew.sh
	$W -c socket_connt.c
getln2.o: getln2.c byte.h getln.h buffer.h stralloc.h gen_alloc.h compile.sh
	$C -c getln2.c
bailout.o: bailout.c error.h bailout.h fmt.h compilew.sh
	$W -c bailout.c
str2ulong.o: str2ulong.c str2num.h compilew.sh
	$W -c str2ulong.c
strhash_look.o: strhash_look.c strhashi.h uint32.h typesize.h \
 typesize2.h strhash.h compilew.sh
	$W -c strhash_look.c
str_diff.o: str_diff.c str.h compilew.sh
	$W -c str_diff.c
dns_dfd.o: dns_dfd.c error.h alloc.h byte.h dns.h stralloc.h \
 gen_alloc.h iopause.h taia.h tai.h uint64.h typesize.h typesize2.h compile.sh
	$C -c dns_dfd.c
readclose.o: readclose.c readwrite.h error.h readclose.h stralloc.h \
 gen_alloc.h compile.sh
	$C -c readclose.c
timeoutconn.o: timeoutconn.c ndelay.h socket.h uint16.h typesize.h \
 typesize2.h iopause.h taia.h tai.h uint64.h error.h timeoutconn.h compilew.sh
	$W -c timeoutconn.c
uo_wildmat.o: uo_wildmat.c uo_wildmat.h compilew.sh
	$W -c uo_wildmat.c
uo_now.o: uo_now.c uotime.h compilew.sh
	$W -c uo_now.c
strhash_crea.o: strhash_crea.c strhashi.h uint32.h typesize.h \
 typesize2.h strhash.h compilew.sh
	$W -c strhash_crea.c
uogetopt.o: uogetopt.c _readwrite.h _str.h env.h scan.h uogetopt.h compilew.sh
	$W -c uogetopt.c
buffer_get.o: buffer_get.c buffer.h byte.h error.h compile.sh
	$C -c buffer_get.c
getln.o: getln.c byte.h getln.h buffer.h stralloc.h gen_alloc.h compile.sh
	$C -c getln.c
uoinstall.o: uoinstall.c error.h _buffer.h _str.h env.h str_ulong.h \
 str2num.h open.h seek.h _stralloc.h gen_alloc.h bailout.h _getln.h \
 buffer.h compilew.sh
	$W -c uoinstall.c
stralloc_cat.o: stralloc_cat.c byte.h stralloc.h gen_alloc.h compilew.sh
	$W -c stralloc_cat.c
dns_packet.o: dns_packet.c error.h dns.h stralloc.h gen_alloc.h \
 iopause.h taia.h tai.h uint64.h typesize.h typesize2.h compile.sh
	$C -c dns_packet.c
strhash_get.o: strhash_get.c strhashi.h uint32.h typesize.h \
 typesize2.h compilew.sh
	$W -c strhash_get.c
str_ulong.o: str_ulong.c str_ulong.h compilew.sh
	$W -c str_ulong.c
alloc_re.o: alloc_re.c alloc.h byte.h compile.sh
	$C -c alloc_re.c
dns_rcrw.o: dns_rcrw.c taia.h tai.h uint64.h typesize.h typesize2.h \
 env.h byte.h str.h openreadclose.h stralloc.h gen_alloc.h dns.h \
 iopause.h compile.sh
	$C -c dns_rcrw.c
yyyy_mm_dd.o: yyyy_mm_dd.c uotime.h str_ulong.h compilew.sh
	$W -c yyyy_mm_dd.c
dns_resolve.o: dns_resolve.c iopause.h taia.h tai.h uint64.h \
 typesize.h typesize2.h byte.h dns.h stralloc.h gen_alloc.h compile.sh
	$C -c dns_resolve.c
dns_name.o: dns_name.c stralloc.h gen_alloc.h uint16.h typesize.h \
 typesize2.h byte.h dns.h iopause.h taia.h tai.h uint64.h compile.sh
	$C -c dns_name.c
socket_bind.o: socket_bind.c byte.h socket.h uint16.h typesize.h \
 typesize2.h compilew.sh
	$W -c socket_bind.c
str_rchr.o: str_rchr.c str.h compilew.sh
	$W -c str_rchr.c
byte_cr.o: byte_cr.c byte.h compilew.sh
	$W -c byte_cr.c
scan_ulong.o: scan_ulong.c scan.h compilew.sh
	$W -c scan_ulong.c
buffer_1.o: buffer_1.c readwrite.h buffer.h compile.sh
	$C -c buffer_1.c
ftp_read_lis.o: ftp_read_lis.c _stralloc.h gen_alloc.h _buffer.h \
 getln.h buffer.h stralloc.h timeoutio.h taia.h tai.h uint64.h \
 typesize.h typesize2.h iopause.h error.h ftplib.h _readwrite.h str.h compilew.sh
	$W -c ftp_read_lis.c
open_read.o: open_read.c open.h compilew.sh
	$W -c open_read.c
urlparse.o: urlparse.c _stralloc.h gen_alloc.h urlparse.h compilew.sh
	$W -c urlparse.c
dns_ipq.o: dns_ipq.c stralloc.h gen_alloc.h case.h byte.h str.h dns.h \
 iopause.h taia.h tai.h uint64.h typesize.h typesize2.h compile.sh
	$C -c dns_ipq.c
stralloc_cats.o: stralloc_cats.c byte.h str.h stralloc.h gen_alloc.h compilew.sh
	$W -c stralloc_cats.c
stralloc_opys.o: stralloc_opys.c byte.h str.h stralloc.h gen_alloc.h compilew.sh
	$W -c stralloc_opys.c
uo_sec702dt.o: uo_sec702dt.c uotime.h compilew.sh
	$W -c uo_sec702dt.c
buffer_put.o: buffer_put.c buffer.h str.h byte.h error.h compile.sh
	$C -c buffer_put.c
socket_htons.o: socket_htons.c socket.h uint16.h typesize.h \
 typesize2.h compilew.sh
	$W -c socket_htons.c
dns_nd.o: dns_nd.c byte.h fmt.h dns.h stralloc.h gen_alloc.h iopause.h \
 taia.h tai.h uint64.h typesize.h typesize2.h compile.sh
	$C -c dns_nd.c
dns_transmit.o: dns_transmit.c socket.h uint16.h typesize.h \
 typesize2.h alloc.h error.h byte.h readwrite.h dns.h stralloc.h \
 gen_alloc.h iopause.h taia.h tai.h uint64.h compile.sh
	$C -c dns_transmit.c
iopause.o: iopause.c taia.h tai.h uint64.h typesize.h typesize2.h \
 iopause.h compile.sh
	$C -c iopause.c
buffer.o: buffer.c buffer.h compile.sh
	$C -c buffer.c
doconnect.o: doconnect.c _stralloc.h gen_alloc.h _scan.h _ip4.h \
 socket.h uint16.h typesize.h typesize2.h bailout.h error.h \
 doconnect.h timeoutconn.h str.h dns.h stralloc.h iopause.h taia.h \
 tai.h uint64.h byte.h compilew.sh
	$W -c doconnect.c
stralloc_copy.o: stralloc_copy.c byte.h stralloc.h gen_alloc.h compilew.sh
	$W -c stralloc_copy.c
strhash_hash.o: strhash_hash.c strhashi.h uint32.h typesize.h \
 typesize2.h strhash.h compilew.sh
	$W -c strhash_hash.c
ftplib.o: ftplib.c _buffer.h _stralloc.h gen_alloc.h _ip4.h getln.h \
 buffer.h stralloc.h ftplib.h doconnect.h str2num.h str.h fmt.h compilew.sh
	$W -c ftplib.c
typesize2.h: typesize.stamp
typesize.stamp: typesize.sh compile.sh link.sh
	CC=$(CC) ./typesize.sh >typesize.t
	@if cmp typesize.t typesize2.h 2>/dev/null >/dev/null ; then : ; else mv typesize.t typesize2.h ; fi
	rm -f typesize.t
	touch $@

gettimeofday.lib: gettimeofday.sh compile.sh link.sh
	./gettimeofday.sh >gettimeofday.t && mv gettimeofday.t $@

fsync.lib: fsync.sh compile.sh link.sh
	./fsync.sh >fsync.t && mv fsync.t $@

utimes.lib: replace.sh compile.sh link.sh
	./replace.sh utimes utimes "" -lsocket >$@.t && mv $@.t $@

socklen_t.h: socklen_t.stamp
socklen_t.stamp: checktype.sh compile.sh link.sh
	CC=$(CC) ./checktype.sh socklen_t int sys/types.h >socklen_t.t
	@if cmp socklen_t.t socklen_t.h 2>/dev/null >/dev/null ; then : ; else mv socklen_t.t socklen_t.h ; fi
	rm -f socklen_t.t
	@touch $@

socket.lib: socket.sh compile.sh link.sh
	./socket.sh >socket.t && mv socket.t $@

.PRECIOUS: Makefile
remake: clean
	rm -f compile.sh link.sh compilew.sh
compile.sh: 
	@echo remaking $@
	@( echo "#! /bin/sh" ; \
	echo '# automatically generated, do not edit' ; \
	echo 'CFLAGS="$${CFLAGS:-$$_CFLAGS_OG}"' ; \
	echo 'CFLAGS="$${CFLAGS:--O2}"' ; \
	echo 'CC="$${CC:-gcc}"' ; \
	echo 'exec $$CC $(DEFS) $(INCLUDES) $$CFLAGS $${1+"$$@"}' ; \
	) > compile.t && chmod 755 compile.t
	@mv compile.t $@
compilew.sh: 
	@echo remaking $@
	@( echo "#! /bin/sh" ; \
	echo '# automatically generated, do not edit' ; \
	echo 'CFLAGS="$${CFLAGS:-$$_CFLAGS_OWG}"' ; \
	echo 'CFLAGS="$${CFLAGS:--O2 -Wall}"' ; \
	echo 'CC="$${CC:-gcc}"' ; \
	echo 'exec $$CC $(DEFS) $(INCLUDES) $$CFLAGS $${1+"$$@"}' ; \
	) > compilew.t && chmod 755 compilew.t
	@mv compilew.t compilew.sh
link.sh:
	@echo remaking $@
	@( echo "#! /bin/sh" ; \
	echo '# automatically generated, do not edit' ; \
	echo 'LDFLAGS="$${LDFLAGS:-$$_CFLAGS_G}"' ; \
	echo 'LDFLAGS="$${LDFLAGS:--g}"' ; \
	echo 'CC="$${CC:-gcc}"' ; \
	echo 'exec $$CC $$LDFLAGS -o $${1+"$$@"} ' ; \
	) > link.t && chmod 755 link.t
	@mv link.t link.sh

clean mostlyclean distclean realclean spotless:
	rm -f *.o $(LIBRARIES) $(TARGETS) $(CLEANFILES)
	rm -rf deps link.sh compile.sh compilew.sh
NEWS-check:
	@if sed 1q NEWS | grep -e "$(VERSION)" > /dev/null; then :; else \
		echo "NEWS not updated; not releasing" 1>&2; \
		exit 1;                                   \
	fi
	@if grep -e "$(VERSION)" ChangeLog > /dev/null; then :; else \
		echo "ChangeLog not updated; not releasing" 1>&2; \
		exit 1;                                   \
	fi
bk-dist: NEWS-check
	bk tag `echo "Release-$(VERSION)" | sed 's/\./-/g'`
	$(MAKE) dist
cvs-dist: NEWS-check
	cvs tag `echo "Release-$(VERSION)" | sed 's/\./-/g'`
	$(MAKE) dist

distdir=$(PACKAGE)-$(VERSION)
dist: $(DISTFILES)
	rm -rf $(PACKAGE_VERSION)
	mkdir $(PACKAGE_VERSION)
	-chmod 755 $(PACKAGE_VERSION)
	@for file in $(DISTFILES); do \
		d=.; \
		if test -d $$d/$$file; then \
			cp -pr $$/$$file $(distdir)/$$file; \
		else \
			test -f $(distdir)/$$file \
				|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
			|| cp -p $$d/$$file $(distdir)/$$file || :; \
		fi; \
	done
	$(TAR) chof $(PACKAGE_VERSION).tar $(PACKAGE_VERSION)
	$(GZIP) $(PACKAGE_VERSION).tar
	rm -rf $(PACKAGE_VERSION)
distcheck: NEWS-check dist 
	$(GZIP) -d <$(PACKAGE_VERSION).tar.gz | $(TAR) xf -
	cd $(PACKAGE_VERSION) && $(MAKE) && $(MAKE) check && $(MAKE) installcheck \
		&& $(MAKE) NEWS-check
force:	

install: $(TARGETS) $(EXTRAINSTALL) uoinstall
	prefix="$(prefix)" exec_prefix="$(exec_prefix)" \
	bindir="$(bindir)" sbindir="$(sbindir)" libexecdir="$(libexecdir)" \
	datadir="$(datadir)" sysconfdir="$(sysconfdir)" \
	sharedstatedir="$(sharedstatedir)" localstatedir="$(localstatedir)" \
	libdir="$(libdir)" infodir="$(infodir)" lispdir="$(lispdir)" \
	includedir="$(includedir)" mandir="$(mandir)" man1dir="$(man1dir)" \
	man2dir="$(man2dir)" man3dir="$(man3dir)" man4dir="$(man4dir)" \
	man5dir="$(man5dir)" man6dir="$(man6dir)" man7dir="$(man7dir)" \
	man8dir="$(man8dir)" man9dir="$(man9dir)" \
	srcdir="$(srcdir)" ./uoinstall <$(srcdir)install.list
installcheck: $(TARGETS) $(EXTRAINSTALL) uoinstall
	rm -rf ./testinstall
	mkdir ./testinstall
	nochown=t $(MAKE) prefix=`pwd`/testinstall install
	rm -rf ./testinstall
	
systype:
	@echo
	@echo "PACKAGE: $(PACKAGE) $(VERSION)"
	@echo "REALNAME: $(REALNAME)"
	@echo "uname-a:" `uname -a`
	@echo "uname-s:" `uname -s`
	@echo "uname-r:" `uname -r`
	@echo "uname-v:" `uname -v`
	@echo "uname-m:" `uname -m`

# that's not the "right" dependency, but that way it works even if
# uolib is absent.
LICENSES: Makefile.pre LICENSES.HEAD LICENSES.LOCAL
	( cat LICENSES.HEAD ; \
	for i in *.[ch] ; do \
		grep -h -s "^$$i:" /home/uwe/work/uolib/LICENSES.REPO \
		|| grep -h -s "^$$i:" ./LICENSES.LOCAL \
		|| grep -h -s "^$$i:" ./LICENSES \
		|| echo "$$i: unknown" ; \
	done ; \
	) >>$@.t
	mv $@.t $@

check:
	@echo "no 'make check' available. Do it by hand, see 'README'"
install.html: install.html.in Makefile.pre
	sed -e "s/@PACKAGE@/$(PACKAGE)/g" \
	-e "s/@VERSION@/$(VERSION)/g" \
	-e "s/@PACKAGE_VERSION@/$(PACKAGE_VERSION)/g" <$@.in >$@.t \
	&& mv $@.t $@
INSTALL.stamp: install.html
	lynx -dump install.html >INSTALL.t
	if cmp INSTALL.t INSTALL 2>/dev/null ; then \
		touch $@ ; \
		rm -f INSTALL.t ; \
	else  \
		if test -w INSTALL ; then \
			mv  INSTALL.t INSTALL && touch $@ ; \
		else \
			echo "can't change INSTALL" ; exit 1 ; \
		fi \
	fi
INSTALL: INSTALL.stamp
	#
