blob: e98680946502e83b7c0894cc93273f5867c04f43 [file] [log] [blame]
Harald Weltebad38972019-11-06 06:51:57 +01001dnl Process this file with autoconf to produce a configure script
2AC_INIT([osmo-e1-recorder],
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])
10AC_CONFIG_TESTDIR(tests)
11
Oliver Smith91a98c02021-01-27 17:47:10 +010012CFLAGS="$CFLAGS -std=gnu11"
13
Harald Weltebad38972019-11-06 06:51:57 +010014dnl kernel style compile messages
15m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
16
17dnl include release helper
18RELMAKE='-include osmo-release.mk'
19AC_SUBST([RELMAKE])
20
21dnl checks for programs
22AC_PROG_MAKE_SET
23AC_PROG_CC
24AC_PROG_INSTALL
25LT_INIT
26
27dnl check for pkg-config (explained in detail in libosmocore/configure.ac)
28AC_PATH_PROG(PKG_CONFIG_INSTALLED, pkg-config, no)
29if test "x$PKG_CONFIG_INSTALLED" = "xno"; then
30 AC_MSG_WARN([You need to install pkg-config])
31fi
32PKG_PROG_PKG_CONFIG([0.20])
33
34dnl check for AX_CHECK_COMPILE_FLAG
35m4_ifdef([AX_CHECK_COMPILE_FLAG], [], [
36 AC_MSG_ERROR([Please install autoconf-archive; re-run 'autoreconf -fi' for it to take effect.])
37 ])
38
39PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.2.0)
40PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.2.0)
41PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.2.0)
42PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.6.0)
43
44dnl checks for header files
45AC_HEADER_STDC
46
47dnl Checks for typedefs, structures and compiler characteristics
48
49AC_ARG_ENABLE(sanitize,
50 [AS_HELP_STRING(
51 [--enable-sanitize],
52 [Compile with address sanitizer enabled],
53 )],
54 [sanitize=$enableval], [sanitize="no"])
55if test x"$sanitize" = x"yes"
56then
57 CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
58 CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
59fi
60
61AC_ARG_ENABLE(werror,
62 [AS_HELP_STRING(
63 [--enable-werror],
64 [Turn all compiler warnings into errors, with exceptions:
65 a) deprecation (allow upstream to mark deprecation without breaking builds);
66 b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds)
67 ]
68 )],
69 [werror=$enableval], [werror="no"])
70if test x"$werror" = x"yes"
71then
72 WERROR_FLAGS="-Werror"
73 WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations"
74 WERROR_FLAGS+=" -Wno-error=cpp" # "#warning"
75 CFLAGS="$CFLAGS $WERROR_FLAGS"
76 CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
77fi
78
79# The following test is taken from WebKit's webkit.m4
80saved_CFLAGS="$CFLAGS"
81CFLAGS="$CFLAGS -fvisibility=hidden "
82AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
83AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
84 [ AC_MSG_RESULT([yes])
85 SYMBOL_VISIBILITY="-fvisibility=hidden"],
86 AC_MSG_RESULT([no]))
87CFLAGS="$saved_CFLAGS"
88AC_SUBST(SYMBOL_VISIBILITY)
89
90AX_CHECK_COMPILE_FLAG([-Werror=implicit], [CFLAGS="$CFLAGS -Werror=implicit"])
91AX_CHECK_COMPILE_FLAG([-Werror=maybe-uninitialized], [CFLAGS="$CFLAGS -Werror=maybe-uninitialized"])
92AX_CHECK_COMPILE_FLAG([-Werror=memset-transposed-args], [CFLAGS="$CFLAGS -Werror=memset-transposed-args"])
93AX_CHECK_COMPILE_FLAG([-Wnull-dereference], [CFLAGS="$CFLAGS -Wnull-dereference"])
94AX_CHECK_COMPILE_FLAG([-Werror=sizeof-array-argument], [CFLAGS="$CFLAGS -Werror=sizeof-array-argument"])
95AX_CHECK_COMPILE_FLAG([-Werror=sizeof-pointer-memaccess], [CFLAGS="$CFLAGS -Werror=sizeof-pointer-memaccess"])
96
97# Coverage build taken from WebKit's configure.in
98AC_MSG_CHECKING([whether to enable code coverage support])
99AC_ARG_ENABLE(coverage,
100 AC_HELP_STRING([--enable-coverage],
101 [enable code coverage support [default=no]]),
102 [],[enable_coverage="no"])
103AC_MSG_RESULT([$enable_coverage])
104if test "$enable_coverage" = "yes"; then
105 COVERAGE_CFLAGS="-ftest-coverage -fprofile-arcs"
106 COVERAGE_LDFLAGS="-ftest-coverage -fprofile-arcs"
107 AC_SUBST([COVERAGE_CFLAGS])
108 AC_SUBST([COVERAGE_LDFLAGS])
109fi
110
111AC_ARG_ENABLE(profile,
112 [AS_HELP_STRING([--enable-profile], [Compile with profiling support enabled], )],
113 [profile=$enableval], [profile="no"])
114if test x"$profile" = x"yes"
115then
116 CFLAGS="$CFLAGS -pg"
117 CPPFLAGS="$CPPFLAGS -pg"
118fi
119
120AC_ARG_ENABLE([external_tests],
121 AC_HELP_STRING([--enable-external-tests],
122 [Include the VTY/CTRL tests in make check [default=no]]),
123 [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
124if test "x$enable_ext_tests" = "xyes" ; then
125 AC_CHECK_PROG(PYTHON2_AVAIL,python2,yes)
126 if test "x$PYTHON2_AVAIL" != "xyes" ; then
127 AC_MSG_ERROR([Please install python2 to run the VTY/CTRL tests.])
128 fi
129 AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes)
130 if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
131 AC_MSG_ERROR([Please install git://osmocom.org/python/osmo-python-tests to run the VTY/CTRL tests.])
132 fi
133fi
134AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
135AC_MSG_RESULT([$enable_ext_tests])
136AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
137
138# Generate manuals
139AC_ARG_ENABLE(manuals,
140 [AS_HELP_STRING(
141 [--enable-manuals],
142 [Generate manual PDFs [default=no]],
143 )],
144 [osmo_ac_build_manuals=$enableval], [osmo_ac_build_manuals="no"])
145AM_CONDITIONAL([BUILD_MANUALS], [test x"$osmo_ac_build_manuals" = x"yes"])
146AC_ARG_VAR(OSMO_GSM_MANUALS_DIR, [path to common osmo-gsm-manuals files, overriding pkg-config and "../osmo-gsm-manuals"
147 fallback])
148if test x"$osmo_ac_build_manuals" = x"yes"
149then
150 # Find OSMO_GSM_MANUALS_DIR (env, pkg-conf, fallback)
151 if test -n "$OSMO_GSM_MANUALS_DIR"; then
152 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from env)"
153 else
154 OSMO_GSM_MANUALS_DIR="$($PKG_CONFIG osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null)"
155 if test -n "$OSMO_GSM_MANUALS_DIR"; then
156 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from pkg-conf)"
157 else
158 OSMO_GSM_MANUALS_DIR="../osmo-gsm-manuals"
159 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (fallback)"
160 fi
161 fi
162 if ! test -d "$OSMO_GSM_MANUALS_DIR"; then
163 AC_MSG_ERROR("OSMO_GSM_MANUALS_DIR does not exist! Install osmo-gsm-manuals or set OSMO_GSM_MANUALS_DIR.")
164 fi
165
166 # Find and run check-depends
167 CHECK_DEPENDS="$OSMO_GSM_MANUALS_DIR/check-depends.sh"
168 if ! test -x "$CHECK_DEPENDS"; then
169 CHECK_DEPENDS="osmo-gsm-manuals-check-depends"
170 fi
171 if ! $CHECK_DEPENDS; then
172 AC_MSG_ERROR("missing dependencies for --enable-manuals")
173 fi
174
175 # Put in Makefile with absolute path
176 OSMO_GSM_MANUALS_DIR="$(realpath "$OSMO_GSM_MANUALS_DIR")"
177 AC_SUBST([OSMO_GSM_MANUALS_DIR])
178fi
179
180# https://www.freedesktop.org/software/systemd/man/daemon.html
181AC_ARG_WITH([systemdsystemunitdir],
182 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
183 [with_systemdsystemunitdir=auto])
184AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
185 def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
186
187 AS_IF([test "x$def_systemdsystemunitdir" = "x"],
188 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
189 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
190 with_systemdsystemunitdir=no],
191 [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
192AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
193 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
194AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
195
196AC_MSG_RESULT([CFLAGS="$CFLAGS"])
197AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
198
199dnl Generate the output
200AM_CONFIG_HEADER(config.h)
201
202AC_OUTPUT(
203 src/Makefile
204 doc/Makefile
205 tests/Makefile
206 doc/examples/Makefile
207 Makefile)