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