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