Imported Upstream version 2.9.1
[platform/upstream/man-db.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2 m4_pattern_forbid([^MAN_])
3
4 # Initialise and check we're in the correct directory.
5 AC_INIT([man-db], [2.9.1], [cjwatson@debian.org])
6 AC_CONFIG_AUX_DIR([build-aux])
7 AM_INIT_AUTOMAKE([1.11 -Wall -Wno-override -Werror foreign dist-xz no-dist-gzip parallel-tests])
8 AM_MAINTAINER_MODE
9 AM_SILENT_RULES([yes])
10 AC_PREREQ([2.63])
11 AC_CONFIG_SRCDIR([src/man.c])
12 AC_GNU_SOURCE
13 MAN_TAR_SORT_NAME
14
15 AC_CONFIG_HEADER([config.h])
16 AC_CANONICAL_HOST
17
18 # Define below date and version information to be put into man pages etc.
19 date=2020-02-25
20 AC_SUBST([date])dnl
21 roff_version=`echo AC_PACKAGE_VERSION | sed 's/-/\\-/g'`
22 AC_SUBST([roff_version])dnl
23
24 # Explicitly check for pkg-config early on, since otherwise the conditional
25 # calls in MAN_ARG_SYSTEMDTMPFILESDIR and MAN_ARG_SYSTEMDSYSTEMUNITDIR are
26 # problematic.
27 PKG_PROG_PKG_CONFIG
28
29 # We have to be a bit naughty here and supply options.
30 # The autoconf literature states that only features that can be separately
31 # 'built' should use --enable and friends. Oh well...
32 MAN_ARG_CACHE_OWNER
33 MAN_ARG_SETUID
34 MAN_ARG_UNDOC
35 MAN_ARG_DEVICE
36 MAN_ARG_DB
37 MAN_ARG_CONFIG_FILE
38 MAN_ARG_SECTIONS
39 MAN_ARG_AUTOMATIC_CREATE
40 MAN_ARG_AUTOMATIC_UPDATE
41 MAN_ARG_CATS
42 MAN_ARG_OVERRIDE_DIR
43 MAN_ARG_SYSTEMDTMPFILESDIR
44 MAN_ARG_SYSTEMDSYSTEMUNITDIR
45 MAN_ARG_MANDIRS
46 MAN_ARG_MANUAL
47
48 # Check $PATH for the following programs and append suitable options.
49 AC_PROG_CC
50 gl_EARLY
51 AC_PROG_CPP
52 CFLAGS="$CFLAGS -Wall"
53 case $host_os in
54         ultrix4.3*)
55                 dnl When compiled for BSD environment, each running `man'
56                 dnl increases the system load as reported by uptime(1) by
57                 dnl one.  The reason for this behaviour is currently
58                 dnl unknown, but the load increase does *not* reflect actual
59                 dnl resource usage.  To avoid it, compile for POSIX
60                 dnl environment:
61                 CFLAGS="$CFLAGS -YPOSIX"
62                 ;;
63 esac
64
65 # Enable all reasonable GCC warnings.
66 gl_MANYWARN_ALL_GCC([warnings])
67 nw=
68 nw="$nw -Wsystem-headers"
69 nw="$nw -Wmissing-field-initializers"
70 nw="$nw -Winline"
71 gl_MANYWARN_COMPLEMENT([warnings], [$warnings], [$nw])
72 for w in $warnings; do
73         gl_WARN_ADD([$w])
74 done
75 gl_WARN_ADD([-Wno-missing-field-initializers])
76 # Disable use of VLAs by Gnulib to avoid tripping over -Wvla.
77 AC_DEFINE([GNULIB_NO_VLA], [1], [Define to 1 to disable use of VLAs.])
78
79 AC_PROG_INSTALL
80 AC_PROG_LN_S
81 AM_PROG_AR
82 LT_INIT([disable-static])
83 AC_CHECK_PROGS([cat], [cat])
84 MAN_CHECK_PROGS([browser], [BROWSER], [use BROWSER as default web browser], [www-browser lynx elinks w3m])
85 test -n "$browser" && browser="exec $browser"
86 AC_CHECK_PROGS([tr], [tr])
87 AC_CHECK_PROGS([grep], [grep])
88 MAN_CHECK_PROGS([pager], [PAGER], [use PAGER as default pager], [pager less more])
89
90 # Define below (in list of preference) *roff macros to check for.
91 macros="andoc an doc"
92
93 # We have problems here, as different systems have different *roff
94 # formatters and they accept different options and do different things :(
95 MAN_CHECK_PROGS([nroff], [NROFF], [use NROFF as roff formatter for character devices], [nroff gnroff groff])
96 if test -n "$nroff"
97 then
98         MAN_PROG_GNU_NROFF([$nroff])
99         if test "$man_cv_prog_gnu_nroff" != "yes"
100         then
101                 MAN_PROG_HEIRLOOM_NROFF([$nroff])
102         fi
103         if test -n "$nroff_device" 
104         then
105                 AC_MSG_CHECKING([that nroff works with argument$nroff_device])
106                 # We cannot cache this result as it can change between runs
107                 # of configure.
108                 if $nroff $nroff_device </dev/null >/dev/null 2>&1 3>&1
109                 then 
110                         AC_MSG_RESULT([yes])
111                 else
112                         AC_MSG_RESULT([no])
113                         AC_MSG_ERROR([nroff does not work with argument$nroff_device])
114                 fi
115         fi
116         AC_MSG_CHECKING([for appropriate nroff macro])
117         AC_CACHE_VAL([man_cv_prog_nroff_macro], [
118         
119         for macro in $macros
120         do
121                 if $nroff -m$macro $nroff_device </dev/null >/dev/null 2>&1 3>&1
122                 then
123                         man_cv_prog_nroff_macro=-m$macro
124                         break
125                 fi
126         done])
127         
128         if test -n "$man_cv_prog_nroff_macro"
129         then
130                 if test "$man_cv_prog_heirloom_nroff" = "yes"
131                 then
132                         # Heirloom works best with some extra options:
133                         #   -mg: groff compatibility
134                         #   -msafe: disable privileged operations
135                         #   -mpadj: clean up line breaking
136                         man_cv_prog_nroff_macro="-mg -msafe -mpadj ${man_cv_prog_nroff_macro}"
137                 fi
138                 nroff="$nroff ${man_cv_prog_nroff_macro}"
139 dnl             nroff="$nroff ${man_cv_prog_nroff_macro}${nroff_device}"
140                 AC_MSG_RESULT([$man_cv_prog_nroff_macro])
141         else
142                 AC_MSG_RESULT([ambiguous])
143                 AC_MSG_WARN([please edit include/manconfig.h and add nroff definition])
144         fi
145 else
146         AC_MSG_WARN([Cannot find an nroff-like program, formatting of manual page source will not be supported.])
147         nroff="(nroff not installed)"
148         AC_DEFINE([NROFF_MISSING], [1], [Define if you don't have nroff.])
149 fi
150
151 dnl It would be nice to use MAN_CHECK_PROGS here, but how do we determine
152 dnl TROFF_IS_GROFF?
153 AC_CHECK_PROGS([troff], [groff])
154 if test -n "$troff"
155 then
156         troff_is_groff=yes
157         AC_DEFINE([TROFF_IS_GROFF], [1], [Define if you are using groff as troff.])
158         TROFF=groff
159 else
160         troff_is_groff=no
161         AC_CHECK_PROGS([troff], [troff gtroff])
162         TROFF=troff
163 fi
164 AC_SUBST([TROFF])
165 if test -n "$troff"
166 then
167         AC_DEFINE([HAS_TROFF], [1], [Define if you have troff.])
168         AC_MSG_CHECKING([for appropriate $TROFF options])
169         AC_CACHE_VAL([man_cv_prog_troff_options], [
170         # Do a quick test to see if -t works [AIX needs this], groff doesn't
171         # as it indicates pre-process with tbl.
172         test "$TROFF" = "troff" && $troff -t </dev/null >/dev/null 2>&1 3>&1 \
173                                 && troff_filter="-t "
174         for macro in $macros
175         do
176                 if $troff $troff_filter -m$macro </dev/null >/dev/null 2>&1 3>&1
177                 then
178                         man_cv_prog_troff_options="${troff_filter}-m${macro}"
179                         break
180                 fi
181         done])
182         if test -n "$man_cv_prog_troff_options"
183         then
184                 if test "$man_cv_prog_heirloom_nroff" = "yes"
185                 then
186                         # Heirloom works best with some extra options:
187                         #   -mg: groff compatibility
188                         #   -msafe: disable privileged operations
189                         #   -mpadj: clean up line breaking
190                         man_cv_prog_troff_options="-mg -msafe -mpadj ${man_cv_prog_troff_options}"
191                 fi
192                 troff="$troff $man_cv_prog_troff_options"
193                 AC_MSG_RESULT([$man_cv_prog_troff_options])
194         else
195                 AC_MSG_RESULT([ambiguous])
196                 AC_MSG_WARN([please edit include/manconfig.h and add troff definition])
197         fi
198 else
199         troff="(troff not installed)"
200 fi
201 dnl We want to end up with "-" written as "\-" in manual pages.  This
202 dnl requires additional \-escaping corresponding to the following quote
203 dnl removal steps:
204 dnl   1) the following sed command
205 dnl   2) the following assignment
206 dnl   2) sed running on the substituted version of man/replace.sin.in
207 troff_as_troff_input=`echo "$troff" | sed 's/-/\\\\\\\\-/g'`
208 AC_SUBST([troff_as_troff_input])
209
210 if test -n "$nroff"
211 then
212         AC_CACHE_CHECK([whether nroff supports warning control],
213                        [man_cv_prog_nroff_warnings], [
214                 if test "x$troff_is_groff" = xyes && \
215                    nroff -wmac </dev/null >/dev/null 2>&1
216                 then
217                         man_cv_prog_nroff_warnings=yes
218                 else
219                         man_cv_prog_nroff_warnings=no
220                 fi])
221         if test "x$man_cv_prog_nroff_warnings" = xyes; then
222                 AC_DEFINE([NROFF_WARNINGS], [1],
223                           [Define if nroff supports warning control.])
224         fi
225 fi
226
227 AC_CHECK_PROGS([preconv], [gpreconv preconv])
228
229 AC_MSG_CHECKING([for groff with Debian multibyte patch or real Unicode support])
230 man_mb_groff=no
231 AC_ARG_ENABLE([mb-groff],
232 [AS_HELP_STRING([--enable-mb-groff], [expect groff with Debian multibyte patch or real Unicode support])],
233         [if test "$enableval" = "yes"
234          then
235                 man_mb_groff=yes
236          fi],
237         [if test -n "$preconv"
238          then
239                 man_mb_groff=yes
240          elif test -n "$troff" && test "$troff_is_groff" = "yes"
241          then
242                 if $troff -Tnippon </dev/null >/dev/null 2>&1
243                 then
244                         man_mb_groff=yes
245                 fi
246          fi])
247 AC_MSG_RESULT([$man_mb_groff])
248 if test "$man_mb_groff" = "yes"
249 then
250         AC_DEFINE([MULTIBYTE_GROFF], 1,
251                   [Define if your groff installation has the Debian multibyte patch.])
252 fi
253
254 MAN_CHECK_PROGS([eqn], [EQN], [use EQN to preprocess equations], [eqn geqn])
255 MAN_CHECK_PROGS([neqn], [NEQN], [use NEQN to preprocess equations for character devices], [neqn gneqn])
256 # If we fail to find an neqn, use eqn and try to force it to output for an
257 # ascii device. As this is only relevant for equations (?), not using latin1
258 # should be acceptable. -Tlatin1 is ignored by some eqn implementations.
259 if test -z "$neqn"
260 then
261         test -n "$eqn" && 
262         (test -n "$nroff_device" && neqn="$eqn -T$nroff_device" || neqn="$eqn -Tascii")
263 fi
264 MAN_CHECK_PROGS([tbl], [TBL], [use TBL to preprocess tables], [tbl gtbl])
265 TBL_X_FORMAT=
266 if test -n "$tbl"
267 then
268         AC_CACHE_CHECK([whether tbl supports the 'x' format character],
269                        [man_cv_tbl_x_format], [
270                 if (echo .TS; echo ';'; echo lx.; echo SENTINEL; echo .TE) | \
271                    $tbl 2>/dev/null | grep SENTINEL >/dev/null 2>&1
272                 then
273                         man_cv_tbl_x_format=yes
274                 else
275                         man_cv_tbl_x_format=no
276                 fi])
277         if test "x$man_cv_tbl_x_format" = xyes
278         then
279                 TBL_X_FORMAT=x
280         fi
281 fi
282 AC_SUBST([TBL_X_FORMAT])
283 MAN_CHECK_PROGS([col], [COL], [use COL to filter formatting characters from output], [col gcol])
284 MAN_CHECK_PROGS([vgrind], [VGRIND], [use VGRIND to preprocess program sources], [vgrind gvgrind])
285 MAN_CHECK_PROGS([refer], [REFER], [use REFER to preprocess bibliographic references], [refer grefer])
286 MAN_CHECK_PROGS([grap], [GRAP], [use GRAP to preprocess graphs], [grap])
287 MAN_CHECK_PROGS([pic], [PIC], [use PIC to preprocess pictures], [pic gpic])
288 test -n "$pic" && pic="$pic -S"
289
290 MAN_CHECK_PROGS([gzip], [GZIP], [use GZIP as GNU compression utility], [gzip])
291 if test -n "$gzip"
292 then
293         gunzip="$gzip -dc"
294         compressor="$gzip -c7"
295         compress_ext="gz"
296 fi
297 MAN_CHECK_PROGS([compress], [COMPRESS], [use COMPRESS as UNIX compression utility], [compress])
298 if test -n "$compress"
299 then
300         uncompress="$compress -dc"
301         if test -z "$gzip"
302         then
303                 compressor="$compress -c"
304                 compress_ext="Z"
305         fi
306 fi
307 MAN_CHECK_PROGS([bzip2], [BZIP2], [use BZIP2 as block-sorting compression utility], [bzip2])
308 if test -n "$bzip2"
309 then
310         bunzip2="$bzip2 -dc"
311 fi
312 MAN_CHECK_PROGS([xz], [XZ], [use XZ as Lempel-Ziv-Markov chain-Algorithm compression utility], [xz])
313 if test -n "$xz"
314 then
315         unxz="$xz -dc"
316         unlzma=
317 else
318         dnl lzma not used/needed if we have xz
319         MAN_CHECK_PROGS([lzma], [LZMA], [use LZMA as Lempel-Ziv-Markov chain-Algorithm compression utility], [lzma])
320         if test -n "$lzma"
321         then
322                 unlzma="$lzma -dc"
323         fi
324 fi
325 MAN_CHECK_PROGS([lzip], [LZIP], [use LZIP as Lempel-Ziv-Markov chain-Algorithm compression utility], [lzip])
326 if test -n "$lzip"
327 then
328         unlzip="$lzip -dc"
329 fi
330 if test -n "$gzip" || test -n "$compress" || test -n "$bzip2" || test -n "$xz" || test -n "$lzip" || test -n "$lzma"
331 then
332         AC_DEFINE([COMP_CAT], [1], [Define if you have compressors and want to support compressed cat files.])
333 fi
334 AC_SUBST([compressor])
335 AC_SUBST([compress_ext])
336 AC_SUBST([gunzip])
337 AC_SUBST([uncompress])
338 AC_SUBST([bunzip2])
339 AC_SUBST([unlzma])
340 AC_SUBST([unxz])
341 AC_SUBST([unlzip])
342 MAN_COMPRESS_LIB([z], [gzopen])
343 dnl To add more decompressors just follow the scheme above.
344
345 # Check for various header files and associated libraries.
346 AC_ISC_POSIX
347 dnl AC_PROG_LEX calls AC_TRY_LINK: must come after above 3
348 AC_PROG_LEX
349 if test "$LEX" = ":" && (test ! -e src/lexgrog.c || test ! -e src/zsoelim.c)
350 then
351         AC_MSG_ERROR([flex is required when building from revision control])
352 fi
353 gl_INIT
354 AC_CHECK_HEADERS([sys/file.h linux/fiemap.h])
355 AC_CHECK_FUNCS([posix_fadvise])
356
357 # Internationalization support.
358 AM_GNU_GETTEXT([external])
359 AM_GNU_GETTEXT_VERSION([0.18.3])
360 AC_SUBST([LINGUAS])
361 AM_ICONV
362 MAN_PO4A
363 MAN_LINGUAS
364
365 # Checks for structures and compiler characteristics.
366 AC_C_CONST
367 AC_C_INLINE
368 AC_TYPE_PID_T
369 AC_TYPE_UID_T
370 AC_TYPE_SIZE_T
371
372 # Check for pipeline library.
373 PKG_CHECK_MODULES([libpipeline], [libpipeline >= 1.5.0])
374
375 # Find a suitable database interface header and library.
376 #
377 # Check for GNU dbm routines.
378 if test "$db" = "no" || test "$db" = "gdbm"
379 then
380   AC_CHECK_HEADER([gdbm.h], [
381     for lib in gdbm c dbm
382     do
383       AC_CHECK_LIB([$lib], [gdbm_fetch],
384                    test "$lib" = "c" || DBLIBS="-l$lib" 
385                    [AC_DEFINE([GDBM], [1], [Define if you have, and want to use, gdbm interface routines.])
386                     AC_SUBST([DBTYPE], [gdbm])]
387                    db=yes, db=no)
388       if test "$db" = "yes" 
389       then
390         man_save_LIBS="$LIBS"
391         LIBS="$LIBS $DBLIBS"
392         AC_CHECK_FUNCS([gdbm_exists])
393         LIBS="$man_save_LIBS"
394         break
395       fi
396     done], db=no)
397 fi
398
399 # Check for Berkeley db routines (first version API).
400 MAN_CHECK_BDB([db5 db], [db5/db_185.h db_185.h], [db5 db-5])
401 MAN_CHECK_BDB([db4 db], [db4/db_185.h db_185.h], [db4 db-4])
402 MAN_CHECK_BDB([db3 db], [db3/db_185.h db_185.h], [db3])
403 MAN_CHECK_BDB([db2 db], [db_185.h db2/db_185.h db2_185.h], [db2 db])
404 MAN_CHECK_BDB([db1 db], [db/db.h db.h db1/db.h], [db db1 c])
405
406 dnl MAN_CHECK_BDB([db2], [db2_185.h], [db2 db c], [AC_DEFINE(DB_ON_LIBC)])
407 dnl MAN_CHECK_BDB([db2], [db2/db_185.h], [db2 db c])
408
409 # Check for UNIX ndbm routines.
410 if test "$db" = "no" || test "$db" = "ndbm"
411 then
412   AC_CHECK_HEADER([ndbm.h], [
413     for lib in ndbm c dbm
414     do
415       AC_CHECK_LIB([$lib], [dbm_fetch],
416                    test "$lib" = "c" || DBLIBS="-l$lib"
417                    [AC_DEFINE([NDBM], [1], [Define if you have, and want to use, ndbm interface routines.])
418                     AC_SUBST([DBTYPE], [ndbm])]
419                    db=yes, db=no)
420       test "$db" = "yes" && break
421     done], db=no)
422   if test "$db" = no
423   then
424     AC_CHECK_HEADER([gdbm-ndbm.h], [
425       for lib in gdbm_compat c dbm
426       do
427         AC_CHECK_LIB([$lib], [dbm_fetch],
428                      test "$lib" = "c" || DBLIBS="-l$lib"
429                      [AC_DEFINE([NDBM], [1], [Define if you have, and want to use, ndbm interface routines.])
430                       AC_SUBST([DBTYPE], [ndbm])]
431                      db=yes, db=no)
432         test "$db" = "yes" && break
433       done], db=no)
434   fi
435 fi 
436
437 if test "$db" != "yes"
438 then 
439     if test "$db" = "no"
440     then
441       AC_MSG_ERROR([Fatal: no supported database library/header found])
442     else
443       AC_MSG_ERROR([Fatal: $db: unsupported database library])
444     fi
445 fi
446 AC_SUBST([DBLIBS])
447
448 # Check for libseccomp library.
449 MAN_LIBSECCOMP
450
451 dnl MAN_ECHO_VAR(ENV-VARIABLE)
452 define([MAN_ECHO_VAR], [AC_MSG_NOTICE([default $1 = "$$1"])])dnl
453 dnl
454 MAN_ECHO_VAR([CC])
455 MAN_ECHO_VAR([CPP])
456 MAN_ECHO_VAR([CPPFLAGS])
457 MAN_ECHO_VAR([CFLAGS])
458 MAN_ECHO_VAR([LDFLAGS])
459 MAN_ECHO_VAR([LIBS])
460 MAN_ECHO_VAR([DBLIBS])
461
462 # Transformed versions of program names for use in Automake variables.
463 MAN_TRANS_SUBST([apropos])
464 MAN_TRANS_SUBST([catman])
465 MAN_TRANS_SUBST([lexgrog])
466 MAN_TRANS_SUBST([man])
467 MAN_TRANS_SUBST([man-recode])
468 MAN_TRANS_SUBST([manconv])
469 MAN_TRANS_SUBST([mandb])
470 MAN_TRANS_SUBST([manpath])
471 MAN_TRANS_SUBST([whatis])
472 MAN_TRANS_SUBST([zsoelim])
473
474 # If we're cross-compiling, tests won't work.
475 AM_CONDITIONAL([CROSS_COMPILING], [test "x$cross_compiling" = xyes])
476
477 # Are Gnulib translations available?
478 AM_CONDITIONAL([HAVE_GNULIB_PO], [test -f "$srcdir/gl/po/POTFILES.in"])
479
480 AC_CONFIG_FILES([Makefile
481         gl/lib/Makefile
482         init/Makefile
483         init/systemd/Makefile
484         lib/Makefile
485         src/Makefile
486         src/man_db.conf
487         src/tests/Makefile
488         man/Makefile
489         man/replace.sin
490         man/po4a/Makefile
491         man/da/Makefile
492         man/de/Makefile
493         man/es/Makefile
494         man/fr/Makefile
495         man/id/Makefile
496         man/it/Makefile
497         man/ja/Makefile
498         man/nl/Makefile
499         man/pl/Makefile
500         man/pt/Makefile
501         man/pt_BR/Makefile
502         man/ru/Makefile
503         man/sr/Makefile
504         man/sv/Makefile
505         man/tr/Makefile
506         man/zh_CN/Makefile
507         manual/Makefile
508         libdb/Makefile
509         docs/Makefile
510         tools/Makefile
511         include/comp_src.h
512         include/manconfig.h
513         po/Makefile.in])
514 if test -f "$srcdir/gl/po/Makefile.in.in"; then
515         AC_CONFIG_FILES([gl/po/Makefile.in])
516 fi
517 AC_OUTPUT