1dnl#
2dnl# Process this file with autoconf to produce a configure script.
3dnl#
4AC_INIT(hsftp.c)
5AC_CONFIG_HEADER(config.h)
6AC_PROG_MAKE_SET
7
8PACKAGE=hsftp
9VERSION=1.15
10
11AC_SUBST(PACKAGE)
12AC_SUBST(VERSION)
13
14
15dnl# --------------------------------------------------------------------------
16dnl# CHECKING COMMAND LINE OPTIONS
17dnl# --------------------------------------------------------------------------
18AC_ARG_WITH(libs-from,
19[  --with-libs-from        pass compiler flags to look for libraries],
20        [lib_search_path="-L$withval"])
21
22AC_ARG_WITH(incs-from,
23[  --with-incs-from        pass compiler flags to look for header files],
24        [inc_search_path="-I$withval"])
25
26AC_ARG_ENABLE(ttygid,
27  [  --enable-ttygid         enable tty setting to group \"tty\" - use only if
28                          your system uses this type of security],
29  [if test x$enableval = xyes; then
30    AC_DEFINE(TTY_GID_SUPPORT)
31  fi])
32
33dnl# --------------------------------------------------------------------------
34dnl# Supply default CFLAGS, if not specified by `CFLAGS=flags ./configure'
35dnl#
36if test -z "$CFLAGS"; then
37    if test -z "$CCOPTS"; then
38	CCOPTS='-O'
39    fi
40    CFLAGS="$CCOPTS"
41fi
42
43
44dnl# Checks for programs.
45dnl AC_MAKE_SET
46
47AC_PROG_CC
48AC_PROG_INSTALL
49
50CFLAGS="$CFLAGS $inc_search_path"
51LDFLAGS="$LDFLAGS $lib_search_path"
52
53AC_PATH_PROG(MV, mv, mv)
54AC_PATH_PROG(RM, rm, rm)
55AC_PATH_PROG(CP, cp, cp)
56AC_PATH_PROG(SED, sed, sed)
57AC_PATH_PROG(AWK, awk, awk)
58AC_PATH_PROG(ECHO, echo, echo)
59AC_PATH_PROG(CMP, cmp, cmp)
60AC_PATH_PROG(TBL, tbl)
61
62dnl# system hacks
63AC_AIX
64AC_ISC_POSIX
65
66dnl# need a neat way to detect SVR4 or its features
67dnl# in src/command.c we use these functions:
68dnl# grantpt(), unlockpt(), ptsname(), which are defined in <sys/ptms.h>
69dnl# - but are these also defined for other systems?
70
71dnl# hack to find if this is SVR4 -- who knows?
72dnl## AC_MSG_CHECKING(for SVR4)
73dnl## AC_EGREP_CPP(yes,
74dnl## [#if defined (SVR4) || defined (_SVR4) || defined (__svr4__)
75dnl##   yes;
76dnl## #endif
77dnl## ], [AC_MSG_RESULT(yes); AC_DEFINE(PERHAPS_SVR4)], AC_MSG_RESULT(perhaps not?))
78
79dnl AC_PATH_XTRA
80
81AC_CHECK_HEADERS( \
82	stdio.h \
83	stdlib.h \
84	stdarg.h \
85	fcntl.h \
86	curses.h \
87	term.h \
88	pwd.h \
89	grp.h \
90	sys/types.h \
91	sys/select.h \
92)
93
94
95dnl# --------------------------------------------------------------------------
96dnl# CHECKING FOR MISSING TYPEDEFS
97dnl# --------------------------------------------------------------------------
98dnl# Missing typedefs and replacements
99AC_TYPE_MODE_T
100AC_TYPE_PID_T
101AC_TYPE_UID_T
102
103dnl# --------------------------------------------------------------------------
104dnl# CHECKING FOR LIBRARY FUNCTIONS
105dnl# --------------------------------------------------------------------------
106AC_TYPE_SIGNAL
107
108AC_CHECK_FUNCS( \
109	vsnprintf \
110	snprintf \
111	atexit \
112	unsetenv \
113	setutent \
114	seteuid \
115	_getpty \
116	grantpt \
117	unlockpt \
118	mlock \
119	initgroups \
120)
121
122cps_snprintf_oflow
123cps_vsnprintf_oflow
124
125dnl# --------------------------------------------------------------------------
126dnl# CHECKING FOR READLINE
127dnl# --------------------------------------------------------------------------
128AC_ARG_WITH(readline,
129        [  --with-readline[=ARG]   include the readline package (ARG is path to
130                          the directory where the library resides)],
131        [test -d "$withval" && LDFLAGS="$LDFLAGS -L$withval"
132        HSFTP_CHECK_READLINE
133        ])
134
135dnl# --------------------------------------------------------------------------
136dnl# CHECKING FOR OPEN_SSH
137dnl# --------------------------------------------------------------------------
138AC_ARG_WITH(openssh,
139        [  --with-openssh	  ssh is OpenSSH],
140        [
141        AC_DEFINE(OPEN_SSH)
142        ])
143
144
145dnl# --------------------------------------------------------------------------
146dnl# CHECKING FOR DROP-ROOT
147dnl# --------------------------------------------------------------------------
148droproot=yes
149AC_ARG_WITH(drop-root,
150        [  --without-drop-root	  do not drop root after mlock()],
151        [
152	echo "WITHVAL is ${withval}"
153	if test x"${withval}" = xno
154	then
155		droproot=no
156	fi
157        ]
158	)
159if test x"$droproot" = xyes
160then
161        AC_DEFINE(DROP_ROOT)
162fi
163
164dnl# --------------------------------------------------------------------------
165dnl# CHECKING FOR PTYS -- stolen from rxvt
166dnl# --------------------------------------------------------------------------
167AC_CACHE_CHECK(for getpt, hsftp_cv_func_getpt,
168[AC_TRY_LINK([#define _GNU_SOURCE
169#ifdef HAVE_STDLIB_H
170# include <stdlib.h>
171#endif],
172  [(void)getpt();],
173  hsftp_cv_func_getpt=yes, hsftp_cv_func_getpt=no)])
174if test x${hsftp_cv_func_getpt} = xyes; then
175  AC_DEFINE(HAVE_GETPT)
176fi
177
178# if we don't guess right then it's up to the user
179AC_CACHE_CHECK(for tty/pty type, hsftp_cv_ptys,
180[AC_TRY_RUN([#include <stdio.h>
181#ifdef HAVE_STDLIB_H
182# ifdef HAVE_GETPT
183#  define _GNU_SOURCE
184# endif
185# include <stdlib.h>
186#endif
187#ifdef HAVE_FCNTL_H
188# include <fcntl.h>
189#endif
190#include <sys/stat.h>
191#include <errno.h>
192main()
193{
194    int pty, checkerror;
195    FILE *a, *f=fopen("conftestval", "w");
196    struct stat statbuf;
197    extern int errno;
198
199    if (!f) exit(1);
200/* presume that S_IXOTH is required for people to access devices */
201    if (stat("/dev", &statbuf) < 0)
202	checkerror = 0;
203    else
204	checkerror = ((statbuf.st_mode & S_IXOTH) == S_IXOTH) ? 1 : 0;
205#if defined(__sgi) || defined(sgi) || defined(__sgi__)
206    if (stat("/dev/ptc", &statbuf) >= 0)
207# ifdef HAVE__GETPTY
208	fprintf(f, "SGI4");
209# else
210	fprintf(f, "SGI3");
211# endif
212    else
213	fprintf(f, "SGI4");
214    exit(0);
215#endif
216#ifdef _SCO_DS
217    if (stat("/dev/ttyp20", &statbuf) == 0) {
218	fprintf(f, "SCO");
219	exit(0);
220    }
221#endif
222/* HPUX: before ptmx */
223    pty = open("/dev/ptym/clone", O_RDWR);
224    if (pty >= 0 || (checkerror && errno == EACCES)) {
225	fprintf(f, "HPUX");
226	exit(0);
227    }
228#if defined(HAVE_GRANTPT) && defined(HAVE_UNLOCKPT)
229# ifdef HAVE_GETPT
230    pty = getpt();
231    if (pty >= 0 || errno == EACCES) {
232	fprintf(f, "GLIBC");
233	exit(0);
234    }
235# endif
236    if (stat("/dev/ptmx", &statbuf) >= 0
237	&& ((statbuf.st_mode & S_IFCHR) == S_IFCHR))
238	if (stat("/dev/pts/0", &statbuf) >= 0
239	    && ((statbuf.st_mode & S_IFCHR) == S_IFCHR)
240	    && ((pty = open("/dev/ptmx", O_RDWR)) >= 0
241		|| (checkerror && errno == EACCES))) {
242	    fprintf(f, "USG");
243	    exit(0);
244    }
245#endif
246    if (stat("/dev/ttyp20", &statbuf) == 0) {
247	fprintf(f, "SCO");
248	exit(0);
249    }
250    fprintf(f, "BSD");
251    exit(0);
252}], hsftp_cv_ptys=`cat conftestval`, hsftp_cv_ptys=UNKNOWN, dnl
253  AC_MSG_WARN([Define/undefine PTYS_ARE_* in config.h manually]))])
254
255if test x${hsftp_cv_ptys} = xSCO; then
256  AC_DEFINE(PTYS_ARE_NUMERIC)
257  AC_SUBST(PTYS_ARE_NUMERIC)
258fi
259if test x${hsftp_cv_ptys} = xUSG; then
260  AC_DEFINE(PTYS_ARE_PTMX)
261  AC_SUBST(PTYS_ARE_PTMX)
262  AC_DEFINE(PTYS_ARE_SEARCHED)
263  AC_SUBST(PTYS_ARE_SEARCHED)
264fi
265if test x${hsftp_cv_ptys} = xSGI3; then
266  AC_DEFINE(PTYS_ARE_PTC)
267  AC_SUBST(PTYS_ARE_PTC)
268fi
269if test x${hsftp_cv_ptys} = xSGI4; then
270  AC_DEFINE(PTYS_ARE__GETPTY)
271  AC_SUBST(PTYS_ARE__GETPTY)
272fi
273if test x${hsftp_cv_ptys} = xCONVEX; then
274  AC_DEFINE(PTYS_ARE_GETPTY)
275  AC_SUBST(PTYS_ARE_GETPTY)
276fi
277if test x${hsftp_cv_ptys} = xGLIBC; then
278  AC_DEFINE(PTYS_ARE_GETPT)
279  AC_SUBST(PTYS_ARE_GETPT)
280  AC_DEFINE(PTYS_ARE_SEARCHED)
281  AC_SUBST(PTYS_ARE_SEARCHED)
282fi
283if test x${hsftp_cv_ptys} = xHPUX; then
284  AC_DEFINE(PTYS_ARE_CLONE)
285  AC_SUBST(PTYS_ARE_CLONE)
286  AC_DEFINE(PTYS_ARE_SEARCHED)
287  AC_SUBST(PTYS_ARE_SEARCHED)
288fi
289if test x${hsftp_cv_ptys} = xBSD; then
290  AC_DEFINE(PTYS_ARE_SEARCHED)
291  AC_SUBST(PTYS_ARE_SEARCHED)
292fi
293
294dnl# FreeBSD needs to link libxpg4
295dnl AC_CHECK_LIB(xpg4, setlocale, [LIBS="$LIBS -lxpg4"])
296
297CFLAGS=${CFLAGS--O}
298LDFLAGS=${LDFLAGS--O}
299
300AC_SUBST(CFLAGS)
301AC_SUBST(LDFLAGS)
302AC_SUBST(LIBS)
303
304AC_OUTPUT(
305makefile \
306)
307
308echo "Configuration:
309
310  Source code location:       ${srcdir}
311  Install path:               ${prefix}/bin
312  Compiler:                   ${CC}
313  Compiler flags:             ${CFLAGS}"
314
315
316echo "
317The following are set in config.h
318"
319echo "  pty/tty type:               "${hsftp_cv_ptys}
320
321if test x${hsftp_cv_ptys} = xUNKNOWN; then
322  echo ".----------------------------------------------------------------."
323  echo ". WARNING: could not determine tty/pty type.  Do not build until ."
324  echo ".          the appropriate PTYS_ARE_* is defined in config.h     ."
325  echo ".----------------------------------------------------------------."
326fi
327
328