blob: 9e573cc3c07997ee46b65ba4f2dc217a480410da [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
Vasil Velichkove3187592016-07-18 22:46:36 +030066AX_CODE_COVERAGE
67AS_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 Walkinefded512017-03-26 16:12:11 -070077 AC_SEARCH_LIBS(gcov_open, gcov, [LDFLAGS="$LDFLAGS $CODE_COVERAGE_LDFLAGS"])
Vasil Velichkove3187592016-07-18 22:46:36 +030078])
79
Lev Walkin97363482016-01-24 19:23:02 -080080dnl Skeletons should be very compatible with most of the compilers, hence
81dnl very strict backward compatibility flags.
Lev Walkin64dd70c2016-03-14 05:14:07 -070082SKELETONS_CFLAGS="${ADD_CFLAGS} ${SKELETONS_CFLAGS}"
Lev Walkin97363482016-01-24 19:23:02 -080083AX_CHECK_COMPILE_FLAG([-std=c89],
Lev Walkin104af192016-01-24 22:13:27 -080084 [SKELETONS_CFLAGS="$SKELETONS_CFLAGS -std=c89"])
Lev Walkin97363482016-01-24 19:23:02 -080085AX_CHECK_COMPILE_FLAG([-Wpedantic],
Vasil Velichkov1144b352016-07-19 19:09:33 +030086 [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 Walkin0f5dd342017-09-13 22:52:39 +000094
95AC_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
106AC_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 Walkina7d64002017-08-23 22:34:29 -0700114dnl Enable Address Sanitizer, if supported by gcc (4.8+) or clang.
115dnl http://clang.llvm.org/docs/AddressSanitizer.html
116dnl https://code.google.com/p/address-sanitizer/wiki/HowToBuild
117AC_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 Walkin0f5dd342017-09-13 22:52:39 +0000120 AS_IF([test "x$enable_test_asan" != xno], [
121echo test asan1 [${enable_test_asan}]
Lev Walkina7d64002017-08-23 22:34:29 -0700122 AX_CHECK_COMPILE_FLAG([-fsanitize=address],
Lev Walkin0f5dd342017-09-13 22:52:39 +0000123 [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 Walkina7d64002017-08-23 22:34:29 -0700127 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
139AC_SUBST(ADD_CFLAGS)
140AC_SUBST(TESTSUITE_CFLAGS)
Lev Walkin97363482016-01-24 19:23:02 -0800141AC_SUBST(SKELETONS_CFLAGS)
142
Lev Walkinf15320b2004-06-03 03:38:44 +0000143dnl Checks for header files.
144AC_HEADER_STDC
Lev Walkin79f54952004-08-13 16:58:19 +0000145AC_CHECK_HEADERS(sys/param.h)
Lev Walkin619f0cd2016-07-02 19:55:23 +0000146AC_CHECK_HEADERS(alloca.h)
Lev Walkinf15320b2004-06-03 03:38:44 +0000147
148dnl Checks for typedefs, structures, and compiler characteristics.
149AC_C_BIGENDIAN
150AC_TYPE_OFF_T
151AC_TYPE_SIZE_T
152AC_STRUCT_TM
Lev Walkinda997b12017-08-04 01:38:41 -0700153AC_CHECK_TYPE([__int128],
154 [AC_DEFINE(HAVE_128_BIT_INT, 1, [Have 128-bit integer])])
Lev Walkinf15320b2004-06-03 03:38:44 +0000155AC_CHECK_TYPE(intmax_t, int64_t)
156
Lev Walkin1d84ea92017-08-02 12:40:13 -0700157dnl Test if we should test features that depend on 64-bitness.
158AC_CHECK_SIZEOF([void *])
159AM_CONDITIONAL([TEST_64BIT], [test "$ac_cv_sizeof_void_p" -eq 8])
Lev Walkinb40ec412014-02-24 00:57:18 -0800160
Lev Walkin058e2222007-12-04 00:27:38 +0000161dnl For mingw
162AC_SEARCH_LIBS(getopt, iberty)
163
Lev Walkinf15320b2004-06-03 03:38:44 +0000164AC_CHECK_FUNCS(strtoimax strtoll)
Lev Walkin49b0a3e2004-06-28 21:22:35 +0000165AC_CHECK_FUNCS(mergesort)
Lev Walkin27fd0b62007-08-27 23:57:45 +0000166AC_CHECK_FUNCS(mkstemps)
Lev Walkin04fbe622014-09-17 02:27:01 -0700167AC_CHECK_FUNCS(timegm)
Frank Morgnercab30af2013-05-21 14:28:35 +0200168AC_CHECK_DECLS(alloca strcasecmp)
Frank Morgner8a759ad2013-05-16 13:32:49 +0200169AC_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 +0000170
Lev Walkinc6080fd2016-01-23 06:35:34 -0800171dnl Use pandoc to generate manual pages.
172AC_PATH_PROG([PANDOC], pandoc)
173AM_CONDITIONAL([HAVE_PANDOC], [test -n "$PANDOC"])
174
Lev Walkin327bab22016-03-14 02:36:27 -0700175AC_CONFIG_FILES([\
Lev Walkin700df492017-08-10 14:59:15 -0700176tests/tests-c-compiler/check-src/Makefile \
177tests/tests-asn1c-compiler/Makefile \
178tests/tests-c-compiler/Makefile \
Lev Walkin56d59b42017-08-24 13:54:58 -0700179tests/tests-skeletons/Makefile \
Lev Walkin700df492017-08-10 14:59:15 -0700180libasn1compiler/Makefile \
Lev Walkind9221842017-08-22 01:44:56 -0700181libasn1common/Makefile \
Lev Walkin700df492017-08-10 14:59:15 -0700182libasn1parser/Makefile \
183libasn1print/Makefile \
184libasn1fix/Makefile \
185doc/docsrc/Makefile \
186skeletons/Makefile \
187examples/Makefile \
188doc/man/Makefile \
189tests/Makefile \
190asn1c/Makefile \
191doc/Makefile \
192Makefile \
Lev Walkin327bab22016-03-14 02:36:27 -0700193])
194AC_OUTPUT
Lev Walkinf15320b2004-06-03 03:38:44 +0000195