blob: 8d49565d1afb167fb19a5c25c35e8436ca4e4080 [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
Vadim Yanitskiycf29f442022-09-29 13:09:47 +070012CFLAGS="$CFLAGS -std=gnu11"
13
Harald Welteb53e2bf2020-08-21 16:33:42 +020014dnl 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 patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang
28AS_CASE(["$LD"],[*clang*],
29 [AS_CASE(["${host_os}"],
30 [*linux*],[archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'])])
31
32dnl check for pkg-config (explained in detail in libosmocore/configure.ac)
33AC_PATH_PROG(PKG_CONFIG_INSTALLED, pkg-config, no)
34if test "x$PKG_CONFIG_INSTALLED" = "xno"; then
35 AC_MSG_WARN([You need to install pkg-config])
36fi
37PKG_PROG_PKG_CONFIG([0.20])
38
Pau Espin Pedrole7535a42023-09-12 17:14:42 +020039PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.9.0)
40PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.9.0)
41PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl >= 1.9.0)
42PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.9.0)
43PKG_CHECK_MODULES(LIBOSMOSIGTRAN, libosmo-sigtran >= 1.8.0)
44PKG_CHECK_MODULES(LIBOSMOSCCP, libosmo-sccp >= 1.8.0)
Harald Welteb53e2bf2020-08-21 16:33:42 +020045
46dnl checks for header files
47AC_HEADER_STDC
48
49dnl Checks for typedefs, structures and compiler characteristics
50
51AC_ARG_ENABLE(sanitize,
52 [AS_HELP_STRING(
53 [--enable-sanitize],
54 [Compile with address sanitizer enabled],
55 )],
56 [sanitize=$enableval], [sanitize="no"])
57if test x"$sanitize" = x"yes"
58then
59 CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
60 CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
61fi
62
63AC_ARG_ENABLE(werror,
64 [AS_HELP_STRING(
65 [--enable-werror],
66 [Turn all compiler warnings into errors, with exceptions:
67 a) deprecation (allow upstream to mark deprecation without breaking builds);
68 b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds)
69 ]
70 )],
71 [werror=$enableval], [werror="no"])
72if test x"$werror" = x"yes"
73then
74 WERROR_FLAGS="-Werror"
75 WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations"
76 WERROR_FLAGS+=" -Wno-error=cpp" # "#warning"
77 CFLAGS="$CFLAGS $WERROR_FLAGS"
78 CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
79fi
80
81# The following test is taken from WebKit's webkit.m4
82saved_CFLAGS="$CFLAGS"
83CFLAGS="$CFLAGS -fvisibility=hidden "
84AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
85AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
86 [ AC_MSG_RESULT([yes])
87 SYMBOL_VISIBILITY="-fvisibility=hidden"],
88 AC_MSG_RESULT([no]))
89CFLAGS="$saved_CFLAGS"
90AC_SUBST(SYMBOL_VISIBILITY)
91
Harald Welteb53e2bf2020-08-21 16:33:42 +020092# Coverage build taken from WebKit's configure.in
93AC_MSG_CHECKING([whether to enable code coverage support])
94AC_ARG_ENABLE(coverage,
95 AC_HELP_STRING([--enable-coverage],
96 [enable code coverage support [default=no]]),
97 [],[enable_coverage="no"])
98AC_MSG_RESULT([$enable_coverage])
99if test "$enable_coverage" = "yes"; then
100 COVERAGE_CFLAGS="-ftest-coverage -fprofile-arcs"
101 COVERAGE_LDFLAGS="-ftest-coverage -fprofile-arcs"
102 AC_SUBST([COVERAGE_CFLAGS])
103 AC_SUBST([COVERAGE_LDFLAGS])
104fi
105
106AC_ARG_ENABLE(profile,
107 [AS_HELP_STRING([--enable-profile], [Compile with profiling support enabled], )],
108 [profile=$enableval], [profile="no"])
109if test x"$profile" = x"yes"
110then
111 CFLAGS="$CFLAGS -pg"
112 CPPFLAGS="$CPPFLAGS -pg"
113fi
114
115AC_ARG_ENABLE([external_tests],
116 AC_HELP_STRING([--enable-external-tests],
117 [Include the VTY/CTRL tests in make check [default=no]]),
118 [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
119if test "x$enable_ext_tests" = "xyes" ; then
Vadim Yanitskiy73854272023-07-15 00:46:54 +0700120 AC_CHECK_PROG(PYTHON3_AVAIL,python3,yes)
121 if test "x$PYTHON3_AVAIL" != "xyes" ; then
122 AC_MSG_ERROR([Please install python3 to run the VTY/CTRL tests.])
Harald Welteb53e2bf2020-08-21 16:33:42 +0200123 fi
124 AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes)
125 if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
Harald Weltebc54ff02022-06-18 13:44:15 +0200126 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 +0200127 fi
128fi
129AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
130AC_MSG_RESULT([$enable_ext_tests])
131AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
132
133# Generate manuals
134AC_ARG_ENABLE(manuals,
135 [AS_HELP_STRING(
136 [--enable-manuals],
137 [Generate manual PDFs [default=no]],
138 )],
139 [osmo_ac_build_manuals=$enableval], [osmo_ac_build_manuals="no"])
140AM_CONDITIONAL([BUILD_MANUALS], [test x"$osmo_ac_build_manuals" = x"yes"])
141AC_ARG_VAR(OSMO_GSM_MANUALS_DIR, [path to common osmo-gsm-manuals files, overriding pkg-config and "../osmo-gsm-manuals"
142 fallback])
143if test x"$osmo_ac_build_manuals" = x"yes"
144then
145 # Find OSMO_GSM_MANUALS_DIR (env, pkg-conf, fallback)
146 if test -n "$OSMO_GSM_MANUALS_DIR"; then
147 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from env)"
148 else
149 OSMO_GSM_MANUALS_DIR="$($PKG_CONFIG osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null)"
150 if test -n "$OSMO_GSM_MANUALS_DIR"; then
151 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from pkg-conf)"
152 else
153 OSMO_GSM_MANUALS_DIR="../osmo-gsm-manuals"
154 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (fallback)"
155 fi
156 fi
157 if ! test -d "$OSMO_GSM_MANUALS_DIR"; then
158 AC_MSG_ERROR("OSMO_GSM_MANUALS_DIR does not exist! Install osmo-gsm-manuals or set OSMO_GSM_MANUALS_DIR.")
159 fi
160
161 # Find and run check-depends
162 CHECK_DEPENDS="$OSMO_GSM_MANUALS_DIR/check-depends.sh"
163 if ! test -x "$CHECK_DEPENDS"; then
164 CHECK_DEPENDS="osmo-gsm-manuals-check-depends"
165 fi
166 if ! $CHECK_DEPENDS; then
167 AC_MSG_ERROR("missing dependencies for --enable-manuals")
168 fi
169
170 # Put in Makefile with absolute path
171 OSMO_GSM_MANUALS_DIR="$(realpath "$OSMO_GSM_MANUALS_DIR")"
172 AC_SUBST([OSMO_GSM_MANUALS_DIR])
173fi
174
175# https://www.freedesktop.org/software/systemd/man/daemon.html
176AC_ARG_WITH([systemdsystemunitdir],
177 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
178 [with_systemdsystemunitdir=auto])
179AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
180 def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
181
182 AS_IF([test "x$def_systemdsystemunitdir" = "x"],
183 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
184 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
185 with_systemdsystemunitdir=no],
186 [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
187AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
188 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
189AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
190
191AC_MSG_RESULT([CFLAGS="$CFLAGS"])
192AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
193
194dnl Generate the output
195AM_CONFIG_HEADER(config.h)
196
197AC_OUTPUT(
198 include/Makefile
199 include/osmocom/Makefile
200 include/osmocom/smlc/Makefile
201 src/Makefile
202 src/osmo-smlc/Makefile
203 tests/Makefile
204 tests/atlocal
Neels Hofmeyr72992152020-09-19 02:36:08 +0200205 tests/smlc_subscr/Makefile
Harald Welteb53e2bf2020-08-21 16:33:42 +0200206 doc/Makefile
207 doc/examples/Makefile
208 doc/manuals/Makefile
209 contrib/Makefile
210 contrib/systemd/Makefile
211 contrib/osmo-smlc.spec
212 Makefile)