blob: 250649d597553d57ebef41652b2aae4ca8489d99 [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
Harald Weltebad38972019-11-06 06:51:57 +010034PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.2.0)
35PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.2.0)
36PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.2.0)
37PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.6.0)
38
39dnl checks for header files
40AC_HEADER_STDC
41
42dnl Checks for typedefs, structures and compiler characteristics
43
44AC_ARG_ENABLE(sanitize,
45 [AS_HELP_STRING(
46 [--enable-sanitize],
47 [Compile with address sanitizer enabled],
48 )],
49 [sanitize=$enableval], [sanitize="no"])
50if test x"$sanitize" = x"yes"
51then
52 CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
53 CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
54fi
55
56AC_ARG_ENABLE(werror,
57 [AS_HELP_STRING(
58 [--enable-werror],
59 [Turn all compiler warnings into errors, with exceptions:
60 a) deprecation (allow upstream to mark deprecation without breaking builds);
61 b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds)
62 ]
63 )],
64 [werror=$enableval], [werror="no"])
65if test x"$werror" = x"yes"
66then
67 WERROR_FLAGS="-Werror"
68 WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations"
69 WERROR_FLAGS+=" -Wno-error=cpp" # "#warning"
70 CFLAGS="$CFLAGS $WERROR_FLAGS"
71 CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
72fi
73
74# The following test is taken from WebKit's webkit.m4
75saved_CFLAGS="$CFLAGS"
76CFLAGS="$CFLAGS -fvisibility=hidden "
77AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
78AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
79 [ AC_MSG_RESULT([yes])
80 SYMBOL_VISIBILITY="-fvisibility=hidden"],
81 AC_MSG_RESULT([no]))
82CFLAGS="$saved_CFLAGS"
83AC_SUBST(SYMBOL_VISIBILITY)
84
Harald Weltebad38972019-11-06 06:51:57 +010085# Coverage build taken from WebKit's configure.in
86AC_MSG_CHECKING([whether to enable code coverage support])
87AC_ARG_ENABLE(coverage,
88 AC_HELP_STRING([--enable-coverage],
89 [enable code coverage support [default=no]]),
90 [],[enable_coverage="no"])
91AC_MSG_RESULT([$enable_coverage])
92if test "$enable_coverage" = "yes"; then
93 COVERAGE_CFLAGS="-ftest-coverage -fprofile-arcs"
94 COVERAGE_LDFLAGS="-ftest-coverage -fprofile-arcs"
95 AC_SUBST([COVERAGE_CFLAGS])
96 AC_SUBST([COVERAGE_LDFLAGS])
97fi
98
99AC_ARG_ENABLE(profile,
100 [AS_HELP_STRING([--enable-profile], [Compile with profiling support enabled], )],
101 [profile=$enableval], [profile="no"])
102if test x"$profile" = x"yes"
103then
104 CFLAGS="$CFLAGS -pg"
105 CPPFLAGS="$CPPFLAGS -pg"
106fi
107
108AC_ARG_ENABLE([external_tests],
109 AC_HELP_STRING([--enable-external-tests],
110 [Include the VTY/CTRL tests in make check [default=no]]),
111 [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
112if test "x$enable_ext_tests" = "xyes" ; then
Vadim Yanitskiydc4b5d62023-07-15 00:58:06 +0700113 AC_CHECK_PROG(PYTHON3_AVAIL,python3,yes)
114 if test "x$PYTHON3_AVAIL" != "xyes" ; then
115 AC_MSG_ERROR([Please install python3 to run the VTY/CTRL tests.])
Harald Weltebad38972019-11-06 06:51:57 +0100116 fi
117 AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes)
118 if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
Harald Weltebe5f2c72022-06-18 11:56:29 +0200119 AC_MSG_ERROR([Please install https://gitea.osmocom.org/cellular-infrastructure/osmo-python-tests to run the VTY/CTRL tests.])
Harald Weltebad38972019-11-06 06:51:57 +0100120 fi
121fi
122AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
123AC_MSG_RESULT([$enable_ext_tests])
124AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
125
126# Generate manuals
127AC_ARG_ENABLE(manuals,
128 [AS_HELP_STRING(
129 [--enable-manuals],
130 [Generate manual PDFs [default=no]],
131 )],
132 [osmo_ac_build_manuals=$enableval], [osmo_ac_build_manuals="no"])
133AM_CONDITIONAL([BUILD_MANUALS], [test x"$osmo_ac_build_manuals" = x"yes"])
134AC_ARG_VAR(OSMO_GSM_MANUALS_DIR, [path to common osmo-gsm-manuals files, overriding pkg-config and "../osmo-gsm-manuals"
135 fallback])
136if test x"$osmo_ac_build_manuals" = x"yes"
137then
138 # Find OSMO_GSM_MANUALS_DIR (env, pkg-conf, fallback)
139 if test -n "$OSMO_GSM_MANUALS_DIR"; then
140 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from env)"
141 else
142 OSMO_GSM_MANUALS_DIR="$($PKG_CONFIG osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null)"
143 if test -n "$OSMO_GSM_MANUALS_DIR"; then
144 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from pkg-conf)"
145 else
146 OSMO_GSM_MANUALS_DIR="../osmo-gsm-manuals"
147 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (fallback)"
148 fi
149 fi
150 if ! test -d "$OSMO_GSM_MANUALS_DIR"; then
151 AC_MSG_ERROR("OSMO_GSM_MANUALS_DIR does not exist! Install osmo-gsm-manuals or set OSMO_GSM_MANUALS_DIR.")
152 fi
153
154 # Find and run check-depends
155 CHECK_DEPENDS="$OSMO_GSM_MANUALS_DIR/check-depends.sh"
156 if ! test -x "$CHECK_DEPENDS"; then
157 CHECK_DEPENDS="osmo-gsm-manuals-check-depends"
158 fi
159 if ! $CHECK_DEPENDS; then
160 AC_MSG_ERROR("missing dependencies for --enable-manuals")
161 fi
162
163 # Put in Makefile with absolute path
164 OSMO_GSM_MANUALS_DIR="$(realpath "$OSMO_GSM_MANUALS_DIR")"
165 AC_SUBST([OSMO_GSM_MANUALS_DIR])
166fi
167
168# https://www.freedesktop.org/software/systemd/man/daemon.html
169AC_ARG_WITH([systemdsystemunitdir],
170 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
171 [with_systemdsystemunitdir=auto])
172AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
173 def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
174
175 AS_IF([test "x$def_systemdsystemunitdir" = "x"],
176 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
177 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
178 with_systemdsystemunitdir=no],
179 [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
180AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
181 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
182AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
183
184AC_MSG_RESULT([CFLAGS="$CFLAGS"])
185AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
186
187dnl Generate the output
188AM_CONFIG_HEADER(config.h)
189
190AC_OUTPUT(
191 src/Makefile
192 doc/Makefile
193 tests/Makefile
194 doc/examples/Makefile
Harald Weltebad38972019-11-06 06:51:57 +0100195 Makefile)