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