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