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