blob: 1f4330b4a644f68da5e4729dd4e91ff3e56e1778 [file] [log] [blame]
Harald Welteb53e2bf2020-08-21 16:33:42 +02001dnl Process this file with autoconf to produce a configure script
2AC_INIT([osmo-smlc],
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
12dnl kernel style compile messages
13m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
14
15dnl include release helper
16RELMAKE='-include osmo-release.mk'
17AC_SUBST([RELMAKE])
18
19dnl checks for programs
20AC_PROG_MAKE_SET
21AC_PROG_CC
22AC_PROG_INSTALL
23LT_INIT
24
25dnl patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang
26AS_CASE(["$LD"],[*clang*],
27 [AS_CASE(["${host_os}"],
28 [*linux*],[archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'])])
29
30dnl check for pkg-config (explained in detail in libosmocore/configure.ac)
31AC_PATH_PROG(PKG_CONFIG_INSTALLED, pkg-config, no)
32if test "x$PKG_CONFIG_INSTALLED" = "xno"; then
33 AC_MSG_WARN([You need to install pkg-config])
34fi
35PKG_PROG_PKG_CONFIG([0.20])
36
Pau Espin Pedrol848316e2023-02-07 17:42:01 +010037PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.8.0)
38PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.8.0)
39PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl >= 1.8.0)
40PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.8.0)
41PKG_CHECK_MODULES(LIBOSMOSIGTRAN, libosmo-sigtran >= 1.7.0)
42PKG_CHECK_MODULES(LIBOSMOSCCP, libosmo-sccp >= 1.7.0)
Harald Welteb53e2bf2020-08-21 16:33:42 +020043
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
Harald Welteb53e2bf2020-08-21 16:33:42 +020090# Coverage build taken from WebKit's configure.in
91AC_MSG_CHECKING([whether to enable code coverage support])
92AC_ARG_ENABLE(coverage,
93 AC_HELP_STRING([--enable-coverage],
94 [enable code coverage support [default=no]]),
95 [],[enable_coverage="no"])
96AC_MSG_RESULT([$enable_coverage])
97if test "$enable_coverage" = "yes"; then
98 COVERAGE_CFLAGS="-ftest-coverage -fprofile-arcs"
99 COVERAGE_LDFLAGS="-ftest-coverage -fprofile-arcs"
100 AC_SUBST([COVERAGE_CFLAGS])
101 AC_SUBST([COVERAGE_LDFLAGS])
102fi
103
104AC_ARG_ENABLE(profile,
105 [AS_HELP_STRING([--enable-profile], [Compile with profiling support enabled], )],
106 [profile=$enableval], [profile="no"])
107if test x"$profile" = x"yes"
108then
109 CFLAGS="$CFLAGS -pg"
110 CPPFLAGS="$CPPFLAGS -pg"
111fi
112
113AC_ARG_ENABLE([external_tests],
114 AC_HELP_STRING([--enable-external-tests],
115 [Include the VTY/CTRL tests in make check [default=no]]),
116 [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
117if test "x$enable_ext_tests" = "xyes" ; then
118 AC_CHECK_PROG(PYTHON2_AVAIL,python2,yes)
119 if test "x$PYTHON2_AVAIL" != "xyes" ; then
120 AC_MSG_ERROR([Please install python2 to run the VTY/CTRL tests.])
121 fi
122 AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes)
123 if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
Harald Weltebc54ff02022-06-18 13:44:15 +0200124 AC_MSG_ERROR([Please install https://gitea.osmocom.org/cellular-infrastructure/osmo-python-tests to run the VTY/CTRL tests.])
Harald Welteb53e2bf2020-08-21 16:33:42 +0200125 fi
126fi
127AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
128AC_MSG_RESULT([$enable_ext_tests])
129AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
130
131# Generate manuals
132AC_ARG_ENABLE(manuals,
133 [AS_HELP_STRING(
134 [--enable-manuals],
135 [Generate manual PDFs [default=no]],
136 )],
137 [osmo_ac_build_manuals=$enableval], [osmo_ac_build_manuals="no"])
138AM_CONDITIONAL([BUILD_MANUALS], [test x"$osmo_ac_build_manuals" = x"yes"])
139AC_ARG_VAR(OSMO_GSM_MANUALS_DIR, [path to common osmo-gsm-manuals files, overriding pkg-config and "../osmo-gsm-manuals"
140 fallback])
141if test x"$osmo_ac_build_manuals" = x"yes"
142then
143 # Find OSMO_GSM_MANUALS_DIR (env, pkg-conf, fallback)
144 if test -n "$OSMO_GSM_MANUALS_DIR"; then
145 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from env)"
146 else
147 OSMO_GSM_MANUALS_DIR="$($PKG_CONFIG osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null)"
148 if test -n "$OSMO_GSM_MANUALS_DIR"; then
149 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from pkg-conf)"
150 else
151 OSMO_GSM_MANUALS_DIR="../osmo-gsm-manuals"
152 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (fallback)"
153 fi
154 fi
155 if ! test -d "$OSMO_GSM_MANUALS_DIR"; then
156 AC_MSG_ERROR("OSMO_GSM_MANUALS_DIR does not exist! Install osmo-gsm-manuals or set OSMO_GSM_MANUALS_DIR.")
157 fi
158
159 # Find and run check-depends
160 CHECK_DEPENDS="$OSMO_GSM_MANUALS_DIR/check-depends.sh"
161 if ! test -x "$CHECK_DEPENDS"; then
162 CHECK_DEPENDS="osmo-gsm-manuals-check-depends"
163 fi
164 if ! $CHECK_DEPENDS; then
165 AC_MSG_ERROR("missing dependencies for --enable-manuals")
166 fi
167
168 # Put in Makefile with absolute path
169 OSMO_GSM_MANUALS_DIR="$(realpath "$OSMO_GSM_MANUALS_DIR")"
170 AC_SUBST([OSMO_GSM_MANUALS_DIR])
171fi
172
173# https://www.freedesktop.org/software/systemd/man/daemon.html
174AC_ARG_WITH([systemdsystemunitdir],
175 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
176 [with_systemdsystemunitdir=auto])
177AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
178 def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
179
180 AS_IF([test "x$def_systemdsystemunitdir" = "x"],
181 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
182 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
183 with_systemdsystemunitdir=no],
184 [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
185AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
186 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
187AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
188
189AC_MSG_RESULT([CFLAGS="$CFLAGS"])
190AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
191
192dnl Generate the output
193AM_CONFIG_HEADER(config.h)
194
195AC_OUTPUT(
196 include/Makefile
197 include/osmocom/Makefile
198 include/osmocom/smlc/Makefile
199 src/Makefile
200 src/osmo-smlc/Makefile
201 tests/Makefile
202 tests/atlocal
Neels Hofmeyr72992152020-09-19 02:36:08 +0200203 tests/smlc_subscr/Makefile
Harald Welteb53e2bf2020-08-21 16:33:42 +0200204 doc/Makefile
205 doc/examples/Makefile
206 doc/manuals/Makefile
207 contrib/Makefile
208 contrib/systemd/Makefile
209 contrib/osmo-smlc.spec
210 Makefile)