aboutsummaryrefslogtreecommitdiffstats
path: root/configure.ac
blob: a59ac43f3795a9fac5019c6bc1ae2b4b20cfc4bd (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
AC_INIT([asn1c], [0.9.28], [vlm@lionet.info])

AC_CONFIG_AUX_DIR(config)
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE([foreign])
AC_CONFIG_MACRO_DIR([m4])

AM_PROG_LIBTOOL

dnl Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_YACC
AM_PROG_LEX
AC_PATH_PROG(AR, ar, ar, $PATH:/usr/ucb:/usr/ccs/bin)	dnl for Solaris

dnl If you need to see the details, just run make V=1.
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

case "$host_os" in
cygwin)
	case "$target" in
	*mingw*)
		CC="$CC -mno-cygwin"
	esac
	;;
esac

AC_ARG_ENABLE([ASN_DEBUG],
  [AS_HELP_STRING([--enable-ASN_DEBUG],
                  [produce debug log during `make check` testing])],
  [enable_asn_debug=$enableval], [enable_asn_debug=no])
  AS_IF([test x$enable_asn_debug != xno], [
      TESTSUITE_CFLAGS="-DEMIT_ASN_DEBUG"
  ])

AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"])
AX_CHECK_COMPILE_FLAG([-Wcast-qual], [CFLAGS="$CFLAGS -Wcast-qual"])
AX_CHECK_COMPILE_FLAG([-Wchar-subscripts],
      [CFLAGS="$CFLAGS -Wchar-subscripts"])
AX_CHECK_COMPILE_FLAG([-Wmissing-prototypes],
      [CFLAGS="$CFLAGS -Wmissing-prototypes"])
AX_CHECK_COMPILE_FLAG([-Wmissing-declarations],
      [CFLAGS="$CFLAGS -Wmissing-declarations"])

dnl There are legitimate uses for these features, disable warnings/errors.
AX_CHECK_COMPILE_FLAG([-Wno-error=cast-align],
      [CFLAGS="$CFLAGS -Wno-error=cast-align"])
AX_CHECK_COMPILE_FLAG([-Wno-error=visibility],
      [CFLAGS="$CFLAGS -Wno-error=visibility"])
AX_CHECK_COMPILE_FLAG([-Wno-error=parentheses-equality],
      [CFLAGS="$CFLAGS -Wno-error=parentheses-equality"])
AX_CHECK_COMPILE_FLAG([-Wno-error=unused-variable],
      [TESTSUITE_CFLAGS="$TESTSUITE_CFLAGS -Wno-error=unused-variable"])

AC_ARG_ENABLE(Werror,
  [AS_HELP_STRING([--enable-Werror],
                  [abort compilation after any C compiler warning])],
  [enable_werror=$enableval], [enable_werror=no])
  AS_IF([test x$enable_werror != xno], [
      ADD_CFLAGS="-Werror -W -Wpointer-arith"
  ])

AC_ARG_ENABLE(test-Werror,
  [AS_HELP_STRING([--enable-test-Werror],
                  [abort compiling tests after any C compiler warning])],
  [enable_test_werror=$enableval], [enable_test_werror=no])
  AS_IF([test x$enable_test_werror != xno], [
      TESTSUITE_CFLAGS="-Werror -W -Wpointer-arith"
  ])

AC_SUBST(ADD_CFLAGS)
AC_SUBST(TESTSUITE_CFLAGS)

dnl Skeletons should be very compatible with most of the compilers, hence
dnl very strict backward compatibility flags.
SKELETONS_CFLAGS="${ADD_CFLAGS}"
AX_CHECK_COMPILE_FLAG([-std=c89],
    [SKELETONS_CFLAGS="$SKELETONS_CFLAGS -std=c89"])
AX_CHECK_COMPILE_FLAG([-Wpedantic],
    [SKELETONS_CFLAGS="$SKELETONS_CFLAGS -Wpedantic"])
AX_CHECK_COMPILE_FLAG([-Wno-duplicate-decl-specifier],
    [SKELETONS_CFLAGS="$SKELETONS_CFLAGS -Wno-duplicate-decl-specifier"])
AC_SUBST(SKELETONS_CFLAGS)

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/param.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_BIGENDIAN
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_STRUCT_TM
AC_CHECK_TYPE(intmax_t, int64_t)

dnl Test if we should check features that depend on 64-bitness.
AC_MSG_CHECKING(size of long is longer than 32 bit)
AS_VAR_PUSHDEF([WIDE_LONG], [WIDE_LONG])
AC_TRY_COMPILE([#include "confdefs.h"
#include <sys/types.h>
], [switch (0) case 0: case (sizeof ($1) >= 8):;],
    WIDE_LONG=yes, WIDE_LONG=no)
AC_MSG_RESULT($WIDE_LONG)
AM_CONDITIONAL([TEST_64BIT], [test x$WIDE_LONG = xyes])
AS_VAR_POPDEF([WIDE_LONG])

dnl For mingw
AC_SEARCH_LIBS(getopt, iberty)

AC_CHECK_FUNCS(strtoimax strtoll)
AC_CHECK_FUNCS(mergesort)
AC_CHECK_FUNCS(mkstemps)
AC_CHECK_FUNCS(timegm)
AC_CHECK_DECLS(alloca strcasecmp)
AC_TRY_LINK_FUNC([symlink],[AC_DEFINE([HAVE_SYMLINK], 1, [Define to 1 if you have the symlink function.])])

dnl Use pandoc to generate manual pages.
AC_PATH_PROG([PANDOC], pandoc)
AM_CONDITIONAL([HAVE_PANDOC], [test -n "$PANDOC"])

AC_OUTPUT(				\
skeletons/tests/Makefile		\
libasn1compiler/Makefile		\
libasn1parser/Makefile			\
libasn1print/Makefile			\
asn1c/tests/Makefile			\
libasn1fix/Makefile			\
doc/docsrc/Makefile			\
skeletons/Makefile			\
examples/Makefile			\
doc/man/Makefile			\
asn1c/Makefile				\
doc/Makefile				\
Makefile				\
)