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