]> git.ipfire.org Git - people/ms/libloc.git/blob - configure.ac
importer: Drop EDROP as it has been merged into DROP
[people/ms/libloc.git] / configure.ac
1 AC_PREREQ(2.60)
2 AC_INIT([libloc],
3 [0.9.17],
4 [location@lists.ipfire.org],
5 [libloc],
6 [https://location.ipfire.org/])
7
8 AC_CONFIG_SRCDIR([src/libloc.c])
9 AC_CONFIG_AUX_DIR([build-aux])
10 AM_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 ])
21 AC_PROG_CC
22 AC_USE_SYSTEM_EXTENSIONS
23 AC_SYS_LARGEFILE
24 AC_CONFIG_MACRO_DIR([m4])
25 AM_SILENT_RULES([yes])
26 LT_INIT([
27 disable-static
28 pic-only
29 ])
30 AC_PREFIX_DEFAULT([/usr])
31 gl_LD_VERSION_SCRIPT
32
33 IT_PROG_INTLTOOL([0.40.0])
34
35 # Interpret embedded Python in HTML files
36 XGETTEXT="${XGETTEXT} -L Python --keyword=_:1,2 --keyword=N_:1,2 --no-location"
37
38 GETTEXT_PACKAGE=${PACKAGE_TARNAME}
39 AC_SUBST(GETTEXT_PACKAGE)
40
41 AC_PROG_SED
42 AC_PROG_MKDIR_P
43
44 # - man ------------------------------------------------------------------------
45
46 have_man_pages=no
47 AC_ARG_ENABLE(man_pages, AS_HELP_STRING([--disable-man-pages],
48 [do not install man pages]))
49 AS_IF([test "x$enable_man_pages" != xno], [have_man_pages=yes])
50 AM_CONDITIONAL(ENABLE_MAN_PAGES, [test "x$have_man_pages" = "xyes"])
51
52 AC_PATH_PROG([XSLTPROC], [xsltproc])
53
54 AC_CHECK_PROGS(ASCIIDOC, [asciidoc])
55 if test "${have_man_pages}" = "yes" && test -z "${ASCIIDOC}"; then
56 AC_MSG_ERROR([Required program 'asciidoc' not found])
57 fi
58
59 # - pkg-config -----------------------------------------------------------------
60
61 m4_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
68 PKG_PROG_PKG_CONFIG
69 PKG_INSTALLDIR(['${usrlib_execdir}/pkgconfig'])
70
71 # - bash-completion ------------------------------------------------------------
72
73 #enable_bash_completion=yes
74 AC_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
84 AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
85
86 AC_ARG_ENABLE([bash-completion],
87 AS_HELP_STRING([--disable-bash-completion], [do not install bash completion files]),
88 [], [enable_bash_completion=yes]
89 )
90
91 AM_CONDITIONAL([BUILD_BASH_COMPLETION], [test "x$enable_bash_completion" = xyes])
92
93 # - debug ----------------------------------------------------------------------
94
95 AC_ARG_ENABLE([debug],
96 AS_HELP_STRING([--enable-debug], [enable debug messages @<:@default=disabled@:>@]),
97 [], [enable_debug=no])
98 AS_IF([test "x$enable_debug" = "xyes"], [
99 AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.])
100 ])
101
102 AC_CHECK_HEADERS_ONCE([
103 arpa/inet.h \
104 arpa/nameser.h \
105 arpa/nameser_compat.h \
106 endian.h \
107 netinet/in.h \
108 resolv.h \
109 string.h \
110 ])
111
112 AC_CHECK_FUNCS([ \
113 be16toh \
114 be32toh \
115 be64toh \
116 htobe16 \
117 htobe32 \
118 htobe64 \
119 madvise \
120 mmap \
121 munmap \
122 res_query \
123 __secure_getenv \
124 secure_getenv \
125 qsort \
126 ])
127
128 my_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 "
141 AC_SUBST([my_CFLAGS])
142 AC_SUBST([my_LDFLAGS])
143
144 # Enable -fanalyzer if requested
145 AC_ARG_ENABLE([analyzer],
146 AS_HELP_STRING([--enable-analyzer], [enable static analyzer (-fanalyzer) @<:@default=disabled@:>@]),
147 [], [enable_analyzer=no])
148 AS_IF([test "x$enable_analyzer" = "xyes"],
149 CC_CHECK_FLAGS_APPEND([my_CFLAGS], [CFLAGS], [-fanalyzer])
150 )
151
152 # Enable -fno-semantic-interposition (if available)
153 CC_CHECK_FLAGS_APPEND([my_CFLAGS], [CFLAGS], [-fno-semantic-interposition])
154 CC_CHECK_FLAGS_APPEND([my_LDFLAGS], [LDFLAGS], [-fno-semantic-interposition])
155
156 # ------------------------------------------------------------------------------
157
158 AC_ARG_WITH([database-path],
159 AS_HELP_STRING([--with-database-path], [The default database path]),
160 [], [with_database_path=/var/lib/location/database.db]
161 )
162
163 if test -z "${with_database_path}"; then
164 AC_MSG_ERROR([The default database path is empty])
165 fi
166
167 AC_DEFINE_UNQUOTED([LIBLOC_DEFAULT_DATABASE_PATH], ["${with_database_path}"],
168 [The default path for the database])
169 AC_SUBST([DEFAULT_DATABASE_PATH], [${with_database_path}])
170
171 AC_ARG_WITH([systemd],
172 AS_HELP_STRING([--with-systemd], [Enable systemd support.])
173 )
174
175 AS_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
181 AS_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
201 AM_CONDITIONAL(HAVE_SYSTEMD, [test "x$have_systemd" = "xyes"])
202
203 # ------------------------------------------------------------------------------
204
205 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
206
207 # Python
208 AM_PATH_PYTHON([3.4])
209 PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}])
210
211 # Lua
212 AC_ARG_ENABLE(lua,
213 AS_HELP_STRING([--disable-lua], [do not build the Lua modules]), [], [enable_lua=yes])
214
215 AM_CONDITIONAL(ENABLE_LUA, test "$enable_lua" = "yes")
216
217 AS_IF(
218 [test "$enable_lua" = "yes"], [
219 PKG_CHECK_MODULES([LUA], [lua])
220
221 AX_PROG_LUA_MODULES([luaunit],, [AC_MSG_ERROR([Lua modules are missing])])
222
223 LUA_INSTALL_LMOD=$($PKG_CONFIG --define-variable=prefix=${prefix} --variable=INSTALL_LMOD lua)
224 AC_SUBST(LUA_INSTALL_LMOD)
225 LUA_INSTALL_CMOD=$($PKG_CONFIG --define-variable=prefix=${prefix} --variable=INSTALL_CMOD lua)
226 AC_SUBST(LUA_INSTALL_CMOD)
227 ],
228 )
229
230 # Perl
231 AC_PATH_PROG(PERL, perl, no)
232 AC_SUBST(PERL)
233
234 AX_PROG_PERL_MODULES(Config ExtUtils::MakeMaker,, AC_MSG_WARN(Need some Perl modules))
235
236 AC_ARG_ENABLE(perl, AS_HELP_STRING([--disable-perl], [do not build the perl modules]), [],[enable_perl=yes])
237 AM_CONDITIONAL(ENABLE_PERL, test "$enable_perl" = "yes")
238 AS_IF([test "$enable_perl" = "yes"],
239 [
240 PERL_MODPATH=$($PERL -MConfig -e 'print $Config{installvendorarch}')
241 PERL_MANPATH=$($PERL -MConfig -e 'print $Config{installvendorman3dir}')
242 AC_SUBST(PERL_MODPATH)
243 AC_SUBST(PERL_MANPATH)
244 ],
245 )
246
247 dnl Checking for libresolv
248 case "${host}" in
249 *-gnu*)
250 AC_CHECK_LIB(resolv, ns_msg_getflag, [LIBS="-lresolv $LIBS"], AC_MSG_ERROR([libresolv has not been found]), -lresolv)
251 ;;
252 *)
253 AC_CHECK_LIB(resolv, res_init, [LIBS="-lresolv $LIBS"], AC_MSG_ERROR([libresolv has not been found]), -lresolv)
254 ;;
255 esac
256 RESOLV_LIBS="${LIBS}"
257 AC_SUBST(RESOLV_LIBS)
258
259 dnl Checking for OpenSSL
260 LIBS=
261 AC_CHECK_LIB(crypto, EVP_EncryptInit,, AC_MSG_ERROR([libcrypto has not been found]))
262 OPENSSL_LIBS="${LIBS}"
263 AC_SUBST(OPENSSL_LIBS)
264
265 AC_CONFIG_HEADERS(config.h)
266 AC_CONFIG_FILES([
267 Makefile
268 po/Makefile.in
269 ])
270
271 AC_OUTPUT
272 AC_MSG_RESULT([
273 $PACKAGE $VERSION
274 =====
275
276 prefix: ${prefix}
277 sysconfdir: ${sysconfdir}
278 libdir: ${libdir}
279 includedir: ${includedir}
280
281 compiler: ${CC}
282 cflags: ${CFLAGS}
283 ldflags: ${LDFLAGS}
284
285 database path: ${with_database_path}
286 debug: ${enable_debug}
287 systemd support: ${have_systemd}
288 bash-completion: ${enable_bash_completion}
289
290 Bindings:
291 Lua: ${enable_lua}
292 Lua shared path: ${LUA_INSTALL_LMOD}
293 Lua module path: ${LUA_INSTALL_CMOD}
294 Perl: ${enable_perl}
295 Perl module path: ${PERL_MODPATH}
296 Perl manual path: ${PERL_MANPATH}
297 ])