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