2 dnl autoconf input file to generate MCONFIG
8 AC_PREFIX_DEFAULT(/usr)
16 dnl Feature-test macros. These need to be set in CFLAGS, rather in
17 dnl aconfig.h, or "configure" will run in a different environment than
18 dnl we eventually we build in.
21 dnl Needed on Solaris/cc or Solaris/gcc
22 CFLAGS="$CFLAGS -D_XPG4_2"
23 CFLAGS="$CFLAGS -D_XOPEN_SOURCE"
24 CFLAGS="$CFLAGS -D__EXTENSIONS__"
26 dnl Needed on some glibc systems
27 CFLAGS="$CFLAGS -D_GNU_SOURCE"
29 dnl Needed on Digital Unix
30 CFLAGS="$CFLAGS -D_OSF_SOURCE"
31 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
38 PA_ADD_CFLAGS(-Wpointer-arith)
39 PA_ADD_CFLAGS(-Wbad-function-cast)
40 PA_ADD_CFLAGS(-Wcast-equal)
41 PA_ADD_CFLAGS(-Wstrict-prototypes)
42 PA_ADD_CFLAGS(-Wmissing-prototypes)
43 PA_ADD_CFLAGS(-Wmissing-declarations)
44 PA_ADD_CFLAGS(-Wnested-externs)
45 PA_ADD_CFLAGS(-Winline)
46 PA_ADD_CFLAGS(-Wwrite-strings)
47 PA_ADD_CFLAGS(-Wundef)
48 PA_ADD_CFLAGS(-Wshadow)
49 PA_ADD_CFLAGS(-Wsign-compare)
51 PA_ADD_CFLAGS(-fno-strict-aliasing)
54 AC_CHECK_HEADERS(inttypes.h)
55 AC_CHECK_HEADERS(stdint.h)
56 PA_CHECK_INTTYPES_H_SANE
57 AC_CHECK_HEADERS(fcntl.h)
58 AC_CHECK_HEADERS(getopt.h)
59 AC_CHECK_HEADERS(grp.h)
60 AC_CHECK_HEADERS(libgen.h)
61 AC_CHECK_HEADERS(memory.h)
62 AC_CHECK_HEADERS(setjmp.h)
63 AC_CHECK_HEADERS(stddef.h)
64 AC_CHECK_HEADERS(stdlib.h)
65 AC_CHECK_HEADERS(string.h)
66 AC_CHECK_HEADERS(strings.h)
67 AC_CHECK_HEADERS(sysexits.h)
68 AC_CHECK_HEADERS(time.h)
69 AC_CHECK_HEADERS(unistd.h)
70 AC_CHECK_HEADERS(sys/filio.h)
71 AC_CHECK_HEADERS(sys/stat.h)
72 AC_CHECK_HEADERS(sys/time.h)
73 AC_CHECK_HEADERS(sys/types.h)
74 AC_CHECK_HEADERS(arpa/inet.h)
76 dnl This is needed on some versions of FreeBSD...
77 AC_CHECK_HEADERS(machine/param.h)
78 AC_CHECK_HEADERS(sys/socket.h)
79 AC_CHECK_HEADERS(winsock2.h)
80 AC_CHECK_HEADERS(winsock.h)
88 AC_CHECK_TYPES(intmax_t)
89 AC_CHECK_TYPES(long long)
90 AC_CHECK_TYPES(uint16_t)
91 AC_CHECK_TYPES(uint32_t)
92 AC_CHECK_TYPES(u_short)
93 AC_CHECK_TYPES(u_long)
96 dnl <sys/socket.h> isn't among the list of standard headers that autoconf checks,
97 dnl but POSIX requires <sys/socket.h> for socklen_t to be defined.
99 AC_CHECK_TYPES(socklen_t,,,
103 # include <sys/types.h>
106 # include <sys/stat.h>
117 # if !STDC_HEADERS && HAVE_MEMORY_H
123 # include <strings.h>
126 # include <inttypes.h>
135 #ifdef HAVE_SYS_SOCKET_H
136 # include <sys/socket.h>
140 AC_SEARCH_LIBS(socket, [socket ws2_32 wsock32], , [AC_MSG_ERROR(socket library not found)])
141 AC_SEARCH_LIBS(gethostbyname, [nsl resolv], , [AC_MSG_ERROR(gethostbyname not found)])
142 AC_SEARCH_LIBS(inet_aton, [nsl resolv], , [AC_MSG_ERROR(inet_aton not found)])
143 AC_SEARCH_LIBS(herror, [nsl resolv], , [AC_MSG_ERROR(herror not found)])
145 AC_CHECK_FUNCS(fcntl)
146 AC_CHECK_FUNCS(setsid)
147 AC_CHECK_FUNCS(recvmsg)
148 AC_CHECK_FUNCS(ftruncate)
149 AC_CHECK_FUNCS(setreuid)
150 AC_CHECK_FUNCS(setregid)
151 AC_CHECK_FUNCS(initgroups)
152 AC_CHECK_FUNCS(setgroups)
154 dnl Solaris 8 has [u]intmax_t but not strtoumax(). How utterly braindamaged.
155 AC_CHECK_FUNCS(strtoumax)
156 AC_CHECK_FUNCS(strtoull)
158 PA_MSGHDR_MSG_CONTROL
161 PA_HEADER_DEFINES(fcntl.h, int, O_NONBLOCK)
162 PA_HEADER_DEFINES(fcntl.h, int, O_BINARY)
163 PA_HEADER_DEFINES(fcntl.h, int, O_TEXT)
165 AH_TEMPLATE([HAVE_SIGSETJMP],
166 [Define if we have sigsetjmp, siglongjmp and sigjmp_buf.])
167 PA_SIGSETJMP([AC_DEFINE(HAVE_SIGSETJMP)])
172 SRCROOT=`cd $srcdir && pwd`
176 AC_SEARCH_LIBS(xmalloc, iberty, , [XTRA=true; AC_LIBOBJ(xmalloc)])
177 AC_SEARCH_LIBS(xstrdup, iberty, , [XTRA=true; AC_LIBOBJ(xstrdup)])
178 AC_SEARCH_LIBS(bsd_signal, bsd, , [XTRA=true; AC_LIBOBJ(bsdsignal)])
179 AC_CHECK_FUNCS(daemon, , [XTRA=true; AC_LIBOBJ(daemon)])
180 AC_CHECK_FUNCS(dup2, , [XTRA=true; AC_LIBOBJ(dup2)])
183 XTRALIBS="$OBJROOT/lib/libxtra.a $XTRALIBS"
187 dnl These libraries apply to the server only
192 PA_HEADER_DEFINES(netinet/in.h, int, IPPORT_TFTP)
194 PA_WITH_BOOL(tcpwrappers, 1,
195 [ --without-tcpwrappers disable tcpwrapper permissions checking],
197 AC_SEARCH_LIBS(yp_get_default_domain, [nsl resolv])
202 AH_TEMPLATE([WITH_REGEX],
203 [Define if we are compiling with regex filename remapping.])
205 PA_WITH_BOOL(remap, 1,
206 [ --without-remap disable regex-based filename remapping],
208 AC_CHECK_HEADER(regex.h,
210 AC_SEARCH_LIBS(regcomp, [regex rx],
212 AC_DEFINE(WITH_REGEX)
213 TFTPDOBJS="remap.${OBJEXT} $TFTPDOBJS"
218 TFTPD_LIBS="$LIBS $XTRALIBS"
222 dnl These libraries apply to the client only
225 AH_TEMPLATE([WITH_READLINE],
226 [Define if we are compiling with readline command-line editing.])
228 PA_WITH_BOOL(readline, 1,
229 [ --without-readline disable the use of readline command-line editing],
231 AC_CHECK_HEADER(readline/readline.h,
233 dnl readline may need libtermcap or somesuch...
234 AC_SEARCH_LIBS(tputs, [termcap terminfo])
236 AC_SEARCH_LIBS(readline, [readline history],
238 AC_DEFINE(WITH_READLINE)
242 AC_CHECK_HEADERS(readline/history.h)
246 TFTP_LIBS="$LIBS $XTRALIBS"
260 dnl Make sure the install program has an absolute path if it
261 dnl has a path at all. autoconf doesn't do this "in order
262 dnl to not pollute the cache." Sigh.
263 dnl Note: the $ needs to be double-quoted for reasons unknown.
266 [if echo "$INSTALL" | grep '^[^/].*/' > /dev/null 2>&1; then
267 INSTALL='\${SRCROOT}'/"$INSTALL"
270 AC_CONFIG_HEADERS(aconfig.h)