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