tftpd.8: we're no longer limited to IPv4
[tftp-hpa.git] / configure.in
blobca21af74d0aa89e91e36e999c5a49803452a5736
1 dnl
2 dnl autoconf input file to generate MCONFIG
3 dnl
5 AC_PREREQ(2.61)
6 AC_INIT(MCONFIG.in)
7 AC_PREFIX_DEFAULT(/usr)
9 AC_USE_SYSTEM_EXTENSIONS
10 AC_ISC_POSIX
11 AC_PROG_CC
13 AC_C_CONST
14 AC_C_INLINE
16 PA_ADD_CFLAGS(-W)
17 PA_ADD_CFLAGS(-Wall)
18 PA_ADD_CFLAGS(-Wpointer-arith)
19 PA_ADD_CFLAGS(-Wbad-function-cast)
20 PA_ADD_CFLAGS(-Wcast-equal)
21 PA_ADD_CFLAGS(-Wstrict-prototypes)
22 PA_ADD_CFLAGS(-Wmissing-prototypes)
23 PA_ADD_CFLAGS(-Wmissing-declarations)
24 PA_ADD_CFLAGS(-Wnested-externs)
25 PA_ADD_CFLAGS(-Winline)
26 PA_ADD_CFLAGS(-Wwrite-strings)
27 PA_ADD_CFLAGS(-Wundef)
28 PA_ADD_CFLAGS(-Wshadow)
29 PA_ADD_CFLAGS(-Wsign-compare)
30 PA_ADD_CFLAGS(-pipe)
31 PA_ADD_CFLAGS(-fno-strict-aliasing)
33 AC_HEADER_STDC
34 AC_CHECK_HEADERS(inttypes.h)
35 AC_CHECK_HEADERS(stdint.h)
36 PA_CHECK_INTTYPES_H_SANE
37 AC_CHECK_HEADERS(fcntl.h)
38 AC_CHECK_HEADERS(grp.h)
39 AC_CHECK_HEADERS(libgen.h)
40 AC_CHECK_HEADERS(memory.h)
41 AC_CHECK_HEADERS(setjmp.h)
42 AC_CHECK_HEADERS(stddef.h)
43 AC_CHECK_HEADERS(stdlib.h)
44 AC_CHECK_HEADERS(string.h)
45 AC_CHECK_HEADERS(strings.h)
46 AC_CHECK_HEADERS(sysexits.h)
47 AC_CHECK_HEADERS(time.h)
48 AC_CHECK_HEADERS(unistd.h)
49 AC_CHECK_HEADERS(sys/filio.h)
50 AC_CHECK_HEADERS(sys/stat.h)
51 AC_CHECK_HEADERS(sys/time.h)
52 AC_CHECK_HEADERS(sys/types.h)
53 AC_CHECK_HEADERS(arpa/inet.h)
54 AC_CHECK_HEADERS(netdb.h)
55 AC_HEADER_TIME
56 dnl This is needed on some versions of FreeBSD...
57 AC_CHECK_HEADERS(machine/param.h)
58 AC_CHECK_HEADERS(sys/socket.h)
59 AC_CHECK_HEADERS(winsock2.h)
60 AC_CHECK_HEADERS(winsock.h)
62 AC_SYS_LARGEFILE
64 AC_TYPE_OFF_T
65 AC_TYPE_PID_T
66 AC_TYPE_MODE_T
67 AC_TYPE_SIZE_T
68 AC_CHECK_TYPES(intmax_t)
69 AC_CHECK_TYPES(long long)
70 AC_CHECK_TYPES(uint16_t)
71 AC_CHECK_TYPES(uint32_t)
72 AC_CHECK_TYPES(u_short)
73 AC_CHECK_TYPES(u_long)
75 dnl
76 dnl <sys/socket.h> isn't among the list of standard headers that autoconf checks,
77 dnl but POSIX requires <sys/socket.h> for socklen_t to be defined.
78 dnl
79 AC_CHECK_TYPES(socklen_t,,,
81 #include <stdio.h>
82 #if HAVE_SYS_TYPES_H
83 # include <sys/types.h>
84 #endif
85 #if HAVE_SYS_STAT_H
86 # include <sys/stat.h>
87 #endif
88 #if STDC_HEADERS
89 # include <stdlib.h>
90 # include <stddef.h>
91 #else
92 # if HAVE_STDLIB_H
93 #  include <stdlib.h>
94 # endif
95 #endif
96 #if HAVE_STRING_H
97 # if !STDC_HEADERS && HAVE_MEMORY_H
98 #  include <memory.h>
99 # endif
100 # include <string.h>
101 #endif
102 #if HAVE_STRINGS_H
103 # include <strings.h>
104 #endif
105 #if HAVE_INTTYPES_H
106 # include <inttypes.h>
107 #else
108 # if HAVE_STDINT_H
109 #  include <stdint.h>
110 # endif
111 #endif
112 #if HAVE_UNISTD_H
113 # include <unistd.h>
114 #endif
115 #ifdef HAVE_SYS_SOCKET_H
116 # include <sys/socket.h>
117 #endif
120 AC_SEARCH_LIBS(socket, [socket ws2_32 wsock32], , [AC_MSG_ERROR(socket library not found)])
122 AC_CHECK_FUNCS(fcntl)
123 AC_CHECK_FUNCS(setsid)
124 AC_CHECK_FUNCS(recvmsg)
125 AC_CHECK_FUNCS(ftruncate)
126 AC_CHECK_FUNCS(setreuid)
127 AC_CHECK_FUNCS(setregid)
128 AC_CHECK_FUNCS(initgroups)
129 AC_CHECK_FUNCS(setgroups)
131 dnl Solaris 8 has [u]intmax_t but not strtoumax().  How utterly braindamaged.
132 AC_CHECK_FUNCS(strtoumax)
133 AC_CHECK_FUNCS(strtoull)
135 PA_MSGHDR_MSG_CONTROL
136 PA_STRUCT_IN_PKTINFO
137 PA_STRUCT_ADDRINFO
139 PA_HEADER_DEFINES(fcntl.h, int, O_NONBLOCK)
140 PA_HEADER_DEFINES(fcntl.h, int, O_BINARY)
141 PA_HEADER_DEFINES(fcntl.h, int, O_TEXT)
143 AH_TEMPLATE([HAVE_SIGSETJMP],
144 [Define if we have sigsetjmp, siglongjmp and sigjmp_buf.])
145 PA_SIGSETJMP([AC_DEFINE(HAVE_SIGSETJMP)])
148 dnl Get common paths
150 SRCROOT=`cd $srcdir && pwd`
151 OBJROOT=`pwd`
153 XTRA=false
154 PA_SEARCH_LIBS_AND_ADD(xmalloc, iberty)
155 PA_SEARCH_LIBS_AND_ADD(xstrdup, iberty)
156 PA_SEARCH_LIBS_AND_ADD(bsd_signal, bsd, bsdsignal)
157 PA_SEARCH_LIBS_AND_ADD(getopt_long, getopt, getopt_long)
158 PA_SEARCH_LIBS_AND_ADD(getaddrinfo, [nsl resolv])
159 if $pa_add_getaddrinfo
160 then
161     AC_SEARCH_LIBS(gethostbyname, [nsl resolv],
162       [AC_SEARCH_LIBS(herror, [nsl resolv], ,
163          [AC_MSG_ERROR(herror not found)])],
164       [AC_MSG_ERROR(gethostbyname not found)])
165 else
166     AC_SEARCH_LIBS(freeaddrinfo, [nsl resolv], ,
167       [AC_MSG_ERROR(getaddrinfo but not freeaddrinfo found)])
168     AC_SEARCH_LIBS(gai_strerror, [nsl resolv], ,
169       [AC_MSG_ERROR(getaddrinfo but not gai_strerror found)])
172 PA_SEARCH_LIBS_AND_ADD(inet_ntop, [nsl resolv])
173 if $pa_add_inet_ntop
174 then
175     AC_SEARCH_LIBS(inet_ntoa, [nsl resolv], ,
176       [AC_MSG_ERROR(inet_ntoa not found)])
178 AC_SEARCH_LIBS(inet_aton, [nsl resolv], ,[AC_MSG_ERROR(inet_aton not found)])
180 AC_CHECK_FUNCS(daemon, , [XTRA=true; AC_LIBOBJ(daemon)])
181 AC_CHECK_FUNCS(dup2, , [XTRA=true; AC_LIBOBJ(dup2)])
182 if $XTRA
183 then
184   XTRALIBS="$OBJROOT/lib/libxtra.a $XTRALIBS"
188 dnl These libraries apply to the server only
191 common_libs="$LIBS"
193 PA_HEADER_DEFINES(netinet/in.h, int, IPPORT_TFTP)
195 PA_WITH_BOOL(tcpwrappers, 1,
196 [  --without-tcpwrappers   disable tcpwrapper permissions checking],
198         AC_SEARCH_LIBS(yp_get_default_domain, [nsl resolv])
199         PA_HAVE_TCPWRAPPERS
200 ],:)
203 AH_TEMPLATE([WITH_REGEX],
204 [Define if we are compiling with regex filename remapping.])
206 PA_WITH_BOOL(remap, 1,
207 [  --without-remap         disable regex-based filename remapping],
209         AC_CHECK_HEADER(regex.h,
210         [
211                 AC_SEARCH_LIBS(regcomp, [regex rx],
212                 [
213                         AC_DEFINE(WITH_REGEX)
214                         TFTPDOBJS="remap.${OBJEXT} $TFTPDOBJS"
215                 ])
216         ])
217 ],:)
219 TFTPD_LIBS="$LIBS $XTRALIBS"
220 LIBS="$common_libs"
223 dnl These libraries apply to the client only
226 AH_TEMPLATE([WITH_READLINE],
227 [Define if we are compiling with readline/editline command-line editing.])
229 PA_WITH_BOOL(readline, 1,
230 [  --without-readline      disable the use of readline command-line editing],
232         AC_CHECK_HEADER(readline/readline.h,
233         [
234                 dnl readline may need libtermcap or somesuch...
235                 AC_SEARCH_LIBS(tputs, [termcap terminfo])
237                 AC_SEARCH_LIBS(readline, [readline history],
238                 [AC_DEFINE(WITH_READLINE)])
239                 AC_CHECK_HEADERS(readline/history.h)
240         ],
241         [AC_CHECK_HEADER(editline/readline.h,
242         [
243                 dnl editline may need libtermcap or somesuch...
244                 AC_SEARCH_LIBS(tputs, [termcap terminfo])
246                 AC_SEARCH_LIBS(editline, [edit],
247                 [AC_DEFINE(WITH_READLINE)])
248         ])])
249 ],:)
251 TFTP_LIBS="$LIBS $XTRALIBS"
252 LIBS="$common_libs"
255 dnl   Check for IPV6 and disable-ipv6
257 PA_STRUCT_SOCKADDR_IN6
258 AC_MSG_CHECKING([for IPv6 support])
259 PA_WITH_BOOL(ipv6, 1,
260 [  --without-ipv6      disable the support for IPv6],
262     if  $HAVE_INET6
263     then
264         AC_MSG_RESULT(yes)
265         AC_DEFINE(HAVE_IPV6, 1, [Define if IPv6 support is enabled.])
266         PA_STRUCT_IN6_PKTINFO
267     else
268         AC_MSG_RESULT(no)
269         AC_MSG_WARN([*** we do not have required IPv6 structs - IPv6 will be disabled])
270     fi
272 [AC_MSG_RESULT(disabled)])
275 AC_SUBST(SRCROOT)
276 AC_SUBST(OBJROOT)
278 AC_SUBST(TFTP_LIBS)
279 AC_SUBST(TFTPD_LIBS)
280 AC_SUBST(TFTPDOBJS)
282 AC_PROG_LN_S
283 AC_PROG_RANLIB
286 dnl Make sure the install program has an absolute path if it
287 dnl has a path at all.  autoconf doesn't do this "in order
288 dnl to not pollute the cache."  Sigh.
289 dnl Note: the $ needs to be double-quoted for reasons unknown.
291 AC_PROG_INSTALL
292 [if echo "$INSTALL" | grep '^[^/].*/' > /dev/null 2>&1; then
293    INSTALL='\${SRCROOT}'/"$INSTALL"
296 AC_CONFIG_HEADERS(aconfig.h)
297 AC_OUTPUT(MCONFIG)