- fix: dependency helpers now rate limited at 10ms, not 1s.
[tools/librpm-tizen.git] / configure.ac
1 dnl configure.in for RPM
2 dnl
3 dnl Don't add checks for things we can't work around, unless those checks
4 dnl failing causes the script to bomb out with a message. If we can't fix
5 dnl it, why check it?
6
7 AC_INIT(rpmqv.c)
8 AC_CANONICAL_SYSTEM
9 AC_PREREQ(2.12)         dnl Minimum Autoconf version required.
10 AC_CONFIG_HEADERS
11 AM_INIT_AUTOMAKE(rpm, 4.2)
12 AM_CONFIG_HEADER(config.h)
13
14 dnl XXX AM_MAINTAINER_MODE
15
16 dnl Set of available languages.
17 ALL_LINGUAS="cs da de fi fr gl is ja ko no pl pt pt_BR ro ru sk sl sr sv tr"
18
19 echo "
20 ****************************************************************************
21 *                                                                          *
22 *                   *** WARNING WARNING WARNING ***                        *
23 *                                                                          *
24 * This is source code from the development branch of rpm-4.2.              *
25 *                                                                          *
26 * If you want the "production" rpm-4.0.4 or rpm-4.1 code, then you should  *
27 * either use an rpm-4.0.4 or rpm-4.1 src.rpm. Alternatively, if using a    *
28 * CVS checkout, do the following:                                          *
29 *                                                                          *
30 *       cvs -d :pserver:anonymous@cvs.rpm.org:/cvs/devel login             *
31 *       (no password, just carriage return)                                *
32 *       cvs -d :pserver:anonymous@cvs.rpm.org:/cvs/devel get rpm           *
33 *       cd rpm                                                             *
34 *                                                                          *
35 * Here's the rpm-4_1 branch:                                               *
36 *       cvs up -r rpm-4_1                                                  *
37 *                                                                          *
38 * Here's the rpm-4_0 branch:                                               *
39 *       cvs up -r rpm-4_0                                                  *
40 *                                                                          *
41 ****************************************************************************
42 "
43 sleep 10
44
45 dnl Checks for programs.
46 AC_PROG_CC
47 AC_AIX
48 AC_MINIX
49 AC_PROG_CXX
50 AS=${AS-as}
51 AC_SUBST(AS)
52 if test "$ac_cv_prog_gcc" = yes; then
53     CFLAGS="$CFLAGS -D_GNU_SOURCE -D_REENTRANT -Wall"
54 fi
55 export CFLAGS
56
57 AC_PROG_CPP
58 AC_PROG_GCC_TRADITIONAL
59 AC_SYS_LARGEFILE
60
61 dnl Does this platform require array notation to assign to a va_list?
62 dnl If cross-compiling, we assume va_list is "normal".  If this breaks
63 dnl you, set ac_cv_valistisarray=true and maybe define HAVE_VA_LIST_AS_ARRAY
64 dnl also just to be sure.
65 AC_MSG_CHECKING(whether va_list assignments need array notation)
66 AC_CACHE_VAL(ac_cv_valistisarray,
67         [AC_TRY_RUN([#include <stdlib.h>
68                      #include <stdarg.h>
69                      void foo(int i, ...) {
70                         va_list ap1, ap2;
71                         va_start(ap1, i);
72                         ap2 = ap1;
73                         if (va_arg(ap2, int) != 123 || va_arg(ap1, int) != 123)
74                             { exit(1); }
75                         va_end(ap1); va_end(ap2);
76                      }
77                      int main() { foo(0, 123); return(0); }],
78                     [ac_cv_valistisarray=false],
79                     [ac_cv_valistisarray=true],
80                     [ac_cv_valistisarray=false])])
81
82 if test "$ac_cv_valistisarray" = true ; then
83         AC_DEFINE(HAVE_VA_LIST_AS_ARRAY, 1,
84                 [Define as 1 if your va_list type is an array])
85         AC_MSG_RESULT(yes)
86 else
87        AC_MSG_RESULT(no)
88 fi
89
90 RPMUSER=rpm
91 RPMUID=37
92 RPMGROUP=rpm
93 RPMGID=37
94 export RPMUSER RPMUID RPMGROUP RPMGID
95 AC_SUBST(RPMUSER)
96 AC_SUBST(RPMUID)
97 AC_SUBST(RPMGROUP)
98 AC_SUBST(RPMGID)
99
100 AC_PATH_PROG(CTAGS, ctags, /bin/true)
101 AC_PATH_PROG(CSCOPE, cscope, /bin/true)
102
103 dnl
104 dnl This now uses libtool. Put
105 dnl     LDFLAGS_STATIC="-all"
106 dnl to attempt static executables using libtool. Otherwise
107 dnl     LDFLAGS_STATIC=""
108 dnl
109 AC_MSG_CHECKING(flag used by libtool to link rpm)
110 if test X"$GCC" = Xyes ; then
111         case "$target" in
112                 *-*-solaris*)   LDFLAGS_STATIC="-static";;
113                 *-*-hpux*)      LDFLAGS_STATIC="-static";;
114                 *-*-sysv5uw*)   LDFLAGS_STATUS="-static";; # Unixware has no shared libthread.
115                 *-*-*)          LDFLAGS_STATIC="-all-static";;
116         esac
117 elif test X"$CC" = Xcc ; then
118         case "$target" in
119                 *-*-linux*)     LDFLAGS_STATIC="-all-static";;
120                 *-*-freebsd*)   LDFLAGS_STATIC="-all-static";;
121                 *-*-osf*)       LDFLAGS_STATIC="";; # OSF5 has no shared pthreads libs
122                 *-*-aix*)       LDFLAGS_STATIC="-static";;  # -Wl,-bnso doesn't seem to work...
123                 *-*-hpux*)      LDFLAGS_STATIC="-static";;
124                 *-*-solaris*)   LDFLAGS_STATIC="-static";;
125                 *-*-irix*)      LDFLAGS_STATIC="-static";;  #should be -non_shared, but can't
126                                                                                         # link because of crt1.o then.
127                 *-*-ultrix*)    LDFLAGS_STATIC="-all-static";;  #ultrix doesn't have shared libs.
128                 *-*-*)          LDFLAGS_STATIC="-static"
129 AC_MSG_WARN([
130
131 Unable to guess what option to pass to $CC to generate a static
132 executable.  You will need to set the LDFLAGS_STATIC macro in Makefile.inc to
133 the appropriate argument(s) if you want to build a static rpm executable.
134
135 ])
136                 ;;
137         esac
138 else
139         # just link it dynamically
140         LDFLAGS_STATIC=""
141 fi
142 LDFLAGS_STATIC="${LDFLAGS} ${LDFLAGS_STATIC}"   # libtool format
143 AC_MSG_RESULT($LDFLAGS_STATIC)
144 AC_SUBST(LDFLAGS_STATIC)
145
146 dnl
147 dnl XXX Test for libpthread.a that is NPTL aware (static link only).
148 dnl
149 LDFLAGS_NPTL=
150 #if test -f /usr/lib/nptl/libpthread.a ; then
151 #    LDFLAGS_NPTL="-L/usr/lib/nptl"
152 #    INCPATH="$INCPATH -I/usr/include/nptl"
153 #fi
154 AC_SUBST(LDFLAGS_NPTL)
155
156 dnl
157 dnl look for POSIX chmod attributes
158 dnl
159 AC_MSG_CHECKING(POSIX chmod)
160 touch foo.chmodtest
161 chmod 744 foo.chmodtest
162 chmod +X foo.chmodtest 2>/dev/null
163 a=`ls -l foo.chmodtest | awk '{print $1}'`
164 rm -f foo.chmodtest
165 if test "$a" = "-rwxr-xr-x"; then
166     AC_MSG_RESULT(yes)
167     FIXPERMS=a+rX,g-w,o-w 
168 else
169     AC_MSG_RESULT(no (tell your OS vendor about GNU fileutils))
170     FIXPERMS=a+r,g-w,o-w 
171 fi
172 AC_SUBST(FIXPERMS)
173
174 dnl
175 dnl see if we have a mkdir that supports `-p'.
176 dnl
177 AC_PATH_PROGS(MKDIR, mkdir, mkdir)
178 AC_MSG_CHECKING(if $MKDIR supports -p)
179 rm -rf conftest
180 $MKDIR -p conftest/a 2>/dev/null
181 if test $? = 0 ; then
182         rmdir conftest/a 2>/dev/null
183         if test $? = 0  ; then
184                 :
185         else
186                 MKDIR_P=0
187         fi
188
189         rmdir conftest 2>/dev/null
190         if test $? = 0 ; then
191                 MKDIR_P="$MKDIR -p"
192         else
193                 MKDIR_P=0
194         fi
195 else
196         MKDIR_P=0
197 fi
198
199 if test X"$MKDIR_P" = X0 ; then
200         AC_MSG_RESULT(no)
201         MKDIR_P="`echo ${prefix}/lib/rpm/mkinstalldirs`"
202 else
203         AC_MSG_RESULT(yes)
204 fi
205 dnl
206 dnl substitute this into config.h, so the C source picks it up.
207 dnl
208 AC_DEFINE_UNQUOTED(MKDIR_P, "${MKDIR_P}",
209 [A full path to a program, possibly with arguments, that will create a
210    directory and all necessary parent directories, ala `mkdir -p'])
211 AC_SUBST(MKDIR_P)
212
213 AC_ISC_POSIX
214
215 dnl This test must precede tests of compiler characteristics like
216 dnl that for the inline keyword, since it may change the degree to
217 dnl which the compiler supports such features.
218 AM_C_PROTOTYPES
219
220 AC_PROG_AWK
221 AC_PROG_LN_S
222 AC_PROG_MAKE_SET
223
224 dnl AM_DISABLE_SHARED
225 AM_PROG_LIBTOOL
226
227 AC_CHECK_TOOL(AR, ar, :)
228
229 dnl
230 dnl use defaults if cross-compiling, otherwise use the default path.
231 dnl
232 if test "$cross_compiling" = "yes"; then
233     MYPATH=""
234 else
235 #    MYPATH="/bin:/usr/bin:/usr/local/bin:$PATH:/sbin:/usr/sbin:/usr/local/sbin:/opt/gnu/bin"
236     MYPATH=$PATH
237 fi
238
239 dnl
240 dnl Find some common programs
241 dnl
242 AC_PATH_PROG(BZIP2BIN, bzip2, /usr/bin/bzip2, $MYPATH)
243 AC_PATH_PROG(__CAT, cat, /bin/cat, $MYPATH)
244 AC_PATH_PROG(__CHGRP, chgrp, /bin/chgrp, $MYPATH)
245 AC_PATH_PROG(__CHMOD, chmod, /bin/chmod, $MYPATH)
246 AC_PATH_PROG(__CHOWN, chown, /bin/chown, $MYPATH)
247 AC_PATH_PROG(__CP, cp, /bin/cp, $MYPATH)
248 AC_PATH_PROG(__CPIO, cpio, /bin/cpio, $MYPATH)
249 AC_PATH_PROG(__FILE, file, /usr/bin/file, $MYPATH)
250 AC_PATH_PROG(__GPG, gpg, /usr/bin/gpg, $MYPATH)
251 AC_PATH_PROG(__GREP, grep, /bin/grep, $MYPATH)
252 AC_PATH_PROG(GZIPBIN, gzip, /bin/gzip, $MYPATH)
253 AC_PATH_PROG(UNZIPBIN, unzip, /usr/bin/unzip, $MYPATH)
254
255 AC_PATH_PROG(__ID, id, /usr/bin/id, $MYPATH)
256 AC_MSG_CHECKING(checking whether id supports -u)
257     if ${__ID} -u 2>&1 > /dev/null ; then
258         __ID_U="%{__id} -u"
259         AC_MSG_RESULT(yes)
260     else
261 dnl XXX Watchout for square brackets fed to m4.
262         __ID_U="%{__id} | %{__sed} 's/[[^=]]*=\\\\([[0-9]][[0-9]]*\\\\).*$/\\\\1/'"
263         AC_MSG_RESULT(no)
264     fi
265 AC_SUBST(__ID_U)
266
267 AC_PATH_PROG(__INSTALL, install, /usr/bin/install, $MYPATH)
268 AC_PATH_PROG(__MAKE, make, /usr/bin/make, $MYPATH)
269 AC_PATH_PROG(__MKDIR, mkdir, /bin/mkdir, $MYPATH)
270 AC_PATH_PROG(__MV, mv, /bin/mv, $MYPATH)
271 AC_PATH_PROG(__PATCH, patch, /usr/bin/patch, $MYPATH)
272 AC_MSG_CHECKING(old version of patch)
273     PATCHVERSION=`patch --version 2>&1`
274
275     if test "$PATCHVERSION" = "Patch version 2.1"; then
276         AC_DEFINE(HAVE_OLDPATCH_21, 1,
277                 [Define if the patch call you'll be using is 2.1 or older])
278         AC_MSG_RESULT(patch older then 2.2 found)
279     else
280         AC_MSG_RESULT(patch later then 2.2 found)
281     fi
282
283 AC_PATH_PROG(__PERL, perl, /usr/bin/perl, $MYPATH)
284 AC_PATH_PROG(PGPBIN, pgp, /usr/bin/pgp, $MYPATH)
285 AC_PATH_PROG(__PYTHON, python, /usr/bin/python, $MYPATH)
286 AC_PATH_PROG(__RM, rm, /bin/rm, $MYPATH)
287 AC_PATH_PROG(__RSH, rsh, /usr/bin/rsh, $MYPATH)
288 AC_PATH_PROG(__SED, sed, /bin/sed, $MYPATH)
289 AC_PATH_PROG(__SSH, ssh, /usr/bin/ssh, $MYPATH)
290 AC_PATH_PROG(__TAR, tar, /bin/tar, $MYPATH)
291
292 AC_PATH_PROG(__LD, ld, /usr/bin/ld, $MYPATH)
293 AC_PATH_PROG(__NM, nm, /usr/bin/nm, $MYPATH)
294 AC_PATH_PROG(__OBJCOPY, objcopy, /usr/bin/objcopy, $MYPATH)
295 AC_PATH_PROG(__OBJDUMP, objdump, /usr/bin/objdump, $MYPATH)
296 AC_PATH_PROG(__STRIP, strip, /usr/bin/strip, $MYPATH)
297
298 addlib() {
299   l=$1
300   shift
301   case "$target" in 
302     *-*-solaris*)       LIBS="$LIBS -L$l -R$l $*";;
303     *)          LIBS="$LIBS -L$l $*";;
304   esac
305 }
306
307 WITH_ZLIB_SUBDIR=
308 WITH_ZLIB_INCLUDE=
309 WITH_ZLIB_LIB=
310 if test -d zlib ; then
311   WITH_ZLIB_SUBDIR=zlib
312   addlib \${top_builddir}/zlib
313   WITH_ZLIB_INCLUDE="-I\${top_srcdir}/${WITH_ZLIB_SUBDIR}"
314   INCPATH="$INCPATH -I\${top_srcdir}/${WITH_ZLIB_SUBDIR}"
315   WITH_ZLIB_LIB="\${top_builddir}/${WITH_ZLIB_SUBDIR}/libz.la"
316   AC_DEFINE(HAVE_GZSEEK, 1, [Define as 1 if your zlib has gzseek()])
317 fi
318 AC_SUBST(WITH_ZLIB_SUBDIR)
319 AC_SUBST(WITH_ZLIB_INCLUDE)
320 AC_SUBST(WITH_ZLIB_LIB)
321
322 localdone=
323
324 dirs=$prefix
325 if test "$cross_compiling" != "yes"; then
326   dirs="$dirs /usr/local"
327 fi
328 for dir in $dirs
329 do
330         case $dir in
331         NONE|/usr)      continue;;
332         /usr/local)
333                 if test X$localdone != X ; then continue; fi
334                 localdone="$dir"
335                 ;;
336         esac
337
338         AC_MSG_CHECKING(for $dir/lib in LIBS)
339         if test -d $dir/lib 2> /dev/null ; then
340                 addlib $dir/lib
341                 AC_MSG_RESULT(yes)
342         else
343                 AC_MSG_RESULT(no)
344         fi
345
346         AC_MSG_CHECKING(for $dir/include in INCPATH)
347         if test -d $dir/include 2>/dev/null ; then
348                 if [ "$dir" != "/usr/local" ] ; then
349                     INCPATH="$INCPATH -I$dir/include"
350                 fi
351                 AC_MSG_RESULT(yes)
352         else
353                 AC_MSG_RESULT(no)
354         fi
355 done
356
357 AC_MSG_CHECKING(for /usr/ucblib in LIBS)
358 if test -d /usr/ucblib ; then
359         if test "$build" = "mips-sni-sysv4" ; then
360                 addlib /usr/ccs/lib -lc
361         fi
362
363         addlib /usr/ucblib
364         
365         AC_MSG_RESULT(yes)
366 else
367         AC_MSG_RESULT(no)
368 fi
369
370 dnl
371 dnl Check for features
372 dnl
373
374 dnl Checks for libraries.
375
376 WITH_ELFUTILS_SUBDIR=
377 WITH_LIBELF_INCLUDE=
378 WITH_LIBELF_LIB=
379 AC_CHECK_HEADER([libelf.h])
380 AC_CHECK_HEADER([gelf.h], [
381         AC_DEFINE(HAVE_GELF_H, 1, [Define to 1 if you have the <gelf.h> header file.])
382         AC_CHECK_LIB(elf, gelf_getvernaux, [
383             AC_DEFINE(HAVE_LIBELF, 1, [Define to 1 if you have the `elf' library (-lelf).])
384             WITH_LIBELF_LIB="-lelf"
385         ])
386     ], [
387         if test -d elfutils/libelf ; then
388             AC_DEFINE(HAVE_GELF_H, 1, [Define to 1 if you have the <gelf.h> header file.])
389             AC_DEFINE(HAVE_LIBELF, 1, [Define to 1 if you have the `elf' library (-lelf).])
390             WITH_ELFUTILS_SUBDIR=elfutils
391             WITH_LIBELF_INCLUDE="-I\${top_srcdir}/${WITH_ELFUTILS_SUBDIR}/libelf"
392             WITH_LIBELF_LIB="\${top_builddir}/${WITH_ELFUTILS_SUBDIR}/libelf/libelf.a"
393         fi
394 ])
395 AC_SUBST(WITH_ELFUTILS_SUBDIR)
396 AC_SUBST(WITH_LIBELF_INCLUDE)
397 AC_SUBST(WITH_LIBELF_LIB)
398
399 WITH_LIBDWARF_INCLUDE=
400 AC_CHECK_HEADER([dwarf.h], [
401         AC_DEFINE(HAVE_DWARF_H, 1, [Define to 1 if you have the <dwarf.h> header file.])
402     ], [
403         if test -d elfutils/libdwarf ; then
404             AC_DEFINE(HAVE_DWARF_H, 1, [Define to 1 if you have the <dwarf.h> header file.])
405             WITH_LIBDWARF_INCLUDE="-I\${top_srcdir}/${WITH_ELFUTILS_SUBDIR}/libdwarf"
406         fi
407 ])
408 AC_SUBST(WITH_LIBDWARF_INCLUDE)
409
410 AC_CHECK_FUNC(setreuid, [], [
411     AC_CHECK_LIB(ucb, setreuid, [if echo $LIBS | grep -- -lucb >/dev/null ;then :; else LIBS="$LIBS -lc -lucb" USEUCB=y;fi])
412 ])
413
414 AC_CHECK_FUNC(rand, [], [
415     AC_CHECK_LIB(rand, rand, [])
416 ])
417
418 AC_CHECK_FUNC(getdomainname, [], [
419     AC_CHECK_LIB(nsl, getdomainname)
420 ])
421 AC_CHECK_FUNC(socket, [], [
422     AC_CHECK_LIB(socket, socket)
423 ])
424
425 AC_CHECK_HEADERS(thread.h pthread.h synch.h semaphore.h)
426
427 AC_CHECK_LIB(pthread, pthread_mutex_trylock, [], [
428   dnl OSF 5.0 has the the symbols prefixed with __ in libpthread.
429   AC_CHECK_LIB(pthread, __pthread_mutex_trylock, [], [
430     AC_CHECK_LIB(thread, mutex_lock)
431   ])
432 ])
433
434 AC_CHECK_HEADERS(aio.h)
435 AC_SEARCH_LIBS(aio_read, [c rt aio posix4])
436
437 dnl Better not use fchmod at all.
438 AC_CHECK_FUNC(fchmod)
439
440 AC_CHECK_FUNCS(vsnprintf snprintf)
441
442 dnl Temporary hack for MiNT.  Some functions (writev, snprintf) are
443 dnl not in the libc but in libport (for political reasons).  This check
444 dnl can hopefully be removed soon.  Please use the default action
445 dnl for this macro (not LIBS=...), otherwise the check for dbopen
446 dnl will fail.
447 AC_CHECK_LIB(port, writev)
448
449 WITH_DB_SUBDIR=
450 WITH_INTERNAL_DB=0
451 DBLIBSRCS=""
452 libdb3=""
453 libdb3a=""
454
455 dnl
456 dnl Detect whether internal Berkeley DB should be built.
457 dnl
458 withval=yes
459 AC_ARG_WITH(db, [  --without-db            do not use internal Berkeley db])
460
461 if test $withval = no ; then
462 dnl ------------------ without internal db
463
464 AC_CHECK_HEADERS(db3/db.h)
465
466 dnl Check for Berkeley db3 API.
467 AC_CHECK_FUNC(db_create, [DBLIBSRCS="$DBLIBSRCS db3.c"],
468   AC_CHECK_LIB(db-3.2, db_create, [DBLIBSRCS="$DBLIBSRCS db3.c"; libdb3="-ldb-3.2"],
469     AC_CHECK_LIB(db-3.1, db_create, [DBLIBSRCS="$DBLIBSRCS db3.c"; libdb3="-ldb-3.1"],
470       AC_CHECK_LIB(db-3.0, db_create, [DBLIBSRCS="$DBLIBSRCS db3.c"; libdb3="-ldb-3.0"],
471         AC_CHECK_LIB(db, db_create, [DBLIBSRCS="$DBLIBSRCS db3.c"; libdb3="-ldb"],
472         )
473       )
474     )
475   )
476 )
477
478 if test X"$DBLIBSRCS" = X; then
479     AC_MSG_ERROR([sorry rpm requires libdb-3.x.a (from the Berkeley db package)]) 
480 fi
481
482 if test -n "$libdb3" -a -n "$libthread" ; then
483    AC_MSG_CHECKING(whether $libdb3 needs $libthread)
484    saveLIBS="$LIBS"
485    LIBS="$LIBS $libdb3"
486    AC_TRY_LINK_FUNC(db_create, AC_MSG_RESULT(no),
487         [libdb3="$libdb3 $libthread"; AC_MSG_RESULT(yes)])
488    LIBS="$saveLIBS"
489 fi
490
491 else
492 dnl ------------------ with    internal db
493   AC_DEFINE(HAVE_DB3_DB_H, 1, [Define if you have the <db3/db.h> header file])
494   WITH_DB_SUBDIR=db3
495   WITH_INTERNAL_DB=1
496   DBLIBSRCS="db3.c"
497   libdb3="# \$(top_builddir)/db3/libdb.la"
498   libdb3a="\$(top_builddir)/db3/libdb.a"
499 dnl  INCPATH="-I\$(top_builddir)/$(WITH_DB_SUBDIR) $INCPATH"
500 fi
501
502 AC_SUBST(WITH_DB_SUBDIR)
503 AC_SUBST(WITH_INTERNAL_DB)
504
505 DBLIBSRCS="$DBLIBSRCS"
506 DBLIBOBJS=`echo $DBLIBSRCS | sed -e "s/\.c/\.lo/g"`
507
508 AC_SUBST(DBLIBSRCS)
509 AC_SUBST(DBLIBOBJS)
510 AC_SUBST(libdb3)
511 AC_SUBST(libdb3a)
512
513 for dbi in $DBLIBSRCS; do
514   case $dbi in
515   db3.c) AC_DEFINE(USE_DB3, 1, [Use the Berkeley db3 API?]) ;;
516   db1.c) AC_DEFINE(USE_DB1, 1, [Use the Berkeley db1 retrofit to db3 API?]) ;;
517   esac
518 done
519
520 dnl AmigaOS and IXEmul have a fork() dummy
521   case "$target" in
522     m68k-*-amigaos ) 
523         echo "Building for AmigaOS: using vfork() instead of fork()"; 
524         CFLAGS="$CFLAGS -Dfork=vfork" 
525         ;;
526   esac
527
528 if test -z "${WITH_ZLIB_LIB}" ; then
529 for zlib in z gz ; do
530    AC_CHECK_LIB(${zlib}, gzread, 
531         [LIBS="$LIBS -l${zlib}"; break], 
532         [if test ${zlib} = gz; then 
533             AC_MSG_ERROR([sorry rpm requires libz.a or libgz.a (from the zlib package)]) 
534          fi]
535                )
536 done
537
538 dnl zlib-1.0.4 has not gzseek
539 AC_CHECK_LIB(${zlib}, gzseek, [AC_DEFINE(HAVE_GZSEEK, 1, [Define as 1 if your zlib has gzseek()])])
540 fi
541
542 AC_CHECK_LIB(bz2, bzread, [LIBS="$LIBS -lbz2"], 
543    AC_CHECK_LIB(bz2, BZ2_bzread, [
544      WITH_BZIP2=1
545      LIBS="$LIBS -lbz2"
546      AC_DEFINE(HAVE_BZ2_1_0, 1, [Define as 1 if you bzip2 1.0]) ], 
547      WITH_BZIP2=0))
548 AC_SUBST(WITH_BZIP2)
549
550 AM_GNU_GETTEXT
551 dnl TVM:
552 dnl horrible *temporary* hack to make sure that if we found gettext() in
553 dnl -lintl that we add -lintl *back* to $LIBS.
554 dnl
555 if test X$gt_cv_func_gettext_libintl = Xyes ; then
556     LIBS="-lintl $LIBS"
557 fi
558
559 dnl Checks for header files we can live without.
560 AC_HEADER_STDC
561 AC_HEADER_MAJOR
562 AC_HEADER_DIRENT
563 AC_HEADER_TIME
564
565 AC_CHECK_HEADERS(fcntl.h getopt.h grp.h memory.h netdb.h pwd.h utime.h)
566
567 AC_CHECK_HEADERS(sys/ipc.h sys/socket.h sys/select.h)
568 AC_CHECK_HEADERS(sys/types.h sys/stdtypes.h)
569 AC_CHECK_HEADERS(sys/mman.h sys/resource.h sys/utsname.h sys/wait.h)
570
571 AC_CHECK_HEADERS(netinet/in_systm.h)
572 AC_CHECK_HEADERS(machine/types.h)
573 AC_CHECK_HEADERS(mntent.h sys/mnttab.h sys/systemcfg.h)
574 AC_CHECK_HEADERS(sys/mount.h sys/mntctl.h sys/param.h sys/vmount.h)
575 AC_CHECK_HEADERS(bzlib.h libio.h zlib.h)
576 AC_CHECK_HEADERS(err.h mcheck.h)
577 AC_CHECK_HEADERS(pthread.h)
578
579 dnl popt w float/double needs.
580 AC_CHECK_HEADERS(float.h)
581
582 AC_CHECK_HEADERS(glob.h)
583
584 dnl statfs portability fiddles.
585 dnl
586 dnl We should really emulate/steal sections of the statfs and struct statfs
587 dnl checks from GNU fileutils.
588 dnl
589 AC_MSG_CHECKING(for struct statfs)
590 dnl
591 dnl this is easier than nesting AC_TRY_COMPILEs...
592 dnl
593 found_struct_statfs=no
594
595 if test X$found_struct_statfs = Xno ; then
596 dnl Solaris 2.6+ wants to use statvfs
597 AC_TRY_COMPILE([
598 #ifdef HAVE_SYS_TYPES_H
599 #include <sys/types.h>
600 #endif
601 #include <sys/statvfs.h> ],
602         [struct statvfs sfs;],
603         [AC_MSG_RESULT(in sys/statvfs.h)
604         AC_DEFINE(STATFS_IN_SYS_STATVFS, 1,
605                 [statfs in <sys/statvfs.h> (for solaris 2.6+ systems)])
606         found_struct_statfs=yes],
607 )
608 fi
609
610 if test X$found_struct_statfs = Xno ; then
611 dnl first try including sys/vfs.h
612 AC_TRY_COMPILE([
613 #ifdef HAVE_SYS_TYPES_H
614 #include <sys/types.h>
615 #endif
616 #include <sys/vfs.h> ],
617         [struct statfs sfs;],
618         [AC_MSG_RESULT(in sys/vfs.h)
619         AC_DEFINE(STATFS_IN_SYS_VFS, 1, [statfs in <sys/vfs.h> (for linux systems)])
620         found_struct_statfs=yes],
621 )
622 fi
623
624 if test X$found_struct_statfs = Xno ; then
625 dnl ...next try including sys/mount.h
626 AC_TRY_COMPILE([
627 #ifdef HAVE_SYS_TYPES_H
628 #include <sys/types.h>
629 #endif
630 #ifdef HAVE_SYS_PARAM_H
631 #include <sys/param.h>
632 #endif
633 #include <sys/mount.h> ],
634         [struct statfs sfs;],
635         [AC_MSG_RESULT(in sys/mount.h)
636         AC_DEFINE(STATFS_IN_SYS_MOUNT, 1, [statfs in <sys/mount.h> (for Digital Unix 4.0D systems)])
637         found_struct_statfs=yes],
638 )
639 fi
640
641 if test X$found_struct_statfs = Xno ; then
642 dnl ...still no joy.  Try sys/statfs.h
643 AC_TRY_COMPILE([
644 #ifdef HAVE_SYS_TYPES_H
645 #include <sys/types.h>
646 #endif
647 #include <sys/statfs.h> ],
648         [struct statfs sfs;],
649         [AC_MSG_RESULT(in sys/statfs.h)
650         AC_DEFINE(STATFS_IN_SYS_STATFS, 1, [statfs in <sys/statfs.h> (for Irix 6.4 systems)])
651         found_struct_statfs=yes],
652 )
653 fi
654
655 if test X$found_struct_statfs = Xno ; then
656 dnl ...no luck.  Warn the user of impending doom.
657 AC_MSG_WARN(not found)
658 fi
659
660 dnl
661 dnl if we found the struct, see if it has the f_bavail member.  Some OSes
662 dnl don't, including IRIX 6.5+
663 dnl
664 if test X$found_struct_statfs = Xyes ; then
665 AC_MSG_CHECKING(for f_bavail member in struct statfs)
666 AC_TRY_COMPILE([
667 #ifdef HAVE_SYS_TYPES_H
668 #include <sys/types.h>
669 #endif
670 #if STATFS_IN_SYS_STATVFS
671 # include <sys/statvfs.h>
672   typedef struct statvfs STATFS_t;
673 #else
674   typedef struct statfs STATFS_t;
675 # if STATFS_IN_SYS_VFS
676 #  include <sys/vfs.h>
677 # elif STATFS_IN_SYS_MOUNT
678 #  include <sys/mouht.h>
679 # elif STATFS_IN_SYS_STATFS
680 #  include <sys/statfs.h>
681 # endif
682 #endif ],
683         [STATFS_t sfs;
684         sfs.f_bavail = 0;],
685         [AC_MSG_RESULT(yes)
686         AC_DEFINE(STATFS_HAS_F_BAVAIL, 1, [Define if struct statfs has the f_bavail member])],
687         [AC_MSG_RESULT(no)]
688 )
689 fi
690
691 if test X$found_struct_statfs = Xyes ; then
692 dnl
693 dnl now check to see if we have the 4-argument variant of statfs()
694 dnl this pretty much requires AC_TRY_RUN
695 dnl
696 AC_MSG_CHECKING([if statfs() requires 4 arguments])
697 AC_TRY_RUN([
698 #ifdef HAVE_SYS_TYPES_H
699 #include <sys/types.h>
700 #endif
701 #ifdef STATFS_IN_SYS_VFS
702 #include <sys/vfs.h>
703 #elif STATFS_IN_SYS_MOUNT
704 #include <sys/mouht.h>
705 #elif STATFS_IN_SYS_STATFS
706 #include <sys/statfs.h>
707 #endif
708 main() {
709         struct statfs sfs;
710         exit (statfs(".", &sfs, sizeof(sfs), 0));
711 }
712 ],
713         [AC_MSG_RESULT(yes)
714         AC_DEFINE(STAT_STATFS4, 1, [Define if the statfs() call takes 4 arguments])],
715         [AC_MSG_RESULT(no)],
716         [AC_MSG_RESULT(no)]
717 )
718 fi
719
720 AC_C_INLINE
721
722 dnl look for libc features
723 PROVIDES_ERRNO=no
724 AC_MSG_CHECKING(if <netdb.h> defines h_errno)
725 AC_TRY_LINK([#include <netdb.h>],printf("%d",h_errno),PROVIDES_ERRNO=yes)
726 AC_MSG_RESULT($PROVIDES_ERRNO)
727 if test $PROVIDES_ERRNO = yes; then
728         AC_DEFINE(HAVE_HERRNO, 1, [ Define as 1 if <netdb.h> defines h_errno])
729 fi
730
731 dnl If a system doesn't have S_IFSOCK, define it as 0 which will
732 dnl make S_ISSOCK always return false (nice, eh?)
733 AC_MSG_CHECKING(if <sys/stat.h> defines S_IFSOCK)
734 AC_TRY_LINK([#include <sys/stat.h>],printf("%d", S_IFSOCK),
735         HAS_S_IFSOCK=yes,HAS_S_IFSOCK=no)
736 AC_MSG_RESULT($HAS_S_IFSOCK)
737 if test $HAS_S_IFSOCK = yes; then
738         AC_DEFINE(HAVE_S_IFSOCK, 1, [Define as 1 if <sys/stat.h> defines S_IFSOCK])
739 fi
740
741 dnl Some Unix's are missing S_ISLNK, S_ISSOCK
742 AC_MSG_CHECKING(if <sys/stat.h> defines S_ISLNK)
743 AC_TRY_LINK([#include <sys/stat.h>],printf("%d", S_ISLNK(0755)),
744         HAS_S_ISLNK=yes,HAS_S_ISLNK=no)
745 AC_MSG_RESULT($HAS_S_ISLNK)
746 if test $HAS_S_ISLNK = yes; then
747         AC_DEFINE(HAVE_S_ISLNK, 1, [Define as 1 if <sys/stat.h> defines S_ISLNK])
748 fi
749
750 AC_MSG_CHECKING(if <sys/stat.h> defines S_ISSOCK)
751 AC_TRY_LINK([#include <sys/stat.h>],printf("%d", S_ISSOCK(0755)),
752         HAS_S_ISSOCK=yes,HAS_S_ISSOCK=no)
753 AC_MSG_RESULT($HAS_S_ISSOCK)
754 if test $HAS_S_ISSOCK = yes; then
755         AC_DEFINE(HAVE_S_ISSOCK, 1, [Define as 1 if <sys/stat.h> defines S_ISSOCK])
756 fi
757
758 AC_MSG_CHECKING(if timezone is defined)
759 AC_TRY_LINK([#include <time.h>],printf("%ld", timezone),
760       HAS_TIMEZONE=yes,HAS_TIMEZONE=no)
761 AC_MSG_RESULT($HAS_TIMEZONE)
762
763 dnl Check for missing typedefs
764 AC_TYPE_MODE_T
765 AC_TYPE_PID_T
766
767 dnl Checks for library functions.
768 AC_FUNC_ALLOCA
769 AC_FUNC_VPRINTF
770
771 dnl XXX AC_FUNC_MEMCMP
772 dnl XXX AC_FUNC_MMAP
773 dnl XXX AC_TYPE_SIGNAL
774 dnl XXX AC_FUNC_STRCOLL
775 dnl XXX AC_FUNC_STRFTIME
776 dnl XXX AC_FUNC_UTIME_NULL
777 dnl XXX AC_FUNC_VFORK
778 dnl XXX AC_CHECK_FUNCS(gethostname mkdir mkfifo rmdir select uname)
779
780 AC_CHECK_FUNCS(basename getcwd getwd inet_aton mtrace putenv realpath setenv)
781 AC_CHECK_FUNCS(stpcpy stpncpy strcspn)
782 AC_CHECK_FUNCS(strdup strerror strtol strtoul strspn strstr)
783
784 AC_CHECK_FUNCS(regcomp)
785
786 AC_CHECK_FUNCS(ftok)
787
788 dnl
789 dnl XXX Regex replacement isn't known to be needed yet.
790 dnl
791 dnl AC_ARG_WITH(regex, [  --with-regex            use the GNU regex library ],
792 dnl     [rpm_cv_regex=yes],
793 dnl     [AC_CHECK_FUNCS(regcomp, rpm_cv_regex=no, rpm_cv_regex=yes)])
794 dnl 
795 dnl if test $rpm_cv_regex = no ; then
796 dnl     AC_MSG_CHECKING(whether the regexp library is broken)
797 dnl     AC_TRY_RUN([
798 dnl #include <unistd.h>
799 dnl #include <regex.h>
800 dnl main() { regex_t blah ; exit(regcomp(&blah, "foo.*bar", REG_NOSUB) || regexec (&blah, "foobar", 0, NULL, 0)); }],
801 dnl     rpm_cv_regex_broken=no, rpm_cv_regex_broken=yes, rpm_cv_regex_broken=yes)
802 dnl     AC_MSG_RESULT([$rpm_cv_regex_broken])
803 dnl     if test $rpm_cv_regex_broken = yes ; then
804 dnl         echo "   --> using the included GNU regex instead." >&AC_FD_MSG
805 dnl         rpm_cv_regex=yes
806 dnl     fi
807 dnl fi
808 dnl 
809 dnl if test $rpm_cv_regex = yes; then
810 dnl     AC_DEFINE(USE_GNU_REGEX, 1)
811 dnl     AC_LIBOBJ(regex)
812 dnl fi
813
814 dnl
815 dnl XXX Glob *is* broken on linux with libc5, solaris and possibly aix when
816 dnl %files gets something like
817 dnl     /usr/*/locale/*/LC_MESSAGES/*.mo
818 dnl (Note: more than one asterisk in glob pattern.)
819 dnl
820 AC_ARG_WITH(glob, [  --with-glob             use the internal GNU glob ],
821     [rpm_cv_glob=yes],
822     [AC_CHECK_FUNCS(glob, rpm_cv_glob=no, rpm_cv_glob=yes)])
823
824 if test $rpm_cv_glob = no ; then
825     AC_CACHE_CHECK([for GNU extensions to glob], rpm_cv_glob_ext, [
826     rm -f t
827     mkdir t
828     mkdir t/p
829     touch t/p/foo.8
830     AC_TRY_RUN([
831 #include <unistd.h>
832 #include <sys/stat.h>
833 #include <glob.h>
834 main() {
835   glob_t gl ;
836   gl.gl_stat = stat;
837   exit(glob("t/*/*.8", GLOB_PERIOD, NULL, &gl) || gl.gl_pathc < 1);
838 } ],
839     rpm_cv_glob_ext=yes, rpm_cv_glob_ext=no, rpm_cv_glob_ext=no)
840     rm -r t
841     ])
842     if test "$rpm_cv_glob_ext" = no ; then
843         echo "    --> using the included GNU glob instead." >&AC_FD_MSG
844         rpm_cv_glob=yes
845     fi
846 fi
847
848 if test "$rpm_cv_glob" = yes; then
849     AC_DEFINE(USE_GNU_GLOB, 1, [Use the included glob.c?])
850     AC_LIBOBJ(glob)
851     AC_LIBOBJ(fnmatch)
852 fi
853 dnl
854 dnl Auto-detect which python bindings should be built.
855 dnl
856 withval=auto
857 AC_ARG_WITH(python, [  --with-python           build rpm python bindings ])
858
859 WITH_PYTHON_VERSION=$withval
860 if test $withval = auto ; then
861
862   AC_MSG_CHECKING(for python 2.2)
863   AC_TRY_RUN([
864 #include <python2.2/Python.h>
865 main() {
866   exit(strncmp("2.2", PY_VERSION, 3));
867 } ],
868   withval=yes, withval=no, withval=yes)
869   AC_MSG_RESULT($withval)
870   if test $withval = yes ; then
871     WITH_PYTHON_VERSION="2.2"
872   else
873
874     AC_MSG_CHECKING(for python 1.5.2)
875     AC_TRY_RUN([
876 #include <python1.5/Python.h>
877 main() {
878   exit(strcmp("1.5.2", PY_VERSION));
879 } ],
880     withval=yes, withval=no, withval=yes)
881     AC_MSG_RESULT($withval)
882     if test $withval = yes ; then
883       WITH_PYTHON_VERSION="1.5"
884     fi
885   fi
886
887 fi
888
889 if test "$WITH_PYTHON_VERSION" != no ; then
890   WITH_PYTHON_SUBDIR=python
891   WITH_PYTHON_SUBPACKAGE=1
892 else
893   WITH_PYTHON_SUBDIR=
894   WITH_PYTHON_SUBPACKAGE=0
895 fi
896 AC_SUBST(WITH_PYTHON_SUBDIR)
897 AC_SUBST(WITH_PYTHON_SUBPACKAGE)
898 AC_SUBST(WITH_PYTHON_VERSION)
899
900 AC_PATH_PROG(__DOXYGEN, doxygen, no, $PATH)
901 dnl
902 dnl Auto-detect whether doxygen generated API docs should be included.
903 dnl
904 withval=auto
905 AC_ARG_WITH(apidocs, [  --with-apidocs          build rpm API docs ])
906
907 if test $withval = auto -a $__DOXYGEN != no ; then
908   withval=yes
909 elif test $withval = yes -a $__DOXYGEN = no ; then
910   AC_MSG_ERROR(--> rpm API docs needs doxygen in PATH)
911 fi
912
913 if test $withval = yes; then
914   WITH_APIDOCS_TARGET=apidocs
915   WITH_APIDOCS=1
916 else
917   WITH_APIDOCS=0
918 fi
919 AC_SUBST(WITH_APIDOCS_TARGET)
920 AC_SUBST(WITH_APIDOCS)
921
922 withval=no
923 AC_ARG_WITH(dmalloc, [  --with-dmalloc          build with dmalloc debugging support ])
924 if test $withval = yes ; then
925   AC_DEFINE(DMALLOC, 1, [Build with dmalloc support?])
926   LIBS="$LIBS -ldmalloc"
927 fi
928
929 withval=no
930 AC_ARG_WITH(efence, [  --with-efence           build with efence debugging support ])
931 if test $withval = yes ; then
932   AC_DEFINE(EFENCE, 1, [Build with libefence support?])
933   LIBS="$LIBS -lefence"
934 fi
935
936 AC_CHECK_FUNCS(setlocale)
937
938 dnl XXX Solaris <= 2.6 only permits 8 chars in password.
939 AC_CHECK_FUNCS(getpassphrase)
940
941 AC_CHECK_FUNC(getmntent, AC_DEFINE(HAVE_GETMNTENT, 1, [Define if you have the getmntent() function]), [
942   AC_CHECK_FUNC(mntctl, AC_DEFINE(HAVE_MNTCTL, 1, [Define as 1 if you have mntctl() (only aix?)]),[
943     AC_CHECK_FUNC(getmntinfo_r, AC_DEFINE(HAVE_GETMNTINFO_R, 1, [Define as 1 if you have getmntinfo_r() (only osf?)]), [
944       AC_CHECK_LIB(c_r, getmntinfo_r, [LIBS="$LIBS -lc_r"; 
945                                         AC_DEFINE(HAVE_GETMNTINFO_R, 1, [Define as 1 if you have getmntinfo_r() (only osf?)])], [
946                  AC_DEFINE([USE_GETMNTENT], 1, [Defined if getmntent replacement is used])
947                  AC_LIBOBJ(getmntent)])])])])
948
949 AC_CHECK_FUNC(lchown,
950    [__CHOWN_RHF="%{__chown} -Rhf"
951     __CHGRP_RHF="%{__chgrp} -Rhf"
952     AC_DEFINE(HAVE_LCHOWN, 1, [Define as 1 if you have lchown()])],
953    [__CHOWN_RHF="%{__chown} -Rf"
954     __CHGRP_RHF="%{__chgrp} -Rf"
955     dnl Does chown() follow symlinks? This should be a good enough test.
956     AC_MSG_CHECKING(whether chown() follows symlinks)
957     AC_ARG_ENABLE([broken-chown],
958     [  --enable-broken-chown   this system's chown follows symbolic links], 
959             result=$enableval, result=unknown)
960     if echo "$build" | egrep "(aix)|(hpux)|(linux)" > /dev/null ; then
961         result=yes
962     elif echo "$build" | egrep "(nextstep)" > /dev/null ; then
963         result=no
964     fi
965     if test $result = unknown; then
966         if test `${__ID} | cut -f2 -d\= | cut -f1 -d\(` = 0; then
967             rm -f foo bar
968             touch foo
969             ln -s foo bar
970             ${__CHOWN} 10 bar
971             if test `ls -l foo | awk '{print $3}'` != "root"; then
972                 result=yes
973             else
974                 result=no
975             fi
976             ${__RM} -f foo bar
977         else
978             AC_MSG_CHECKING((cannot check by non-root user))
979             result=no
980         fi
981     fi
982
983     AC_MSG_RESULT($result)
984     if test $result = yes; then
985             AC_DEFINE(CHOWN_FOLLOWS_SYMLINK, 1, [Define as 1 if chown() follows symlinks and you don't have lchown()])
986     fi])
987 AC_SUBST(__CHOWN_RHF)
988 AC_SUBST(__CHGRP_RHF)
989
990 dnl
991 dnl figure out what root's primary group is
992 dnl
993 AC_MSG_CHECKING(root's primary group)
994 AC_TRY_RUN([#include <stdio.h>
995 #include <sys/types.h>
996 #include <pwd.h>
997 #include <grp.h>
998
999 int main()
1000 {
1001         struct passwd *root = NULL;
1002         struct group *roots_group = NULL;
1003         FILE * tempfile = NULL;
1004
1005         root = getpwuid( (uid_t) 0 );
1006         if (root != NULL) {
1007                 roots_group = getgrgid(root->pw_gid);
1008                 if (roots_group != NULL) {
1009                         tempfile = fopen("conftest_rootg", "w");
1010                         if (tempfile != NULL) {
1011                                 fprintf(tempfile, "%s\n", roots_group->gr_name);
1012                                 fclose(tempfile);
1013                                 exit(0);
1014                         }
1015                 }
1016         }
1017
1018         exit(1);
1019 }], ROOT_GROUP=`cat conftest_rootg`,
1020         ROOT_GROUP="root",ROOT_GROUP="root"
1021 )
1022 AC_MSG_RESULT($ROOT_GROUP)
1023 AC_SUBST(ROOT_GROUP)
1024
1025 if test "x$varprefix" = "x"; then
1026     # For /usr and /usr/local, we want the 'var' directory to go
1027     # in /var and /var/local respectively. For everything else, 
1028     # just put the 'var' directory in prefix/var.
1029     case $prefix in
1030         /usr | /usr/local )
1031             varprefix=`echo $prefix | sed 's/usr/var/'` ;;
1032         NONE)
1033             varprefix=`echo $ac_default_prefix | sed 's/usr/var/'` ;;
1034         *) 
1035             varprefix=$prefix/var ;;
1036     esac        
1037 fi
1038 AC_SUBST(varprefix)
1039
1040 if test "x$tmpdir" = "x"; then
1041     if test -d $varprefix/tmp; then
1042         tmpdir=$varprefix/tmp
1043     else
1044         if test -d /var/tmp; then
1045             tmpdir=/var/tmp
1046         else
1047             tmpdir=/tmp
1048         fi
1049     fi
1050 fi
1051 AC_SUBST(tmpdir)
1052
1053 if echo "$build_os" | grep sco > /dev/null; then
1054         echo "hacking things up for sco"
1055         AC_DEFINE(NEED_STRINGS_H, 1, [Define as one if we need to include <strings.h> (along with <string.h>)])
1056         AC_DEFINE(HAVE_STRUCT_MNTTAB, 1,
1057         [Define as 1 if you have "struct mnttab" (only sco?)])
1058 elif echo "$build_os" | grep sunos > /dev/null; then
1059         echo "hacking things up for sunos"
1060         CFLAGS="$CFLAGS -D__USE_FIXED_PROTOTYPES__"
1061         AC_DEFINE(NEED_STRINGS_H, 1, [Define as one if we need to include <strings.h> (along with <string.h>)])
1062         AC_DEFINE(NEED_MYREALLOC, 1, [Define as 1 if we need myrealloc])
1063         AC_LIBOBJ(myrealloc)
1064 fi
1065
1066 #
1067 # get rid of the 4-th tuple, if config.guess returned "linux-gnu" for build_os
1068 #
1069 if echo "$build_os" | grep '.*-gnulibc1' > /dev/null ; then
1070         build_os=`echo "${build_os}" | sed 's/-gnulibc1$//'`
1071 fi
1072 if echo "$build_os" | grep '.*-gnu' > /dev/null ; then
1073         build_os=`echo "${build_os}" | sed 's/-gnu$//'`
1074 fi
1075
1076 changequote(<, >)
1077 build_os_exact="${build_os}"
1078 build_os_major=`echo "${build_os}" | sed 's/\..*$//'`
1079 build_os_noversion=`echo "${build_os}" | sed 's/[0-9]*\..*$//'`
1080 changequote([, ])
1081
1082 rm -f ./find-provides
1083 if test -f ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.prov ; then
1084         echo "using ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.prov for automatic provides generation"
1085     ln -s ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.prov ./find-provides
1086 elif test -f ${srcdir}/autodeps/${build_os_exact}.prov ; then
1087         echo "using ${srcdir}/autodeps/${build_os_exact}.prov for automatic provides generation"
1088     ln -s ${srcdir}/autodeps/${build_os_exact}.prov ./find-provides
1089 elif test -f ${srcdir}/autodeps/${build_os_major}.prov ; then
1090         echo "using ${srcdir}/autodeps/${build_os_major}.prov for automatic provides generation"
1091     ln -s ${srcdir}/autodeps/${build_os_major}.prov ./find-provides
1092 elif test -f ${srcdir}/autodeps/${build_os_noversion}.prov ; then
1093         echo "using ${srcdir}/autodeps/${build_os_noversion}.prov for automatic provides generation"
1094     ln -s ${srcdir}/autodeps/${build_os_noversion}.prov ./find-provides
1095 else
1096     echo "*** no default provides information is available for ${build_os_noversion}"
1097     ln -s ${srcdir}/autodeps/none ./find-provides
1098 fi
1099
1100 rm -f ./find-requires
1101 if test -f ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.req ; then
1102         echo "using ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.req for automatic requires generation"
1103     ln -s ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.req ./find-requires
1104 elif test -f ${srcdir}/autodeps/${build_os_exact}.req ; then
1105         echo "using ${srcdir}/autodeps/${build_os_exact}.req for automatic requires generation"
1106     ln -s ${srcdir}/autodeps/${build_os_exact}.req ./find-requires
1107 elif test -f ${srcdir}/autodeps/${build_os_major}.req ; then
1108         echo "using ${srcdir}/autodeps/${build_os_major}.req for automatic requires generation"
1109     ln -s ${srcdir}/autodeps/${build_os_major}.req ./find-requires
1110 elif test -f ${srcdir}/autodeps/${build_os_noversion}.req ; then
1111         echo "using ${srcdir}/autodeps/${build_os_noversion}.req for automatic requires generation"
1112     ln -s ${srcdir}/autodeps/${build_os_noversion}.req ./find-requires
1113 else
1114     echo "*** no default requires information is available for ${build_os_noversion}"
1115     ln -s ${srcdir}/autodeps/none ./find-requires
1116 fi
1117
1118 dnl XXX Choose /usr/lib or /usr/lib64 for library installs.
1119 MARK64=
1120 case "${target_cpu}" in
1121 x86_64*|ppc64*|powerpc64*|sparc64*|s390x*)      MARK64=64 ;;
1122 esac
1123 AC_SUBST(MARK64)
1124
1125 dnl Determine the canonical arch-vendor-os for the build machine
1126 case "${build_cpu}" in
1127 *86)            RPMCANONCOLOR=0; RPMCANONARCH=i386 ;;
1128 x86_64*)        RPMCANONCOLOR=3; RPMCANONARCH=x86_64 ;;
1129 alpha*)         RPMCANONCOLOR=0; RPMCANONARCH=alpha ;;
1130 sparc*)         RPMCANONCOLOR=0; RPMCANONARCH=sparc ;;
1131 ia64*)          RPMCANONCOLOR=0; RPMCANONARCH=ia64 ;;
1132 s390x*)         RPMCANONCOLOR=0; RPMCANONARCH=s390x ;;
1133 s390*)          RPMCANONCOLOR=0; RPMCANONARCH=s390 ;;
1134 powerpc64*|ppc64*)      RPMCANONCOLOR=0; RPMCANONARCH=ppc64 ;;
1135 powerpc*|ppc*)  RPMCANONCOLOR=0; RPMCANONARCH=ppc ;;
1136 armv3l*)        RPMCANONCOLOR=0; RPMCANONARCH=armv3l ;;
1137 armv4l*)        RPMCANONCOLOR=0; RPMCANONARCH=armv4l ;;
1138 armv4b*)        RPMCANONCOLOR=0; RPMCANONARCH=armv4b ;;
1139 arm*)           RPMCANONCOLOR=0; RPMCANONARCH="${build_cpu}" ;;
1140 mipsel*)        RPMCANONCOLOR=0; RPMCANONARCH=mipsel ;;
1141 mips*)          RPMCANONCOLOR=0; RPMCANONARCH=mips ;;
1142 m68k*)          RPMCANONCOLOR=0; RPMCANONARCH=m68k ;;
1143 *)              RPMCANONCOLOR=0; RPMCANONARCH=unknown ;;
1144 esac
1145 case "${build_os_noversion}" in
1146 mint)           RPMCANONARCH=m68kmint ;;
1147 esac
1148 RPMCANONVENDOR="$build_vendor"
1149 case "${build_vendor}" in
1150 unknown|pc|ibm|redhat|pld|mandrake|conectiva|lvr|yellowdog)
1151         test -f /etc/redhat-release &&          RPMCANONVENDOR=redhat
1152         test -f /etc/pld-release &&             RPMCANONVENDOR=pld
1153         test -f /etc/mandrake-release &&        RPMCANONVENDOR=mandrake
1154         test -f /etc/conectiva-release &&       RPMCANONVENDOR=conectiva
1155         test -f /etc/lvr-release &&             RPMCANONVENDOR=lvr
1156         test -f /etc/yellowdog-release &&       RPMCANONVENDOR=yellowdog
1157         ;;
1158 esac
1159 RPMCANONOS="$build_os_noversion"
1160 AC_SUBST(RPMCANONCOLOR)
1161 AC_SUBST(RPMCANONARCH)
1162 AC_SUBST(RPMCANONVENDOR)
1163 AC_SUBST(RPMCANONOS)
1164
1165 if test X"$prefix" = XNONE ; then
1166     usrprefix="$ac_default_prefix"
1167 else
1168     usrprefix=$prefix
1169 fi
1170 LOCALEDIR="`echo ${usrprefix}/share/locale`"
1171 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR",
1172         [Full path to rpm locale directory (usually /usr/share/locale)])
1173 AC_SUBST(LOCALEDIR)
1174 LIBDIR="`echo $libdir | sed 's-/lib$-/%{_lib}-'`"
1175 AC_SUBST(LIBDIR)
1176 RPMCONFIGDIR="`echo ${usrprefix}/lib/rpm`"
1177 AC_DEFINE_UNQUOTED(RPMCONFIGDIR, "$RPMCONFIGDIR",
1178         [Full path to rpm global configuration directory (usually /usr/lib/rpm)])
1179 AC_SUBST(RPMCONFIGDIR)
1180
1181 SYSCONFIGDIR="`echo /etc/rpm`"
1182 AC_DEFINE_UNQUOTED(SYSCONFIGDIR, "$SYSCONFIGDIR",
1183         [Full path to rpm system configuration directory (usually /etc/rpm)])
1184 AC_SUBST(SYSCONFIGDIR)
1185
1186 MACROFILES="${RPMCONFIGDIR}/macros:${RPMCONFIGDIR}/%{_target_platform}/macros:${SYSCONFIGDIR}/macros:${SYSCONFIGDIR}/macros.specspo:${SYSCONFIGDIR}/macros.db1:${SYSCONFIGDIR}/%{_target_platform}/macros:~/.rpmmacros"
1187 AC_DEFINE_UNQUOTED(MACROFILES, "$MACROFILES",
1188         [Colon separated paths of macro files to read.])
1189 AC_SUBST(MACROFILES)
1190
1191 LIBRPMRC_FILENAME="${RPMCONFIGDIR}/rpmrc"
1192 AC_DEFINE_UNQUOTED(LIBRPMRC_FILENAME, "$LIBRPMRC_FILENAME",
1193         [Full path to rpmrc configuration file (usually /usr/lib/rpm/rpmrc)])
1194 AC_SUBST(LIBRPMRC_FILENAME)
1195
1196 VENDORRPMRC_FILENAME="${RPMCONFIGDIR}/${RPMCANONVENDOR}/rpmrc"
1197 AC_DEFINE_UNQUOTED(VENDORRPMRC_FILENAME, "$VENDORRPMRC_FILENAME",
1198        [Full path to vendor rpmrc configuration file (usually /usr/lib/rpm/vendor/rpmrc)])
1199 AC_SUBST(VENDORRPMRC_FILENAME)
1200
1201 LIBRPMALIAS_FILENAME="${RPMCONFIGDIR}/rpmpopt-${VERSION}"
1202 AC_DEFINE_UNQUOTED(LIBRPMALIAS_FILENAME, "$LIBRPMALIAS_FILENAME",
1203         [Full path to rpmpopt configuration file (usually /usr/lib/rpm/rpmpopt)])
1204 AC_SUBST(LIBRPMALIAS_FILENAME)
1205 FINDREQUIRES="${RPMCONFIGDIR}/find-requires"
1206 AC_DEFINE_UNQUOTED(FINDREQUIRES, "$FINDREQUIRES",
1207         [Full path to find-requires script (usually /usr/lib/rpm/find-requires)])
1208 AC_SUBST(FINDREQUIRES)
1209 FINDPROVIDES="${RPMCONFIGDIR}/find-provides"
1210 AC_DEFINE_UNQUOTED(FINDPROVIDES, "$FINDPROVIDES",
1211         [Full path to find-provides script (usually /usr/lib/rpm/find-provides)])
1212 AC_SUBST(FINDPROVIDES)
1213
1214 testdir="`pwd`/tests"
1215 dnl AC_DEFINE_UNQUOTED(testdir, "$testdir")
1216 AC_SUBST(testdir)
1217
1218 AC_SUBST(INCPATH)
1219 AC_SUBST(LIBMISC)
1220
1221 AC_SUBST(RPM)
1222
1223 AC_SUBST(OBJDUMP)
1224
1225 dnl XXX this causes popt to depend on zlib et al
1226 dnl # XXX Propagate -lucb to popt ...
1227 dnl export LIBS INCPATH CONFIG_SITE
1228
1229 AC_CONFIG_SUBDIRS(popt beecrypt zlib elfutils file db3)
1230
1231 AC_OUTPUT([ Doxyfile Makefile rpmrc macros platform rpmpopt rpm.spec
1232         rpmio/Makefile rpmdb/Makefile lib/Makefile build/Makefile
1233         scripts/Makefile scripts/brp-redhat
1234         scripts/macros.perl scripts/macros.php scripts/macros.python
1235         tools/Makefile
1236         tests/Makefile tests/rpmrc tests/macros tests/hello-test/Makefile
1237         misc/Makefile intl/Makefile po/Makefile.in
1238         doc/Makefile
1239         doc/manual/Makefile
1240         doc/fr/Makefile
1241         doc/ja/Makefile
1242         doc/ko/Makefile
1243         doc/pl/Makefile
1244         doc/ru/Makefile
1245         doc/sk/Makefile
1246         python/Makefile
1247         python/rpmdb/Makefile
1248         python/test/Makefile
1249   ], [  echo timestamp > popt/stamp-h.in
1250         echo timestamp > beecrypt/stamp-h.in
1251         echo timestamp > stamp-h.in
1252   ]
1253 )