1AC_INIT([asn1c], [0.9.27], [vlm@lionet.info])
2AM_INIT_AUTOMAKE([-Wall -Werror foreign])
3AC_CONFIG_HEADER([config.h])
4AC_CONFIG_MACRO_DIR([m4])
5
6AM_MAINTAINER_MODE
7
8AM_PROG_LIBTOOL
9
10dnl Checks for programs.
11AC_PROG_CC
12AC_PROG_CPP
13AC_PROG_INSTALL
14AC_PROG_LN_S
15AC_PROG_MAKE_SET
16AC_PROG_YACC
17AM_PROG_LEX
18AC_PATH_PROG(AR, ar, ar, $PATH:/usr/ucb:/usr/ccs/bin)	dnl for Solaris
19
20case "$host_os" in
21cygwin)
22	case "$target" in
23	*mingw*)
24		CC="$CC -mno-cygwin"
25	esac
26	;;
27esac
28
29AC_ARG_ENABLE(Werror,
30  [  --enable-Werror         abort compilation after any C compiler warning],
31	enable_werror=$enableval, enable_werror=no)
32if test x$enable_werror = xyes; then
33  TESTSUITE_CFLAGS="-Werror -W -Wpointer-arith"
34  ADD_CFLAGS="-Werror -W -Wpointer-arith"
35fi
36
37AC_ARG_ENABLE([ASN_DEBUG],
38  [  --enable-ASN_DEBUG      produce debug log during `make check` testing],
39	enable_asn_debug=$enableval, enable_asn_debug=no)
40if test x$enable_asn_debug = xyes; then
41  TESTSUITE_CFLAGS="-DEMIT_ASN_DEBUG"
42fi
43
44AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"])
45AX_CHECK_COMPILE_FLAG([-Wcast-qual], [CFLAGS="$CFLAGS -Wcast-qual"])
46AX_CHECK_COMPILE_FLAG([-Wchar-subscripts],
47      [CFLAGS="$CFLAGS -Wchar-subscripts"])
48AX_CHECK_COMPILE_FLAG([-Wmissing-prototypes],
49      [CFLAGS="$CFLAGS -Wmissing-prototypes"])
50AX_CHECK_COMPILE_FLAG([-Wmissing-declarations],
51      [CFLAGS="$CFLAGS -Wmissing-declarations"])
52
53dnl There are legitimate uses for these features, disable warnings/errors.
54AX_CHECK_COMPILE_FLAG([-Wno-error=cast-align],
55      [CFLAGS="$CFLAGS -Wno-error=cast-align"])
56AX_CHECK_COMPILE_FLAG([-Wno-error=visibility],
57      [CFLAGS="$CFLAGS -Wno-error=visibility"])
58AX_CHECK_COMPILE_FLAG([-Wno-error=parentheses-equality],
59      [CFLAGS="$CFLAGS -Wno-error=parentheses-equality"])
60AX_CHECK_COMPILE_FLAG([-Wno-error=unused-variable],
61      [TESTSUITE_CFLAGS="$TESTSUITE_CFLAGS -Wno-error=unused-variable"])
62
63AC_SUBST(ADD_CFLAGS)
64AC_SUBST(TESTSUITE_CFLAGS)
65
66dnl Checks for header files.
67AC_HEADER_STDC
68AC_CHECK_HEADERS(sys/param.h)
69
70dnl Checks for typedefs, structures, and compiler characteristics.
71AC_C_BIGENDIAN
72AC_TYPE_OFF_T
73AC_TYPE_SIZE_T
74AC_STRUCT_TM
75AC_CHECK_TYPE(intmax_t, int64_t)
76
77dnl Test if we should check features that depend on 64-bitness.
78AC_MSG_CHECKING(size of long is longer than 32 bit)
79AS_VAR_PUSHDEF([WIDE_LONG], [WIDE_LONG])
80AC_TRY_COMPILE([#include "confdefs.h"
81#include <sys/types.h>
82], [switch (0) case 0: case (sizeof ($1) >= 8):;],
83    WIDE_LONG=yes, WIDE_LONG=no)
84AC_MSG_RESULT($WIDE_LONG)
85AM_CONDITIONAL([TEST_64BIT], [test x$WIDE_LONG = xyes])
86AS_VAR_POPDEF([WIDE_LONG])
87
88dnl For mingw
89AC_SEARCH_LIBS(getopt, iberty)
90
91AC_CHECK_FUNCS(strtoimax strtoll)
92AC_CHECK_FUNCS(mergesort)
93AC_CHECK_FUNCS(mkstemps)
94
95AC_OUTPUT(				\
96skeletons/tests/Makefile		\
97libasn1compiler/Makefile		\
98libasn1parser/Makefile			\
99libasn1print/Makefile			\
100asn1c/tests/Makefile			\
101libasn1fix/Makefile			\
102doc/docsrc/Makefile			\
103skeletons/Makefile			\
104examples/Makefile			\
105asn1c/Makefile				\
106doc/Makefile				\
107asn1c.spec				\
108Makefile				\
109)
110
111