Remove support for ancient bzip2 library versions
[platform/upstream/rpm.git] / configure.ac
1 AC_PREREQ(2.61)
2 AC_INIT(rpm, 4.9.90, rpm-maint@lists.rpm.org)
3
4 AC_CONFIG_SRCDIR([rpmqv.c])
5 AC_CONFIG_HEADERS([config.h])
6 AC_CONFIG_MACRO_DIR([m4])
7
8 AM_INIT_AUTOMAKE([1.10 foreign tar-ustar dist-bzip2 subdir-objects nostdinc])
9
10 AC_CONFIG_TESTDIR(tests)
11
12 AC_USE_SYSTEM_EXTENSIONS
13
14 AC_DISABLE_STATIC
15
16 PKG_PROG_PKG_CONFIG
17
18 dnl Checks for programs.
19 AC_PROG_CXX
20 AC_PROG_AWK
21 AC_PROG_CC
22 AC_PROG_CPP
23 AC_PROG_INSTALL
24 AC_PROG_LN_S
25 AC_PROG_MAKE_SET
26 AC_PROG_LIBTOOL
27 AC_PROG_YACC
28
29 AC_SUBST(__CC, $CC)
30 AC_PROG_CC_C99
31 if test "$ac_cv_prog_cc_c99" = no; then
32     AC_MSG_ERROR([ISO C99 capable compiler required])
33 fi
34
35 AS=${AS-as}
36 AC_SUBST(AS)
37 if test "$GCC" = yes; then
38     CFLAGS="$CFLAGS -fPIC -DPIC -D_REENTRANT -Wall -Wpointer-arith -Wmissing-prototypes -Wno-char-subscripts"
39     # XXX disabled for now due to noise from NSPR headers
40     # CFLAGS="$CFLAGS -Wstrict-prototypes"
41     cflags_to_try="-fno-strict-aliasing -fstack-protector -Wempty-body"
42     AC_MSG_CHECKING([supported compiler flags])
43     old_cflags=$CFLAGS
44     echo
45     for flag in $cflags_to_try; do
46         CFLAGS="$CFLAGS $flag"
47         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[return 0;]])],[
48                 echo "   $flag"
49                 RPMCFLAGS="$RPMCFLAGS $flag"
50         ],[])
51         CFLAGS=$old_cflags
52     done
53     CFLAGS="$CFLAGS $RPMCFLAGS"
54 fi
55 export CFLAGS
56
57 AC_SYS_LARGEFILE
58
59 dnl
60 dnl look for POSIX chmod attributes
61 dnl
62 AC_MSG_CHECKING(POSIX chmod)
63 touch foo.chmodtest
64 chmod 744 foo.chmodtest
65 chmod +X foo.chmodtest 2>/dev/null
66 a=`ls -l foo.chmodtest | awk '{print substr($1,1,10)}'`
67 rm -f foo.chmodtest
68 if test "$a" = "-rwxr-xr-x"; then
69     AC_MSG_RESULT(yes)
70     FIXPERMS=a+rX,u+w,g-w,o-w 
71 else
72     AC_MSG_RESULT(no (tell your OS vendor about GNU fileutils))
73     FIXPERMS=a+r,u+w,g-w,o-w 
74 fi
75 AC_SUBST(FIXPERMS)
76
77 dnl AM_DISABLE_SHARED
78 AM_PROG_LIBTOOL
79
80 AC_CHECK_TOOL(AR, ar, :)
81
82 dnl
83 dnl use defaults if cross-compiling, otherwise use the default path.
84 dnl
85 if test "$cross_compiling" = "yes"; then
86     MYPATH=":"
87 else
88     MYPATH=$PATH
89 fi
90
91 dnl
92 dnl Find some common programs
93 dnl
94 AC_PATH_PROG(__BZIP2, bzip2, /usr/bin/bzip2, $MYPATH)
95 AC_PATH_PROG(__CAT, cat, /bin/cat, $MYPATH)
96 AC_PATH_PROG(__CHGRP, chgrp, /bin/chgrp, $MYPATH)
97 AC_PATH_PROG(__CHMOD, chmod, /bin/chmod, $MYPATH)
98 AC_PATH_PROG(__CHOWN, chown, /bin/chown, $MYPATH)
99 AC_PATH_PROG(__CP, cp, /bin/cp, $MYPATH)
100 AC_PATH_PROG(__CPIO, cpio, /bin/cpio, $MYPATH)
101 AC_PATH_PROG(__CURL, curl, /usr/bin/curl, $MYPATH)
102 AC_PATH_PROG(__FILE, file, /usr/bin/file, $MYPATH)
103 AC_PATH_PROG(__GPG, gpg, /usr/bin/gpg, $MYPATH)
104 AC_PATH_PROG(__GREP, grep, /bin/grep, $MYPATH)
105 AC_PATH_PROG(__GZIP, gzip, /bin/gzip, $MYPATH)
106 AC_PATH_PROG(__UNZIP, unzip, /usr/bin/unzip, $MYPATH)
107 AC_PATH_PROG(__ID, id, /usr/bin/id, $MYPATH)
108 AC_PATH_PROG(__INSTALL, install, /usr/bin/install, $MYPATH)
109 AC_PATH_PROG(__LRZIP, lrzip, /usr/bin/lrzip, $MYPATH)
110 AC_PATH_PROG(__LZIP, lzip, /usr/bin/lzip, $MYPATH)
111 AC_PATH_PROG(__XZ, xz, /usr/bin/xz, $MYPATH)
112 AC_PATH_PROG(__MAKE, make, /usr/bin/make, $MYPATH)
113 AC_PATH_PROG(__MKDIR, mkdir, /bin/mkdir, $MYPATH)
114 AC_PATH_PROG(__MV, mv, /bin/mv, $MYPATH)
115 AC_PATH_PROG(__PATCH, patch, /usr/bin/patch, $MYPATH)
116 AC_PATH_PROG(__RESTORECON, restorecon, /sbin/restorecon, $MYPATH)
117 AC_MSG_CHECKING(old version of patch)
118     PATCHVERSION=`patch --version 2>&1`
119
120     if test "$PATCHVERSION" = "Patch version 2.1"; then
121         AC_DEFINE(HAVE_OLDPATCH_21, 1,
122                 [Define if the patch call you'll be using is 2.1 or older])
123         AC_MSG_RESULT(patch older then 2.2 found)
124     else
125         AC_MSG_RESULT(patch later then 2.2 found)
126     fi
127
128 AC_PATH_PROG(__PERL, perl, /usr/bin/perl, $MYPATH)
129 AC_PATH_PROG(__PGP, pgp, /usr/bin/pgp, $MYPATH)
130 AC_PATH_PROG(__PYTHON, python, /usr/bin/python, $MYPATH) 
131 AC_PATH_PROG(__RM, rm, /bin/rm, $MYPATH)
132 AC_PATH_PROG(__RSH, rsh, /usr/bin/rsh, $MYPATH)
133 AC_PATH_PROG(__SED, sed, /bin/sed, $MYPATH)
134 AC_PATH_PROG(__SEMODULE, semodule, /usr/bin/semodule, $MYPATH)
135 AC_PATH_PROG(__SSH, ssh, /usr/bin/ssh, $MYPATH)
136 AC_PATH_PROG(__TAR, tar, /bin/tar, $MYPATH)
137
138 AC_PATH_PROG(__LD, ld, /usr/bin/ld, $MYPATH)
139 AC_PATH_PROG(__NM, nm, /usr/bin/nm, $MYPATH)
140 AC_PATH_PROG(__OBJCOPY, objcopy, /usr/bin/objcopy, $MYPATH)
141 AC_PATH_PROG(__OBJDUMP, objdump, /usr/bin/objdump, $MYPATH)
142 AC_PATH_PROG(__STRIP, strip, /usr/bin/strip, $MYPATH)
143
144 AC_PATH_PROG(__FAKECHROOT, fakechroot, no, $MYPATH)
145 AM_CONDITIONAL(HAVE_FAKECHROOT, [test "$__FAKECHROOT" != "no"])
146
147 dnl see if we have a mkdir that supports `-p' for rpmbuild's purposes
148 AC_PROG_MKDIR_P
149 if ! echo $MKDIR_P | grep -q mkdir; then 
150   __MKDIR_P="`echo ${prefix}/lib/rpm/mkinstalldirs`"
151 else
152   __MKDIR_P=$MKDIR_P
153 fi
154 AC_DEFINE_UNQUOTED(__MKDIR_P, "${__MKDIR_P}",
155 [A full path to a program, possibly with arguments, that will create a
156    directory and all necessary parent directories, ala 'mkdir -p'])
157 AC_SUBST(__MKDIR_P)
158
159 #=================
160 # Check for zlib library. 
161
162 WITH_ZLIB_INCLUDE=
163 WITH_ZLIB_LIB=
164
165 AC_CHECK_HEADERS([zlib.h],[
166   AS_IF([test -z "${WITH_ZLIB_LIB}"],[
167     for zlib in z gz ; do
168       AC_CHECK_LIB(${zlib}, gzread, 
169         [WITH_ZLIB_LIB="-l${zlib}"; break])
170     done
171
172 dnl zlib-1.0.4 has not gzseek
173     AC_CHECK_LIB(${zlib}, gzseek, [AC_DEFINE(HAVE_GZSEEK, 1, [Define as 1 if your zlib has gzseek()])])
174   ])
175 ],[
176   AC_MSG_ERROR([missing required header zlib.h])
177 ])
178
179 AC_SUBST(WITH_ZLIB_INCLUDE)
180 AC_SUBST(WITH_ZLIB_LIB)
181
182 #=================
183 # Check for bzip2 library.
184
185 AC_CHECK_HEADERS([bzlib.h],[
186   AC_CHECK_LIB(bz2, BZ2_bzread, [WITH_BZ2_LIB=-lbz2])
187 ])
188 AC_SUBST(WITH_BZ2_LIB)
189
190 #=================
191 # Check for lzma library.
192
193 AC_CHECK_HEADERS([lzma.h],[
194   AC_CHECK_LIB(lzma, lzma_easy_encoder, [WITH_LZMA_LIB=-llzma])
195 ])
196 AC_SUBST(WITH_LZMA_LIB)
197
198 #=================
199
200 dnl
201 dnl Check for features
202 dnl
203
204 dnl Checks for libraries.
205
206 AC_CHECK_FUNC(gethostname, [], [
207     AC_CHECK_LIB(nsl, gethostname)
208 ])
209
210 AC_CHECK_HEADERS(pthread.h)
211
212 AC_CHECK_LIB(pthread, pthread_mutex_trylock, [], [
213   dnl OSF 5.0 has the the symbols prefixed with __ in libpthread.
214   AC_CHECK_LIB(pthread, __pthread_mutex_trylock, [], [
215     AC_CHECK_LIB(thread, mutex_lock)
216   ])
217 ])
218
219 AC_SEARCH_LIBS(dlopen, [dl])
220
221 #=================
222 # Check for libelf library. Prefer external, otherwise none.
223 WITH_LIBELF_LIB=
224 AC_CHECK_HEADER([libelf.h])
225 AC_CHECK_HEADERS([gelf.h], [
226         AC_CHECK_LIB(elf, gelf_getvernaux, [
227             AC_DEFINE(HAVE_LIBELF, 1, [Define to 1 if you have the 'elf' library (-lelf).])
228             WITH_LIBELF_LIB="-lelf"
229             WITH_LIBELF=yes
230         ])
231 ])
232 AC_SUBST(WITH_LIBELF_LIB)
233 AM_CONDITIONAL(LIBELF,[test "$WITH_LIBELF" = yes])
234
235 AC_CHECK_HEADERS([dwarf.h], [
236   WITH_LIBDWARF=yes
237 ])
238 AM_CONDITIONAL(LIBDWARF,[test "$WITH_LIBDWARF" = yes])
239
240 #=================
241 # Check for NSS library.
242 # We need nss.h from NSS which needs nspr.h. Unfortunately both glibc and NSS 
243 # have a header named nss.h... so make extra check for NSS's sechash.h 
244 # which we use too and hopefully is slightly more unique to NSS.
245 WITH_NSS_INCLUDE=
246 WITH_NSS_LIB=
247 AC_CHECK_HEADERS([nspr.h nss.h sechash.h], [], [
248   AC_MSG_ERROR([missing required NSPR / NSS header])
249 ])
250 AC_CHECK_LIB(nss3, NSS_NoDB_Init, [
251   WITH_NSS_LIB=-lnss3
252 ], [
253   AC_MSG_ERROR([missing required NSS library 'nss3'])
254 ])
255 AC_SUBST(WITH_NSS_INCLUDE)
256 AC_SUBST(WITH_NSS_LIB)
257
258 #=================
259 # Check for magic library.
260 WITH_MAGIC_INCLUDE=
261 WITH_MAGIC_LIB=
262
263 AC_CHECK_HEADER([magic.h], [
264     AC_CHECK_LIB(magic, magic_open, [
265       WITH_MAGIC_INCLUDE=
266       WITH_MAGIC_LIB="-lmagic"
267     ],[
268       AC_MSG_ERROR([missing required library 'libmagic']) 
269     ])
270 ],[
271       AC_MSG_ERROR([missing required header magic.h]) 
272 ])
273
274 AC_SUBST(WITH_MAGIC_INCLUDE)
275 AC_SUBST(WITH_MAGIC_LIB)
276
277 #=================
278 # Check for popt library.
279 WITH_POPT_INCLUDE=
280 WITH_POPT_LIB=
281
282 AC_CHECK_HEADER([popt.h], [
283   AC_CHECK_LIB(popt, poptGetContext, [
284       WITH_POPT_INCLUDE=
285       WITH_POPT_LIB="-lpopt"
286   ],[
287     AC_MSG_ERROR([missing required library popt])
288   ])
289 ],[
290   AC_MSG_ERROR([missing required header popt.h])
291 ])
292
293 AC_SUBST(WITH_POPT_INCLUDE)
294 AC_SUBST(WITH_POPT_LIB)
295
296 #=================
297 # Process --with/without-external-db
298 AC_ARG_WITH(external_db, [AS_HELP_STRING([--with-external-db],[build against an external Berkeley db])],
299 [case "$with_external_db" in
300 yes|no) ;;
301 *) AC_MSG_ERROR([invalid argument to --with-external-db]) ;;
302 esac],
303 [with_external_db=no])
304
305 case "$with_external_db" in
306 yes )
307   AC_CHECK_HEADERS([db.h],[
308     AC_PREPROC_IFELSE([
309       AC_LANG_SOURCE([
310         #include <db.h>
311         #if ((DB_VERSION_MAJOR < 4) || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 5))
312         #error Berkeley DB too old
313         #endif
314       ])
315     ],[ WITH_DB_LIB=-ldb ], 
316       [ AC_MSG_ERROR([Berkeley DB version >= 4.5 required])
317     ])
318   ],[
319     AC_MSG_ERROR([missing required header db.h])
320   ])
321   ;;
322 * ) # Fall back to internal db if available
323   if [ test -x db/dist/configure ]; then
324     AC_DEFINE(HAVE_DB_H, 1, [Define if you have the <db3/db.h> header file])
325   else
326     AC_MSG_ERROR([internal Berkeley DB directory not present, see INSTALL])
327   fi
328   ;;
329 esac
330
331 AC_SUBST([WITH_DB_LIB])
332
333 AM_GNU_GETTEXT_VERSION([0.16.1])
334 AM_GNU_GETTEXT([external])
335
336 dnl Checks for header files we can live without.
337 AC_HEADER_STDC
338 AC_HEADER_MAJOR
339 AC_STRUCT_DIRENT_D_TYPE
340
341 AC_CHECK_HEADERS(limits.h)
342 AC_CHECK_HEADERS(fcntl.h getopt.h)
343
344 AC_CHECK_HEADERS(sys/utsname.h)
345
346 AC_CHECK_HEADERS(sys/systemcfg.h)
347 AC_CHECK_HEADERS(sys/param.h)
348
349 AC_CHECK_HEADERS(glob.h)
350
351 dnl statfs portability fiddles.
352 dnl
353 dnl We should really emulate/steal sections of the statfs and struct statfs
354 dnl checks from GNU fileutils.
355 dnl
356 AC_MSG_CHECKING(for struct statfs)
357
358 dnl
359 dnl this is easier than nesting AC_TRY_COMPILEs...
360 dnl
361 found_struct_statfs=no
362
363 if test X$found_struct_statfs = Xno ; then
364 dnl Solaris 2.6+ wants to use statvfs
365 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
366 #ifdef HAVE_SYS_TYPES_H
367 #include <sys/types.h>
368 #endif
369 #include <sys/statvfs.h> ]], [[struct statvfs sfs;]])],[AC_MSG_RESULT(in sys/statvfs.h)
370         AC_DEFINE(STATFS_IN_SYS_STATVFS, 1,
371                 [statfs in <sys/statvfs.h> (for solaris 2.6+ systems)])
372         found_struct_statfs=yes],[])
373 fi
374
375 if test X$found_struct_statfs = Xno ; then
376 dnl first try including sys/vfs.h
377 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
378 #ifdef HAVE_SYS_TYPES_H
379 #include <sys/types.h>
380 #endif
381 #include <sys/vfs.h> ]], [[struct statfs sfs;]])],[AC_MSG_RESULT(in sys/vfs.h)
382         AC_DEFINE(STATFS_IN_SYS_VFS, 1, [statfs in <sys/vfs.h> (for linux systems)])
383         found_struct_statfs=yes],[])
384 fi
385
386 if test X$found_struct_statfs = Xno ; then
387 dnl ...next try including sys/mount.h
388 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
389 #ifdef HAVE_SYS_TYPES_H
390 #include <sys/types.h>
391 #endif
392 #ifdef HAVE_SYS_PARAM_H
393 #include <sys/param.h>
394 #endif
395 #include <sys/mount.h> ]], [[struct statfs sfs;]])],[AC_MSG_RESULT(in sys/mount.h)
396         AC_DEFINE(STATFS_IN_SYS_MOUNT, 1, [statfs in <sys/mount.h> (for Digital Unix 4.0D systems)])
397         found_struct_statfs=yes],[])
398 fi
399
400 if test X$found_struct_statfs = Xno ; then
401 dnl ...still no joy.  Try sys/statfs.h
402 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
403 #ifdef HAVE_SYS_TYPES_H
404 #include <sys/types.h>
405 #endif
406 #include <sys/statfs.h> ]], [[struct statfs sfs;]])],[AC_MSG_RESULT(in sys/statfs.h)
407         AC_DEFINE(STATFS_IN_SYS_STATFS, 1, [statfs in <sys/statfs.h> (for Irix 6.4 systems)])
408         found_struct_statfs=yes],[])
409 fi
410
411 if test X$found_struct_statfs = Xno ; then
412 dnl ...no luck.  Warn the user of impending doom.
413 AC_MSG_WARN(not found)
414 fi
415
416 dnl
417 dnl if we found the struct, see if it has the f_bavail member.  Some OSes
418 dnl don't, including IRIX 6.5+
419 dnl
420 if test X$found_struct_statfs = Xyes ; then
421 AC_MSG_CHECKING(for f_bavail member in struct statfs)
422 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
423 #ifdef HAVE_SYS_TYPES_H
424 #include <sys/types.h>
425 #endif
426 #if STATFS_IN_SYS_STATVFS
427 # include <sys/statvfs.h>
428   typedef struct statvfs STATFS_t;
429 #else
430   typedef struct statfs STATFS_t;
431 # if STATFS_IN_SYS_VFS
432 #  include <sys/vfs.h>
433 # elif STATFS_IN_SYS_MOUNT
434 #  include <sys/mount.h>
435 # elif STATFS_IN_SYS_STATFS
436 #  include <sys/statfs.h>
437 # endif
438 #endif ]], [[STATFS_t sfs;
439         sfs.f_bavail = 0;]])],[AC_MSG_RESULT(yes)
440         AC_DEFINE(STATFS_HAS_F_BAVAIL, 1, [Define if struct statfs has the f_bavail member])],[AC_MSG_RESULT(no)
441 ])
442 fi
443
444 if test X$found_struct_statfs = Xyes ; then
445 dnl
446 dnl now check to see if we have the 4-argument variant of statfs()
447 dnl this pretty much requires AC_RUN_IFELSE([AC_LANG_SOURCE([[]])],[],[],[])
448 dnl
449 AC_MSG_CHECKING([if statfs() requires 4 arguments])
450 AC_RUN_IFELSE([AC_LANG_SOURCE([[
451 #ifdef HAVE_SYS_TYPES_H
452 #include <sys/types.h>
453 #endif
454 #ifdef STATFS_IN_SYS_VFS
455 #include <sys/vfs.h>
456 #elif STATFS_IN_SYS_MOUNT
457 #include <sys/mouht.h>
458 #elif STATFS_IN_SYS_STATFS
459 #include <sys/statfs.h>
460 #endif
461 main() {
462         struct statfs sfs;
463         exit (statfs(".", &sfs, sizeof(sfs), 0));
464 }
465 ]])],[AC_MSG_RESULT(yes)
466         AC_DEFINE(STAT_STATFS4, 1, [Define if the statfs() call takes 4 arguments])],[AC_MSG_RESULT(no)],[AC_MSG_RESULT(no)
467 ])
468 fi
469
470 dnl look for libc features
471
472 dnl Check for missing typedefs
473 AC_TYPE_MODE_T
474 AC_TYPE_OFF_T
475 AC_TYPE_PID_T
476 AC_TYPE_SIZE_T
477
478 dnl Checks for library functions.
479 AC_FUNC_MMAP
480
481 AC_CHECK_FUNCS(putenv)
482
483 AC_REPLACE_FUNCS(stpcpy stpncpy)
484
485 AC_CHECK_FUNCS(__secure_getenv)
486
487 AC_CHECK_FUNCS(
488    [mkstemp getcwd basename dirname realpath setenv unsetenv regcomp lchown],
489    [], [AC_MSG_ERROR([function required by rpm])])
490
491 dnl XXX Glob *is* broken on linux with libc5, solaris and possibly aix when
492 dnl %files gets something like
493 dnl     /usr/*/locale/*/LC_MESSAGES/*.mo
494 dnl (Note: more than one asterisk in glob pattern.)
495 dnl
496 dnl XXX Glob is "fixed" in glibc-2.3.3-61, but the cost is that
497 dnl dangling symlinks are no longer globbed. Always use the internal glob.
498 AC_DEFINE(USE_GNU_GLOB, 1, [Use the included glob.c?])
499 AC_LIBOBJ(glob)
500 AC_LIBOBJ(fnmatch)
501
502 dnl check if python is requested
503 AC_ARG_ENABLE(python, [AS_HELP_STRING([--enable-python],[build rpm python bindings])],
504 [case "$enable_python" in
505 yes|no) ;;
506 *) AC_MSG_ERROR([invalid argument to --enable-python])
507   ;;
508 esac],
509 [enable_python=no])
510
511 AS_IF([test "$enable_python" = yes],[
512   AM_PATH_PYTHON([2.6],[
513     WITH_PYTHON_INCLUDE=`${PYTHON} -c 'from distutils.sysconfig import *; import sys; sys.stdout.write(get_python_inc())'`
514     WITH_PYTHON_SUBPACKAGE=1
515     save_CPPFLAGS="$CPPFLAGS"
516     CPPFLAGS="$CPPFLAGS -I$WITH_PYTHON_INCLUDE"
517     AC_CHECK_HEADER([Python.h],[],
518       [AC_MSG_ERROR([missing Python.h])
519       ])
520     CPPFLAGS="$save_CPPFLAGS"
521     save_LIBS="$LIBS"
522     AC_SEARCH_LIBS([Py_Main],[python${PYTHON_VERSION} python],[
523       WITH_PYTHON_LIB="$ac_res"
524     ],[AC_MSG_ERROR([missing python library])
525     ])
526     LIBS="$save_LIBS"
527   ])
528 ],[
529     WITH_PYTHON_INCLUDE=
530     WITH_PYTHON_LIB=
531     WITH_PYTHON_SUBPACKAGE=0
532 ])
533
534 AC_SUBST(WITH_PYTHON_INCLUDE)
535 AC_SUBST(WITH_PYTHON_LIB)
536
537 AM_CONDITIONAL(ENABLE_PYTHON,[test "$WITH_PYTHON_SUBPACKAGE" = 1])
538
539 AC_PATH_PROG(DOXYGEN, doxygen, no)
540 dnl
541 dnl Only build internal API + source hacking docs on request
542 dnl
543 AC_ARG_WITH(hackingdocs, [AS_HELP_STRING([--with-hackingdocs],[build rpm hacking docs])],,[with_hackingdocs=no])
544
545 case "$with_hackingdocs" in
546 auto)
547   AS_IF([test "$DOXYGEN" = no],[with_hackingdocs=no],[with_hackingdocs=no])
548   ;;
549 yes)
550   AS_IF([test "$DOXYGEN" = no],
551     [AC_MSG_ERROR([rpm hacking docs eeds doxygen in PATH])])
552   ;;
553 esac
554 AC_CHECK_PROG(HAVE_DOT,[dot],[YES],[NO])
555
556 WITH_SELINUX_LIB=
557 AC_ARG_WITH(selinux, [AS_HELP_STRING([--with-selinux],[build with selinux support])],
558 [case "$with_selinux" in
559 yes|no) ;;
560 *) AC_MSG_ERROR([invalid argument to --with-selinux])
561   ;;
562 esac],
563 [with_selinux=no])
564
565 AS_IF([test "$with_selinux" = yes],[
566   AC_CHECK_HEADER([selinux/selinux.h],[
567     save_LIBS="$LIBS"
568     AC_CHECK_LIB([selinux],[is_selinux_enabled],[],[
569       AC_MSG_ERROR([--with-selinux given, but is_selinux_enabled not found in libselinux])])
570     AC_CHECK_LIB([selinux],[selinux_getpolicytype],[],[
571       AC_MSG_ERROR([--with-selinux given, but selinux_getpolicytype not found in libselinux])])
572     AC_CHECK_LIB([selinux],[selinux_reset_config],[],[
573       AC_MSG_ERROR([--with-selinux given, but selinux_reset_config not found in libselinux])])
574     LIBS="$save_LIBS"
575   ],[
576     AC_MSG_ERROR([--with-selinux given, but selinux/selinux.h not found])
577   ])
578
579   AC_CHECK_HEADER([selinux/label.h],[
580     save_LIBS="$LIBS"
581     AC_CHECK_LIB([selinux],[selabel_close],[],[
582       AC_MSG_ERROR([--with-selinux given, but selabel_close not found in libselinux])])
583     AC_CHECK_LIB([selinux],[selabel_lookup_raw],[],[
584       AC_MSG_ERROR([--with-selinux given, but selabel_lookup_raw not found in libselinux])])
585     AC_CHECK_LIB([selinux],[selabel_open],[],[
586       AC_MSG_ERROR([--with-selinux given, but selabel_open not found in libselinux])])
587     LIBS="$save_LIBS"
588   ],[
589     AC_MSG_ERROR([--with-selinux given, but selinux/label.h not found])
590   ])
591
592   dnl FIXME: semanage is only needed for the sepolicy plugin
593   AC_CHECK_HEADER([semanage/semanage.h],[
594     save_LIBS="$LIBS"
595     AC_CHECK_LIB([semanage],[semanage_begin_transaction],[],[
596       AC_MSG_ERROR([--with-selinux given, but semanage_begin_transaction missing in libsemanage])])
597     AC_CHECK_LIB([semanage],[semanage_commit],[],[
598       AC_MSG_ERROR([--with-selinux given, but semanage_commit missing in libsemanage])])
599     AC_CHECK_LIB([semanage],[semanage_connect],[],[
600       AC_MSG_ERROR([--with-selinux given, but semanage_connect missing in libsemanage])])
601     AC_CHECK_LIB([semanage],[semanage_disconnect],[],[
602       AC_MSG_ERROR([--with-selinux given, but semanage_disconnect missing in libsemanage])])
603     AC_CHECK_LIB([semanage],[semanage_handle_create],[],[
604       AC_MSG_ERROR([--with-selinux given, but semanage_handle_create missing in libsemanage])])
605     AC_CHECK_LIB([semanage],[semanage_handle_destroy],[],[
606       AC_MSG_ERROR([--with-selinux given, but semanage_handle_destroy missing in libsemanage])])
607     AC_CHECK_LIB([semanage],[semanage_is_connected],[],[
608       AC_MSG_ERROR([--with-selinux given, but semanage_is_connected missing in libsemanage])])
609     AC_CHECK_LIB([semanage],[semanage_module_install_base_file],[],[
610       AC_MSG_ERROR([--with-selinux given, but semanage_module_install_base_file missing in libsemanage])])
611     AC_CHECK_LIB([semanage],[semanage_module_install_file],[],[
612       AC_MSG_ERROR([--with-selinux given, but semanage_module_install_file missing in libsemanage])])
613     AC_CHECK_LIB([semanage],[semanage_module_remove],[],[
614       AC_MSG_ERROR([--with-selinux given, but semanage_module_remove missing in libsemanage])])
615     AC_CHECK_LIB([semanage],[semanage_select_store],[],[
616       AC_MSG_ERROR([--with-selinux given, but semanage_select_store missing in libsemanage])])
617     AC_CHECK_LIB([semanage],[semanage_set_check_contexts],[],[
618       AC_MSG_ERROR([--with-selinux given, but semanage_set_check_contexts missing in libsemanage])])
619     AC_CHECK_LIB([semanage],[semanage_set_create_store],[],[
620       AC_MSG_ERROR([--with-selinux given, but semanage_set_create_store missing in libsemanage])])
621     AC_CHECK_LIB([semanage],[semanage_set_reload],[],[
622       AC_MSG_ERROR([--with-selinux given, but semanage_set_reload missing in libsemanage])])
623     LIBS="$save_LIBS"
624   ],[
625     AC_MSG_ERROR([--with-selinux given, but semanage/semanage.h not found])
626   ])
627 ])
628
629 AS_IF([test "$with_selinux" = yes],[
630   AC_DEFINE(WITH_SELINUX, 1, [Build with selinux support?])
631   WITH_SELINUX_LIB="-lselinux"
632   WITH_SEMANAGE_LIB="-lsemanage"
633 ])
634 AC_SUBST(WITH_SELINUX_LIB)
635 AC_SUBST(WITH_SEMANAGE_LIB)
636 AM_CONDITIONAL(SELINUX,[test "$with_selinux" = yes])
637
638 # libcap
639 WITH_CAP_LIB=
640 AC_ARG_WITH(cap, [AS_HELP_STRING([--with-cap],[build with capability support])],
641 [case "$with_cap" in
642 yes|no) ;;
643 *) AC_MSG_ERROR([invalid argument to --with-cap])
644   ;;
645 esac],
646 [with_cap=no])
647
648 AS_IF([test "$with_cap" = yes],[
649   AC_CHECK_HEADER([sys/capability.h],[
650     AC_CHECK_LIB(cap,[cap_get_file], [
651       with_cap=yes
652       save_LIBS="$LIBS"
653       AC_CHECK_LIB(cap,[cap_compare], [
654         AC_DEFINE(HAVE_CAP_COMPARE, 1, [Have cap_compare function?])
655       ])
656       LIBS="$save_LIBS"
657     ],[
658       AC_MSG_ERROR([--with-cap given, but libcap not found])])
659   ],[
660     AC_MSG_ERROR([--with-cap given, but sys/capability.h not found])
661   ])
662 ])
663
664 AS_IF([test "$with_cap" = yes],[
665   AC_DEFINE(WITH_CAP, 1, [Build with capability support?])
666   WITH_CAP_LIB="-lcap"
667 ])
668 AC_SUBST(WITH_CAP_LIB)
669 AM_CONDITIONAL(CAP,[test "$with_cap" = yes])
670
671 WITH_ACL_LIB=
672 AC_ARG_WITH(acl, [AS_HELP_STRING([--with-acl],[build with acl support])],
673 [case "$with_acl" in
674 yes|no) ;;
675 *) AC_MSG_ERROR([invalid argument to --with-acl])
676   ;;
677 esac],
678 [with_acl=no])
679
680 AS_IF([test "$with_acl" = yes],[
681   dnl verification uses non-portable acl_equiv_mode() 
682   AC_CHECK_HEADER([acl/libacl.h],[
683     AC_CHECK_LIB(acl,[acl_equiv_mode],[with_acl=yes],[
684       AC_MSG_ERROR([--with-acl given, but libacl not found or not suitable])])
685   ],[
686     AC_MSG_ERROR([--with-acl given, but acl/libacl.h not found])
687   ])
688 ])
689
690 AS_IF([test "$with_acl" = yes],[
691   AC_DEFINE(WITH_ACL, 1, [Build with acl support?])
692   WITH_ACL_LIB="-lacl"
693 ])
694 AC_SUBST(WITH_ACL_LIB)
695 AM_CONDITIONAL(ACL,[test "$with_acl" = yes])
696
697 AC_ARG_WITH([lua], [AS_HELP_STRING([--with-lua], [build with lua support])],
698             [],
699             [with_lua=yes])
700
701 AS_IF([test "$with_lua" != no],[
702   PKG_CHECK_MODULES([LUA],
703     [lua >= 5.1],
704     [AC_DEFINE(WITH_LUA, 1, [Build with lua support?])],
705     [AC_MSG_ERROR([lua not present (--without-lua to disable)])])
706   AC_SUBST(LUA_CFLAGS)
707   AC_SUBST(LUA_LIBS)
708 ])
709 AM_CONDITIONAL(WITH_LUA,[test "$with_lua" = yes])
710
711 AC_ARG_ENABLE(plugins, [AS_HELP_STRING([--disable-plugins],[build without plugin support])],,[enable_plugins=yes])
712 AS_IF([test "$enable_plugins" = yes],[
713   AC_DEFINE(ENABLE_PLUGINS, 1, [Build with plugin support?])
714 ])
715 AM_CONDITIONAL(ENABLE_PLUGINS,[test "$enable_plugins" = yes])
716
717
718 with_dmalloc=no
719 AC_ARG_WITH(dmalloc, [AS_HELP_STRING([--with-dmalloc],[build with dmalloc debugging support])])
720 if test "$with_dmalloc" = yes ; then
721   AC_DEFINE(DMALLOC, 1, [Build with dmalloc support?])
722   LIBS="$LIBS -ldmalloc"
723 fi
724
725 AC_CHECK_FUNCS(getpassphrase)
726
727 #
728 # get rid of the 4-th tuple, if config.guess returned "linux-gnu" for host_os
729 #
730 host_os_gnu=-gnu
731 if echo "$host_os" | grep '.*-gnulibc1' > /dev/null ; then
732         host_os=`echo "${host_os}" | sed 's/-gnulibc1$//'`
733 fi
734 if echo "$host_os" | grep '.*-gnueabi' > /dev/null ; then
735         host_os=`echo "${host_os}" | sed 's/-gnueabi$//'`
736         host_os_gnu=-gnueabi
737 fi
738 if echo "$host_os" | grep '.*-gnu' > /dev/null ; then
739         host_os=`echo "${host_os}" | sed 's/-gnu$//'`
740 fi
741
742 changequote(<, >)
743 host_os_exact="${host_os}"
744 host_os_major=`echo "${host_os}" | sed 's/\..*$//'`
745 host_os_noversion=`echo "${host_os}" | sed 's/[0-9]*\..*$//'`
746 changequote([, ])
747
748 for provscript in ${host_cpu}-${host_os_exact}.prov ${host_os_exact}.prov ${host_os_major}.prov ${host_os_noversion}.prov none ; do {
749     if test -f ${srcdir}/autodeps/${provscript} ; then
750        if [[ ${provscript} == none ]] ; then
751            echo "*** no default provides information is available for ${host_os_noversion}"
752        else
753            echo "using ${srcdir}/autodeps/${provscript} for automatic provides generation"
754        fi
755        ln -sf ${provscript} ${srcdir}/autodeps/find-provides
756        break
757     fi
758 }; done
759
760
761 for reqscript in ${host_cpu}-${host_os_exact}.req ${host_os_exact}.req ${host_os_major}.req ${host_os_noversion}.req none ; do {
762     if test -f ${srcdir}/autodeps/${reqscript} ; then
763        if [[ ${reqscript} == none ]] ; then
764            echo "*** no default requires information is available for ${host_os_noversion}"
765        else
766           echo "using ${srcdir}/autodeps/${reqscript} for automatic requires generation"
767        fi
768        ln -sf ${reqscript} ./autodeps/find-requires
769        break
770     fi
771 } done
772
773 dnl permit overriding build_vendor for "canonical rpm vendor"
774 RPMCANONVENDOR="$build_vendor"
775 AC_ARG_WITH([vendor], 
776   AS_HELP_STRING([--with-vendor=VENDOR], [specify rpm vendor name]),
777   [RPMCANONVENDOR=$withval])
778 AC_DEFINE_UNQUOTED([RPMCANONVENDOR],["${RPMCANONVENDOR}"],[canonical vendor])
779            
780 RPMCANONOS="$host_os_noversion"
781 RPMCANONGNU="$host_os_gnu"
782 AC_SUBST(RPMCANONVENDOR)
783 AC_SUBST(RPMCANONOS)
784 AC_SUBST(RPMCANONGNU)
785
786 if test X"$prefix" = XNONE ; then
787     usrprefix="$ac_default_prefix"
788 else
789     usrprefix=$prefix
790 fi
791
792 RPMCONFIGDIR="`echo ${usrprefix}/lib/rpm`"
793 AC_SUBST(RPMCONFIGDIR)
794
795 AC_SUBST(OBJDUMP)
796
797 if test "$with_external_db" = no; then
798     AC_CONFIG_SUBDIRS(db3)
799 fi
800
801 AM_CONDITIONAL([WITH_INTERNAL_DB],[test "$with_external_db" = no])
802 AM_CONDITIONAL([DOXYGEN],[test "$DOXYGEN" != no])
803 AM_CONDITIONAL([HACKINGDOCS],[test "$with_hackingdocs" = yes])
804
805 AC_PATH_PROG(AUTOM4TE,autom4te,:)
806
807 AC_SUBST([dirstamp],[\${am__leading_dot}dirstamp])
808
809 AC_CONFIG_FILES([Makefile
810         rpmio/Makefile lib/Makefile build/Makefile sign/Makefile
811         po/Makefile.in scripts/Makefile fileattrs/Makefile
812         misc/Makefile 
813         doc/Makefile
814         python/Makefile
815         luaext/Makefile
816         tests/Makefile
817         plugins/Makefile
818         python/setup.py
819   ])
820 AC_OUTPUT