1dnl Process this file with autoconf to produce a configure script.
2AC_INIT(rcmd.c)
3AC_PREREQ(2.4)
4AC_CONFIG_HEADER(config.h)
5
6nc_cv_socks5=no
7no_signals=yes
8
9AC_ARG_ENABLE(socks5,[  --enable-socks5        try to find and use the socks5 library],nc_cv_socks5=yes,nc_cv_socks5=no)
10AC_ARG_ENABLE(signals,[  --enable-signals       allow use of signal handling],[no_signals=no])
11
12
13wi_OS_VAR
14
15changequote(<<, >>)dnl
16MAINDIR=`pwd`
17if test -f "$MAINDIR/dos2unix.sh" ; then
18	chmod u+rwx $MAINDIR/dos2unix.sh
19	for dir in . ../sio ../Strn ; do
20		if [ -d "$dir" ] ; then
21			dir=`cd "$dir" ; pwd`
22			find "$dir" -name '*.in' -exec "$MAINDIR/dos2unix.sh" {} \;
23			find "$dir" -name '*.h' -exec "$MAINDIR/dos2unix.sh" {} \;
24			find "$dir" -name '*.c' -exec "$MAINDIR/dos2unix.sh" {} \;
25		fi
26	done
27fi
28MAKE=make
29STATIC=""
30BDYNAMIC="# -Wl,-Bdynamic"
31BSTATIC="# -Wl,-Bstatic"
32LIBSET='$(LIB)'
33Z31=''
34Z32=''
35Z33=''
36Z34=''
37REDWING='no'
38SFLAG='-s'
39
40case "$host" in
41	redwing*)	CC=cc
42			LDFLAGS=''
43			STATIC=''
44			Z31='	-@mv $(STGZFILE) newbin/'
45			Z32='	-@mv $(DTGZFILE) newbin/'
46			Z33='	-@mv $(MTGZFILE) newbin/'
47			Z34='	-@mv $(PTGZFILE) newbin/'
48			REDWING='yes'
49			;;
50esac
51
52case "$os" in
53	linux)
54		BDYNAMIC="-Wl,-Bdynamic"
55		BSTATIC="-Wl,-Bstatic"
56		if [ "$MAKEWORLD_SH" = "" ] ; then
57			LIBSET='$(LIBSO) $(LIB)'
58		fi
59		;;
60	freebsd)
61		BDYNAMIC="-Wl,-Bdynamic"
62		BSTATIC="-Wl,-Bstatic"
63		;;
64	macosx*|rhapsody)
65		SFLAG='-Wl,-x'
66		;;
67esac
68
69changequote([, ])dnl
70
71AC_SUBST(CC)
72AC_SUBST(CFLAGS)
73AC_SUBST(CPPFLAGS)
74AC_SUBST(LDFLAGS)
75AC_SUBST(STATIC)
76AC_SUBST(SFLAG)
77AC_SUBST(LIBS)
78AC_SUBST(DEFS)
79AC_SUBST(MAKE)
80AC_SUBST(Z31)
81AC_SUBST(Z32)
82AC_SUBST(Z33)
83AC_SUBST(Z34)
84AC_SUBST(LIBSET)
85AC_SUBST(BDYNAMIC)
86AC_SUBST(BSTATIC)
87AC_SUBST(MAINDIR)
88
89if test -f ./samples/ncftpput2probe.c ; then
90	PROBE="ncftpget2probe ncftpput2probe"
91else
92	PROBE=""
93fi
94AC_SUBST(PROBE)
95
96AC_PROG_CC
97wi_REQUEST_NO_Y2K_WARNINGS
98wi_CFLAGS_LFS64
99wi_DEFINE_UNAME
100
101if test -f /usr/src/include/eos.h ; then
102	if test "$REDWING" = no ; then
103		prefix=/usr/src
104	fi
105fi
106
107if test "$wi_cv_prototypes" = no ; then
108	AC_WARN([Your compiler is probably won't be able to compile the package.])
109	AC_WARN([Get gcc, or any compiler that supports function prototypes.])
110fi
111
112dnl # See if we should add -I/usr/local/include -L/usr/local/lib, etc.
113dnl wi_EXTRA_DIRS(yes, /usr/local /usr/ccs, -)
114
115dnl For the sample programs.
116wi_NET_LIBS
117
118if test "$nc_cv_socks5" = yes ; then
119# Look for the "SOCKS" library for use with Firewalls/Gateways.
120savelibs="$LIBS"
121AC_CHECK_LIB(db,          main)
122AC_CHECK_LIB(isode,       main)
123AC_CHECK_LIB(com_err,     main)
124AC_CHECK_LIB(crypto,      main)
125AC_CHECK_LIB(krb5,        main)
126AC_CHECK_LIB(gssapi_krb5, main)
127AC_CHECK_LIB(socks5,SOCKSinit)
128      if test "$ac_cv_lib_socks5" = yes ; then
129              nc_cv_socks=no
130      else
131              LIBS="$savelibs"
132      fi
133else
134ac_cv_lib_socks5=no
135fi
136
137
138dnl Checks for header files.
139AC_HEADER_STDC
140AC_CHECK_HEADERS(sys/time.h unistd.h utime.h nserve.h resolv.h arpa/nameser.h)
141AC_TIME_WITH_SYS_TIME
142
143dnl Checks for typedefs, structures, and compiler characteristics.
144AC_C_CONST
145AC_TYPE_SIZE_T
146AC_TYPE_OFF_T
147AC_TYPE_MODE_T
148AC_TYPE_PID_T
149AC_TYPE_UID_T
150wi__RES_DEFDNAME
151wi_USE_LONG_LONG
152
153dnl Checks for library functions.
154if test "$SYS" != sunos ; then
155	# Use getwd on SunOS -- getcwd does a "popen("/bin/pwd")" -- aaaccck.
156	#
157	AC_CHECK_FUNCS(getcwd)
158fi
159AC_CHECK_FUNCS(getwd gethostname socket strerror strstr)
160AC_CHECK_FUNCS(getpass strcasecmp getdomainname mktime symlink inet_ntop)
161AC_CHECK_FUNCS(res_init snprintf vsnprintf strtoq sigaction waitpid)
162AC_CHECK_FUNCS(open64 stat64 fstat64 lstat64 lseek64 llseek)
163wi_FUNC_SIGSETJMP
164AC_FUNC_SETVBUF_REVERSED
165
166wi_HEADER_SYS_SELECT_H
167AC_FUNC_SELECT_ARGTYPES
168
169if test -f ../sio/sio.h ; then
170	ldir=`cd ../sio ; pwd`
171	LDFLAGS="$LDFLAGS -L${ldir}"
172	CPPFLAGS="$CPPFLAGS -I${ldir}"
173	LIBS="$LIBS -lsio"
174fi
175
176if test -f ../Strn/Strn.h ; then
177	ldir=`cd ../Strn ; pwd`
178	LDFLAGS="$LDFLAGS -L${ldir}"
179	CPPFLAGS="$CPPFLAGS -I${ldir}"
180	LIBS="$LIBS -lStrn"
181fi
182
183if test $ac_cv_func_getcwd = no && test $ac_cv_func_getwd = no ; then
184AC_WARN(This system does not have either getwd or getcwd?)
185AC_WARN(I find that a little hard to believe.)
186AC_WARN(You may want to try -DHAVE_GETWD anyway.)
187AC_WARN([
188This could also mean that your compiler isn't working])
189AC_WARN(with this configure script.  Check the ./config.log)
190AC_WARN(and look for anomalies.)
191fi
192
193wi_PROG_TAR
194AC_PROG_RANLIB
195
196if test "$LONGEST_INT" = "long long" ; then
197	if sed 's/^#define longest_int.*/#define longest_int long long/;
198s/^#define longest_uint.*/#define longest_uint unsigned long long/' ncftp.h > temp.h ; then
199		mv temp.h ncftp.h
200		chmod a+r ncftp.h
201	fi
202else
203	if sed 's/^#define longest_int.*/#define longest_int long/;
204s/^#define longest_uint.*/#define longest_uint unsigned long/' ncftp.h > temp.h ; then
205		mv temp.h ncftp.h
206		chmod a+r ncftp.h
207	fi
208fi
209
210CPPFLAGS="-I$MAINDIR $CPPFLAGS"
211
212if test "$no_signals" = no ; then
213	dv1='#	if 0'
214	dv2='#if 0'
215else
216	dv1='#	if 1'
217	dv2='#if 1'
218fi
219
220if sed "s!^.*/. %config1!${dv1} /* %config1!;s!^.*/. %config2!${dv2} /* %config2!" ncftp.h > temp.h ; then
221	mv temp.h ncftp.h
222	chmod a+r ncftp.h
223fi
224
225if sed "s!^.*/. %config1!${dv1} /* %config1!;s!^.*/. %config2!${dv2} /* %config2!" syshdrs.h > temp.h ; then
226	mv temp.h syshdrs.h
227	chmod a+r syshdrs.h
228fi
229
230changequote(<<, >>)dnl
231#
232# Configure sio specially, like it would do.
233#
234if [ -d ../sio ] ; then
235	if sed "s!^.*/. %config1!${dv1} /* %config1!;s!^.*/. %config2!${dv2} /* %config2!" ../sio/sio.h > temp.h ; then
236		mv temp.h ../sio/sio.h
237		chmod a+r ../sio/sio.h
238	fi
239	if sed "s!^.*/. %config1!${dv1} /* %config1!;s!^.*/. %config2!${dv2} /* %config2!" ../sio/usio.h > temp.h ; then
240		mv temp.h ../sio/usio.h
241		chmod a+r ../sio/usio.h
242	fi
243
244	patterns1=""
245	patterns2=""
246	if [ "$SYS" = solaris ] ; then
247		patterns1='s!/. %configure%.*!#define SAccept SAcceptS!'
248		patterns2='s!/. %configure%.*!#define UAccept UAcceptS!'
249	fi
250
251	if [ "$patterns1" != "" ] ; then
252		sed "$patterns1" < ../sio/sio.h > tmpfile
253		if [ $? -eq 0 ] ; then
254			mv tmpfile ../sio/sio.h
255			chmod 644 ../sio/sio.h
256		else
257			/bin/rm tmpfile
258		fi
259	fi
260
261	if [ "$patterns2" != "" ] ; then
262		sed "$patterns2" < ../sio/usio.h > tmpfile
263		if [ $? -eq 0 ] ; then
264			mv tmpfile ../sio/usio.h
265			chmod 644 ../sio/usio.h
266		else
267			/bin/rm tmpfile
268		fi
269	fi
270fi
271changequote([, ])dnl
272
273if test -d bin.only ; then
274	binonly="bin.only/Makefile bin.only/samples/Makefile"
275else
276	binonly=""
277fi
278
279LIBS=`echo "$LIBS" | sed 's/^ *//;s/ *$//;s/  */ /g'`
280LDFLAGS=`echo "$LDFLAGS" | sed 's/^ *//;s/ *$//;s/  */ /g'`
281CPPFLAGS=`echo "$CPPFLAGS" | sed 's/^ *//;s/ *$//;s/  */ /g'`
282CFLAGS=`echo "$CFLAGS" | sed 's/^ *//;s/ *$//;s/  */ /g'`
283DEFS=`echo "$DEFS" | sed 's/^ *//;s/ *$//;s/  */ /g'`
284
285samples=''
286for sample in minincftp monkey ncftpget ncftpput ncftpls simpleget ncftpsyncput misc ; do
287	if test -f samples/$sample/Makefile.in ; then
288		samples="$samples samples/$sample/Makefile"
289	fi
290done
291
292AC_OUTPUT([Makefile ../Strn/Makefile ../sio/Makefile $samples $binonly])
293