1 dnl Process this file with autoconf to produce a configure script.
3 dnl This configure.ac is only for building a standalone argp library.
6 AM_INIT_AUTOMAKE(argp, standalone-1.3)
7 AM_CONFIG_HEADER(config.h)
9 # GNU libc defaults to supplying the ISO C library functions only. The
10 # _GNU_SOURCE define enables these extensions, in particular we want
11 # errno.h to declare program_invocation_name. Enable it on all
12 # systems; no problems have been reported with it so far.
15 # Checks for programs.
19 AC_PROGRAM_CHECK(AR,ar,ar,:)
20 AC_PROGRAM_CHECK(AR,gar,gar,:)
25 if test "x$am_cv_prog_cc_stdc" = xno ; then
26 AC_ERROR([the C compiler doesn't handle ANSI-C])
29 # Checks for libraries.
31 # Checks for header files.
33 AC_CHECK_HEADERS(limits.h malloc.h unistd.h)
35 # Checks for typedefs, structures, and compiler characteristics.
42 # Checks for library functions.
45 AC_CHECK_FUNCS(strerror)
47 AC_REPLACE_FUNCS(mempcpy strndup strchrnul)
49 dnl ARGP_CHECK_FUNC(includes, function-call [, if-found [, if-not-found]])
50 AC_DEFUN([ARGP_CHECK_FUNC],
51 [AS_VAR_PUSHDEF([ac_func], m4_substr([$2], 0, m4_index([$2], [(])))
52 AS_VAR_PUSHDEF([ac_var], [ac_cv_func_call_]ac_func)
53 AH_TEMPLATE(AS_TR_CPP(HAVE_[]ac_func),
54 [Define to 1 if you have the `]ac_func[' function.])
55 AC_CACHE_CHECK([for $2], ac_var,
56 [AC_TRY_LINK([$1], [$2],
57 [AS_VAR_SET(ac_var, yes)],
58 [AS_VAR_SET(ac_var, no)])])
59 if test AS_VAR_GET(ac_var) = yes ; then
61 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]ac_func))],
65 ifelse([$4],, true, [$4])
67 AS_VAR_POPDEF([ac_var])
68 AS_VAR_POPDEF([ac_func])
71 # At least on freebsd, putc_unlocked is a macro, so the standard
72 # AC_CHECK_FUNCS doesn't work well.
73 ARGP_CHECK_FUNC([#include <stdio.h>], [putc_unlocked('x', stdout)])
75 AC_CHECK_FUNCS(flockfile)
76 AC_CHECK_FUNCS(fputs_unlocked fwrite_unlocked)
78 # Used only by argp-test.c, so don't use AC_REPLACE_FUNCS.
79 AC_CHECK_FUNCS(strdup asprintf)
81 AC_CHECK_DECLS([program_invocation_name, program_invocation_short_name],
82 [], [], [[#include <errno.h>]])
84 # Set these flags *last*, or else the test programs won't compile
85 if test x$GCC = xyes ; then
86 # Using -ggdb3 makes (some versions of) Redhat's gcc-2.96 dump core
87 if "$CC" --version | grep '^2\.96$' 1>/dev/null 2>&1; then
90 CFLAGS="$CFLAGS -ggdb3"
92 CFLAGS="$CFLAGS -Wall -W \
93 -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes \
95 -Wpointer-arith -Wbad-function-cast -Wnested-externs"
98 CPPFLAGS="$CPPFLAGS -I$srcdir"
100 AC_OUTPUT(Makefile testsuite/Makefile)