blob: e03640485d335d2e98b73c7c351e3fa51544b30b [file] [log] [blame]
Harald Welte54ca6f42018-06-04 21:52:30 +02001dnl Process this file with autoconf to produce a configure script
2AC_INIT([osysmon],
3 m4_esyscmd([./git-version-gen .tarball-version]),
4 [openbsc@lists.osmocom.org])
5
6dnl *This* is the root dir, even if an install-sh exists in ../ or ../../
7AC_CONFIG_AUX_DIR([.])
8
9AM_INIT_AUTOMAKE([dist-bzip2 foreign])
10
11dnl kernel style compile messages
12m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
13
14dnl include release helper
15RELMAKE='-include osmo-release.mk'
16AC_SUBST([RELMAKE])
17
18dnl checks for programs
19AC_PROG_MAKE_SET
20AC_PROG_CC
21AC_PROG_INSTALL
22LT_INIT
23
24dnl check for pkg-config (explained in detail in libosmocore/configure.ac)
25AC_PATH_PROG(PKG_CONFIG_INSTALLED, pkg-config, no)
26if test "x$PKG_CONFIG_INSTALLED" = "xno"; then
27 AC_MSG_WARN([You need to install pkg-config])
28fi
29PKG_PROG_PKG_CONFIG([0.20])
30
31dnl check for AX_CHECK_COMPILE_FLAG
32m4_ifdef([AX_CHECK_COMPILE_FLAG], [], [
33 AC_MSG_ERROR([Please install autoconf-archive; re-run 'autoreconf -fi' for it to take effect.])
34 ])
35
36dnl checks for libraries
37AC_SEARCH_LIBS([dlopen], [dl dld], [LIBRARY_DL="$LIBS";LIBS=""])
38AC_SUBST(LIBRARY_DL)
39
40
41PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.11.0)
42PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.11.0)
43PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl >= 0.11.0)
44PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.11.0)
45PKG_CHECK_MODULES(LIBMNL, libmnl)
46
47dnl checks for header files
48AC_HEADER_STDC
49
50dnl Checks for typedefs, structures and compiler characteristics
51
52AC_ARG_ENABLE(sanitize,
53 [AS_HELP_STRING(
54 [--enable-sanitize],
55 [Compile with address sanitizer enabled],
56 )],
57 [sanitize=$enableval], [sanitize="no"])
58if test x"$sanitize" = x"yes"
59then
60 CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
61 CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
62fi
63
64AC_ARG_ENABLE(werror,
65 [AS_HELP_STRING(
66 [--enable-werror],
67 [Turn all compiler warnings into errors, with exceptions:
68 a) deprecation (allow upstream to mark deprecation without breaking builds);
69 b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds)
70 ]
71 )],
72 [werror=$enableval], [werror="no"])
73if test x"$werror" = x"yes"
74then
75 WERROR_FLAGS="-Werror"
76 WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations"
77 WERROR_FLAGS+=" -Wno-error=cpp" # "#warning"
78 CFLAGS="$CFLAGS $WERROR_FLAGS"
79 CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
80fi
81
82# The following test is taken from WebKit's webkit.m4
83saved_CFLAGS="$CFLAGS"
84CFLAGS="$CFLAGS -fvisibility=hidden "
85AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
86AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
87 [ AC_MSG_RESULT([yes])
88 SYMBOL_VISIBILITY="-fvisibility=hidden"],
89 AC_MSG_RESULT([no]))
90CFLAGS="$saved_CFLAGS"
91AC_SUBST(SYMBOL_VISIBILITY)
92
93AX_CHECK_COMPILE_FLAG([-Werror=implicit], [CFLAGS="$CFLAGS -Werror=implicit"])
94AX_CHECK_COMPILE_FLAG([-Werror=maybe-uninitialized], [CFLAGS="$CFLAGS -Werror=maybe-uninitialized"])
95AX_CHECK_COMPILE_FLAG([-Werror=memset-transposed-args], [CFLAGS="$CFLAGS -Werror=memset-transposed-args"])
96AX_CHECK_COMPILE_FLAG([-Werror=null-dereference], [CFLAGS="$CFLAGS -Werror=null-dereference"])
97AX_CHECK_COMPILE_FLAG([-Werror=sizeof-array-argument], [CFLAGS="$CFLAGS -Werror=sizeof-array-argument"])
98AX_CHECK_COMPILE_FLAG([-Werror=sizeof-pointer-memaccess], [CFLAGS="$CFLAGS -Werror=sizeof-pointer-memaccess"])
99
100# Coverage build taken from WebKit's configure.in
101AC_MSG_CHECKING([whether to enable code coverage support])
102AC_ARG_ENABLE(coverage,
103 AC_HELP_STRING([--enable-coverage],
104 [enable code coverage support [default=no]]),
105 [],[enable_coverage="no"])
106AC_MSG_RESULT([$enable_coverage])
107if test "$enable_coverage" = "yes"; then
108 COVERAGE_CFLAGS="-ftest-coverage -fprofile-arcs"
109 COVERAGE_LDFLAGS="-ftest-coverage -fprofile-arcs"
110 AC_SUBST([COVERAGE_CFLAGS])
111 AC_SUBST([COVERAGE_LDFLAGS])
112fi
113
114AC_ARG_ENABLE(profile,
115 [AS_HELP_STRING([--enable-profile], [Compile with profiling support enabled], )],
116 [profile=$enableval], [profile="no"])
117if test x"$profile" = x"yes"
118then
119 CFLAGS="$CFLAGS -pg"
120 CPPFLAGS="$CPPFLAGS -pg"
121fi
122
123AC_MSG_RESULT([CFLAGS="$CFLAGS"])
124AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
125
126dnl Generate the output
127AM_CONFIG_HEADER(config.h)
128
129AC_OUTPUT(
130 Makefile)