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