Use selabel interfaces instead of matchpathcon
[platform/upstream/rpm.git] / configure.ac
1 AC_PREREQ(2.61)
2 AC_INIT(rpm, 4.8.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 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 AC_SEARCH_LIBS(dlopen, [dl])
219
220 dnl Temporary hack for MiNT.  Some functions (writev, snprintf) are
221 dnl not in the libc but in libport (for political reasons).  This check
222 dnl can hopefully be removed soon.  Please use the default action
223 dnl for this macro (not LIBS=...), otherwise the check for dbopen
224 dnl will fail.
225 AC_CHECK_LIB(port, writev)
226
227 #=================
228 # Check for libelf library. Prefer external, otherwise none.
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_LIB)
239 AM_CONDITIONAL(LIBELF,[test "$WITH_LIBELF" = yes])
240
241 AC_CHECK_HEADERS([dwarf.h], [
242   WITH_LIBDWARF=yes
243 ])
244 AM_CONDITIONAL(LIBDWARF,[test "$WITH_LIBDWARF" = yes])
245
246 #=================
247 # Check for NSS library.
248 # We need nss.h from NSS which needs nspr.h. Unfortunately both glibc and NSS 
249 # have a header named nss.h... so make extra check for NSS's sechash.h 
250 # which we use too and hopefully is slightly more unique to NSS.
251 WITH_NSS_INCLUDE=
252 WITH_NSS_LIB=
253 AC_CHECK_HEADERS([nspr.h nss.h sechash.h], [], [
254   AC_MSG_ERROR([missing required NSPR / NSS header])
255 ])
256 AC_CHECK_LIB(nss3, NSS_NoDB_Init, [
257   WITH_NSS_LIB=-lnss3
258 ], [
259   AC_MSG_ERROR([missing required NSS library 'nss3'])
260 ])
261 AC_SUBST(WITH_NSS_INCLUDE)
262 AC_SUBST(WITH_NSS_LIB)
263
264 #=================
265 # Check for magic library.
266 WITH_MAGIC_INCLUDE=
267 WITH_MAGIC_LIB=
268
269 AC_CHECK_HEADER([magic.h], [
270     AC_CHECK_LIB(magic, magic_open, [
271       WITH_MAGIC_INCLUDE=
272       WITH_MAGIC_LIB="-lmagic"
273     ],[
274       AC_MSG_ERROR([missing required library 'libmagic']) 
275     ])
276 ],[
277       AC_MSG_ERROR([missing required header magic.h]) 
278 ])
279
280 AC_SUBST(WITH_MAGIC_INCLUDE)
281 AC_SUBST(WITH_MAGIC_LIB)
282
283 #=================
284 # Check for popt library.
285 WITH_POPT_INCLUDE=
286 WITH_POPT_LIB=
287
288 AC_CHECK_HEADER([popt.h], [
289   AC_CHECK_LIB(popt, poptGetContext, [
290       WITH_POPT_INCLUDE=
291       WITH_POPT_LIB="-lpopt"
292   ],[
293     AC_MSG_ERROR([missing required library popt])
294   ])
295 ],[
296   AC_MSG_ERROR([missing required header popt.h])
297 ])
298
299 AC_SUBST(WITH_POPT_INCLUDE)
300 AC_SUBST(WITH_POPT_LIB)
301
302 #=================
303 # Process --with/without-external-db
304 AC_ARG_WITH(external_db, [AS_HELP_STRING([--with-external-db],[build against an external Berkeley db])],
305 [case "$with_external_db" in
306 yes|no) ;;
307 *) AC_MSG_ERROR([invalid argument to --with-external-db]) ;;
308 esac],
309 [with_external_db=no])
310
311 case "$with_external_db" in
312 yes )
313   AC_CHECK_HEADERS([db.h],[
314     AC_PREPROC_IFELSE([
315         #include <db.h>
316         #if !(DB_VERSION_MAJOR >= 4 && DB_VERSION_MINOR >= 5)
317         #error Berkeley DB too old
318         #endif
319     ],[ WITH_DB_LIB=-ldb ], 
320       [ AC_MSG_ERROR([Berkeley DB version >= 4.5 required])
321     ])
322   ],[
323     AC_MSG_ERROR([missing required header db.h])
324   ])
325   ;;
326 * ) # Fall back to internal db if available
327   if [ test -x db/dist/configure ]; then
328     AC_DEFINE(HAVE_DB_H, 1, [Define if you have the <db3/db.h> header file])
329   else
330     AC_MSG_ERROR([internal Berkeley DB directory not present, see INSTALL])
331   fi
332   ;;
333 esac
334
335 AC_SUBST([WITH_DB_LIB])
336
337 AM_GNU_GETTEXT_VERSION([0.16.1])
338 AM_GNU_GETTEXT([external])
339
340 dnl Checks for header files we can live without.
341 AC_HEADER_STDC
342 AC_HEADER_MAJOR
343 AC_HEADER_DIRENT
344
345 AC_CHECK_HEADERS(limits.h)
346 AC_CHECK_HEADERS(fcntl.h getopt.h memory.h)
347
348 AC_CHECK_HEADERS(sys/ipc.h)
349 AC_CHECK_HEADERS(sys/utsname.h)
350
351 AC_CHECK_HEADERS(sys/systemcfg.h)
352 AC_CHECK_HEADERS(sys/param.h)
353 AC_CHECK_HEADERS(libio.h)
354 AC_CHECK_HEADERS(mcheck.h)
355
356 AC_CHECK_HEADERS(glob.h)
357
358 dnl statfs portability fiddles.
359 dnl
360 dnl We should really emulate/steal sections of the statfs and struct statfs
361 dnl checks from GNU fileutils.
362 dnl
363 AC_MSG_CHECKING(for struct statfs)
364
365 dnl
366 dnl this is easier than nesting AC_TRY_COMPILEs...
367 dnl
368 found_struct_statfs=no
369
370 if test X$found_struct_statfs = Xno ; then
371 dnl Solaris 2.6+ wants to use statvfs
372 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
373 #ifdef HAVE_SYS_TYPES_H
374 #include <sys/types.h>
375 #endif
376 #include <sys/statvfs.h> ]], [[struct statvfs sfs;]])],[AC_MSG_RESULT(in sys/statvfs.h)
377         AC_DEFINE(STATFS_IN_SYS_STATVFS, 1,
378                 [statfs in <sys/statvfs.h> (for solaris 2.6+ systems)])
379         found_struct_statfs=yes],[])
380 fi
381
382 if test X$found_struct_statfs = Xno ; then
383 dnl first try including sys/vfs.h
384 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
385 #ifdef HAVE_SYS_TYPES_H
386 #include <sys/types.h>
387 #endif
388 #include <sys/vfs.h> ]], [[struct statfs sfs;]])],[AC_MSG_RESULT(in sys/vfs.h)
389         AC_DEFINE(STATFS_IN_SYS_VFS, 1, [statfs in <sys/vfs.h> (for linux systems)])
390         found_struct_statfs=yes],[])
391 fi
392
393 if test X$found_struct_statfs = Xno ; then
394 dnl ...next try including sys/mount.h
395 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
396 #ifdef HAVE_SYS_TYPES_H
397 #include <sys/types.h>
398 #endif
399 #ifdef HAVE_SYS_PARAM_H
400 #include <sys/param.h>
401 #endif
402 #include <sys/mount.h> ]], [[struct statfs sfs;]])],[AC_MSG_RESULT(in sys/mount.h)
403         AC_DEFINE(STATFS_IN_SYS_MOUNT, 1, [statfs in <sys/mount.h> (for Digital Unix 4.0D systems)])
404         found_struct_statfs=yes],[])
405 fi
406
407 if test X$found_struct_statfs = Xno ; then
408 dnl ...still no joy.  Try sys/statfs.h
409 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
410 #ifdef HAVE_SYS_TYPES_H
411 #include <sys/types.h>
412 #endif
413 #include <sys/statfs.h> ]], [[struct statfs sfs;]])],[AC_MSG_RESULT(in sys/statfs.h)
414         AC_DEFINE(STATFS_IN_SYS_STATFS, 1, [statfs in <sys/statfs.h> (for Irix 6.4 systems)])
415         found_struct_statfs=yes],[])
416 fi
417
418 if test X$found_struct_statfs = Xno ; then
419 dnl ...no luck.  Warn the user of impending doom.
420 AC_MSG_WARN(not found)
421 fi
422
423 dnl
424 dnl if we found the struct, see if it has the f_bavail member.  Some OSes
425 dnl don't, including IRIX 6.5+
426 dnl
427 if test X$found_struct_statfs = Xyes ; then
428 AC_MSG_CHECKING(for f_bavail member in struct statfs)
429 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
430 #ifdef HAVE_SYS_TYPES_H
431 #include <sys/types.h>
432 #endif
433 #if STATFS_IN_SYS_STATVFS
434 # include <sys/statvfs.h>
435   typedef struct statvfs STATFS_t;
436 #else
437   typedef struct statfs STATFS_t;
438 # if STATFS_IN_SYS_VFS
439 #  include <sys/vfs.h>
440 # elif STATFS_IN_SYS_MOUNT
441 #  include <sys/mount.h>
442 # elif STATFS_IN_SYS_STATFS
443 #  include <sys/statfs.h>
444 # endif
445 #endif ]], [[STATFS_t sfs;
446         sfs.f_bavail = 0;]])],[AC_MSG_RESULT(yes)
447         AC_DEFINE(STATFS_HAS_F_BAVAIL, 1, [Define if struct statfs has the f_bavail member])],[AC_MSG_RESULT(no)
448 ])
449 fi
450
451 if test X$found_struct_statfs = Xyes ; then
452 dnl
453 dnl now check to see if we have the 4-argument variant of statfs()
454 dnl this pretty much requires AC_RUN_IFELSE([AC_LANG_SOURCE([[]])],[],[],[])
455 dnl
456 AC_MSG_CHECKING([if statfs() requires 4 arguments])
457 AC_RUN_IFELSE([AC_LANG_SOURCE([[
458 #ifdef HAVE_SYS_TYPES_H
459 #include <sys/types.h>
460 #endif
461 #ifdef STATFS_IN_SYS_VFS
462 #include <sys/vfs.h>
463 #elif STATFS_IN_SYS_MOUNT
464 #include <sys/mouht.h>
465 #elif STATFS_IN_SYS_STATFS
466 #include <sys/statfs.h>
467 #endif
468 main() {
469         struct statfs sfs;
470         exit (statfs(".", &sfs, sizeof(sfs), 0));
471 }
472 ]])],[AC_MSG_RESULT(yes)
473         AC_DEFINE(STAT_STATFS4, 1, [Define if the statfs() call takes 4 arguments])],[AC_MSG_RESULT(no)],[AC_MSG_RESULT(no)
474 ])
475 fi
476
477 dnl look for libc features
478
479 dnl Check for missing typedefs
480 AC_TYPE_MODE_T
481 AC_TYPE_OFF_T
482 AC_TYPE_PID_T
483 AC_TYPE_SIZE_T
484
485 dnl Checks for library functions.
486 AC_FUNC_MMAP
487
488 AC_CHECK_FUNCS(mtrace)
489 AC_CHECK_FUNCS(putenv)
490
491 AC_REPLACE_FUNCS(stpcpy stpncpy)
492
493 AC_CHECK_FUNCS(__secure_getenv)
494
495 AC_CHECK_FUNCS(
496    [mkstemp getcwd basename dirname realpath setenv unsetenv regcomp lchown],
497    [], [AC_MSG_ERROR([function required by rpm])])
498
499 dnl XXX Glob *is* broken on linux with libc5, solaris and possibly aix when
500 dnl %files gets something like
501 dnl     /usr/*/locale/*/LC_MESSAGES/*.mo
502 dnl (Note: more than one asterisk in glob pattern.)
503 dnl
504 dnl XXX Glob is "fixed" in glibc-2.3.3-61, but the cost is that
505 dnl dangling symlinks are no longer globbed. Always use the internal glob.
506 AC_DEFINE(USE_GNU_GLOB, 1, [Use the included glob.c?])
507 AC_LIBOBJ(glob)
508 AC_LIBOBJ(fnmatch)
509
510 dnl check if python is requested
511 AC_ARG_ENABLE(python, [AS_HELP_STRING([--enable-python],[build rpm python bindings])],
512 [case "$enable_python" in
513 yes|no) ;;
514 *) AC_MSG_ERROR([invalid argument to --enable-python])
515   ;;
516 esac],
517 [enable_python=no])
518
519 AS_IF([test "$enable_python" = yes],[
520   AM_PATH_PYTHON([2.6],[
521     WITH_PYTHON_INCLUDE=`${PYTHON} -c 'from distutils.sysconfig import *; import sys; sys.stdout.write(get_python_inc())'`
522     WITH_PYTHON_SUBPACKAGE=1
523     save_CPPFLAGS="$CPPFLAGS"
524     CPPFLAGS="$CPPFLAGS -I$WITH_PYTHON_INCLUDE"
525     AC_CHECK_HEADER([Python.h],[],
526       [AC_MSG_ERROR([missing Python.h])
527       ])
528     CPPFLAGS="$save_CPPFLAGS"
529     save_LIBS="$LIBS"
530     AC_SEARCH_LIBS([Py_Main],[python${PYTHON_VERSION} python],[
531       WITH_PYTHON_LIB="$ac_res"
532     ],[AC_MSG_ERROR([missing python library])
533     ])
534     LIBS="$save_LIBS"
535   ])
536 ],[
537     WITH_PYTHON_INCLUDE=
538     WITH_PYTHON_LIB=
539     WITH_PYTHON_SUBPACKAGE=0
540 ])
541
542 AC_SUBST(WITH_PYTHON_INCLUDE)
543 AC_SUBST(WITH_PYTHON_LIB)
544
545 AM_CONDITIONAL(PYTHON,[test "$WITH_PYTHON_SUBPACKAGE" = 1])
546
547 AC_PATH_PROG(DOXYGEN, doxygen, no)
548 dnl
549 dnl Only build internal API + source hacking docs on request
550 dnl
551 AC_ARG_WITH(hackingdocs, [AS_HELP_STRING([--with-hackingdocs],[build rpm hacking docs])],,[with_hackingdocs=no])
552
553 case "$with_hackingdocs" in
554 auto)
555   AS_IF([test "$DOXYGEN" = no],[with_hackingdocs=no],[with_hackingdocs=no])
556   ;;
557 yes)
558   AS_IF([test "$DOXYGEN" = no],
559     [AC_MSG_ERROR([rpm hacking docs eeds doxygen in PATH])])
560   ;;
561 esac
562 AC_CHECK_PROG(HAVE_DOT,[dot],[YES],[NO])
563
564 WITH_SELINUX_LIB=
565 AC_ARG_WITH(selinux, [AS_HELP_STRING([--with-selinux],[build with selinux support])],
566 [case "$with_selinux" in
567 yes|no) ;;
568 *) AC_MSG_ERROR([invalid argument to --with-selinux])
569   ;;
570 esac],
571 [with_selinux=no])
572
573 AS_IF([test "$with_selinux" = yes],[
574   AC_CHECK_HEADER([selinux/selinux.h],[
575     AC_CHECK_LIB(selinux,[is_selinux_enabled],[with_selinux=yes],[
576       AC_MSG_ERROR([--with-selinux given, but libselinux not found])])
577   ],[
578     AC_MSG_ERROR([--with-selinux given, but selinux/selinux.h not found])
579   ])
580
581   AC_CHECK_HEADER([selinux/label.h],[
582     save_LIBS="$LIBS"
583     AC_CHECK_LIB([selinux],[selabel_close],[],[
584       AC_MSG_ERROR([--with-selinux given, but selabel_close not found in libselinux])])
585     AC_CHECK_LIB([selinux],[selabel_lookup_raw],[],[
586       AC_MSG_ERROR([--with-selinux given, but selabel_lookup_raw not found in libselinux])])
587     AC_CHECK_LIB([selinux],[selabel_open],[],[
588       AC_MSG_ERROR([--with-selinux given, but selabel_open not found in libselinux])])
589     LIBS="$save_LIBS"
590   ],[
591     AC_MSG_ERROR([--with-selinux given, but selinux/label.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(getpassphrase)
692
693 #
694 # get rid of the 4-th tuple, if config.guess returned "linux-gnu" for host_os
695 #
696 host_os_gnu=-gnu
697 if echo "$host_os" | grep '.*-gnulibc1' > /dev/null ; then
698         host_os=`echo "${host_os}" | sed 's/-gnulibc1$//'`
699 fi
700 if echo "$host_os" | grep '.*-gnueabi' > /dev/null ; then
701         host_os=`echo "${host_os}" | sed 's/-gnueabi$//'`
702         host_os_gnu=-gnueabi
703 fi
704 if echo "$host_os" | grep '.*-gnu' > /dev/null ; then
705         host_os=`echo "${host_os}" | sed 's/-gnu$//'`
706 fi
707
708 changequote(<, >)
709 host_os_exact="${host_os}"
710 host_os_major=`echo "${host_os}" | sed 's/\..*$//'`
711 host_os_noversion=`echo "${host_os}" | sed 's/[0-9]*\..*$//'`
712 changequote([, ])
713
714 rm -f ./find-provides
715 if test -f ${srcdir}/autodeps/${host_cpu}-${host_os_exact}.prov ; then
716         echo "using ${srcdir}/autodeps/${host_cpu}-${host_os_exact}.prov for automatic provides generation"
717     ln -s ${srcdir}/autodeps/${host_cpu}-${host_os_exact}.prov ./find-provides
718 elif test -f ${srcdir}/autodeps/${host_os_exact}.prov ; then
719         echo "using ${srcdir}/autodeps/${host_os_exact}.prov for automatic provides generation"
720     ln -s ${srcdir}/autodeps/${host_os_exact}.prov ./find-provides
721 elif test -f ${srcdir}/autodeps/${host_os_major}.prov ; then
722         echo "using ${srcdir}/autodeps/${host_os_major}.prov for automatic provides generation"
723     ln -s ${srcdir}/autodeps/${host_os_major}.prov ./find-provides
724 elif test -f ${srcdir}/autodeps/${host_os_noversion}.prov ; then
725         echo "using ${srcdir}/autodeps/${host_os_noversion}.prov for automatic provides generation"
726     ln -s ${srcdir}/autodeps/${host_os_noversion}.prov ./find-provides
727 else
728     echo "*** no default provides information is available for ${host_os_noversion}"
729     ln -s ${srcdir}/autodeps/none ./find-provides
730 fi
731
732 rm -f ./find-requires
733 if test -f ${srcdir}/autodeps/${host_cpu}-${host_os_exact}.req ; then
734         echo "using ${srcdir}/autodeps/${host_cpu}-${host_os_exact}.req for automatic requires generation"
735     ln -s ${srcdir}/autodeps/${host_cpu}-${host_os_exact}.req ./find-requires
736 elif test -f ${srcdir}/autodeps/${host_os_exact}.req ; then
737         echo "using ${srcdir}/autodeps/${host_os_exact}.req for automatic requires generation"
738     ln -s ${srcdir}/autodeps/${host_os_exact}.req ./find-requires
739 elif test -f ${srcdir}/autodeps/${host_os_major}.req ; then
740         echo "using ${srcdir}/autodeps/${host_os_major}.req for automatic requires generation"
741     ln -s ${srcdir}/autodeps/${host_os_major}.req ./find-requires
742 elif test -f ${srcdir}/autodeps/${host_os_noversion}.req ; then
743         echo "using ${srcdir}/autodeps/${host_os_noversion}.req for automatic requires generation"
744     ln -s ${srcdir}/autodeps/${host_os_noversion}.req ./find-requires
745 else
746     echo "*** no default requires information is available for ${host_os_noversion}"
747     ln -s ${srcdir}/autodeps/none ./find-requires
748 fi
749
750 dnl Determine the canonical arch-vendor-os for the host machine
751 case "${host_cpu}" in
752 *86)            RPMCANONCOLOR=0; RPMCANONARCH=i386 ;;
753 ia32e*)         RPMCANONCOLOR=3; RPMCANONARCH=ia32e ;;
754 amd64*)         RPMCANONCOLOR=3; RPMCANONARCH=amd64 ;;
755 x86_64*)        RPMCANONCOLOR=3; RPMCANONARCH=x86_64 ;;
756 alpha*)         RPMCANONCOLOR=0; RPMCANONARCH=alpha ;;
757 sparc64*)       RPMCANONCOLOR=3; RPMCANONARCH=sparc64 ;;
758 sparc*)         RPMCANONCOLOR=3; RPMCANONARCH=sparc ;;
759 ia64*)          RPMCANONCOLOR=2; RPMCANONARCH=ia64 ;;
760 s390x*)         RPMCANONCOLOR=3; RPMCANONARCH=s390x ;;
761 s390*)          RPMCANONCOLOR=0; RPMCANONARCH=s390 ;;
762 powerpc64*|ppc64*)      RPMCANONCOLOR=3; RPMCANONARCH=ppc64 ;;
763 powerpc*|ppc*)  RPMCANONCOLOR=0; RPMCANONARCH=ppc ;;
764 arm*)           RPMCANONCOLOR=0; RPMCANONARCH=arm ;;
765 mipsel*)        RPMCANONCOLOR=0; RPMCANONARCH=mipsel ;;
766 mips*)          RPMCANONCOLOR=0; RPMCANONARCH=mips ;;
767 m68k*)          RPMCANONCOLOR=0; RPMCANONARCH=m68k ;;
768 sh3*)           RPMCANONCOLOR=0; RPMCANONARCH=sh3 ;;
769 sh4*)           RPMCANONCOLOR=0; RPMCANONARCH=sh4 ;;
770 *)              RPMCANONCOLOR=0; RPMCANONARCH=unknown ;;
771 esac
772 case "${host_os_noversion}" in
773 mint)           RPMCANONARCH=m68kmint ;;
774 esac
775 RPMCANONVENDOR="$build_vendor"
776 case "${build_vendor}" in
777 unknown|pc|ibm|redhat|pld|mandrake|conectiva|lvr|yellowdog|caos|suse)
778         test -f /etc/redhat-release &&          RPMCANONVENDOR=redhat
779         test -f /etc/SuSE-release &&            RPMCANONVENDOR=suse
780         test -f /etc/pld-release &&             RPMCANONVENDOR=pld
781         test -f /etc/mandrake-release &&        RPMCANONVENDOR=mandrake
782         test -f /etc/conectiva-release &&       RPMCANONVENDOR=conectiva
783         test -f /etc/lvr-release &&             RPMCANONVENDOR=lvr
784         test -f /etc/yellowdog-release &&       RPMCANONVENDOR=yellowdog
785         test -f /etc/caos-release &&            RPMCANONVENDOR=caos
786         ;;
787 esac
788 RPMCANONOS="$host_os_noversion"
789 RPMCANONGNU="$host_os_gnu"
790 AC_SUBST(RPMCANONCOLOR)
791 AC_SUBST(RPMCANONARCH)
792 AC_SUBST(RPMCANONVENDOR)
793 AC_SUBST(RPMCANONOS)
794 AC_SUBST(RPMCANONGNU)
795 AC_DEFINE_UNQUOTED([RPMCANONVENDOR],["${RPMCANONVENDOR}"],[canonical vendor])
796
797 if test X"$prefix" = XNONE ; then
798     usrprefix="$ac_default_prefix"
799 else
800     usrprefix=$prefix
801 fi
802
803 RPMCONFIGDIR="`echo ${usrprefix}/lib/rpm`"
804 AC_SUBST(RPMCONFIGDIR)
805
806 AC_SUBST(OBJDUMP)
807
808 if test "$with_external_db" = no; then
809     AC_CONFIG_SUBDIRS(db3)
810 fi
811
812 AM_CONDITIONAL([WITH_INTERNAL_DB],[test "$with_external_db" = no])
813 AM_CONDITIONAL([DOXYGEN],[test "$DOXYGEN" != no])
814 AM_CONDITIONAL([HACKINGDOCS],[test "$with_hackingdocs" = yes])
815
816 AC_PATH_PROG(AUTOM4TE,autom4te,:)
817
818 AC_SUBST([dirstamp],[\${am__leading_dot}dirstamp])
819
820 AC_CONFIG_FILES([Makefile
821         rpmio/Makefile lib/Makefile build/Makefile
822         po/Makefile.in scripts/Makefile fileattrs/Makefile
823         misc/Makefile 
824         doc/Makefile
825         python/Makefile
826         luaext/Makefile
827         tests/Makefile
828         plugins/Makefile
829   ])
830 AC_OUTPUT