summaryrefslogtreecommitdiff
path: root/net/tnftp/files/configure.ac
blob: 6794bf0627742e479b2e3de2d1cb577dcaa4f37f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
#       $NetBSD: configure.ac,v 1.2 2011/10/30 15:30:17 cheusov Exp $
#
# Process this file with autoconf to produce a configure script.

AC_INIT([tnftp], [20070806], [lukem@NetBSD.org])
AC_PREREQ([2.61])
AC_REVISION([$Revision: 1.2 $])

AS_SHELL_SANITIZE

AC_CONFIG_SRCDIR([tnftp.h])
AC_CONFIG_AUX_DIR(build-aux)
AC_CONFIG_HEADERS([config.h])

#
# Arguments for which features are included.
#
AC_CANONICAL_TARGET
AC_ARG_PROGRAM
AC_ARG_ENABLE([editcomplete],
              [AS_HELP_STRING([--enable-editcomplete],
                              [turn on command line editing and completion.
                               (default: enabled)])],
              [opt_editcomplete=$enableval],
              [opt_editcomplete=yes])
AC_ARG_ENABLE([ipv6],
              [AS_HELP_STRING([--enable-ipv6],
                              [enable IPv6 support (if your OS supports it).
                               (default: enabled)])],
              [opt_ipv6=$enableval],
              [opt_ipv6=yes])
AC_ARG_WITH([socks],
            [AS_HELP_STRING([--with-socks],
                            [enable support for (Dante) SOCKS5 proxy])],
            [],
            [with_socks=check])

#
# Autoheader templates symbols.
#
AH_TEMPLATE([HAVE_POLL],
            [Define if we have poll() and it is not emulated.])
AH_TEMPLATE([HAVE_PRINTF_QD],
            [Define if *printf() uses %qd to print `long long'
             (otherwise uses %lld).])
AH_TEMPLATE([HAVE_PRINTF_LONG_LONG],
            [Define if `long long' is supported and
             *printf() supports %lld or %qd to print them.])
AH_TEMPLATE([USE_SOCKS],
            [Define if using (Dante) SOCKS5 proxy.])

#
# Checks for programs.
#
AC_PROG_MAKE_SET
AC_PROG_CC
AC_PROG_AWK
AC_PROG_INSTALL
AC_CHECK_TOOL([AR], [ar], [:])
AC_CHECK_TOOL([RANLIB], [ranlib], [:])

#
# Checks for tool features.
#
AS_CASE([$target_os],
        [darwin*],
        [# Mac OS X linker needs -search_paths_first so our private libraries
         # are used before system libraries.
         #
         old_LDFLAGS=$LDFLAGS
         LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
         AC_MSG_CHECKING([if ld accepts -search_paths_first])
         AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[int i;]])],
                        [AC_MSG_RESULT([yes])],
                        [AC_MSG_RESULT([no])
                         LDFLAGS=$old_LDFLAGS])],
        )

#
# Checks for libraries.
#
AS_IF([test "$opt_editcomplete" = yes],
      [AC_SEARCH_LIBS([tgetent],
                      [termcap termlib curses ncurses tinfo],
                      [],
                      [AC_MSG_ERROR(
                           [no relevant library found containing tgetent])])])

AC_SEARCH_LIBS([gethostbyname], [nsl])
AC_SEARCH_LIBS([socket],
               [socket],
               [],
               [AC_CHECK_LIB([socket],
                             [socket],
                             [LIBS="-lsocket -lnsl $LIBS"],
                             [],
                             [-lnsl])])

# Check for (Dante) SOCKS5.
#
AS_IF([test "$with_socks" != no],
      [AC_SEARCH_LIBS([SOCKSinit],
                      [socksd socks],
                      [AC_DEFINE([USE_SOCKS], [1])
                       AS_IF([test "$opt_ipv6" = yes],
                             [AC_MSG_WARN(
                [IPv6 is incompatible with socks, disabling IPv6 support])
                              opt_ipv6=no])],
                      [AS_IF([test "$with_socks" != check],
                             [AC_MSG_FAILURE(
                [--with-socks was given, but SOCKSinit() wasn't found])])])])

#
# Checks for header files.
#
accheck_includes='
#include <stdio.h>
#if defined(HAVE_SYS_TYPES_H)
# include <sys/types.h>
#endif
#if defined(HAVE_SYS_STAT_H)
# include <sys/stat.h>
#endif
#if defined(STDC_HEADERS)
# include <stdarg.h>
# include <stdlib.h>
# include <string.h>
#endif
#if defined(HAVE_LIBGEN_H)
# include <libgen.h>
#endif
#if defined(HAVE_PWD_H)
# include <pwd.h>
#endif
#if defined(HAVE_UNISTD_H)
# include <unistd.h>
#endif
#if defined(HAVE_POLL_H)
# include <poll.h>
#elif defined(HAVE_SYS_POLL_H)
# include <sys/poll.h>
#endif
#if defined(HAVE_SYS_SOCKET_H)
# include <sys/socket.h>
#endif
#if defined(HAVE_NETINET_IN_H)
# include <netinet/in.h>
#endif
#if defined(HAVE_NETINET_IN_SYSTM_H)
# include <netinet/in_systm.h>
#endif
#if defined(HAVE_NETDB_H)
# include <netdb.h>
#endif
#if defined(HAVE_ARPA_INET_H)
# include <arpa/inet.h>
#endif
#if defined(HAVE_DIRENT_H)
# include <dirent.h>
#else
# define dirent direct
# if defined(HAVE_SYS_NDIR_H)
#  include <sys/ndir.h>
# endif
# if defined(HAVE_SYS_DIR_H)
#  include <sys/dir.h>
# endif
# if defined(HAVE_NDIR_H)
#  include <ndir.h>
# endif
#endif
' # accheck_includes

AC_CHECK_HEADERS([sys/types.h sys/ioctl.h sys/param.h sys/stat.h \
                  sys/socket.h sys/syslimits.h sys/time.h sys/wait.h],
                 [], [], [$accheck_includes])
AC_HEADER_DIRENT
AC_HEADER_RESOLV
AC_HEADER_STAT
AC_HEADER_STDC
AC_HEADER_TIME
AC_HEADER_TIOCGWINSZ
AC_CHECK_HEADERS([arpa/ftp.h arpa/inet.h arpa/nameser.h err.h \
                  fcntl.h libgen.h limits.h malloc.h \
                  netinet/in.h netinet/in_systm.h netinet/ip.h \
                  paths.h poll.h pwd.h sys/poll.h regex.h \
                  setjmp.h signal.h stddef.h termcap.h termios.h \
                  unistd.h utime.h vis.h],
                  [], [], [$accheck_includes])

#
# Checks for typedefs, structures, and compiler characteristics.
#
AC_CHECK_DECLS([AI_NUMERICHOST, dirname, fclose, getpass, h_errno, pclose,
                optarg, optind],
               [], [], [$accheck_includes])
AC_TYPE_LONG_DOUBLE
AC_TYPE_LONG_LONG_INT
AC_TYPE_UINT32_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIGNAL
AC_TYPE_SIZE_T
AC_STRUCT_TM
AC_CHECK_MEMBERS([struct sockaddr.sa_len, struct sockaddr_in.sin_len,
                  struct dirent.d_namlen],
                 [], [], [$accheck_includes])
AC_CHECK_TYPES([in_port_t, sa_family_t, socklen_t, struct addrinfo],
               [], [], [$accheck_includes])
AC_SYS_LARGEFILE

# If IPv6 is enabled, check for necessary items.
#
AS_IF([test "$opt_ipv6" = yes],
      [AC_CHECK_DECLS([AF_INET6, NS_IN6ADDRSZ], [], [],
[$accheck_includes
#if defined(HAVE_ARPA_NAMESER_H)
#include <arpa/nameser.h>
#endif
])
       AC_CHECK_TYPES([struct sockaddr_in6], [], [], [$accheck_includes])])

#
# Checks for library functions.
#
#XXX    remove alloca use
AC_FUNC_ALLOCA
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_FORK
AC_FUNC_FSEEKO
AC_FUNC_STRCOLL
AC_REPLACE_FUNCS([dirname err fgetln getaddrinfo getnameinfo \
                  inet_ntop inet_pton mkstemp setprogname sl_init snprintf \
                  strdup strerror strlcat strlcpy strptime strsep strunvis \
                  strvis timegm usleep utimes])
AC_CHECK_FUNCS([getcwd gethostbyaddr gethostbyname gethostbyname2 gethostname \
                getpass getpassphrase getpgrp gettimeofday isascii \
                memchr memmove memset realpath regcomp \
                select setlocale socket strcasecmp strchr strcspn strdup \
                strerror strncasecmp strpbrk strrchr strstr strtol strtoul \
                utime])
AS_IF([test "$ac_cv_func_getpgrp" = yes], [AC_FUNC_GETPGRP])
AS_IF([test "$ac_cv_func_strptime" = yes], [AC_CHECK_DECLS([strptime])])

# Always replace glob(); the vendor's may not be secure.
#
AC_LIBOBJ([glob])

# We assume that if sprintf() supports %lld or %qd,
# then all of *printf() does. If not, disable long long
# support because we don't know how to display it.
#
AS_IF([test "$ac_cv_type_long_long_int" = yes],
      [AC_MSG_CHECKING([*printf() support for %lld])
       can_printf_longlong=no
       AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdio.h>
int main() {
        char buf[100];
        sprintf(buf, "%lld", 4294967300LL);
        return (strcmp(buf, "4294967300"));
}
]])],
                     [AC_MSG_RESULT([yes])
                      can_printf_longlong=yes],
                     [AC_MSG_RESULT([no])],
                     [AC_MSG_RESULT([unknown - cross-compiling])])
        AS_IF([test "$can_printf_longlong" != yes],
              [AC_MSG_CHECKING([*printf() support for %qd])
               AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdio.h>
int main() {
        char buf[100];
        sprintf(buf, "%qd", 4294967300LL);
        return (strcmp(buf, "4294967300"));
}
]])],
                             [AC_MSG_RESULT([yes])
                              can_printf_longlong=yes
                              AC_DEFINE([HAVE_PRINTF_QD], [1])],
                             [AC_MSG_RESULT([no])],
                             [AC_MSG_RESULT([unknown - cross-compiling])])])
        AC_MSG_CHECKING([if *printf() can print long long ints])
        AS_IF([test "$can_printf_longlong" = yes],
              [AC_MSG_RESULT([yes])
               AC_DEFINE([HAVE_PRINTF_LONG_LONG], [1])
               AC_REPLACE_FUNCS([strtoll])],
              [AC_MSG_RESULT([no])])])

# Handle Darwin 7 having a poll() compatibility function,
# and don't use it if it's emulated.
# Be conservative, if we don't find one of poll.h or sys/poll.h,
# don't attempt to use poll().
#
AC_CHECK_TYPES([struct pollfd], [], [], [$accheck_includes])
AC_CHECK_FUNC([poll],
              [AC_CHECK_DECL([_POLL_EMUL_H_],
                             [],
                             [AC_DEFINE([HAVE_POLL], [1])],
                             [$accheck_includes])])

# Assume libedit is not up-to-date and force own version.
#
have_libedit=no
AS_IF([test "$opt_editcomplete" = yes],
      [AC_MSG_CHECKING([for up-to-date libedit])
       AS_IF([test "$have_libedit" = no],
             [AC_MSG_RESULT([no - using my own])
              INCLUDES="-I\${srcdir}/../libedit $INCLUDES"
              LDFLAGS="-L../libedit $LDFLAGS"
              LIBS="-ledit $LIBS"
              LIBEDIT=libedit.a
              LIBDEPENDS="$LIBDEPENDS ../libedit/libedit.a"],
             [AC_MSG_RESULT([yes])])],
      [CFLAGS="-DNO_EDITCOMPLETE $CFLAGS"])

# Replace sl_init() (et al) if it provides the older API.
#
AS_IF([test "$ac_cv_func_sl_init" = yes],
      [AC_MSG_CHECKING([if sl_add() returns int])
       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stringlist.h>]],
                                          [[int f = sl_add((StringList *)0,
                                                           "foo");]])],
                         [AC_MSG_RESULT([yes])],
                         [AC_MSG_RESULT([no - using local version])
                          AC_LIBOBJ([sl_init])],
                         [AC_MSG_RESULT([unknown - cross-compiling])])])

# Replace getaddrinfo() if missing or AI_NUMERICHOST isn't declared.
#
AC_MSG_CHECKING([for working getaddrinfo()])
AS_IF([test "$ac_cv_have_decl_AI_NUMERICHOST" = yes],
      [AC_MSG_RESULT([yes])],
      [AS_IF([test "$ac_cv_func_getaddrinfo" = yes],
             [AC_LIBOBJ([getaddrinfo])
              AC_MSG_RESULT([no - using local version])],
             [AC_MSG_RESULT([using local version])])])

# Check for VIS_WHITE in <vis.h>
#
AS_IF([test "$ac_cv_header_vis_h" = yes],
      [AC_CHECK_DECL([VIS_WHITE], [], [], [
#include <vis.h>
])])

# Build libnetbsd if necessary.
#
AS_IF([test -n "$LIBOBJS"],
      [INCLUDES="$INCLUDES -I\${srcdir}/../libnetbsd"
       LDFLAGS="$LDFLAGS -L../libnetbsd"
       LIBS="$LIBS -lnetbsd"
       LIBNETBSD=libnetbsd.a
       LIBDEPENDS="$LIBDEPENDS ../libnetbsd/libnetbsd.a"])

#
# Create the Makefiles.
#
AC_SUBST(INCLUDES)
AC_SUBST(LIBEDIT)
AC_SUBST(LIBNETBSD)
AC_SUBST(LIBDEPENDS)

AC_CONFIG_FILES([Makefile
                 libedit/Makefile
                 libedit/makelist
                 libnetbsd/Makefile
                 src/Makefile])

AC_OUTPUT