]> git.ipfire.org Git - location/libloc.git/blame - configure.ac
configure: Scan for multiple Lua versions
[location/libloc.git] / configure.ac
CommitLineData
46aded9a
MT
1AC_PREREQ(2.60)
2AC_INIT([libloc],
3d22ff68 3 [0.9.17],
3b4f1368 4 [location@lists.ipfire.org],
46aded9a 5 [libloc],
3b4f1368 6 [https://location.ipfire.org/])
46aded9a
MT
7
8AC_CONFIG_SRCDIR([src/libloc.c])
9AC_CONFIG_AUX_DIR([build-aux])
10AM_INIT_AUTOMAKE([
11 foreign
12 1.11
13 -Wall
14 -Wno-portability
15 silent-rules
16 tar-pax
17 no-dist-gzip
18 dist-xz
19 subdir-objects
20])
45197e29 21AC_PROG_CC
46aded9a
MT
22AC_USE_SYSTEM_EXTENSIONS
23AC_SYS_LARGEFILE
24AC_CONFIG_MACRO_DIR([m4])
25AM_SILENT_RULES([yes])
26LT_INIT([
27 disable-static
28 pic-only
29])
30AC_PREFIX_DEFAULT([/usr])
a76b0b96 31gl_LD_VERSION_SCRIPT
46aded9a 32
2bb7d64e 33IT_PROG_INTLTOOL([0.40.0])
7b76dffa
MT
34
35# Interpret embedded Python in HTML files
36XGETTEXT="${XGETTEXT} -L Python --keyword=_:1,2 --keyword=N_:1,2 --no-location"
37
2bb7d64e
MT
38GETTEXT_PACKAGE=${PACKAGE_TARNAME}
39AC_SUBST(GETTEXT_PACKAGE)
40
46aded9a
MT
41AC_PROG_SED
42AC_PROG_MKDIR_P
43
161ac92d
MT
44# - man ------------------------------------------------------------------------
45
5b4bd18a
MT
46have_man_pages=no
47AC_ARG_ENABLE(man_pages, AS_HELP_STRING([--disable-man-pages],
161ac92d 48 [do not install man pages]))
5b4bd18a
MT
49AS_IF([test "x$enable_man_pages" != xno], [have_man_pages=yes])
50AM_CONDITIONAL(ENABLE_MAN_PAGES, [test "x$have_man_pages" = "xyes"])
161ac92d
MT
51
52AC_PATH_PROG([XSLTPROC], [xsltproc])
53
54AC_CHECK_PROGS(ASCIIDOC, [asciidoc])
5b4bd18a 55if test "${have_man_pages}" = "yes" && test -z "${ASCIIDOC}"; then
161ac92d
MT
56 AC_MSG_ERROR([Required program 'asciidoc' not found])
57fi
2e52c3bc
SS
58
59# - pkg-config -----------------------------------------------------------------
60
61m4_ifndef([PKG_PROG_PKG_CONFIG],
62 [m4_fatal([Could not locate the pkg-config autoconf
63 macros. These are usually located in /usr/share/aclocal/pkg.m4.
64 If your macros are in a different location, try setting the
65 environment variable AL_OPTS="-I/other/macro/dir" before running
66 ./autogen.sh or autoreconf again. Make sure pkg-config is installed.])])
67
68PKG_PROG_PKG_CONFIG
69PKG_INSTALLDIR(['${usrlib_execdir}/pkgconfig'])
70
71# - bash-completion ------------------------------------------------------------
72
73#enable_bash_completion=yes
74AC_ARG_WITH([bashcompletiondir],
75 AS_HELP_STRING([--with-bashcompletiondir=DIR], [Bash completions directory]),
76 [],
77 [AS_IF([`$PKG_CONFIG --exists bash-completion`], [
78 with_bashcompletiondir=`$PKG_CONFIG --variable=completionsdir bash-completion`
79 ], [
80 with_bashcompletiondir=${datadir}/bash-completion/completions
81 ])
82])
83
84AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
85
86AC_ARG_ENABLE([bash-completion],
87 AS_HELP_STRING([--disable-bash-completion], [do not install bash completion files]),
88 [], [enable_bash_completion=yes]
89)
90
91AM_CONDITIONAL([BUILD_BASH_COMPLETION], [test "x$enable_bash_completion" = xyes])
92
161ac92d
MT
93# - debug ----------------------------------------------------------------------
94
46aded9a
MT
95AC_ARG_ENABLE([debug],
96 AS_HELP_STRING([--enable-debug], [enable debug messages @<:@default=disabled@:>@]),
97 [], [enable_debug=no])
98AS_IF([test "x$enable_debug" = "xyes"], [
99 AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.])
100])
101
dda7cfb5
MT
102AC_CHECK_HEADERS_ONCE([
103 arpa/inet.h \
f7b7019a
MT
104 arpa/nameser.h \
105 arpa/nameser_compat.h \
dda7cfb5
MT
106 endian.h \
107 netinet/in.h \
f4fef543 108 resolv.h \
dda7cfb5
MT
109 string.h \
110])
111
46aded9a 112AC_CHECK_FUNCS([ \
f4fef543
MT
113 be16toh \
114 be32toh \
115 be64toh \
116 htobe16 \
117 htobe32 \
118 htobe64 \
9294469c 119 madvise \
f4fef543
MT
120 mmap \
121 munmap \
122 res_query \
46aded9a 123 __secure_getenv \
a5db3e49 124 secure_getenv \
f4fef543 125 qsort \
46aded9a
MT
126])
127
128my_CFLAGS="\
129-Wall \
130-Wchar-subscripts \
131-Wformat-security \
132-Wmissing-declarations \
133-Wmissing-prototypes \
134-Wnested-externs \
135-Wpointer-arith \
136-Wshadow \
137-Wsign-compare \
138-Wstrict-prototypes \
139-Wtype-limits \
140"
141AC_SUBST([my_CFLAGS])
1c75dcbb 142AC_SUBST([my_LDFLAGS])
46aded9a 143
40ae2a9c
MT
144# Enable -fanalyzer if requested
145AC_ARG_ENABLE([analyzer],
146 AS_HELP_STRING([--enable-analyzer], [enable static analyzer (-fanalyzer) @<:@default=disabled@:>@]),
147 [], [enable_analyzer=no])
148AS_IF([test "x$enable_analyzer" = "xyes"],
149 CC_CHECK_FLAGS_APPEND([my_CFLAGS], [CFLAGS], [-fanalyzer])
150)
151
1c75dcbb
MT
152# Enable -fno-semantic-interposition (if available)
153CC_CHECK_FLAGS_APPEND([my_CFLAGS], [CFLAGS], [-fno-semantic-interposition])
154CC_CHECK_FLAGS_APPEND([my_LDFLAGS], [LDFLAGS], [-fno-semantic-interposition])
155
be748fa8
MT
156# ------------------------------------------------------------------------------
157
a0e8d454
MT
158AC_ARG_WITH([database-path],
159 AS_HELP_STRING([--with-database-path], [The default database path]),
14e821d4 160 [], [with_database_path=/var/lib/location/database.db]
a0e8d454
MT
161)
162
163if test -z "${with_database_path}"; then
164 AC_MSG_ERROR([The default database path is empty])
165fi
166
167AC_DEFINE_UNQUOTED([LIBLOC_DEFAULT_DATABASE_PATH], ["${with_database_path}"],
168 [The default path for the database])
169AC_SUBST([DEFAULT_DATABASE_PATH], [${with_database_path}])
170
be748fa8
MT
171AC_ARG_WITH([systemd],
172 AS_HELP_STRING([--with-systemd], [Enable systemd support.])
173)
174
175AS_IF([test "x$with_systemd" != "xno"],
176 [PKG_CHECK_MODULES(systemd, [libsystemd],
177 [have_systemd=yes], [have_systemd=no])],
178 [have_systemd=no]
179)
180
181AS_IF([test "x$have_systemd" = "xyes"],
182 [AC_MSG_CHECKING([for systemd system unit directory])
183 AC_ARG_WITH([systemdsystemunitdir],
184 AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
185 [], [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)]
186 )
187
188 AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
189
190 if test -n "$systemdsystemunitdir" -a "x$systemdsystemunitdir" != xno; then
191 AC_MSG_RESULT([$systemdsystemunitdir])
192 else
193 AC_MSG_ERROR([not found (try --with-systemdsystemunitdir)])
194 fi
195 ],
196 [AS_IF([test "x$with_systemd" = "xyes"],
197 [AC_MSG_ERROR([Systemd support is enabled but no systemd has been found.])
198 ])
199])
200
201AM_CONDITIONAL(HAVE_SYSTEMD, [test "x$have_systemd" = "xyes"])
202
203# ------------------------------------------------------------------------------
204
8f440c38
MT
205AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
206
18e2b14c 207# Python
1cd4ddbc 208AM_PATH_PYTHON([3.4])
18e2b14c
MT
209PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}])
210
8f440c38 211# Lua
8f440c38
MT
212AC_ARG_ENABLE(lua,
213 AS_HELP_STRING([--disable-lua], [do not build the Lua modules]), [], [enable_lua=yes])
214
215AM_CONDITIONAL(ENABLE_LUA, test "$enable_lua" = "yes")
216
217AS_IF(
218 [test "$enable_lua" = "yes"], [
7681b3ba
MT
219 for lua in lua lua5.4 lua5.3 lua5.2 lua5.1; do
220 PKG_CHECK_MODULES([LUA], [${lua}],[break], [true])
221 done
bc0395a4 222
e8434601
MT
223 AX_PROG_LUA_MODULES([luaunit],, [AC_MSG_ERROR([Lua modules are missing])])
224
7681b3ba 225 LUA_INSTALL_LMOD=$($PKG_CONFIG --define-variable=prefix=${prefix} --variable=INSTALL_LMOD ${lua})
8f440c38 226 AC_SUBST(LUA_INSTALL_LMOD)
7681b3ba 227 LUA_INSTALL_CMOD=$($PKG_CONFIG --define-variable=prefix=${prefix} --variable=INSTALL_CMOD ${lua})
8f440c38
MT
228 AC_SUBST(LUA_INSTALL_CMOD)
229 ],
230)
231
747cbcb1
MT
232# Perl
233AC_PATH_PROG(PERL, perl, no)
234AC_SUBST(PERL)
235
b26c2109 236AX_PROG_PERL_MODULES(Config ExtUtils::MakeMaker,, AC_MSG_WARN(Need some Perl modules))
747cbcb1
MT
237
238AC_ARG_ENABLE(perl, AS_HELP_STRING([--disable-perl], [do not build the perl modules]), [],[enable_perl=yes])
239AM_CONDITIONAL(ENABLE_PERL, test "$enable_perl" = "yes")
b26c2109
PP
240AS_IF([test "$enable_perl" = "yes"],
241 [
242 PERL_MODPATH=$($PERL -MConfig -e 'print $Config{installvendorarch}')
243 PERL_MANPATH=$($PERL -MConfig -e 'print $Config{installvendorman3dir}')
244 AC_SUBST(PERL_MODPATH)
245 AC_SUBST(PERL_MANPATH)
246 ],
247)
747cbcb1 248
f4fef543 249dnl Checking for libresolv
f60ee33f
MT
250case "${host}" in
251 *-gnu*)
252 AC_CHECK_LIB(resolv, ns_msg_getflag, [LIBS="-lresolv $LIBS"], AC_MSG_ERROR([libresolv has not been found]), -lresolv)
253 ;;
254 *)
255 AC_CHECK_LIB(resolv, res_init, [LIBS="-lresolv $LIBS"], AC_MSG_ERROR([libresolv has not been found]), -lresolv)
256 ;;
257esac
f4fef543 258RESOLV_LIBS="${LIBS}"
18ecd261 259AC_SUBST(RESOLV_LIBS)
f4fef543 260
e568f8d4 261dnl Checking for OpenSSL
9bfb8ed2 262PKG_CHECK_MODULES([OPENSSL], [openssl])
e568f8d4 263
46aded9a
MT
264AC_CONFIG_HEADERS(config.h)
265AC_CONFIG_FILES([
266 Makefile
2bb7d64e 267 po/Makefile.in
46aded9a
MT
268])
269
270AC_OUTPUT
271AC_MSG_RESULT([
272 $PACKAGE $VERSION
273 =====
274
275 prefix: ${prefix}
276 sysconfdir: ${sysconfdir}
277 libdir: ${libdir}
278 includedir: ${includedir}
279
280 compiler: ${CC}
281 cflags: ${CFLAGS}
282 ldflags: ${LDFLAGS}
283
a0e8d454 284 database path: ${with_database_path}
46aded9a 285 debug: ${enable_debug}
be748fa8 286 systemd support: ${have_systemd}
2e52c3bc 287 bash-completion: ${enable_bash_completion}
747cbcb1
MT
288
289 Bindings:
8f440c38
MT
290 Lua: ${enable_lua}
291 Lua shared path: ${LUA_INSTALL_LMOD}
292 Lua module path: ${LUA_INSTALL_CMOD}
b26c2109
PP
293 Perl: ${enable_perl}
294 Perl module path: ${PERL_MODPATH}
295 Perl manual path: ${PERL_MANPATH}
46aded9a 296])