blob: b1eb4324974c6c2bc524389e2906c9c459a1c7b4 [file] [log] [blame]
Lev Walkinfa9bb6d2017-03-26 03:48:43 -07001AC_INIT([asn1c],[0.9.29],[vlm@lionet.info])
Lev Walkin1b03c792014-10-12 17:31:26 -07002
3AC_CONFIG_AUX_DIR(config)
Lev Walkine7c4b962010-11-09 03:10:36 -08004AC_CONFIG_HEADER([config.h])
Lev Walkinf7613202016-01-10 13:27:18 -08005AM_INIT_AUTOMAKE([foreign])
Lev Walkine7c4b962010-11-09 03:10:36 -08006AC_CONFIG_MACRO_DIR([m4])
Lev Walkinf15320b2004-06-03 03:38:44 +00007
Lev Walkinf15320b2004-06-03 03:38:44 +00008dnl Checks for programs.
9AC_PROG_CC
10AC_PROG_CPP
11AC_PROG_INSTALL
12AC_PROG_LN_S
13AC_PROG_MAKE_SET
14AC_PROG_YACC
15AM_PROG_LEX
theirixb577d4d2016-07-30 17:14:59 +030016dnl locate ar using standard macro (old automake 1.11 does not know about AM_PROG_AR)
17m4_ifdef([AM_PROG_AR],
18 [AM_PROG_AR],
19 [AC_PATH_PROG(AR, ar, ar, $PATH:/usr/ucb:/usr/ccs/bin)])
20
21LT_INIT
Lev Walkinf15320b2004-06-03 03:38:44 +000022
Lev Walkin32789952014-10-12 18:51:52 -070023dnl If you need to see the details, just run make V=1.
24m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
Frank Morgnerfb63c012013-05-21 09:56:38 +020025
Lev Walkinbec70d82004-08-23 10:40:21 +000026case "$host_os" in
Lev Walkin19abe222006-03-18 06:39:12 +000027cygwin)
Lev Walkinbec70d82004-08-23 10:40:21 +000028 case "$target" in
29 *mingw*)
30 CC="$CC -mno-cygwin"
31 esac
32 ;;
Lev Walkin615a7fa2006-03-18 06:24:33 +000033esac
34
Lev Walkin58ecc7b2014-09-17 00:32:03 -070035AC_ARG_ENABLE([ASN_DEBUG],
Lev Walkin271131c2015-04-10 00:09:57 -070036 [AS_HELP_STRING([--enable-ASN_DEBUG],
37 [produce debug log during `make check` testing])],
38 [enable_asn_debug=$enableval], [enable_asn_debug=no])
39 AS_IF([test x$enable_asn_debug != xno], [
40 TESTSUITE_CFLAGS="-DEMIT_ASN_DEBUG"
Lev Walkin64dd70c2016-03-14 05:14:07 -070041 SKELETONS_CFLAGS="-DEMIT_ASN_DEBUG"
Lev Walkin271131c2015-04-10 00:09:57 -070042 ])
Lev Walkin58ecc7b2014-09-17 00:32:03 -070043
Lev Walkinf84cc012014-01-14 02:12:24 -080044AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"])
45AX_CHECK_COMPILE_FLAG([-Wcast-qual], [CFLAGS="$CFLAGS -Wcast-qual"])
46AX_CHECK_COMPILE_FLAG([-Wchar-subscripts],
Lev Walkin65907f02014-09-14 17:19:21 -070047 [CFLAGS="$CFLAGS -Wchar-subscripts"])
Lev Walkinf84cc012014-01-14 02:12:24 -080048AX_CHECK_COMPILE_FLAG([-Wmissing-prototypes],
Lev Walkin65907f02014-09-14 17:19:21 -070049 [CFLAGS="$CFLAGS -Wmissing-prototypes"])
Lev Walkinf84cc012014-01-14 02:12:24 -080050AX_CHECK_COMPILE_FLAG([-Wmissing-declarations],
Lev Walkin65907f02014-09-14 17:19:21 -070051 [CFLAGS="$CFLAGS -Wmissing-declarations"])
Lev Walkinf15320b2004-06-03 03:38:44 +000052
Lev Walkinf84cc012014-01-14 02:12:24 -080053dnl There are legitimate uses for these features, disable warnings/errors.
54AX_CHECK_COMPILE_FLAG([-Wno-error=cast-align],
Lev Walkin65907f02014-09-14 17:19:21 -070055 [CFLAGS="$CFLAGS -Wno-error=cast-align"])
Lev Walkinf84cc012014-01-14 02:12:24 -080056AX_CHECK_COMPILE_FLAG([-Wno-error=visibility],
Lev Walkin65907f02014-09-14 17:19:21 -070057 [CFLAGS="$CFLAGS -Wno-error=visibility"])
Lev Walkinf84cc012014-01-14 02:12:24 -080058AX_CHECK_COMPILE_FLAG([-Wno-error=parentheses-equality],
Lev Walkin65907f02014-09-14 17:19:21 -070059 [CFLAGS="$CFLAGS -Wno-error=parentheses-equality"])
Lev Walkin3798f342016-03-14 04:07:45 -070060AX_CHECK_COMPILE_FLAG([-std=gnu99],
Lev Walkin62d95d22017-08-06 23:41:11 -070061 [CFLAGS="$CFLAGS -std=gnu99"
Lev Walkin645d2de2017-08-06 23:30:36 -070062TESTSUITE_CFLAGS="$TESTSUITE_CFLAGS -std=gnu99"])
Lev Walkin65907f02014-09-14 17:19:21 -070063AX_CHECK_COMPILE_FLAG([-Wno-error=unused-variable],
64 [TESTSUITE_CFLAGS="$TESTSUITE_CFLAGS -Wno-error=unused-variable"])
65
Lev Walkinf7613202016-01-10 13:27:18 -080066AC_ARG_ENABLE(Werror,
67 [AS_HELP_STRING([--enable-Werror],
68 [abort compilation after any C compiler warning])],
69 [enable_werror=$enableval], [enable_werror=no])
70 AS_IF([test x$enable_werror != xno], [
71 ADD_CFLAGS="-Werror -W -Wpointer-arith"
72 ])
73
74AC_ARG_ENABLE(test-Werror,
75 [AS_HELP_STRING([--enable-test-Werror],
76 [abort compiling tests after any C compiler warning])],
77 [enable_test_werror=$enableval], [enable_test_werror=no])
78 AS_IF([test x$enable_test_werror != xno], [
79 TESTSUITE_CFLAGS="-Werror -W -Wpointer-arith"
80 ])
81
Vasil Velichkove3187592016-07-18 22:46:36 +030082AX_CODE_COVERAGE
83AS_IF([test x$enable_code_coverage != xno], [
84 CFLAGS="$CFLAGS $CODE_COVERAGE_CFLAGS"
85 # The CODE_COVERAGE_CPPFLAGS contains -DNDEBUG flag
86 # which removes assert(...) macros from code coverage and improves the
87 # branches score. But when it is defined it results in few
88 # unsed-but-set-variable warnings that are treated as errors in the travis-ci
89 # build because these variables are only used inside assert macros.
90 # error: variable ‘ret’ set but not used [-Werror=unused-but-set-variable]
91 #CPPFLAGS="$CPPFLAGS $CODE_COVERAGE_CPPFLAGS"
92 CXXFLAGS="$CXXFLAGS $CODE_COVERAGE_CXXFLAGS"
Lev Walkinefded512017-03-26 16:12:11 -070093 AC_SEARCH_LIBS(gcov_open, gcov, [LDFLAGS="$LDFLAGS $CODE_COVERAGE_LDFLAGS"])
Vasil Velichkove3187592016-07-18 22:46:36 +030094])
95
Lev Walkin97363482016-01-24 19:23:02 -080096dnl Skeletons should be very compatible with most of the compilers, hence
97dnl very strict backward compatibility flags.
Lev Walkin64dd70c2016-03-14 05:14:07 -070098SKELETONS_CFLAGS="${ADD_CFLAGS} ${SKELETONS_CFLAGS}"
Lev Walkin97363482016-01-24 19:23:02 -080099AX_CHECK_COMPILE_FLAG([-std=c89],
Lev Walkin104af192016-01-24 22:13:27 -0800100 [SKELETONS_CFLAGS="$SKELETONS_CFLAGS -std=c89"])
Lev Walkin97363482016-01-24 19:23:02 -0800101AX_CHECK_COMPILE_FLAG([-Wpedantic],
Vasil Velichkov1144b352016-07-19 19:09:33 +0300102 [SKELETONS_CFLAGS="$SKELETONS_CFLAGS -Wpedantic"],
103 [
104 dnl When -Wpedantic is not supported try the -pedantic instead. (gcc-4.7)
105 dnl See https://gcc.gnu.org/gcc-4.8/changes.html
106 AX_CHECK_COMPILE_FLAG([-pedantic],
107 [SKELETONS_CFLAGS="$SKELETONS_CFLAGS -pedantic"], [], [-Werror])
108 ],
109 [-Werror]) #clang 3.0 prints warning when the flag is not supported
Lev Walkina7d64002017-08-23 22:34:29 -0700110dnl Enable Address Sanitizer, if supported by gcc (4.8+) or clang.
111dnl http://clang.llvm.org/docs/AddressSanitizer.html
112dnl https://code.google.com/p/address-sanitizer/wiki/HowToBuild
113AC_ARG_ENABLE([test-asan],
114 [AS_HELP_STRING([--enable-test-asan], [Enable Address Sanitizer for tests of generated code])],
115 [enable_test_asan=$enableval], [enable_test_asan=no])
116 AS_IF([test "x$enable_asan" != xno], [
117 AX_CHECK_COMPILE_FLAG([-fsanitize=address],
118 [SKELETONS_CFLAGS="${SKELETONS_CFLAGS} -fsanitize=address"
119 TESTSUITE_CFLAGS="${TESTSUITE_CFLAGS} -fsanitize=address"],
120 [enable_test_asan=no], [])
121 AS_IF([test "x$enable_asan" = xno], [
122 AC_MSG_FAILURE(
123 [--enable-test-asan is given, but not supported on this platform.
124 Check out https://code.google.com/p/address-sanitizer/wiki/HowToBuild])])
125 dnl Keep error messages nice. Also consider:
126 dnl export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer
127 dnl export ASAN_OPTIONS=symbolize=1
128 AX_CHECK_COMPILE_FLAG([-fno-omit-frame-pointer],
129 [SKELETONS_CFLAGS="${SKELETONS_CFLAGS} -fno-omit-frame-pointer"
130 TESTSUITE_CFLAGS="${TESTSUITE_CFLAGS} -fno-omit-frame-pointer"],
131 [], [])
132 ])
133
134AC_SUBST(ADD_CFLAGS)
135AC_SUBST(TESTSUITE_CFLAGS)
Lev Walkin97363482016-01-24 19:23:02 -0800136AC_SUBST(SKELETONS_CFLAGS)
137
Lev Walkinf15320b2004-06-03 03:38:44 +0000138dnl Checks for header files.
139AC_HEADER_STDC
Lev Walkin79f54952004-08-13 16:58:19 +0000140AC_CHECK_HEADERS(sys/param.h)
Lev Walkin619f0cd2016-07-02 19:55:23 +0000141AC_CHECK_HEADERS(alloca.h)
Lev Walkinf15320b2004-06-03 03:38:44 +0000142
143dnl Checks for typedefs, structures, and compiler characteristics.
144AC_C_BIGENDIAN
145AC_TYPE_OFF_T
146AC_TYPE_SIZE_T
147AC_STRUCT_TM
Lev Walkinda997b12017-08-04 01:38:41 -0700148AC_CHECK_TYPE([__int128],
149 [AC_DEFINE(HAVE_128_BIT_INT, 1, [Have 128-bit integer])])
Lev Walkinf15320b2004-06-03 03:38:44 +0000150AC_CHECK_TYPE(intmax_t, int64_t)
151
Lev Walkin1d84ea92017-08-02 12:40:13 -0700152dnl Test if we should test features that depend on 64-bitness.
153AC_CHECK_SIZEOF([void *])
154AM_CONDITIONAL([TEST_64BIT], [test "$ac_cv_sizeof_void_p" -eq 8])
Lev Walkinb40ec412014-02-24 00:57:18 -0800155
Lev Walkin058e2222007-12-04 00:27:38 +0000156dnl For mingw
157AC_SEARCH_LIBS(getopt, iberty)
158
Lev Walkinf15320b2004-06-03 03:38:44 +0000159AC_CHECK_FUNCS(strtoimax strtoll)
Lev Walkin49b0a3e2004-06-28 21:22:35 +0000160AC_CHECK_FUNCS(mergesort)
Lev Walkin27fd0b62007-08-27 23:57:45 +0000161AC_CHECK_FUNCS(mkstemps)
Lev Walkin04fbe622014-09-17 02:27:01 -0700162AC_CHECK_FUNCS(timegm)
Frank Morgnercab30af2013-05-21 14:28:35 +0200163AC_CHECK_DECLS(alloca strcasecmp)
Frank Morgner8a759ad2013-05-16 13:32:49 +0200164AC_TRY_LINK_FUNC([symlink],[AC_DEFINE([HAVE_SYMLINK], 1, [Define to 1 if you have the symlink function.])])
Lev Walkin27fd0b62007-08-27 23:57:45 +0000165
Lev Walkinc6080fd2016-01-23 06:35:34 -0800166dnl Use pandoc to generate manual pages.
167AC_PATH_PROG([PANDOC], pandoc)
168AM_CONDITIONAL([HAVE_PANDOC], [test -n "$PANDOC"])
169
Lev Walkin327bab22016-03-14 02:36:27 -0700170AC_CONFIG_FILES([\
Lev Walkin700df492017-08-10 14:59:15 -0700171tests/tests-c-compiler/check-src/Makefile \
172tests/tests-asn1c-compiler/Makefile \
173tests/tests-c-compiler/Makefile \
174skeletons/tests/Makefile \
175libasn1compiler/Makefile \
Lev Walkind9221842017-08-22 01:44:56 -0700176libasn1common/Makefile \
Lev Walkin700df492017-08-10 14:59:15 -0700177libasn1parser/Makefile \
178libasn1print/Makefile \
179libasn1fix/Makefile \
180doc/docsrc/Makefile \
181skeletons/Makefile \
182examples/Makefile \
183doc/man/Makefile \
184tests/Makefile \
185asn1c/Makefile \
186doc/Makefile \
187Makefile \
Lev Walkin327bab22016-03-14 02:36:27 -0700188])
189AC_OUTPUT
Lev Walkinf15320b2004-06-03 03:38:44 +0000190