Update version for release
[tftp-hpa.git] / configure.in
blob4d8521636d95e35babb45d3198e48a85eaf1c4d0
1 dnl
2 dnl autoconf input file to generate MCONFIG
3 dnl
5 AC_PREREQ(2.52)
6 AC_REVISION([$Id$])
7 AC_INIT(MCONFIG.in)
8 AC_PREFIX_DEFAULT(/usr)
10 AC_ISC_POSIX
11 AC_AIX
12 AC_MINIX
13 AC_PROG_CC
15 dnl
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.
19 dnl
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"
33 AC_C_CONST
34 AC_C_INLINE
36 PA_ADD_CFLAGS(-W)
37 PA_ADD_CFLAGS(-Wall)
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)
50 PA_ADD_CFLAGS(-pipe)
51 PA_ADD_CFLAGS(-fno-strict-aliasing)
53 AC_HEADER_STDC
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)
75 AC_HEADER_TIME
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)
82 AC_SYS_LARGEFILE
84 AC_TYPE_OFF_T
85 AC_TYPE_PID_T
86 AC_TYPE_MODE_T
87 AC_TYPE_SIZE_T
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)
95 dnl
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.
98 dnl
99 AC_CHECK_TYPES(socklen_t,,,
101 #include <stdio.h>
102 #if HAVE_SYS_TYPES_H
103 # include <sys/types.h>
104 #endif
105 #if HAVE_SYS_STAT_H
106 # include <sys/stat.h>
107 #endif
108 #if STDC_HEADERS
109 # include <stdlib.h>
110 # include <stddef.h>
111 #else
112 # if HAVE_STDLIB_H
113 #  include <stdlib.h>
114 # endif
115 #endif
116 #if HAVE_STRING_H
117 # if !STDC_HEADERS && HAVE_MEMORY_H
118 #  include <memory.h>
119 # endif
120 # include <string.h>
121 #endif
122 #if HAVE_STRINGS_H
123 # include <strings.h>
124 #endif
125 #if HAVE_INTTYPES_H
126 # include <inttypes.h>
127 #else
128 # if HAVE_STDINT_H
129 #  include <stdint.h>
130 # endif
131 #endif
132 #if HAVE_UNISTD_H
133 # include <unistd.h>
134 #endif
135 #ifdef HAVE_SYS_SOCKET_H
136 # include <sys/socket.h>
137 #endif
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
159 PA_STRUCT_IN_PKTINFO
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)])
170 dnl Get common paths
172 SRCROOT=`cd $srcdir && pwd`
173 OBJROOT=`pwd`
175 XTRA=false
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)])
181 if $XTRA
182 then
183   XTRALIBS="$OBJROOT/lib/libxtra.a $XTRALIBS"
187 dnl These libraries apply to the server only
190 common_libs="$LIBS"
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])
198         PA_HAVE_TCPWRAPPERS
199 ],:)
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,
209         [
210                 AC_SEARCH_LIBS(regcomp, [regex rx],
211                 [
212                         AC_DEFINE(WITH_REGEX)
213                         TFTPDOBJS="remap.${OBJEXT} $TFTPDOBJS"
214                 ])
215         ])
216 ],:)
218 TFTPD_LIBS="$LIBS $XTRALIBS"
219 LIBS="$common_libs"
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,
232         [
233                 dnl readline may need libtermcap or somesuch...
234                 AC_SEARCH_LIBS(tputs, [termcap terminfo])
236                 AC_SEARCH_LIBS(readline, [readline history],
237                 [
238                         AC_DEFINE(WITH_READLINE)
239                 ],
240                 [],
241                 [-ltermcap])
242                 AC_CHECK_HEADERS(readline/history.h)
243         ])
244 ],:)
246 TFTP_LIBS="$LIBS $XTRALIBS"
247 LIBS="$common_libs"
249 AC_SUBST(SRCROOT)
250 AC_SUBST(OBJROOT)
252 AC_SUBST(TFTP_LIBS)
253 AC_SUBST(TFTPD_LIBS)
254 AC_SUBST(TFTPDOBJS)
256 AC_PROG_LN_S
257 AC_PROG_RANLIB
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.
265 AC_PROG_INSTALL
266 [if echo "$INSTALL" | grep '^[^/].*/' > /dev/null 2>&1; then
267    INSTALL='\${SRCROOT}'/"$INSTALL"
270 AC_CONFIG_HEADERS(aconfig.h)
271 AC_OUTPUT(MCONFIG)