Preparing for 4.9.1.1
[platform/upstream/rpm.git] / configure.ac
1 AC_PREREQ(2.61)
2 AC_INIT(rpm, 4.9.1.1, 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 -Wno-unused-but-set-variable"
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 AC_PATH_PROG(__FAKECHROOT, fakechroot, /usr/bin/fakechroot, $MYPATH)
144
145 dnl see if we have a mkdir that supports `-p' for rpmbuild's purposes
146 AC_PROG_MKDIR_P
147 if ! echo $MKDIR_P | grep -q mkdir; then 
148   __MKDIR_P="`echo ${prefix}/lib/rpm/mkinstalldirs`"
149 else
150   __MKDIR_P=$MKDIR_P
151 fi
152 AC_DEFINE_UNQUOTED(__MKDIR_P, "${__MKDIR_P}",
153 [A full path to a program, possibly with arguments, that will create a
154    directory and all necessary parent directories, ala 'mkdir -p'])
155 AC_SUBST(__MKDIR_P)
156
157 #=================
158 # Check for zlib library. 
159
160 WITH_ZLIB_INCLUDE=
161 WITH_ZLIB_LIB=
162
163 AC_CHECK_HEADERS([zlib.h],[
164   AS_IF([test -z "${WITH_ZLIB_LIB}"],[
165     for zlib in z gz ; do
166       AC_CHECK_LIB(${zlib}, gzread, 
167         [WITH_ZLIB_LIB="-l${zlib}"; break])
168     done
169
170 dnl zlib-1.0.4 has not gzseek
171     AC_CHECK_LIB(${zlib}, gzseek, [AC_DEFINE(HAVE_GZSEEK, 1, [Define as 1 if your zlib has gzseek()])])
172   ])
173 ],[
174   AC_MSG_ERROR([missing required header zlib.h])
175 ])
176
177 AC_SUBST(WITH_ZLIB_INCLUDE)
178 AC_SUBST(WITH_ZLIB_LIB)
179
180 #=================
181 # Check for bzip2 library.
182
183 AC_CHECK_HEADERS([bzlib.h],[
184   AC_CHECK_LIB(bz2, bzread, [WITH_BZ2_LIB=-lbz2],
185   [
186     AC_CHECK_LIB(bz2, BZ2_bzread,[ 
187       WITH_BZ2_LIB="-lbz2"
188       AC_DEFINE(HAVE_BZ2_1_0, 1, [Define as 1 if you bzip2 1.0])
189     ]) 
190   ])
191 ])
192 AC_SUBST(WITH_BZ2_LIB)
193
194 #=================
195 # Check for lzma library.
196
197 AC_CHECK_HEADERS([lzma.h],[
198   AC_CHECK_LIB(lzma, lzma_easy_encoder, [WITH_LZMA_LIB=-llzma])
199 ])
200 AC_SUBST(WITH_LZMA_LIB)
201
202 #=================
203
204 dnl
205 dnl Check for features
206 dnl
207
208 dnl Checks for libraries.
209
210 AC_CHECK_FUNC(gethostname, [], [
211     AC_CHECK_LIB(nsl, gethostname)
212 ])
213
214 AC_CHECK_HEADERS(poll.h)
215
216 AC_CHECK_HEADERS(pthread.h)
217
218 AC_CHECK_LIB(pthread, pthread_mutex_trylock, [], [
219   dnl OSF 5.0 has the the symbols prefixed with __ in libpthread.
220   AC_CHECK_LIB(pthread, __pthread_mutex_trylock, [], [
221     AC_CHECK_LIB(thread, mutex_lock)
222   ])
223 ])
224
225 AC_SEARCH_LIBS(aio_read, [c rt aio posix4])
226 AC_SEARCH_LIBS(dlopen, [dl])
227
228 dnl Temporary hack for MiNT.  Some functions (writev, snprintf) are
229 dnl not in the libc but in libport (for political reasons).  This check
230 dnl can hopefully be removed soon.  Please use the default action
231 dnl for this macro (not LIBS=...), otherwise the check for dbopen
232 dnl will fail.
233 AC_CHECK_LIB(port, writev)
234
235 #=================
236 # Check for libelf library. Prefer external, otherwise none.
237 WITH_LIBELF_LIB=
238 AC_CHECK_HEADER([libelf.h])
239 AC_CHECK_HEADERS([gelf.h], [
240         AC_CHECK_LIB(elf, gelf_getvernaux, [
241             AC_DEFINE(HAVE_LIBELF, 1, [Define to 1 if you have the 'elf' library (-lelf).])
242             WITH_LIBELF_LIB="-lelf"
243             WITH_LIBELF=yes
244         ])
245 ])
246 AC_SUBST(WITH_LIBELF_LIB)
247 AM_CONDITIONAL(LIBELF,[test "$WITH_LIBELF" = yes])
248
249 AC_CHECK_HEADERS([dwarf.h], [
250   WITH_LIBDWARF=yes
251 ])
252 AM_CONDITIONAL(LIBDWARF,[test "$WITH_LIBDWARF" = yes])
253
254 #=================
255 # Check for NSS library.
256 # We need nss.h from NSS which needs nspr.h. Unfortunately both glibc and NSS 
257 # have a header named nss.h... so make extra check for NSS's sechash.h 
258 # which we use too and hopefully is slightly more unique to NSS.
259 WITH_NSS_INCLUDE=
260 WITH_NSS_LIB=
261 AC_CHECK_HEADERS([nspr.h nss.h sechash.h], [], [
262   AC_MSG_ERROR([missing required NSPR / NSS header])
263 ])
264 AC_CHECK_LIB(nss3, NSS_NoDB_Init, [
265   WITH_NSS_LIB=-lnss3
266 ], [
267   AC_MSG_ERROR([missing required NSS library 'nss3'])
268 ])
269 AC_SUBST(WITH_NSS_INCLUDE)
270 AC_SUBST(WITH_NSS_LIB)
271
272 #=================
273 # Check for magic library.
274 WITH_MAGIC_INCLUDE=
275 WITH_MAGIC_LIB=
276
277 AC_CHECK_HEADER([magic.h], [
278     AC_CHECK_LIB(magic, magic_open, [
279       WITH_MAGIC_INCLUDE=
280       WITH_MAGIC_LIB="-lmagic"
281     ],[
282       AC_MSG_ERROR([missing required library 'libmagic']) 
283     ])
284 ],[
285       AC_MSG_ERROR([missing required header magic.h]) 
286 ])
287
288 AC_SUBST(WITH_MAGIC_INCLUDE)
289 AC_SUBST(WITH_MAGIC_LIB)
290
291 #=================
292 # Check for popt library.
293 WITH_POPT_INCLUDE=
294 WITH_POPT_LIB=
295
296 AC_CHECK_HEADER([popt.h], [
297   AC_CHECK_LIB(popt, poptGetContext, [
298       WITH_POPT_INCLUDE=
299       WITH_POPT_LIB="-lpopt"
300   ],[
301     AC_MSG_ERROR([missing required library popt])
302   ])
303 ],[
304   AC_MSG_ERROR([missing required header popt.h])
305 ])
306
307 AC_SUBST(WITH_POPT_INCLUDE)
308 AC_SUBST(WITH_POPT_LIB)
309
310 #=================
311 # Process --with/without-external-db
312 AC_ARG_WITH(external_db, [AS_HELP_STRING([--with-external-db],[build against an external Berkeley db])],
313 [case "$with_external_db" in
314 yes|no) ;;
315 *) AC_MSG_ERROR([invalid argument to --with-external-db]) ;;
316 esac],
317 [with_external_db=no])
318
319 case "$with_external_db" in
320 yes )
321   AC_CHECK_HEADERS([db.h],[
322     AC_PREPROC_IFELSE([
323       AC_LANG_SOURCE([
324         #include <db.h>
325         #if ((DB_VERSION_MAJOR < 4) || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 5))
326         #error Berkeley DB too old
327         #endif
328       ])
329     ],[ WITH_DB_LIB=-ldb ], 
330       [ AC_MSG_ERROR([Berkeley DB version >= 4.5 required])
331     ])
332   ],[
333     AC_MSG_ERROR([missing required header db.h])
334   ])
335   ;;
336 * ) # Fall back to internal db if available
337   if [ test -x db/dist/configure ]; then
338     AC_DEFINE(HAVE_DB_H, 1, [Define if you have the <db3/db.h> header file])
339   else
340     AC_MSG_ERROR([internal Berkeley DB directory not present, see INSTALL])
341   fi
342   ;;
343 esac
344
345 AC_SUBST([WITH_DB_LIB])
346
347 AM_GNU_GETTEXT_VERSION([0.16.1])
348 AM_GNU_GETTEXT([external])
349
350 dnl Checks for header files we can live without.
351 AC_HEADER_STDC
352 AC_HEADER_MAJOR
353 AC_STRUCT_DIRENT_D_TYPE
354
355 AC_CHECK_HEADERS(limits.h)
356 AC_CHECK_HEADERS(fcntl.h getopt.h memory.h)
357
358 AC_CHECK_HEADERS(sys/ipc.h)
359 AC_CHECK_HEADERS(sys/utsname.h)
360
361 AC_CHECK_HEADERS(sys/systemcfg.h)
362 AC_CHECK_HEADERS(sys/param.h)
363 AC_CHECK_HEADERS(libio.h)
364 AC_CHECK_HEADERS(mcheck.h)
365
366 AC_CHECK_HEADERS(glob.h)
367
368 dnl statfs portability fiddles.
369 dnl
370 dnl We should really emulate/steal sections of the statfs and struct statfs
371 dnl checks from GNU fileutils.
372 dnl
373 AC_MSG_CHECKING(for struct statfs)
374
375 dnl
376 dnl this is easier than nesting AC_TRY_COMPILEs...
377 dnl
378 found_struct_statfs=no
379
380 if test X$found_struct_statfs = Xno ; then
381 dnl Solaris 2.6+ wants to use statvfs
382 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
383 #ifdef HAVE_SYS_TYPES_H
384 #include <sys/types.h>
385 #endif
386 #include <sys/statvfs.h> ]], [[struct statvfs sfs;]])],[AC_MSG_RESULT(in sys/statvfs.h)
387         AC_DEFINE(STATFS_IN_SYS_STATVFS, 1,
388                 [statfs in <sys/statvfs.h> (for solaris 2.6+ systems)])
389         found_struct_statfs=yes],[])
390 fi
391
392 if test X$found_struct_statfs = Xno ; then
393 dnl first try including sys/vfs.h
394 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
395 #ifdef HAVE_SYS_TYPES_H
396 #include <sys/types.h>
397 #endif
398 #include <sys/vfs.h> ]], [[struct statfs sfs;]])],[AC_MSG_RESULT(in sys/vfs.h)
399         AC_DEFINE(STATFS_IN_SYS_VFS, 1, [statfs in <sys/vfs.h> (for linux systems)])
400         found_struct_statfs=yes],[])
401 fi
402
403 if test X$found_struct_statfs = Xno ; then
404 dnl ...next try including sys/mount.h
405 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
406 #ifdef HAVE_SYS_TYPES_H
407 #include <sys/types.h>
408 #endif
409 #ifdef HAVE_SYS_PARAM_H
410 #include <sys/param.h>
411 #endif
412 #include <sys/mount.h> ]], [[struct statfs sfs;]])],[AC_MSG_RESULT(in sys/mount.h)
413         AC_DEFINE(STATFS_IN_SYS_MOUNT, 1, [statfs in <sys/mount.h> (for Digital Unix 4.0D systems)])
414         found_struct_statfs=yes],[])
415 fi
416
417 if test X$found_struct_statfs = Xno ; then
418 dnl ...still no joy.  Try sys/statfs.h
419 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
420 #ifdef HAVE_SYS_TYPES_H
421 #include <sys/types.h>
422 #endif
423 #include <sys/statfs.h> ]], [[struct statfs sfs;]])],[AC_MSG_RESULT(in sys/statfs.h)
424         AC_DEFINE(STATFS_IN_SYS_STATFS, 1, [statfs in <sys/statfs.h> (for Irix 6.4 systems)])
425         found_struct_statfs=yes],[])
426 fi
427
428 if test X$found_struct_statfs = Xno ; then
429 dnl ...no luck.  Warn the user of impending doom.
430 AC_MSG_WARN(not found)
431 fi
432
433 dnl
434 dnl if we found the struct, see if it has the f_bavail member.  Some OSes
435 dnl don't, including IRIX 6.5+
436 dnl
437 if test X$found_struct_statfs = Xyes ; then
438 AC_MSG_CHECKING(for f_bavail member in struct statfs)
439 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
440 #ifdef HAVE_SYS_TYPES_H
441 #include <sys/types.h>
442 #endif
443 #if STATFS_IN_SYS_STATVFS
444 # include <sys/statvfs.h>
445   typedef struct statvfs STATFS_t;
446 #else
447   typedef struct statfs STATFS_t;
448 # if STATFS_IN_SYS_VFS
449 #  include <sys/vfs.h>
450 # elif STATFS_IN_SYS_MOUNT
451 #  include <sys/mount.h>
452 # elif STATFS_IN_SYS_STATFS
453 #  include <sys/statfs.h>
454 # endif
455 #endif ]], [[STATFS_t sfs;
456         sfs.f_bavail = 0;]])],[AC_MSG_RESULT(yes)
457         AC_DEFINE(STATFS_HAS_F_BAVAIL, 1, [Define if struct statfs has the f_bavail member])],[AC_MSG_RESULT(no)
458 ])
459 fi
460
461 if test X$found_struct_statfs = Xyes ; then
462 dnl
463 dnl now check to see if we have the 4-argument variant of statfs()
464 dnl this pretty much requires AC_RUN_IFELSE([AC_LANG_SOURCE([[]])],[],[],[])
465 dnl
466 AC_MSG_CHECKING([if statfs() requires 4 arguments])
467 AC_RUN_IFELSE([AC_LANG_SOURCE([[
468 #ifdef HAVE_SYS_TYPES_H
469 #include <sys/types.h>
470 #endif
471 #ifdef STATFS_IN_SYS_VFS
472 #include <sys/vfs.h>
473 #elif STATFS_IN_SYS_MOUNT
474 #include <sys/mouht.h>
475 #elif STATFS_IN_SYS_STATFS
476 #include <sys/statfs.h>
477 #endif
478 main() {
479         struct statfs sfs;
480         exit (statfs(".", &sfs, sizeof(sfs), 0));
481 }
482 ]])],[AC_MSG_RESULT(yes)
483         AC_DEFINE(STAT_STATFS4, 1, [Define if the statfs() call takes 4 arguments])],[AC_MSG_RESULT(no)],[AC_MSG_RESULT(no)
484 ])
485 fi
486
487 dnl look for libc features
488
489 dnl Check for missing typedefs
490 AC_TYPE_MODE_T
491 AC_TYPE_OFF_T
492 AC_TYPE_PID_T
493 AC_TYPE_SIZE_T
494
495 dnl Checks for library functions.
496 AC_FUNC_MMAP
497
498 AC_CHECK_FUNCS(mtrace)
499 AC_CHECK_FUNCS(putenv)
500
501 AC_REPLACE_FUNCS(stpcpy stpncpy)
502
503 AC_CHECK_FUNCS(__secure_getenv)
504
505 AC_CHECK_FUNCS(
506    [mkstemp getcwd basename dirname realpath setenv unsetenv regcomp lchown],
507    [], [AC_MSG_ERROR([function required by rpm])])
508
509 dnl XXX Glob *is* broken on linux with libc5, solaris and possibly aix when
510 dnl %files gets something like
511 dnl     /usr/*/locale/*/LC_MESSAGES/*.mo
512 dnl (Note: more than one asterisk in glob pattern.)
513 dnl
514 dnl XXX Glob is "fixed" in glibc-2.3.3-61, but the cost is that
515 dnl dangling symlinks are no longer globbed. Always use the internal glob.
516 AC_DEFINE(USE_GNU_GLOB, 1, [Use the included glob.c?])
517 AC_LIBOBJ(glob)
518 AC_LIBOBJ(fnmatch)
519
520 dnl check if python is requested
521 AC_ARG_ENABLE(python, [AS_HELP_STRING([--enable-python],[build rpm python bindings])],
522 [case "$enable_python" in
523 yes|no) ;;
524 *) AC_MSG_ERROR([invalid argument to --enable-python])
525   ;;
526 esac],
527 [enable_python=no])
528
529 AS_IF([test "$enable_python" = yes],[
530   AM_PATH_PYTHON([2.6],[
531     WITH_PYTHON_INCLUDE=`${PYTHON} -c 'from distutils.sysconfig import *; import sys; sys.stdout.write(get_python_inc())'`
532     WITH_PYTHON_SUBPACKAGE=1
533     save_CPPFLAGS="$CPPFLAGS"
534     CPPFLAGS="$CPPFLAGS -I$WITH_PYTHON_INCLUDE"
535     AC_CHECK_HEADER([Python.h],[],
536       [AC_MSG_ERROR([missing Python.h])
537       ])
538     CPPFLAGS="$save_CPPFLAGS"
539     save_LIBS="$LIBS"
540     AC_SEARCH_LIBS([Py_Main],[python${PYTHON_VERSION} python],[
541       WITH_PYTHON_LIB="$ac_res"
542     ],[AC_MSG_ERROR([missing python library])
543     ])
544     LIBS="$save_LIBS"
545   ])
546 ],[
547     WITH_PYTHON_INCLUDE=
548     WITH_PYTHON_LIB=
549     WITH_PYTHON_SUBPACKAGE=0
550 ])
551
552 AC_SUBST(WITH_PYTHON_INCLUDE)
553 AC_SUBST(WITH_PYTHON_LIB)
554
555 AM_CONDITIONAL(ENABLE_PYTHON,[test "$WITH_PYTHON_SUBPACKAGE" = 1])
556
557 AC_PATH_PROG(DOXYGEN, doxygen, no)
558 dnl
559 dnl Only build internal API + source hacking docs on request
560 dnl
561 AC_ARG_WITH(hackingdocs, [AS_HELP_STRING([--with-hackingdocs],[build rpm hacking docs])],,[with_hackingdocs=no])
562
563 case "$with_hackingdocs" in
564 auto)
565   AS_IF([test "$DOXYGEN" = no],[with_hackingdocs=no],[with_hackingdocs=no])
566   ;;
567 yes)
568   AS_IF([test "$DOXYGEN" = no],
569     [AC_MSG_ERROR([rpm hacking docs eeds doxygen in PATH])])
570   ;;
571 esac
572 AC_CHECK_PROG(HAVE_DOT,[dot],[YES],[NO])
573
574 WITH_SELINUX_LIB=
575 AC_ARG_WITH(selinux, [AS_HELP_STRING([--with-selinux],[build with selinux support])],
576 [case "$with_selinux" in
577 yes|no) ;;
578 *) AC_MSG_ERROR([invalid argument to --with-selinux])
579   ;;
580 esac],
581 [with_selinux=no])
582
583 AS_IF([test "$with_selinux" = yes],[
584   AC_CHECK_HEADER([selinux/selinux.h],[
585     save_LIBS="$LIBS"
586     AC_CHECK_LIB([selinux],[is_selinux_enabled],[],[
587       AC_MSG_ERROR([--with-selinux given, but is_selinux_enabled not found in libselinux])])
588     AC_CHECK_LIB([selinux],[selinux_getpolicytype],[],[
589       AC_MSG_ERROR([--with-selinux given, but selinux_getpolicytype not found in libselinux])])
590     AC_CHECK_LIB([selinux],[selinux_reset_config],[],[
591       AC_MSG_ERROR([--with-selinux given, but selinux_reset_config not found in libselinux])])
592     LIBS="$save_LIBS"
593   ],[
594     AC_MSG_ERROR([--with-selinux given, but selinux/selinux.h not found])
595   ])
596
597   AC_CHECK_HEADER([selinux/label.h],[
598     save_LIBS="$LIBS"
599     AC_CHECK_LIB([selinux],[selabel_close],[],[
600       AC_MSG_ERROR([--with-selinux given, but selabel_close not found in libselinux])])
601     AC_CHECK_LIB([selinux],[selabel_lookup_raw],[],[
602       AC_MSG_ERROR([--with-selinux given, but selabel_lookup_raw not found in libselinux])])
603     AC_CHECK_LIB([selinux],[selabel_open],[],[
604       AC_MSG_ERROR([--with-selinux given, but selabel_open not found in libselinux])])
605     LIBS="$save_LIBS"
606   ],[
607     AC_MSG_ERROR([--with-selinux given, but selinux/label.h not found])
608   ])
609
610   dnl FIXME: semanage is only needed for the sepolicy plugin
611   AC_CHECK_HEADER([semanage/semanage.h],[
612     save_LIBS="$LIBS"
613     AC_CHECK_LIB([semanage],[semanage_begin_transaction],[],[
614       AC_MSG_ERROR([--with-selinux given, but semanage_begin_transaction missing in libsemanage])])
615     AC_CHECK_LIB([semanage],[semanage_commit],[],[
616       AC_MSG_ERROR([--with-selinux given, but semanage_commit missing in libsemanage])])
617     AC_CHECK_LIB([semanage],[semanage_connect],[],[
618       AC_MSG_ERROR([--with-selinux given, but semanage_connect missing in libsemanage])])
619     AC_CHECK_LIB([semanage],[semanage_disconnect],[],[
620       AC_MSG_ERROR([--with-selinux given, but semanage_disconnect missing in libsemanage])])
621     AC_CHECK_LIB([semanage],[semanage_handle_create],[],[
622       AC_MSG_ERROR([--with-selinux given, but semanage_handle_create missing in libsemanage])])
623     AC_CHECK_LIB([semanage],[semanage_handle_destroy],[],[
624       AC_MSG_ERROR([--with-selinux given, but semanage_handle_destroy missing in libsemanage])])
625     AC_CHECK_LIB([semanage],[semanage_is_connected],[],[
626       AC_MSG_ERROR([--with-selinux given, but semanage_is_connected missing in libsemanage])])
627     AC_CHECK_LIB([semanage],[semanage_module_install_base_file],[],[
628       AC_MSG_ERROR([--with-selinux given, but semanage_module_install_base_file missing in libsemanage])])
629     AC_CHECK_LIB([semanage],[semanage_module_install_file],[],[
630       AC_MSG_ERROR([--with-selinux given, but semanage_module_install_file missing in libsemanage])])
631     AC_CHECK_LIB([semanage],[semanage_module_remove],[],[
632       AC_MSG_ERROR([--with-selinux given, but semanage_module_remove missing in libsemanage])])
633     AC_CHECK_LIB([semanage],[semanage_select_store],[],[
634       AC_MSG_ERROR([--with-selinux given, but semanage_select_store missing in libsemanage])])
635     AC_CHECK_LIB([semanage],[semanage_set_check_contexts],[],[
636       AC_MSG_ERROR([--with-selinux given, but semanage_set_check_contexts missing in libsemanage])])
637     AC_CHECK_LIB([semanage],[semanage_set_create_store],[],[
638       AC_MSG_ERROR([--with-selinux given, but semanage_set_create_store missing in libsemanage])])
639     AC_CHECK_LIB([semanage],[semanage_set_reload],[],[
640       AC_MSG_ERROR([--with-selinux given, but semanage_set_reload missing in libsemanage])])
641     LIBS="$save_LIBS"
642   ],[
643     AC_MSG_ERROR([--with-selinux given, but semanage/semanage.h not found])
644   ])
645 ])
646
647 AS_IF([test "$with_selinux" = yes],[
648   AC_DEFINE(WITH_SELINUX, 1, [Build with selinux support?])
649   WITH_SELINUX_LIB="-lselinux"
650   WITH_SEMANAGE_LIB="-lsemanage"
651 ])
652 AC_SUBST(WITH_SELINUX_LIB)
653 AC_SUBST(WITH_SEMANAGE_LIB)
654 AM_CONDITIONAL(SELINUX,[test "$with_selinux" = yes])
655
656 # libcap
657 WITH_CAP_LIB=
658 AC_ARG_WITH(cap, [AS_HELP_STRING([--with-cap],[build with capability support])],
659 [case "$with_cap" in
660 yes|no) ;;
661 *) AC_MSG_ERROR([invalid argument to --with-cap])
662   ;;
663 esac],
664 [with_cap=no])
665
666 AS_IF([test "$with_cap" = yes],[
667   AC_CHECK_HEADER([sys/capability.h],[
668     AC_CHECK_LIB(cap,[cap_get_file], [
669       with_cap=yes
670       save_LIBS="$LIBS"
671       AC_CHECK_LIB(cap,[cap_compare], [
672         AC_DEFINE(HAVE_CAP_COMPARE, 1, [Have cap_compare function?])
673       ])
674       LIBS="$save_LIBS"
675     ],[
676       AC_MSG_ERROR([--with-cap given, but libcap not found])])
677   ],[
678     AC_MSG_ERROR([--with-cap given, but sys/capability.h not found])
679   ])
680 ])
681
682 AS_IF([test "$with_cap" = yes],[
683   AC_DEFINE(WITH_CAP, 1, [Build with capability support?])
684   WITH_CAP_LIB="-lcap"
685 ])
686 AC_SUBST(WITH_CAP_LIB)
687 AM_CONDITIONAL(CAP,[test "$with_cap" = yes])
688
689 WITH_ACL_LIB=
690 AC_ARG_WITH(acl, [AS_HELP_STRING([--with-acl],[build with acl support])],
691 [case "$with_acl" in
692 yes|no) ;;
693 *) AC_MSG_ERROR([invalid argument to --with-acl])
694   ;;
695 esac],
696 [with_acl=no])
697
698 AS_IF([test "$with_acl" = yes],[
699   dnl verification uses non-portable acl_equiv_mode() 
700   AC_CHECK_HEADER([acl/libacl.h],[
701     AC_CHECK_LIB(acl,[acl_equiv_mode],[with_acl=yes],[
702       AC_MSG_ERROR([--with-acl given, but libacl not found or not suitable])])
703   ],[
704     AC_MSG_ERROR([--with-acl given, but acl/libacl.h not found])
705   ])
706 ])
707
708 AS_IF([test "$with_acl" = yes],[
709   AC_DEFINE(WITH_ACL, 1, [Build with acl support?])
710   WITH_ACL_LIB="-lacl"
711 ])
712 AC_SUBST(WITH_ACL_LIB)
713 AM_CONDITIONAL(ACL,[test "$with_acl" = yes])
714
715 AC_ARG_WITH([lua], [AS_HELP_STRING([--with-lua], [build with lua support])],
716             [],
717             [with_lua=yes])
718
719 AS_IF([test "$with_lua" != no],[
720   PKG_CHECK_MODULES([LUA],
721     [lua >= 5.1],
722     [AC_DEFINE(WITH_LUA, 1, [Build with lua support?])],
723     [AC_MSG_ERROR([lua not present (--without-lua to disable)])])
724   AC_SUBST(LUA_CFLAGS)
725   AC_SUBST(LUA_LIBS)
726 ])
727 AM_CONDITIONAL(WITH_LUA,[test "$with_lua" = yes])
728
729 AC_ARG_ENABLE(plugins, [AS_HELP_STRING([--disable-plugins],[build without plugin support])],,[enable_plugins=yes])
730 AS_IF([test "$enable_plugins" = yes],[
731   AC_DEFINE(ENABLE_PLUGINS, 1, [Build with plugin support?])
732 ])
733 AM_CONDITIONAL(ENABLE_PLUGINS,[test "$enable_plugins" = yes])
734
735
736 with_dmalloc=no
737 AC_ARG_WITH(dmalloc, [AS_HELP_STRING([--with-dmalloc],[build with dmalloc debugging support])])
738 if test "$with_dmalloc" = yes ; then
739   AC_DEFINE(DMALLOC, 1, [Build with dmalloc support?])
740   LIBS="$LIBS -ldmalloc"
741 fi
742
743 AC_CHECK_FUNCS(getpassphrase)
744
745 #
746 # get rid of the 4-th tuple, if config.guess returned "linux-gnu" for host_os
747 #
748 host_os_gnu=-gnu
749 if echo "$host_os" | grep '.*-gnulibc1' > /dev/null ; then
750         host_os=`echo "${host_os}" | sed 's/-gnulibc1$//'`
751 fi
752 if echo "$host_os" | grep '.*-gnueabi' > /dev/null ; then
753         host_os=`echo "${host_os}" | sed 's/-gnueabi$//'`
754         host_os_gnu=-gnueabi
755 fi
756 if echo "$host_os" | grep '.*-gnu' > /dev/null ; then
757         host_os=`echo "${host_os}" | sed 's/-gnu$//'`
758 fi
759
760 changequote(<, >)
761 host_os_exact="${host_os}"
762 host_os_major=`echo "${host_os}" | sed 's/\..*$//'`
763 host_os_noversion=`echo "${host_os}" | sed 's/[0-9]*\..*$//'`
764 changequote([, ])
765
766 rm -f ./find-provides
767 if test -f ${srcdir}/autodeps/${host_cpu}-${host_os_exact}.prov ; then
768         echo "using ${srcdir}/autodeps/${host_cpu}-${host_os_exact}.prov for automatic provides generation"
769     ln -s ${srcdir}/autodeps/${host_cpu}-${host_os_exact}.prov ./find-provides
770 elif test -f ${srcdir}/autodeps/${host_os_exact}.prov ; then
771         echo "using ${srcdir}/autodeps/${host_os_exact}.prov for automatic provides generation"
772     ln -s ${srcdir}/autodeps/${host_os_exact}.prov ./find-provides
773 elif test -f ${srcdir}/autodeps/${host_os_major}.prov ; then
774         echo "using ${srcdir}/autodeps/${host_os_major}.prov for automatic provides generation"
775     ln -s ${srcdir}/autodeps/${host_os_major}.prov ./find-provides
776 elif test -f ${srcdir}/autodeps/${host_os_noversion}.prov ; then
777         echo "using ${srcdir}/autodeps/${host_os_noversion}.prov for automatic provides generation"
778     ln -s ${srcdir}/autodeps/${host_os_noversion}.prov ./find-provides
779 else
780     echo "*** no default provides information is available for ${host_os_noversion}"
781     ln -s ${srcdir}/autodeps/none ./find-provides
782 fi
783
784 rm -f ./find-requires
785 if test -f ${srcdir}/autodeps/${host_cpu}-${host_os_exact}.req ; then
786         echo "using ${srcdir}/autodeps/${host_cpu}-${host_os_exact}.req for automatic requires generation"
787     ln -s ${srcdir}/autodeps/${host_cpu}-${host_os_exact}.req ./find-requires
788 elif test -f ${srcdir}/autodeps/${host_os_exact}.req ; then
789         echo "using ${srcdir}/autodeps/${host_os_exact}.req for automatic requires generation"
790     ln -s ${srcdir}/autodeps/${host_os_exact}.req ./find-requires
791 elif test -f ${srcdir}/autodeps/${host_os_major}.req ; then
792         echo "using ${srcdir}/autodeps/${host_os_major}.req for automatic requires generation"
793     ln -s ${srcdir}/autodeps/${host_os_major}.req ./find-requires
794 elif test -f ${srcdir}/autodeps/${host_os_noversion}.req ; then
795         echo "using ${srcdir}/autodeps/${host_os_noversion}.req for automatic requires generation"
796     ln -s ${srcdir}/autodeps/${host_os_noversion}.req ./find-requires
797 else
798     echo "*** no default requires information is available for ${host_os_noversion}"
799     ln -s ${srcdir}/autodeps/none ./find-requires
800 fi
801
802 dnl Determine the canonical arch-vendor-os for the host machine
803 case "${host_cpu}" in
804 *86)            RPMCANONCOLOR=0; RPMCANONARCH=i386 ;;
805 ia32e*)         RPMCANONCOLOR=3; RPMCANONARCH=ia32e ;;
806 amd64*)         RPMCANONCOLOR=3; RPMCANONARCH=amd64 ;;
807 x86_64*)        RPMCANONCOLOR=3; RPMCANONARCH=x86_64 ;;
808 alpha*)         RPMCANONCOLOR=0; RPMCANONARCH=alpha ;;
809 sparc64*)       RPMCANONCOLOR=3; RPMCANONARCH=sparc64 ;;
810 sparc*)         RPMCANONCOLOR=3; RPMCANONARCH=sparc ;;
811 ia64*)          RPMCANONCOLOR=2; RPMCANONARCH=ia64 ;;
812 s390x*)         RPMCANONCOLOR=3; RPMCANONARCH=s390x ;;
813 s390*)          RPMCANONCOLOR=0; RPMCANONARCH=s390 ;;
814 powerpc64*|ppc64*)      RPMCANONCOLOR=3; RPMCANONARCH=ppc64 ;;
815 powerpc*|ppc*)  RPMCANONCOLOR=0; RPMCANONARCH=ppc ;;
816 arm*)           RPMCANONCOLOR=0; RPMCANONARCH=arm ;;
817 mipsel*)        RPMCANONCOLOR=0; RPMCANONARCH=mipsel ;;
818 mips*)          RPMCANONCOLOR=0; RPMCANONARCH=mips ;;
819 m68k*)          RPMCANONCOLOR=0; RPMCANONARCH=m68k ;;
820 sh3*)           RPMCANONCOLOR=0; RPMCANONARCH=sh3 ;;
821 sh4*)           RPMCANONCOLOR=0; RPMCANONARCH=sh4 ;;
822 *)              RPMCANONCOLOR=0; RPMCANONARCH=unknown ;;
823 esac
824 case "${host_os_noversion}" in
825 mint)           RPMCANONARCH=m68kmint ;;
826 esac
827 RPMCANONVENDOR="$build_vendor"
828 case "${build_vendor}" in
829 unknown|pc|ibm|redhat|pld|mandrake|conectiva|lvr|yellowdog|caos|suse)
830         test -f /etc/redhat-release &&          RPMCANONVENDOR=redhat
831         test -f /etc/SuSE-release &&            RPMCANONVENDOR=suse
832         test -f /etc/pld-release &&             RPMCANONVENDOR=pld
833         test -f /etc/mandrake-release &&        RPMCANONVENDOR=mandrake
834         test -f /etc/conectiva-release &&       RPMCANONVENDOR=conectiva
835         test -f /etc/lvr-release &&             RPMCANONVENDOR=lvr
836         test -f /etc/yellowdog-release &&       RPMCANONVENDOR=yellowdog
837         test -f /etc/caos-release &&            RPMCANONVENDOR=caos
838         ;;
839 esac
840 RPMCANONOS="$host_os_noversion"
841 RPMCANONGNU="$host_os_gnu"
842 AC_SUBST(RPMCANONCOLOR)
843 AC_SUBST(RPMCANONARCH)
844 AC_SUBST(RPMCANONVENDOR)
845 AC_SUBST(RPMCANONOS)
846 AC_SUBST(RPMCANONGNU)
847 AC_DEFINE_UNQUOTED([RPMCANONVENDOR],["${RPMCANONVENDOR}"],[canonical vendor])
848
849 if test X"$prefix" = XNONE ; then
850     usrprefix="$ac_default_prefix"
851 else
852     usrprefix=$prefix
853 fi
854
855 RPMCONFIGDIR="`echo ${usrprefix}/lib/rpm`"
856 AC_SUBST(RPMCONFIGDIR)
857
858 AC_SUBST(OBJDUMP)
859
860 if test "$with_external_db" = no; then
861     AC_CONFIG_SUBDIRS(db3)
862 fi
863
864 AM_CONDITIONAL([WITH_INTERNAL_DB],[test "$with_external_db" = no])
865 AM_CONDITIONAL([DOXYGEN],[test "$DOXYGEN" != no])
866 AM_CONDITIONAL([HACKINGDOCS],[test "$with_hackingdocs" = yes])
867
868 AC_PATH_PROG(AUTOM4TE,autom4te,:)
869
870 AC_SUBST([dirstamp],[\${am__leading_dot}dirstamp])
871
872 AC_CONFIG_FILES([Makefile
873         rpmio/Makefile lib/Makefile build/Makefile sign/Makefile
874         po/Makefile.in scripts/Makefile fileattrs/Makefile
875         misc/Makefile 
876         doc/Makefile
877         python/Makefile
878         luaext/Makefile
879         tests/Makefile
880         plugins/Makefile
881   ])
882 AC_OUTPUT