Imported Upstream version 2.8.6.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.8.6.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=2019-08-05
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         *darwin*)
64                 dnl libman intentionally has an undefined "sandbox" symbol
65                 dnl which is supplied by each application.  The Darwin
66                 dnl linker refuses to do this by default, and needs some
67                 dnl help.
68                 CFLAGS="$CFLAGS -Wl,-flat_namespace,-undefined,suppress"
69                 ;;
70 esac
71 if test "$GCC" = yes
72 then
73         gl_WARN_ADD([-W])
74         gl_WARN_ADD([-Wpointer-arith])
75         gl_WARN_ADD([-Wwrite-strings])
76         gl_WARN_ADD([-Wstrict-prototypes])
77         gl_WARN_ADD([-Wshadow])
78         gl_WARN_ADD([-Wformat-security])
79         gl_WARN_ADD([-Wredundant-decls])
80         gl_WARN_ADD([-Wno-missing-field-initializers])
81 fi
82 AC_PROG_INSTALL
83 AC_PROG_LN_S
84 AM_PROG_AR
85 LT_INIT([disable-static])
86 AC_CHECK_PROGS([cat], [cat])
87 MAN_CHECK_PROGS([browser], [BROWSER], [use BROWSER as default web browser], [www-browser lynx elinks w3m])
88 test -n "$browser" && browser="exec $browser"
89 AC_CHECK_PROGS([tr], [tr])
90 AC_CHECK_PROGS([grep], [grep])
91 MAN_CHECK_PROGS([pager], [PAGER], [use PAGER as default pager], [pager less more])
92
93 # Define below (in list of preference) *roff macros to check for.
94 macros="andoc an doc"
95
96 # We have problems here, as different systems have different *roff
97 # formatters and they accept different options and do different things :(
98 MAN_CHECK_PROGS([nroff], [NROFF], [use NROFF as roff formatter for character devices], [nroff gnroff groff])
99 if test -n "$nroff"
100 then
101         MAN_PROG_GNU_NROFF([$nroff])
102         if test "$man_cv_prog_gnu_nroff" != "yes"
103         then
104                 MAN_PROG_HEIRLOOM_NROFF([$nroff])
105         fi
106         if test -n "$nroff_device" 
107         then
108                 AC_MSG_CHECKING([that nroff works with argument$nroff_device])
109                 # We cannot cache this result as it can change between runs
110                 # of configure.
111                 if $nroff $nroff_device </dev/null >/dev/null 2>&1 3>&1
112                 then 
113                         AC_MSG_RESULT([yes])
114                 else
115                         AC_MSG_RESULT([no])
116                         AC_MSG_ERROR([nroff does not work with argument$nroff_device])
117                 fi
118         fi
119         AC_MSG_CHECKING([for appropriate nroff macro])
120         AC_CACHE_VAL([man_cv_prog_nroff_macro], [
121         
122         for macro in $macros
123         do
124                 if $nroff -m$macro $nroff_device </dev/null >/dev/null 2>&1 3>&1
125                 then
126                         man_cv_prog_nroff_macro=-m$macro
127                         break
128                 fi
129         done])
130         
131         if test -n "$man_cv_prog_nroff_macro"
132         then
133                 if test "$man_cv_prog_heirloom_nroff" = "yes"
134                 then
135                         # Heirloom works best with some extra options:
136                         #   -mg: groff compatibility
137                         #   -msafe: disable privileged operations
138                         #   -mpadj: clean up line breaking
139                         man_cv_prog_nroff_macro="-mg -msafe -mpadj ${man_cv_prog_nroff_macro}"
140                 fi
141                 nroff="$nroff ${man_cv_prog_nroff_macro}"
142 dnl             nroff="$nroff ${man_cv_prog_nroff_macro}${nroff_device}"
143                 AC_MSG_RESULT([$man_cv_prog_nroff_macro])
144         else
145                 AC_MSG_RESULT([ambiguous])
146                 AC_MSG_WARN([please edit include/manconfig.h and add nroff definition])
147         fi
148 else
149         AC_MSG_WARN([Cannot find an nroff-like program, formatting of manual page source will not be supported.])
150         nroff="(nroff not installed)"
151         AC_DEFINE([NROFF_MISSING], [1], [Define if you don't have nroff.])
152 fi
153
154 dnl It would be nice to use MAN_CHECK_PROGS here, but how do we determine
155 dnl TROFF_IS_GROFF?
156 AC_CHECK_PROGS([troff], [groff])
157 if test -n "$troff"
158 then
159         troff_is_groff=yes
160         AC_DEFINE([TROFF_IS_GROFF], [1], [Define if you are using groff as troff.])
161         TROFF=groff
162 else
163         troff_is_groff=no
164         AC_CHECK_PROGS([troff], [troff gtroff])
165         TROFF=troff
166 fi
167 AC_SUBST([TROFF])
168 if test -n "$troff"
169 then
170         AC_DEFINE([HAS_TROFF], [1], [Define if you have troff.])
171         AC_MSG_CHECKING([for appropriate $TROFF options])
172         AC_CACHE_VAL([man_cv_prog_troff_options], [
173         # Do a quick test to see if -t works [AIX needs this], groff doesn't
174         # as it indicates pre-process with tbl.
175         test "$TROFF" = "troff" && $troff -t </dev/null >/dev/null 2>&1 3>&1 \
176                                 && troff_filter="-t "
177         for macro in $macros
178         do
179                 if $troff $troff_filter -m$macro </dev/null >/dev/null 2>&1 3>&1
180                 then
181                         man_cv_prog_troff_options="${troff_filter}-m${macro}"
182                         break
183                 fi
184         done])
185         if test -n "$man_cv_prog_troff_options"
186         then
187                 if test "$man_cv_prog_heirloom_nroff" = "yes"
188                 then
189                         # Heirloom works best with some extra options:
190                         #   -mg: groff compatibility
191                         #   -msafe: disable privileged operations
192                         #   -mpadj: clean up line breaking
193                         man_cv_prog_troff_options="-mg -msafe -mpadj ${man_cv_prog_troff_options}"
194                 fi
195                 troff="$troff $man_cv_prog_troff_options"
196                 AC_MSG_RESULT([$man_cv_prog_troff_options])
197         else
198                 AC_MSG_RESULT([ambiguous])
199                 AC_MSG_WARN([please edit include/manconfig.h and add troff definition])
200         fi
201 else
202         troff="(troff not installed)"
203 fi
204
205 if test -n "$nroff"
206 then
207         AC_CACHE_CHECK([whether nroff supports warning control],
208                        [man_cv_prog_nroff_warnings], [
209                 if test "x$troff_is_groff" = xyes && \
210                    nroff -wmac </dev/null >/dev/null 2>&1
211                 then
212                         man_cv_prog_nroff_warnings=yes
213                 else
214                         man_cv_prog_nroff_warnings=no
215                 fi])
216         if test "x$man_cv_prog_nroff_warnings" = xyes; then
217                 AC_DEFINE([NROFF_WARNINGS], [1],
218                           [Define if nroff supports warning control.])
219         fi
220 fi
221
222 AC_CHECK_PROGS([preconv], [gpreconv preconv])
223
224 AC_MSG_CHECKING([for groff with Debian multibyte patch or real Unicode support])
225 man_mb_groff=no
226 AC_ARG_ENABLE([mb-groff],
227 [AS_HELP_STRING([--enable-mb-groff], [expect groff with Debian multibyte patch or real Unicode support])],
228         [if test "$enableval" = "yes"
229          then
230                 man_mb_groff=yes
231          fi],
232         [if test -n "$preconv"
233          then
234                 man_mb_groff=yes
235          elif test -n "$troff" && test "$troff_is_groff" = "yes"
236          then
237                 if $troff -Tnippon </dev/null >/dev/null 2>&1
238                 then
239                         man_mb_groff=yes
240                 fi
241          fi])
242 AC_MSG_RESULT([$man_mb_groff])
243 if test "$man_mb_groff" = "yes"
244 then
245         AC_DEFINE([MULTIBYTE_GROFF], 1,
246                   [Define if your groff installation has the Debian multibyte patch.])
247 fi
248
249 MAN_CHECK_PROGS([eqn], [EQN], [use EQN to preprocess equations], [eqn geqn])
250 MAN_CHECK_PROGS([neqn], [NEQN], [use NEQN to preprocess equations for character devices], [neqn gneqn])
251 # If we fail to find an neqn, use eqn and try to force it to output for an
252 # ascii device. As this is only relevant for equations (?), not using latin1
253 # should be acceptable. -Tlatin1 is ignored by some eqn implementations.
254 if test -z "$neqn"
255 then
256         test -n "$eqn" && 
257         (test -n "$nroff_device" && neqn="$eqn -T$nroff_device" || neqn="$eqn -Tascii")
258 fi
259 MAN_CHECK_PROGS([tbl], [TBL], [use TBL to preprocess tables], [tbl gtbl])
260 TBL_X_FORMAT=
261 if test -n "$tbl"
262 then
263         AC_CACHE_CHECK([whether tbl supports the 'x' format character],
264                        [man_cv_tbl_x_format], [
265                 if (echo .TS; echo ';'; echo lx.; echo SENTINEL; echo .TE) | \
266                    $tbl 2>/dev/null | grep SENTINEL >/dev/null 2>&1
267                 then
268                         man_cv_tbl_x_format=yes
269                 else
270                         man_cv_tbl_x_format=no
271                 fi])
272         if test "x$man_cv_tbl_x_format" = xyes
273         then
274                 TBL_X_FORMAT=x
275         fi
276 fi
277 AC_SUBST([TBL_X_FORMAT])
278 MAN_CHECK_PROGS([col], [COL], [use COL to filter formatting characters from output], [col gcol])
279 MAN_CHECK_PROGS([vgrind], [VGRIND], [use VGRIND to preprocess program sources], [vgrind gvgrind])
280 MAN_CHECK_PROGS([refer], [REFER], [use REFER to preprocess bibliographic references], [refer grefer])
281 MAN_CHECK_PROGS([grap], [GRAP], [use GRAP to preprocess graphs], [grap])
282 MAN_CHECK_PROGS([pic], [PIC], [use PIC to preprocess pictures], [pic gpic])
283 test -n "$pic" && pic="$pic -S"
284
285 MAN_CHECK_PROGS([gzip], [GZIP], [use GZIP as GNU compression utility], [gzip])
286 if test -n "$gzip"
287 then
288         gunzip="$gzip -dc"
289         compressor="$gzip -c7"
290         compress_ext="gz"
291 fi
292 MAN_CHECK_PROGS([compress], [COMPRESS], [use COMPRESS as UNIX compression utility], [compress])
293 if test -n "$compress"
294 then
295         uncompress="$compress -dc"
296         if test -z "$gzip"
297         then
298                 compressor="$compress -c"
299                 compress_ext="Z"
300         fi
301 fi
302 MAN_CHECK_PROGS([bzip2], [BZIP2], [use BZIP2 as block-sorting compression utility], [bzip2])
303 if test -n "$bzip2"
304 then
305         bunzip2="$bzip2 -dc"
306 fi
307 MAN_CHECK_PROGS([xz], [XZ], [use XZ as Lempel-Ziv-Markov chain-Algorithm compression utility], [xz])
308 if test -n "$xz"
309 then
310         unxz="$xz -dc"
311         unlzma=
312 else
313         dnl lzma not used/needed if we have xz
314         MAN_CHECK_PROGS([lzma], [LZMA], [use LZMA as Lempel-Ziv-Markov chain-Algorithm compression utility], [lzma])
315         if test -n "$lzma"
316         then
317                 unlzma="$lzma -dc"
318         fi
319 fi
320 MAN_CHECK_PROGS([lzip], [LZIP], [use LZIP as Lempel-Ziv-Markov chain-Algorithm compression utility], [lzip])
321 if test -n "$lzip"
322 then
323         unlzip="$lzip -dc"
324 fi
325 if test -n "$gzip" || test -n "$compress" || test -n "$bzip2" || test -n "$xz" || test -n "$lzip" || test -n "$lzma"
326 then
327         AC_DEFINE([COMP_CAT], [1], [Define if you have compressors and want to support compressed cat files.])
328         AC_DEFINE([COMP_SRC], [1], [Define if you have compressors and want to support compressed manual source.])
329 fi
330 AC_SUBST([compressor])
331 AC_SUBST([compress_ext])
332 AC_SUBST([gunzip])
333 AC_SUBST([uncompress])
334 AC_SUBST([bunzip2])
335 AC_SUBST([unlzma])
336 AC_SUBST([unxz])
337 AC_SUBST([unlzip])
338 MAN_COMPRESS_LIB([z], [gzopen])
339 dnl To add more decompressors just follow the scheme above.
340
341 # Check for various header files and associated libraries.
342 AC_ISC_POSIX
343 dnl AC_PROG_LEX calls AC_TRY_LINK: must come after above 3
344 AC_PROG_LEX
345 if test "$LEX" = ":" && (test ! -e src/lexgrog.c || test ! -e src/zsoelim.c)
346 then
347         AC_MSG_ERROR([flex is required when building from revision control])
348 fi
349 gl_INIT
350 AC_CHECK_HEADERS([sys/file.h linux/fiemap.h])
351 AC_CHECK_FUNCS([posix_fadvise])
352
353 # Internationalization support.
354 AM_GNU_GETTEXT([external])
355 AM_GNU_GETTEXT_VERSION([0.18.3])
356 AC_SUBST([LINGUAS])
357 AM_ICONV
358 MAN_PO4A
359 MAN_LINGUAS
360
361 # Checks for structures and compiler characteristics.
362 AC_C_CONST
363 AC_C_INLINE
364 AC_TYPE_PID_T
365 AC_TYPE_UID_T
366 AC_TYPE_SIZE_T
367
368 # Check for pipeline library.
369 PKG_CHECK_MODULES([libpipeline], [libpipeline >= 1.5.0])
370
371 # Find a suitable database interface header and library.
372 #
373 # Check for GNU dbm routines.
374 if test "$db" = "no" || test "$db" = "gdbm"
375 then
376   AC_CHECK_HEADER([gdbm.h], [
377     for lib in gdbm c dbm
378     do
379       AC_CHECK_LIB([$lib], [gdbm_fetch],
380                    test "$lib" = "c" || DBLIBS="-l$lib" 
381                    [AC_DEFINE([GDBM], [1], [Define if you have, and want to use, gdbm interface routines.])
382                     AC_SUBST([DBTYPE], [gdbm])]
383                    db=yes, db=no)
384       if test "$db" = "yes" 
385       then
386         man_save_LIBS="$LIBS"
387         LIBS="$LIBS $DBLIBS"
388         AC_CHECK_FUNCS([gdbm_exists])
389         LIBS="$man_save_LIBS"
390         break
391       fi
392     done], db=no)
393 fi
394
395 # Check for Berkeley db routines (first version API).
396 MAN_CHECK_BDB([db5 db], [db5/db_185.h db_185.h], [db5 db-5])
397 MAN_CHECK_BDB([db4 db], [db4/db_185.h db_185.h], [db4 db-4])
398 MAN_CHECK_BDB([db3 db], [db3/db_185.h db_185.h], [db3])
399 MAN_CHECK_BDB([db2 db], [db_185.h db2/db_185.h db2_185.h], [db2 db])
400 MAN_CHECK_BDB([db1 db], [db/db.h db.h db1/db.h], [db db1 c])
401
402 dnl MAN_CHECK_BDB([db2], [db2_185.h], [db2 db c], [AC_DEFINE(DB_ON_LIBC)])
403 dnl MAN_CHECK_BDB([db2], [db2/db_185.h], [db2 db c])
404
405 # Check for UNIX ndbm routines.
406 if test "$db" = "no" || test "$db" = "ndbm"
407 then
408   AC_CHECK_HEADER([ndbm.h], [
409     for lib in ndbm c dbm
410     do
411       AC_CHECK_LIB([$lib], [dbm_fetch],
412                    test "$lib" = "c" || DBLIBS="-l$lib"
413                    [AC_DEFINE([NDBM], [1], [Define if you have, and want to use, ndbm interface routines.])
414                     AC_SUBST([DBTYPE], [ndbm])]
415                    db=yes, db=no)
416       test "$db" = "yes" && break
417     done], db=no)
418   if test "$db" = no
419   then
420     AC_CHECK_HEADER([gdbm-ndbm.h], [
421       for lib in gdbm_compat c dbm
422       do
423         AC_CHECK_LIB([$lib], [dbm_fetch],
424                      test "$lib" = "c" || DBLIBS="-l$lib"
425                      [AC_DEFINE([NDBM], [1], [Define if you have, and want to use, ndbm interface routines.])
426                       AC_SUBST([DBTYPE], [ndbm])]
427                      db=yes, db=no)
428         test "$db" = "yes" && break
429       done], db=no)
430   fi
431 fi 
432
433 if test "$db" != "yes"
434 then 
435     if test "$db" = "no"
436     then
437       AC_MSG_ERROR([Fatal: no supported database library/header found])
438     else
439       AC_MSG_ERROR([Fatal: $db: unsupported database library])
440     fi
441 fi
442 AC_SUBST([DBLIBS])
443
444 # Check for libseccomp library.
445 MAN_LIBSECCOMP
446
447 dnl MAN_ECHO_VAR(ENV-VARIABLE)
448 define([MAN_ECHO_VAR], [AC_MSG_NOTICE([default $1 = "$$1"])])dnl
449 dnl
450 MAN_ECHO_VAR([CC])
451 MAN_ECHO_VAR([CPP])
452 MAN_ECHO_VAR([CPPFLAGS])
453 MAN_ECHO_VAR([CFLAGS])
454 MAN_ECHO_VAR([LDFLAGS])
455 MAN_ECHO_VAR([LIBS])
456 MAN_ECHO_VAR([DBLIBS])
457
458 # Transformed versions of program names for use in Automake variables.
459 MAN_TRANS_SUBST([apropos])
460 MAN_TRANS_SUBST([catman])
461 MAN_TRANS_SUBST([lexgrog])
462 MAN_TRANS_SUBST([man])
463 MAN_TRANS_SUBST([manconv])
464 MAN_TRANS_SUBST([mandb])
465 MAN_TRANS_SUBST([manpath])
466 MAN_TRANS_SUBST([whatis])
467 MAN_TRANS_SUBST([zsoelim])
468
469 # If we're cross-compiling, tests won't work.
470 AM_CONDITIONAL([CROSS_COMPILING], [test "x$cross_compiling" = xyes])
471
472 # Are Gnulib translations available?
473 AM_CONDITIONAL([HAVE_GNULIB_PO], [test -f "$srcdir/gl/po/POTFILES.in"])
474
475 AC_CONFIG_FILES([Makefile
476         gl/lib/Makefile
477         init/Makefile
478         init/systemd/Makefile
479         lib/Makefile
480         src/Makefile
481         src/man_db.conf
482         src/tests/Makefile
483         man/Makefile
484         man/replace.sin
485         man/po4a/Makefile
486         man/da/Makefile
487         man/de/Makefile
488         man/es/Makefile
489         man/fr/Makefile
490         man/id/Makefile
491         man/it/Makefile
492         man/ja/Makefile
493         man/nl/Makefile
494         man/pl/Makefile
495         man/pt/Makefile
496         man/pt_BR/Makefile
497         man/ru/Makefile
498         man/sr/Makefile
499         man/sv/Makefile
500         man/tr/Makefile
501         man/zh_CN/Makefile
502         manual/Makefile
503         libdb/Makefile
504         docs/Makefile
505         tools/Makefile
506         include/comp_src.h
507         include/manconfig.h
508         po/Makefile.in])
509 if test -f "$srcdir/gl/po/Makefile.in.in"; then
510         AC_CONFIG_FILES([gl/po/Makefile.in])
511 fi
512 AC_OUTPUT