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