Lev Walkin | fa9bb6d | 2017-03-26 03:48:43 -0700 | [diff] [blame] | 1 | AC_INIT([asn1c],[0.9.29],[vlm@lionet.info]) |
Lev Walkin | 1b03c79 | 2014-10-12 17:31:26 -0700 | [diff] [blame] | 2 | |
| 3 | AC_CONFIG_AUX_DIR(config) |
Lev Walkin | e7c4b96 | 2010-11-09 03:10:36 -0800 | [diff] [blame] | 4 | AC_CONFIG_HEADER([config.h]) |
Lev Walkin | f761320 | 2016-01-10 13:27:18 -0800 | [diff] [blame] | 5 | AM_INIT_AUTOMAKE([foreign]) |
Lev Walkin | e7c4b96 | 2010-11-09 03:10:36 -0800 | [diff] [blame] | 6 | AC_CONFIG_MACRO_DIR([m4]) |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 7 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 8 | dnl Checks for programs. |
| 9 | AC_PROG_CC |
| 10 | AC_PROG_CPP |
| 11 | AC_PROG_INSTALL |
| 12 | AC_PROG_LN_S |
| 13 | AC_PROG_MAKE_SET |
| 14 | AC_PROG_YACC |
| 15 | AM_PROG_LEX |
theirix | b577d4d | 2016-07-30 17:14:59 +0300 | [diff] [blame] | 16 | dnl locate ar using standard macro (old automake 1.11 does not know about AM_PROG_AR) |
| 17 | m4_ifdef([AM_PROG_AR], |
| 18 | [AM_PROG_AR], |
| 19 | [AC_PATH_PROG(AR, ar, ar, $PATH:/usr/ucb:/usr/ccs/bin)]) |
| 20 | |
| 21 | LT_INIT |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 22 | |
Lev Walkin | 3278995 | 2014-10-12 18:51:52 -0700 | [diff] [blame] | 23 | dnl If you need to see the details, just run make V=1. |
| 24 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) |
Frank Morgner | fb63c01 | 2013-05-21 09:56:38 +0200 | [diff] [blame] | 25 | |
Lev Walkin | bec70d8 | 2004-08-23 10:40:21 +0000 | [diff] [blame] | 26 | case "$host_os" in |
Lev Walkin | 19abe22 | 2006-03-18 06:39:12 +0000 | [diff] [blame] | 27 | cygwin) |
Lev Walkin | bec70d8 | 2004-08-23 10:40:21 +0000 | [diff] [blame] | 28 | case "$target" in |
| 29 | *mingw*) |
| 30 | CC="$CC -mno-cygwin" |
| 31 | esac |
| 32 | ;; |
Lev Walkin | 615a7fa | 2006-03-18 06:24:33 +0000 | [diff] [blame] | 33 | esac |
| 34 | |
Lev Walkin | 58ecc7b | 2014-09-17 00:32:03 -0700 | [diff] [blame] | 35 | AC_ARG_ENABLE([ASN_DEBUG], |
Lev Walkin | 271131c | 2015-04-10 00:09:57 -0700 | [diff] [blame] | 36 | [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 Walkin | 64dd70c | 2016-03-14 05:14:07 -0700 | [diff] [blame] | 41 | SKELETONS_CFLAGS="-DEMIT_ASN_DEBUG" |
Lev Walkin | 271131c | 2015-04-10 00:09:57 -0700 | [diff] [blame] | 42 | ]) |
Lev Walkin | 58ecc7b | 2014-09-17 00:32:03 -0700 | [diff] [blame] | 43 | |
Lev Walkin | f84cc01 | 2014-01-14 02:12:24 -0800 | [diff] [blame] | 44 | AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"]) |
| 45 | AX_CHECK_COMPILE_FLAG([-Wcast-qual], [CFLAGS="$CFLAGS -Wcast-qual"]) |
| 46 | AX_CHECK_COMPILE_FLAG([-Wchar-subscripts], |
Lev Walkin | 65907f0 | 2014-09-14 17:19:21 -0700 | [diff] [blame] | 47 | [CFLAGS="$CFLAGS -Wchar-subscripts"]) |
Lev Walkin | f84cc01 | 2014-01-14 02:12:24 -0800 | [diff] [blame] | 48 | AX_CHECK_COMPILE_FLAG([-Wmissing-prototypes], |
Lev Walkin | 65907f0 | 2014-09-14 17:19:21 -0700 | [diff] [blame] | 49 | [CFLAGS="$CFLAGS -Wmissing-prototypes"]) |
Lev Walkin | f84cc01 | 2014-01-14 02:12:24 -0800 | [diff] [blame] | 50 | AX_CHECK_COMPILE_FLAG([-Wmissing-declarations], |
Lev Walkin | 65907f0 | 2014-09-14 17:19:21 -0700 | [diff] [blame] | 51 | [CFLAGS="$CFLAGS -Wmissing-declarations"]) |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 52 | |
Lev Walkin | f84cc01 | 2014-01-14 02:12:24 -0800 | [diff] [blame] | 53 | dnl There are legitimate uses for these features, disable warnings/errors. |
| 54 | AX_CHECK_COMPILE_FLAG([-Wno-error=cast-align], |
Lev Walkin | 65907f0 | 2014-09-14 17:19:21 -0700 | [diff] [blame] | 55 | [CFLAGS="$CFLAGS -Wno-error=cast-align"]) |
Lev Walkin | f84cc01 | 2014-01-14 02:12:24 -0800 | [diff] [blame] | 56 | AX_CHECK_COMPILE_FLAG([-Wno-error=visibility], |
Lev Walkin | 65907f0 | 2014-09-14 17:19:21 -0700 | [diff] [blame] | 57 | [CFLAGS="$CFLAGS -Wno-error=visibility"]) |
Lev Walkin | f84cc01 | 2014-01-14 02:12:24 -0800 | [diff] [blame] | 58 | AX_CHECK_COMPILE_FLAG([-Wno-error=parentheses-equality], |
Lev Walkin | 65907f0 | 2014-09-14 17:19:21 -0700 | [diff] [blame] | 59 | [CFLAGS="$CFLAGS -Wno-error=parentheses-equality"]) |
Lev Walkin | 3798f34 | 2016-03-14 04:07:45 -0700 | [diff] [blame] | 60 | AX_CHECK_COMPILE_FLAG([-std=gnu99], |
Lev Walkin | 62d95d2 | 2017-08-06 23:41:11 -0700 | [diff] [blame] | 61 | [CFLAGS="$CFLAGS -std=gnu99" |
Lev Walkin | 645d2de | 2017-08-06 23:30:36 -0700 | [diff] [blame] | 62 | TESTSUITE_CFLAGS="$TESTSUITE_CFLAGS -std=gnu99"]) |
Lev Walkin | 65907f0 | 2014-09-14 17:19:21 -0700 | [diff] [blame] | 63 | AX_CHECK_COMPILE_FLAG([-Wno-error=unused-variable], |
| 64 | [TESTSUITE_CFLAGS="$TESTSUITE_CFLAGS -Wno-error=unused-variable"]) |
| 65 | |
Vasil Velichkov | e318759 | 2016-07-18 22:46:36 +0300 | [diff] [blame] | 66 | AX_CODE_COVERAGE |
| 67 | AS_IF([test x$enable_code_coverage != xno], [ |
| 68 | CFLAGS="$CFLAGS $CODE_COVERAGE_CFLAGS" |
| 69 | # The CODE_COVERAGE_CPPFLAGS contains -DNDEBUG flag |
| 70 | # which removes assert(...) macros from code coverage and improves the |
| 71 | # branches score. But when it is defined it results in few |
| 72 | # unsed-but-set-variable warnings that are treated as errors in the travis-ci |
| 73 | # build because these variables are only used inside assert macros. |
| 74 | # error: variable ‘ret’ set but not used [-Werror=unused-but-set-variable] |
| 75 | #CPPFLAGS="$CPPFLAGS $CODE_COVERAGE_CPPFLAGS" |
| 76 | CXXFLAGS="$CXXFLAGS $CODE_COVERAGE_CXXFLAGS" |
Lev Walkin | efded51 | 2017-03-26 16:12:11 -0700 | [diff] [blame] | 77 | AC_SEARCH_LIBS(gcov_open, gcov, [LDFLAGS="$LDFLAGS $CODE_COVERAGE_LDFLAGS"]) |
Vasil Velichkov | e318759 | 2016-07-18 22:46:36 +0300 | [diff] [blame] | 78 | ]) |
| 79 | |
Lev Walkin | 9736348 | 2016-01-24 19:23:02 -0800 | [diff] [blame] | 80 | dnl Skeletons should be very compatible with most of the compilers, hence |
| 81 | dnl very strict backward compatibility flags. |
Lev Walkin | 64dd70c | 2016-03-14 05:14:07 -0700 | [diff] [blame] | 82 | SKELETONS_CFLAGS="${ADD_CFLAGS} ${SKELETONS_CFLAGS}" |
Lev Walkin | 9736348 | 2016-01-24 19:23:02 -0800 | [diff] [blame] | 83 | AX_CHECK_COMPILE_FLAG([-std=c89], |
Lev Walkin | 104af19 | 2016-01-24 22:13:27 -0800 | [diff] [blame] | 84 | [SKELETONS_CFLAGS="$SKELETONS_CFLAGS -std=c89"]) |
Lev Walkin | 9736348 | 2016-01-24 19:23:02 -0800 | [diff] [blame] | 85 | AX_CHECK_COMPILE_FLAG([-Wpedantic], |
Vasil Velichkov | 1144b35 | 2016-07-19 19:09:33 +0300 | [diff] [blame] | 86 | [SKELETONS_CFLAGS="$SKELETONS_CFLAGS -Wpedantic"], |
| 87 | [ |
| 88 | dnl When -Wpedantic is not supported try the -pedantic instead. (gcc-4.7) |
| 89 | dnl See https://gcc.gnu.org/gcc-4.8/changes.html |
| 90 | AX_CHECK_COMPILE_FLAG([-pedantic], |
| 91 | [SKELETONS_CFLAGS="$SKELETONS_CFLAGS -pedantic"], [], [-Werror]) |
| 92 | ], |
| 93 | [-Werror]) #clang 3.0 prints warning when the flag is not supported |
Lev Walkin | 0f5dd34 | 2017-09-13 22:52:39 +0000 | [diff] [blame^] | 94 | |
| 95 | AC_ARG_ENABLE(Werror, |
| 96 | [AS_HELP_STRING([--enable-Werror], |
| 97 | [abort compilation after any C compiler warning])], |
| 98 | [enable_werror=$enableval], [enable_werror=no]) |
| 99 | AS_IF([test x$enable_werror != xno], [ |
| 100 | ADD_CFLAGS="${ADD_CFLAGS} -Werror -W -Wall -Wpointer-arith" |
| 101 | SKELETONS_CFLAGS="${SKELETONS_CFLAGS} -Werror -W -Wall -Wpointer-arith" |
| 102 | AX_CHECK_COMPILE_FLAG([-Wgnu], |
| 103 | [SKELETONS_CFLAGS="${SKELETONS_CFLAGS} -Wgnu"]) |
| 104 | ]) |
| 105 | |
| 106 | AC_ARG_ENABLE(test-Werror, |
| 107 | [AS_HELP_STRING([--enable-test-Werror], |
| 108 | [abort compiling tests after any C compiler warning])], |
| 109 | [enable_test_werror=$enableval], [enable_test_werror=no]) |
| 110 | AS_IF([test x$enable_test_werror != xno], [ |
| 111 | TESTSUITE_CFLAGS="${TESTSUITE_CFLAGS} -Werror -W -Wpointer-arith" |
| 112 | ]) |
| 113 | |
Lev Walkin | a7d6400 | 2017-08-23 22:34:29 -0700 | [diff] [blame] | 114 | dnl Enable Address Sanitizer, if supported by gcc (4.8+) or clang. |
| 115 | dnl http://clang.llvm.org/docs/AddressSanitizer.html |
| 116 | dnl https://code.google.com/p/address-sanitizer/wiki/HowToBuild |
| 117 | AC_ARG_ENABLE([test-asan], |
| 118 | [AS_HELP_STRING([--enable-test-asan], [Enable Address Sanitizer for tests of generated code])], |
| 119 | [enable_test_asan=$enableval], [enable_test_asan=no]) |
Lev Walkin | 0f5dd34 | 2017-09-13 22:52:39 +0000 | [diff] [blame^] | 120 | AS_IF([test "x$enable_test_asan" != xno], [ |
| 121 | echo test asan1 [${enable_test_asan}] |
Lev Walkin | a7d6400 | 2017-08-23 22:34:29 -0700 | [diff] [blame] | 122 | AX_CHECK_COMPILE_FLAG([-fsanitize=address], |
Lev Walkin | 0f5dd34 | 2017-09-13 22:52:39 +0000 | [diff] [blame^] | 123 | [SKELETONS_CFLAGS="${SKELETONS_CFLAGS} -fsanitize=address" |
| 124 | TESTSUITE_CFLAGS="${TESTSUITE_CFLAGS} -fsanitize=address"] |
| 125 | [enable_test_asan=no]) |
| 126 | AS_IF([test "x$enable_test_asan" = xno], [ |
Lev Walkin | a7d6400 | 2017-08-23 22:34:29 -0700 | [diff] [blame] | 127 | AC_MSG_FAILURE( |
| 128 | [--enable-test-asan is given, but not supported on this platform. |
| 129 | Check out https://code.google.com/p/address-sanitizer/wiki/HowToBuild])]) |
| 130 | dnl Keep error messages nice. Also consider: |
| 131 | dnl export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer |
| 132 | dnl export ASAN_OPTIONS=symbolize=1 |
| 133 | AX_CHECK_COMPILE_FLAG([-fno-omit-frame-pointer], |
| 134 | [SKELETONS_CFLAGS="${SKELETONS_CFLAGS} -fno-omit-frame-pointer" |
| 135 | TESTSUITE_CFLAGS="${TESTSUITE_CFLAGS} -fno-omit-frame-pointer"], |
| 136 | [], []) |
| 137 | ]) |
| 138 | |
| 139 | AC_SUBST(ADD_CFLAGS) |
| 140 | AC_SUBST(TESTSUITE_CFLAGS) |
Lev Walkin | 9736348 | 2016-01-24 19:23:02 -0800 | [diff] [blame] | 141 | AC_SUBST(SKELETONS_CFLAGS) |
| 142 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 143 | dnl Checks for header files. |
| 144 | AC_HEADER_STDC |
Lev Walkin | 79f5495 | 2004-08-13 16:58:19 +0000 | [diff] [blame] | 145 | AC_CHECK_HEADERS(sys/param.h) |
Lev Walkin | 619f0cd | 2016-07-02 19:55:23 +0000 | [diff] [blame] | 146 | AC_CHECK_HEADERS(alloca.h) |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 147 | |
| 148 | dnl Checks for typedefs, structures, and compiler characteristics. |
| 149 | AC_C_BIGENDIAN |
| 150 | AC_TYPE_OFF_T |
| 151 | AC_TYPE_SIZE_T |
| 152 | AC_STRUCT_TM |
Lev Walkin | da997b1 | 2017-08-04 01:38:41 -0700 | [diff] [blame] | 153 | AC_CHECK_TYPE([__int128], |
| 154 | [AC_DEFINE(HAVE_128_BIT_INT, 1, [Have 128-bit integer])]) |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 155 | AC_CHECK_TYPE(intmax_t, int64_t) |
| 156 | |
Lev Walkin | 1d84ea9 | 2017-08-02 12:40:13 -0700 | [diff] [blame] | 157 | dnl Test if we should test features that depend on 64-bitness. |
| 158 | AC_CHECK_SIZEOF([void *]) |
| 159 | AM_CONDITIONAL([TEST_64BIT], [test "$ac_cv_sizeof_void_p" -eq 8]) |
Lev Walkin | b40ec41 | 2014-02-24 00:57:18 -0800 | [diff] [blame] | 160 | |
Lev Walkin | 058e222 | 2007-12-04 00:27:38 +0000 | [diff] [blame] | 161 | dnl For mingw |
| 162 | AC_SEARCH_LIBS(getopt, iberty) |
| 163 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 164 | AC_CHECK_FUNCS(strtoimax strtoll) |
Lev Walkin | 49b0a3e | 2004-06-28 21:22:35 +0000 | [diff] [blame] | 165 | AC_CHECK_FUNCS(mergesort) |
Lev Walkin | 27fd0b6 | 2007-08-27 23:57:45 +0000 | [diff] [blame] | 166 | AC_CHECK_FUNCS(mkstemps) |
Lev Walkin | 04fbe62 | 2014-09-17 02:27:01 -0700 | [diff] [blame] | 167 | AC_CHECK_FUNCS(timegm) |
Frank Morgner | cab30af | 2013-05-21 14:28:35 +0200 | [diff] [blame] | 168 | AC_CHECK_DECLS(alloca strcasecmp) |
Frank Morgner | 8a759ad | 2013-05-16 13:32:49 +0200 | [diff] [blame] | 169 | AC_TRY_LINK_FUNC([symlink],[AC_DEFINE([HAVE_SYMLINK], 1, [Define to 1 if you have the symlink function.])]) |
Lev Walkin | 27fd0b6 | 2007-08-27 23:57:45 +0000 | [diff] [blame] | 170 | |
Lev Walkin | c6080fd | 2016-01-23 06:35:34 -0800 | [diff] [blame] | 171 | dnl Use pandoc to generate manual pages. |
| 172 | AC_PATH_PROG([PANDOC], pandoc) |
| 173 | AM_CONDITIONAL([HAVE_PANDOC], [test -n "$PANDOC"]) |
| 174 | |
Lev Walkin | 327bab2 | 2016-03-14 02:36:27 -0700 | [diff] [blame] | 175 | AC_CONFIG_FILES([\ |
Lev Walkin | 700df49 | 2017-08-10 14:59:15 -0700 | [diff] [blame] | 176 | tests/tests-c-compiler/check-src/Makefile \ |
| 177 | tests/tests-asn1c-compiler/Makefile \ |
| 178 | tests/tests-c-compiler/Makefile \ |
Lev Walkin | 56d59b4 | 2017-08-24 13:54:58 -0700 | [diff] [blame] | 179 | tests/tests-skeletons/Makefile \ |
Lev Walkin | 700df49 | 2017-08-10 14:59:15 -0700 | [diff] [blame] | 180 | libasn1compiler/Makefile \ |
Lev Walkin | d922184 | 2017-08-22 01:44:56 -0700 | [diff] [blame] | 181 | libasn1common/Makefile \ |
Lev Walkin | 700df49 | 2017-08-10 14:59:15 -0700 | [diff] [blame] | 182 | libasn1parser/Makefile \ |
| 183 | libasn1print/Makefile \ |
| 184 | libasn1fix/Makefile \ |
| 185 | doc/docsrc/Makefile \ |
| 186 | skeletons/Makefile \ |
| 187 | examples/Makefile \ |
| 188 | doc/man/Makefile \ |
| 189 | tests/Makefile \ |
| 190 | asn1c/Makefile \ |
| 191 | doc/Makefile \ |
| 192 | Makefile \ |
Lev Walkin | 327bab2 | 2016-03-14 02:36:27 -0700 | [diff] [blame] | 193 | ]) |
| 194 | AC_OUTPUT |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 195 | |