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