1dnl Process this file with autoconf to produce a configure script. 2 3dnl This configure.ac is only for building a standalone argp library. 4AC_INIT([argp], [standalone-1.3]) 5AC_PREREQ(2.54) 6AC_CONFIG_SRCDIR([argp-ba.c]) 7# Needed to stop autoconf from looking for files in parent directories. 8AC_CONFIG_AUX_DIR([.]) 9 10AM_INIT_AUTOMAKE 11AC_CONFIG_HEADERS(config.h) 12 13m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)]) 14 15# GNU libc defaults to supplying the ISO C library functions only. The 16# _GNU_SOURCE define enables these extensions, in particular we want 17# errno.h to declare program_invocation_name. Enable it on all 18# systems; no problems have been reported with it so far. 19AC_GNU_SOURCE 20 21# Checks for programs. 22AC_PROG_CC 23AC_PROG_MAKE_SET 24AC_PROG_RANLIB 25AC_PROG_CC 26 27if test "x$am_cv_prog_cc_stdc" = xno ; then 28 AC_ERROR([the C compiler doesn't handle ANSI-C]) 29fi 30 31# Checks for libraries. 32 33# Checks for header files. 34AC_HEADER_STDC 35AC_CHECK_HEADERS(limits.h malloc.h unistd.h sysexits.h stdarg.h) 36 37# Checks for typedefs, structures, and compiler characteristics. 38AC_C_CONST 39AC_C_INLINE 40AC_TYPE_SIZE_T 41 42LSH_GCC_ATTRIBUTES 43 44# Checks for library functions. 45AC_FUNC_ALLOCA 46AC_FUNC_VPRINTF 47AC_CHECK_FUNCS(strerror sleep getpid snprintf) 48 49AC_REPLACE_FUNCS(mempcpy strndup strchrnul strcasecmp vsnprintf) 50 51dnl ARGP_CHECK_FUNC(includes, function-call [, if-found [, if-not-found]]) 52AC_DEFUN([ARGP_CHECK_FUNC], 53 [AS_VAR_PUSHDEF([ac_func], m4_substr([$2], 0, m4_index([$2], [(]))) 54 AS_VAR_PUSHDEF([ac_var], [ac_cv_func_call_]ac_func) 55 AH_TEMPLATE(AS_TR_CPP(HAVE_[]ac_func), 56 [Define to 1 if you have the `]ac_func[' function.]) 57 AC_CACHE_CHECK([for $2], ac_var, 58 [AC_TRY_LINK([$1], [$2], 59 [AS_VAR_SET(ac_var, yes)], 60 [AS_VAR_SET(ac_var, no)])]) 61 if test AS_VAR_GET(ac_var) = yes ; then 62 ifelse([$3],, 63 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]ac_func))], 64 [$3 65]) 66 else 67 ifelse([$4],, true, [$4]) 68 fi 69 AS_VAR_POPDEF([ac_var]) 70 AS_VAR_POPDEF([ac_func]) 71 ]) 72 73# At least on freebsd, putc_unlocked is a macro, so the standard 74# AC_CHECK_FUNCS doesn't work well. 75ARGP_CHECK_FUNC([#include <stdio.h>], [putc_unlocked('x', stdout)]) 76 77AC_CHECK_FUNCS(flockfile) 78AC_CHECK_FUNCS(fputs_unlocked fwrite_unlocked) 79 80# Used only by argp-test.c, so don't use AC_REPLACE_FUNCS. 81AC_CHECK_FUNCS(strdup asprintf) 82 83AC_CHECK_DECLS([program_invocation_name, program_invocation_short_name], 84 [], [], [[#include <errno.h>]]) 85 86# Set these flags *last*, or else the test programs won't compile 87if test x$GCC = xyes ; then 88 # Using -ggdb3 makes (some versions of) Redhat's gcc-2.96 dump core 89 if "$CC" --version | grep '^2\.96$' 1>/dev/null 2>&1; then 90 true 91 else 92 CFLAGS="$CFLAGS -ggdb3" 93 fi 94 CFLAGS="$CFLAGS -Wall -W \ 95 -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes \ 96 -Waggregate-return \ 97 -Wpointer-arith -Wbad-function-cast -Wnested-externs" 98fi 99 100CPPFLAGS="$CPPFLAGS -I$srcdir" 101 102dnl Added for C99 standards 103CFLAGS="$CFLAGS -std=gnu89" 104 105AC_OUTPUT(Makefile) 106