VERSION=0.4.8
PACKAGE=ftpcopy
CLASS=web
prefix=/usr/local
EXTRA_SYSTYPE=have_futimes.h have_utimes.h iopause.h


INCLUDES=-I. -DPACKAGE_VERSION=\"$(PACKAGE)-$(VERSION)\" \
   -DPACKAGE=\"$(PACKAGE)\" -DVERSION=\"$(VERSION)\"

CC=gcc
L=./auto-link.sh
C=./auto-compile.sh
W=./auto-compilew.sh
GZIP=gzip --force --best
CLEANFILES+=distcheck.tmp distcheck.tmp2
PACKAGE_VERSION=$(PACKAGE)-$(VERSION)
INCLUDES=-DPACKAGE_VERSION=\"$(PACKAGE)-$(VERSION)\" \
 -DPACKAGE=\"$(PACKAGE)\" -DVERSION=\"$(VERSION)\"
NEED_LFS=0


#
#
#
#


libtai_a_SOURCES=taia_pack.c tai_pack.c taia_sub.c taia_approx.c \
taia_frac.c taia_less.c taia_uint.c tai_uint.c tai_sub.c taia_add.c \
tai_add.c taia_now.c taia_half.c tai_now.c 
libtai_a_OBJECTS=$(libtai_a_SOURCES:.c=.o)
 
libdns_a_SOURCES=dns_ipq.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_rcrw.c dns_name.c dns_nd.c dns_dtda.c 
libdns_a_OBJECTS=$(libdns_a_SOURCES:.c=.o)
 
libbyte_a_SOURCES=scan_long.c scan_sign.c scan_ulong.c str_chr.c \
str_len.c str_diff.c byte_copy.c case_diffb.c case_lwrtab.c \
uint32_unpack.c uint32_pack.c ip4_scan.c byte_zero.c uint16_pack.c \
uint16_unpack.c byte_chr.c byte_diff.c byte_cr.c fmt_ulong.c \
str_start.c str_rchr.c case_lowers.c case_lowerb.c fmt_uint0.c \
case_starts.c 
libbyte_a_OBJECTS=$(libbyte_a_SOURCES:.c=.o)
 
libuomisc_a_SOURCES=uogetopt.c uo_wildmat.c bailout.c bailout_name.c \
host_connect4.c timeoutconn.c 
libuomisc_a_OBJECTS=$(libuomisc_a_SOURCES:.c=.o)
 
libunix_a_SOURCES=env_get.c buffer_2.c buffer_put.c error.c \
error_str.c socket_connt.c socket_tcp.c ndelay_on.c socket_udp.c \
socket_bind.c socket_htons.c socket_conn.c iopause.c stralloc_pend.c \
gen_alloc_end.c gen_alloc_ady.c alloc.c alloc_re.c stralloc_cats.c \
stralloc_catb.c stralloc_plus.c gen_alloc_lus.c stralloc_opyb.c \
stralloc_eady.c stralloc_opys.c stralloc_copy.c openreadclose.c \
readclose.c readclose_app.c open_read.c stralloc_free.c ndelay_off.c \
stralloc_cat.c buffer_0.c buffer_1.c buffer_get.c open_trunc.c \
buffer.c getln.c get_cwd.c api_futimes.c api_utimes.c api_dir.c 
libunix_a_OBJECTS=$(libunix_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)
 
libstrhash_a_SOURCES=strhash_look.c strhash_get.c strhash_crea.c \
strhash_ente.c strhash_hash.c strhash_dest.c 
libstrhash_a_OBJECTS=$(libstrhash_a_SOURCES:.c=.o)
 
LIBRARIES += libuomisc.a libstrhash.a libunix.a libbyte.a libdns.a \
libtai.a libuotime.a
 
TARGETS += ftpcopy ftpls ftpcopy.1 ftpcp.1 ftpls.1
 
CLEANFILES += *.da *.bb *.bbg check.out conftest.c conftest conftest.o \
fsync.o fsync.lib gettimeofday.lib inet_aton.o inet_aton.lib \
auto-lfs.* socket.lib socklen_t.h socklen_t.stamp ssize_t.h \
ssize_t.stamp auto-typesize.h typesize.stamp have_futimes.h \
have_utimes.h iopause.h utimes.o utimes.lib vfork.o vfork.lib \
auto-version.tmac ftpcopy.html.t ftpcp.html.t install.html.t \
ftpls.html.t INSTALL.t ftpcopy.1 ftpcopy.1.t ftpcp.1 ftpcp.1.t ftpls.1 \
ftpls.1.t *.stamp
 
MAINTAINERCLEAN_FILES += ftpcopy.html ftpcp.html install.html \
ftpls.html INSTALL
 

all:  auto-systype $(TARGETS) $(EXTRA_TARGETS)
 
have_futimes.h: have_func.sh auto-compile.sh auto-link.sh
	sh have_func.sh futimes "" "futimes(0,0)" "" "" >$@.t && mv $@.t \
$@
have_utimes.h:have_func.sh auto-compile.sh auto-link.sh
	sh have_func.sh utimes "" "utimes(0,0)" "" "" >$@.t && mv $@.t \
$@
iopause.h: iopause.sh auto-compile.sh auto-link.sh
	sh iopause.sh >iopause.t && mv iopause.t $@
ftpcopy:  ftpcopy.o ftpparse.o ftplib.o ftp_read_lis.o urlparse.o \
common.o mdtm.o mlsx.o mysleep.o libuotime.a libuomisc.a libdns.a \
libstrhash.a libunix.a libtai.a libbyte.a socket.lib fsync.lib \
utimes.lib gettimeofday.lib auto-link.sh
	$L ftpcopy  ftpcopy.o ftpparse.o ftplib.o ftp_read_lis.o urlparse.o \
common.o mdtm.o mlsx.o mysleep.o libuotime.a libuomisc.a libdns.a \
libstrhash.a libunix.a libtai.a libbyte.a `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 mlsx.o \
sort_it.o common.o mysleep.o libuotime.a libdns.a libuomisc.a \
libstrhash.a libdns.a libunix.a libtai.a libbyte.a socket.lib \
gettimeofday.lib auto-link.sh
	$L ftpls  ftpls.o ftpparse.o ftplib.o ftp_read_lis.o urlparse.o mlsx.o \
sort_it.o common.o mysleep.o libuotime.a libdns.a libuomisc.a \
libstrhash.a libdns.a libunix.a libtai.a libbyte.a `cat socket.lib` \
`cat gettimeofday.lib` 
libtai.a: $(libtai_a_OBJECTS) auto-makelib.sh
	./auto-makelib.sh $@ $(libtai_a_OBJECTS)
libdns.a: $(libdns_a_OBJECTS) auto-makelib.sh
	./auto-makelib.sh $@ $(libdns_a_OBJECTS)
libbyte.a: $(libbyte_a_OBJECTS) auto-makelib.sh
	./auto-makelib.sh $@ $(libbyte_a_OBJECTS)
libuomisc.a: $(libuomisc_a_OBJECTS) auto-makelib.sh
	./auto-makelib.sh $@ $(libuomisc_a_OBJECTS)
libunix.a: $(libunix_a_OBJECTS) auto-makelib.sh
	./auto-makelib.sh $@ $(libunix_a_OBJECTS)
libuotime.a: $(libuotime_a_OBJECTS) auto-makelib.sh
	./auto-makelib.sh $@ $(libuotime_a_OBJECTS)
libstrhash.a: $(libstrhash_a_OBJECTS) \
auto-makelib.sh
	./auto-makelib.sh $@ $(libstrhash_a_OBJECTS)
ftpcopy.html: ftpcopy.1.in groff.tmac auto-version.tmac
	groff -mwww -Thtml -P-l groff.tmac auto-version.tmac ftpcopy.1.in \
>ftpcopy.html.t && mv ftpcopy.html.t ftpcopy.html
ftpcp.html: ftpcp.1.in groff.tmac auto-version.tmac
	groff -mwww -Thtml -P-l groff.tmac auto-version.tmac ftpcp.1.in \
>ftpcp.html.t && mv ftpcp.html.t ftpcp.html
install.html: install.0.in groff.tmac auto-version.tmac
	groff -mwww -Thtml -P-l groff.tmac auto-version.tmac install.0.in \
>install.html.t && mv install.html.t install.html
ftpls.html: ftpls.1.in groff.tmac auto-version.tmac
	groff -mwww -Thtml -P-l groff.tmac auto-version.tmac ftpls.1.in \
>ftpls.html.t && mv ftpls.html.t ftpls.html
INSTALL: install.0.in groff.tmac auto-version.tmac
	groff -man -Tascii groff.tmac auto-version.tmac install.0.in |col -b \
>INSTALL.t && mv INSTALL.t INSTALL
ftpcopy.1: ftpcopy.1.in groff.tmac auto-version.tmac
	cat groff.tmac auto-version.tmac ftpcopy.1.in \
 | sed 's/^.section/.SH/' >ftpcopy.1.t \
 && mv ftpcopy.1.t ftpcopy.1
ftpcp.1: ftpcp.1.in groff.tmac auto-version.tmac
	cat groff.tmac auto-version.tmac ftpcp.1.in \
 | sed 's/^.section/.SH/' >ftpcp.1.t \
 && mv ftpcp.1.t ftpcp.1
ftpls.1: ftpls.1.in groff.tmac auto-version.tmac
	cat groff.tmac auto-version.tmac ftpls.1.in \
 | sed 's/^.section/.SH/' >ftpls.1.t \
 && mv ftpls.1.t ftpls.1
auto-version.tmac: version.tmac.stamp
version.tmac.stamp: Makefile
	(echo .ds PA $(PACKAGE) ;\
	 echo .ds VE $(VERSION) ;\
	 echo .ds CL $(CLASS) ;\
	) >auto-version.tmac.t
	cmp auto-version.tmac auto-version.tmac.t \
	 || cp auto-version.tmac.t auto-version.tmac
	touch $@ && rm auto-version.tmac.t
html: ftpcopy.html ftpcp.html install.html ftpls.html INSTALL \
$(EXTRA_HTML)

 
stralloc_copy.o: stralloc_copy.c stralloc.h gen_alloc.h auto-compilew.sh
	$W  -c $<
buffer_put.o: buffer_put.c buffer.h str.h byte.h error.h auto-compile.sh
	$C  -c $<
bailout.o: bailout.c error.h buffer.h bailout.h fmt.h auto-compilew.sh
	$W  -c $<
dns_resolve.o: dns_resolve.c iopause.h taia.h tai.h uint64.h typesize.h \
  auto-typesize.h byte.h dns.h stralloc.h gen_alloc.h auto-compile.sh
	$C  -c $<
str_len.o: str_len.c str.h auto-compilew.sh
	$W  -c $<
ftplib.o: ftplib.c buffer.h stralloc.h gen_alloc.h ip4.h scan.h getln.h \
  ftplib.h host_connect.h str.h fmt.h byte.h auto-compilew.sh
	$W  -c $<
ftpparse.o: ftpparse.c ftpparse.h auto-compilew.sh
	$W  -c $<
strhash_crea.o: strhash_crea.c strhashi.h uint32.h typesize.h \
  auto-typesize.h strhash.h auto-compilew.sh
	$W  -c $<
api_futimes.o: api_futimes.c have_futimes.h api_futimes.h api_utimes.h auto-compilew.sh
	$W  -c $<
taia_less.o: taia_less.c taia.h tai.h uint64.h typesize.h auto-typesize.h auto-compilew.sh
	$W  -c $<
alloc_re.o: alloc_re.c alloc.h byte.h auto-compilew.sh
	$W  -c $<
getln.o: getln.c byte.h getln.h buffer.h stralloc.h gen_alloc.h auto-compilew.sh
	$W  -c $<
stralloc_opyb.o: stralloc_opyb.c stralloc.h gen_alloc.h byte.h auto-compilew.sh
	$W  -c $<
uint32_unpack.o: uint32_unpack.c uint32.h typesize.h auto-typesize.h auto-compilew.sh
	$W  -c $<
case_diffb.o: case_diffb.c case.h auto-compilew.sh
	$W  -c $<
fmt_ulong.o: fmt_ulong.c gen_fmt.h fmt.h auto-compilew.sh
	$W  -c $<
readclose.o: readclose.c readclose.h stralloc.h gen_alloc.h auto-compilew.sh
	$W  -c $<
socket_bind.o: socket_bind.c byte.h socket.h uint16.h typesize.h \
  auto-typesize.h auto-compilew.sh
	$W  -c $<
buffer.o: buffer.c buffer.h auto-compile.sh
	$C  -c $<
tai_sub.o: tai_sub.c tai.h uint64.h typesize.h auto-typesize.h auto-compilew.sh
	$W  -c $<
strhash_get.o: strhash_get.c strhashi.h uint32.h typesize.h \
  auto-typesize.h auto-compilew.sh
	$W  -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 auto-typesize.h auto-compile.sh
	$C  -c $<
ndelay_on.o: ndelay_on.c ndelay.h auto-compilew.sh
	$W  -c $<
byte_copy.o: byte_copy.c byte.h auto-compilew.sh
	$W  -c $<
sort_it.o: sort_it.c ftpparse.h sort_it.h byte.h auto-compilew.sh
	$W  -c $<
mlsx.o: mlsx.c bailout.h ftpparse.h str.h case.h mlsx.h auto-compilew.sh
	$W  -c $<
case_lwrtab.o: case_lwrtab.c case.h auto-compilew.sh
	$W  -c $<
buffer_2.o: buffer_2.c readwrite.h buffer.h auto-compile.sh
	$C  -c $<
uogetopt.o: uogetopt.c readwrite.h str.h env.h scan.h uogetopt.h \
  attributes.h auto-compilew.sh
	$W  -c $<
stralloc_cat.o: stralloc_cat.c stralloc.h gen_alloc.h auto-compilew.sh
	$W  -c $<
stralloc_opys.o: stralloc_opys.c str.h stralloc.h gen_alloc.h auto-compilew.sh
	$W  -c $<
yyyy_mm_dd.o: yyyy_mm_dd.c uotime.h fmt.h auto-compilew.sh
	$W  -c $<
dns_ip.o: dns_ip.c stralloc.h gen_alloc.h uint16.h typesize.h \
  auto-typesize.h byte.h dns.h iopause.h taia.h tai.h uint64.h auto-compile.sh
	$C  -c $<
openreadclose.o: openreadclose.c error.h open.h readclose.h stralloc.h \
  gen_alloc.h openreadclose.h auto-compilew.sh
	$W  -c $<
iopause.o: iopause.c taia.h tai.h uint64.h typesize.h auto-typesize.h \
  iopause.h auto-compilew.sh
	$W  -c $<
taia_now.o: taia_now.c taia.h tai.h uint64.h typesize.h auto-typesize.h auto-compilew.sh
	$W  -c $<
uo_wildmat.o: uo_wildmat.c uo_wildmat.h auto-compilew.sh
	$W  -c $<
mysleep.o: mysleep.c iopause.h taia.h tai.h uint64.h typesize.h \
  auto-typesize.h mysleep.h auto-compilew.sh
	$W  -c $<
case_starts.o: case_starts.c case.h auto-compilew.sh
	$W  -c $<
dns_dtda.o: dns_dtda.c stralloc.h gen_alloc.h dns.h iopause.h taia.h \
  tai.h uint64.h typesize.h auto-typesize.h auto-compile.sh
	$C  -c $<
taia_frac.o: taia_frac.c taia.h tai.h uint64.h typesize.h auto-typesize.h auto-compilew.sh
	$W  -c $<
error_str.o: error_str.c error.h auto-compilew.sh
	$W  -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 auto-typesize.h auto-compile.sh
	$C  -c $<
uo_now.o: uo_now.c uotime.h auto-compilew.sh
	$W  -c $<
api_utimes.o: api_utimes.c api_utimes.h have_utimes.h auto-compilew.sh
	$W  -c $<
taia_pack.o: taia_pack.c taia.h tai.h uint64.h typesize.h auto-typesize.h \
  uint32.h auto-compilew.sh
	$W  -c $<
bailout_name.o: bailout_name.c bailout.h auto-compilew.sh
	$W  -c $<
buffer_1.o: buffer_1.c readwrite.h buffer.h auto-compile.sh
	$C  -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 auto-typesize.h auto-compile.sh
	$C  -c $<
ip4_scan.o: ip4_scan.c ip4.h scan.h auto-compile.sh
	$C  -c $<
ftpls.o: ftpls.c attributes.h stralloc.h gen_alloc.h ftpparse.h buffer.h \
  ftplib.h alloc.h uogetopt.h uotime.h urlparse.h iopause.h taia.h tai.h \
  uint64.h typesize.h auto-typesize.h getln.h fmt.h str.h error.h \
  ftpcopy.h bailout.h close.h readwrite.h sort_it.h mlsx.h strhash.h \
  uint32.h auto-compilew.sh
	$W  -c $<
ftp_read_lis.o: ftp_read_lis.c stralloc.h gen_alloc.h buffer.h getln.h \
  timeoutio.h taia.h tai.h uint64.h typesize.h auto-typesize.h iopause.h \
  error.h ftplib.h readwrite.h str.h auto-compilew.sh
	$W  -c $<
error.o: error.c error.h auto-compilew.sh
	$W  -c $<
byte_zero.o: byte_zero.c byte.h auto-compilew.sh
	$W  -c $<
timeoutconn.o: timeoutconn.c error.h iopause.h taia.h tai.h uint64.h \
  typesize.h auto-typesize.h timeoutconn.h uint16.h ndelay.h socket.h \
  close.h auto-compilew.sh
	$W  -c $<
byte_chr.o: byte_chr.c byte.h auto-compilew.sh
	$W  -c $<
tai_now.o: tai_now.c tai.h uint64.h typesize.h auto-typesize.h auto-compile.sh
	$C  -c $<
taia_uint.o: taia_uint.c taia.h tai.h uint64.h typesize.h auto-typesize.h auto-compilew.sh
	$W  -c $<
strhash_ente.o: strhash_ente.c strhashi.h uint32.h typesize.h \
  auto-typesize.h strhash.h auto-compilew.sh
	$W  -c $<
str_start.o: str_start.c str.h auto-compilew.sh
	$W  -c $<
byte_cr.o: byte_cr.c byte.h auto-compilew.sh
	$W  -c $<
ndelay_off.o: ndelay_off.c ndelay.h auto-compilew.sh
	$W  -c $<
gen_alloc_ady.o: gen_alloc_ady.c alloc.h gen_alloci.h auto-compilew.sh
	$W  -c $<
scan_ulong.o: scan_ulong.c gen_scan.h scan.h case.h auto-compilew.sh
	$W  -c $<
socket_connt.o: socket_connt.c readwrite.h byte.h socket.h uint16.h \
  typesize.h auto-typesize.h socklen_t.h auto-compilew.sh
	$W  -c $<
socket_tcp.o: socket_tcp.c ndelay.h socket.h uint16.h typesize.h \
  auto-typesize.h auto-compilew.sh
	$W  -c $<
urlparse.o: urlparse.c stralloc.h gen_alloc.h urlparse.h str.h auto-compilew.sh
	$W  -c $<
tai_pack.o: tai_pack.c tai.h uint64.h typesize.h auto-typesize.h uint32.h auto-compilew.sh
	$W  -c $<
scan_long.o: scan_long.c gen_scan.h scan.h case.h auto-compilew.sh
	$W  -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 auto-typesize.h auto-compile.sh
	$C  -c $<
dns_rcip.o: dns_rcip.c taia.h tai.h uint64.h typesize.h auto-typesize.h \
  openreadclose.h stralloc.h gen_alloc.h byte.h ip4.h env.h dns.h \
  iopause.h auto-compile.sh
	$C  -c $<
alloc.o: alloc.c alloc.h error.h auto-compilew.sh
	$W  -c $<
dns_random.o: dns_random.c dns.h stralloc.h gen_alloc.h iopause.h taia.h \
  tai.h uint64.h typesize.h auto-typesize.h uint32.h auto-compile.sh
	$C  -c $<
socket_udp.o: socket_udp.c ndelay.h socket.h uint16.h typesize.h \
  auto-typesize.h auto-compilew.sh
	$W  -c $<
scan_sign.o: scan_sign.c scan.h auto-compilew.sh
	$W  -c $<
buffer_get.o: buffer_get.c buffer.h byte.h error.h auto-compile.sh
	$C  -c $<
strhash_look.o: strhash_look.c strhashi.h uint32.h typesize.h \
  auto-typesize.h strhash.h auto-compilew.sh
	$W  -c $<
str_diff.o: str_diff.c str.h auto-compilew.sh
	$W  -c $<
ftpcopy.o: ftpcopy.c attributes.h ftpparse.h buffer.h stralloc.h \
  gen_alloc.h scan.h ip4.h alloc.h byte.h getln.h ftplib.h strhash.h \
  uint32.h typesize.h auto-typesize.h fmt.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 readwrite.h close.h nowarn.h \
  get_cwd.h api_futimes.h api_utimes.h case.h mdtm.h mlsx.h api_dir.h \
  mysleep.h auto-compilew.sh
	$W  -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 auto-typesize.h auto-compile.sh
	$C  -c $<
api_dir.o: api_dir.c stralloc.h gen_alloc.h alloc.h str.h api_dir.h auto-compilew.sh
	$W  -c $<
uint32_pack.o: uint32_pack.c uint32.h typesize.h auto-typesize.h auto-compilew.sh
	$W  -c $<
buffer_0.o: buffer_0.c readwrite.h buffer.h auto-compile.sh
	$C  -c $<
stralloc_pend.o: stralloc_pend.c stralloc.h gen_alloc.h gen_alloci.h auto-compilew.sh
	$W  -c $<
stralloc_eady.o: stralloc_eady.c stralloc.h gen_alloc.h gen_alloci.h auto-compilew.sh
	$W  -c $<
case_lowerb.o: case_lowerb.c case.h auto-compilew.sh
	$W  -c $<
stralloc_free.o: stralloc_free.c stralloc.h gen_alloc.h alloc.h auto-compilew.sh
	$W  -c $<
tai_uint.o: tai_uint.c tai.h uint64.h typesize.h auto-typesize.h auto-compilew.sh
	$W  -c $<
strhash_hash.o: strhash_hash.c strhashi.h uint32.h typesize.h \
  auto-typesize.h strhash.h auto-compilew.sh
	$W  -c $<
taia_approx.o: taia_approx.c taia.h tai.h uint64.h typesize.h \
  auto-typesize.h auto-compilew.sh
	$W  -c $<
uint16_unpack.o: uint16_unpack.c uint16.h typesize.h auto-typesize.h auto-compilew.sh
	$W  -c $<
byte_diff.o: byte_diff.c byte.h auto-compilew.sh
	$W  -c $<
taia_add.o: taia_add.c taia.h tai.h uint64.h typesize.h auto-typesize.h auto-compilew.sh
	$W  -c $<
uint16_pack.o: uint16_pack.c uint16.h typesize.h auto-typesize.h auto-compilew.sh
	$W  -c $<
stralloc_plus.o: stralloc_plus.c stralloc.h gen_alloc.h gen_alloci.h auto-compilew.sh
	$W  -c $<
gen_alloc_end.o: gen_alloc_end.c gen_alloci.h byte.h auto-compilew.sh
	$W  -c $<
dns_transmit.o: dns_transmit.c socket.h uint16.h typesize.h \
  auto-typesize.h alloc.h error.h byte.h readwrite.h dns.h stralloc.h \
  gen_alloc.h iopause.h taia.h tai.h uint64.h auto-compile.sh
	$C  -c $<
stralloc_catb.o: stralloc_catb.c stralloc.h gen_alloc.h byte.h auto-compilew.sh
	$W  -c $<
dns_rcrw.o: dns_rcrw.c taia.h tai.h uint64.h typesize.h auto-typesize.h \
  env.h byte.h str.h openreadclose.h stralloc.h gen_alloc.h dns.h \
  iopause.h auto-compile.sh
	$C  -c $<
get_cwd.o: get_cwd.c alloc.h error.h stralloc.h gen_alloc.h byte.h str.h \
  get_cwd.h auto-compilew.sh
	$W  -c $<
fmt_uint0.o: fmt_uint0.c gen_fmt.h fmt.h auto-compilew.sh
	$W  -c $<
env_get.o: env_get.c env.h auto-compilew.sh
	$W  -c $<
socket_htons.o: socket_htons.c socket.h uint16.h typesize.h \
  auto-typesize.h auto-compilew.sh
	$W  -c $<
case_lowers.o: case_lowers.c case.h auto-compilew.sh
	$W  -c $<
host_connect4.o: host_connect4.c stralloc.h gen_alloc.h scan.h ip4.h \
  socket.h uint16.h typesize.h auto-typesize.h error.h host_connect.h \
  timeoutconn.h str.h dns.h iopause.h taia.h tai.h uint64.h byte.h \
  bailout.h auto-compilew.sh
	$W  -c $<
str_chr.o: str_chr.c str.h auto-compilew.sh
	$W  -c $<
gen_alloc_lus.o: gen_alloc_lus.c gen_alloci.h auto-compilew.sh
	$W  -c $<
uo_sec702dt.o: uo_sec702dt.c uotime.h auto-compilew.sh
	$W  -c $<
socket_conn.o: socket_conn.c byte.h socket.h uint16.h typesize.h \
  auto-typesize.h auto-compilew.sh
	$W  -c $<
readclose_app.o: readclose_app.c readwrite.h error.h readclose.h \
  stralloc.h gen_alloc.h close.h auto-compilew.sh
	$W  -c $<
mdtm.o: mdtm.c ftpparse.h buffer.h stralloc.h gen_alloc.h ftplib.h \
  ftpcopy.h mdtm.h bailout.h error.h auto-compilew.sh
	$W  -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 auto-typesize.h auto-compile.sh
	$C  -c $<
str_rchr.o: str_rchr.c str.h auto-compilew.sh
	$W  -c $<
common.o: common.c buffer.h attributes.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 auto-typesize.h iopause.h host_connect.h readwrite.h close.h \
  mysleep.h auto-compilew.sh
	$W  -c $<
stralloc_cats.o: stralloc_cats.c str.h stralloc.h gen_alloc.h auto-compilew.sh
	$W  -c $<
taia_half.o: taia_half.c taia.h tai.h uint64.h typesize.h auto-typesize.h auto-compile.sh
	$C  -c $<
tai_add.o: tai_add.c tai.h uint64.h typesize.h auto-typesize.h auto-compilew.sh
	$W  -c $<
dns_name.o: dns_name.c stralloc.h gen_alloc.h uint16.h typesize.h \
  auto-typesize.h byte.h dns.h iopause.h taia.h tai.h uint64.h auto-compile.sh
	$C  -c $<
strhash_dest.o: strhash_dest.c strhashi.h uint32.h typesize.h \
  auto-typesize.h strhash.h auto-compilew.sh
	$W  -c $<
open_read.o: open_read.c open.h auto-compilew.sh
	$W  -c $<
taia_sub.o: taia_sub.c taia.h tai.h uint64.h typesize.h auto-typesize.h auto-compilew.sh
	$W  -c $<
open_trunc.o: open_trunc.c open.h auto-compilew.sh
	$W  -c $<
auto-typesize.h: typesize.stamp
typesize.stamp: typesize.sh auto-compile.sh auto-link.sh
	CC="$(CC)" sh typesize.sh >typesize.t
	@if cmp typesize.t auto-typesize.h 2>/dev/null >/dev/null ; then : ; else mv typesize.t auto-typesize.h ; fi
	rm -f typesize.t
	touch $@

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

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

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

socklen_t.h: socklen_t.stamp
socklen_t.stamp: checktype.sh auto-compile.sh auto-link.sh
	CC="$(CC)" sh 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 auto-compile.sh auto-link.sh
	sh socket.sh >socket.t && mv socket.t $@

.PRECIOUS: Makefile
remake: clean
	rm -f auto-compile.sh auto-link.sh auto-compilew.sh auto-makelib.sh
packageinfo: 
	@echo version="$(VERSION)"
	@echo package="$(PACKAGE)"
	@echo class="$(CLASS)"
auto-compile.sh: 
	@echo remaking $@
	@( echo "#! /bin/sh" ; \
	echo '# automatically generated, do not edit' ; \
	echo 'CFLAGS="$${CFLAGS:-$$_CFLAGS_OG}"' ; \
	echo 'CFLAGS="$${CFLAGS:--O2}"' ; \
	echo 'DEFS="$${DEFS:--${DEFS}}"' ; \
	echo 'INCLUDES="$${INCLUDES:--${INCLUDES}}"' ; \
	echo 'CC="$${CC:-gcc}"' ; \
	if test $(NEED_LFS) -gt 0 ; then echo 'CFLAGS="$$CFLAGS `head -1 auto-lfs.cflags`"' ; fi ; \
	echo 'exec $$CC $(DEFS) $(INCLUDES) $$CFLAGS "$$@"' ; \
	) > auto-compile.t && chmod 755 auto-compile.t
	@mv auto-compile.t $@
auto-compilew.sh: 
	@echo remaking $@
	@( echo "#! /bin/sh" ; \
	echo '# automatically generated, do not edit' ; \
	echo 'CFLAGS="$${CFLAGS:-$$_CFLAGS_OWG}"' ; \
	echo 'CFLAGS="$${CFLAGS:--O2 -Wall}"' ; \
	echo 'DEFS="$${DEFS:--${DEFS}}"' ; \
	echo 'INCLUDES="$${INCLUDES:--${INCLUDES}}"' ; \
	echo 'CC="$${CC:-gcc}"' ; \
	if test $(NEED_LFS) -gt 0 ; then echo 'CFLAGS="$$CFLAGS `head -1 auto-lfs.cflags`"' ; fi ; \
	echo 'exec $$CC $(DEFS) $(INCLUDES) $$CFLAGS "$$@"' ; \
	) > auto-compilew.t && chmod 755 auto-compilew.t
	@mv auto-compilew.t auto-compilew.sh
auto-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}"' ; \
	if test $(NEED_LFS) -gt 0 ; then echo 'LDFLAGS="$$LDFLAGS `head -1 auto-lfs.ldflags`"' ; fi ; \
	echo 'exec $$CC $$LDFLAGS -o "$$@" ' ; \
	) > auto-link.t && chmod 755 auto-link.t
	@mv auto-link.t auto-link.sh
auto-makelib.sh:
	@echo remaking $@
	@( echo "#! /bin/sh" ; \
	echo '# automatically generated, do not edit' ; \
	echo 'RANLIB="$${RANLIB:-ranlib}"' ; \
	echo 'AR="$${AR:-ar}"' ; \
	echo '$$AR cru "$$@" ' ; \
	echo 'exec $$RANLIB $$1' ; \
	) > auto-makelib.t && chmod 755 auto-makelib.t
	@mv auto-makelib.t auto-makelib.sh
maintainer-clean: distclean
	rm -f Makefile $(MAINTAINERCLEANFILES)
distclean: clean
	rm -f $(DISTCLEANFILES) dummy.tmp # to avoid "no arguments" error
clean spotless: mostlyclean
	rm -f $(LIBRARIES) $(TARGETS) auto-link.sh auto-compile.sh auto-compilew.sh makelib.sh
	rm -rf deps
mostlyclean:
	rm -f *.o $(TARGETS) $(CLEANFILES)

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
gpg-dist: $(DIST)
	gpg -b --armor $(DIST)
DIST=$(PACKAGE)-$(VERSION).tar.gz

dist: $(DIST)
$(DIST): $(DISTFILES)
	rm -f $@
	package

force:	

auto-systype: auto-typesize.h $(EXTRA_SYSTYPE) $(PREMAKE_EXTRA_SYSTYPE)
	rm -f $@.t
	@echo  >>$@.t
	@echo "PACKAGE: $(PACKAGE) $(VERSION)" >>$@.t
	@echo "REALNAME: $(REALNAME)" >>$@.t
	@echo "uname-a:" `uname -a` >>$@.t
	@echo "uname-s:" `uname -s` >>$@.t
	@echo "uname-r:" `uname -r` >>$@.t
	@echo "uname-v:" `uname -v` >>$@.t
	@echo "uname-m:" `uname -m` >>$@.t
	cat auto-typesize.h >>$@.t
	if test "$(PREMAKE_EXTRA_SYSTYPE)x$(EXTRA_SYSTYPE)" = x ; then true ; else \
	  for i in $(PREMAKE_EXTRA_SYSTYPE) $(EXTRA_SYSTYPE) dummy ; do \
	    if test "x$$i" = "xdummy" ; then true ; else \
	      grep systype-info $$i 2>/dev/null >> $@.t || exit 0; \
	    fi \
	  done \
	fi
	mv $@.t $@

# 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: docheck check.exp
	env - PATH="`pwd`:$$PATH" sh docheck 2>&1 | cat -v \
	| sed "s,`env - /bin/sh -c pwd`/tmp.check/,%,g" \
	| tee check.out | diff -u check.exp -
