- use poll(2) if available, avoid borked aurora/sparc select (#124574).
[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.1 code, then you should use a       *
10 * rpm-4.3.1 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.1:                          *
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             WITH_BEECRYPT_INCLUDE="-I/usr/include/beecrypt"
417             WITH_BEECRYPT_LIB="-lbeecrypt"
418         ])
419     ], [
420         if test -d beecrypt ; then
421             AC_DEFINE(HAVE_LIBBEECRYPT, 1, [Define to 1 if you have the `beecrypt' library (-lbeecrypt).])
422             WITH_BEECRYPT_SUBDIR=beecrypt
423             WITH_BEECRYPT_INCLUDE="-I\${top_srcdir}/${WITH_BEECRYPT_SUBDIR}"
424             WITH_BEECRYPT_LIB="\${top_builddir}/${WITH_BEECRYPT_SUBDIR}/libbeecrypt.la"
425         fi
426 ])
427 AC_SUBST(WITH_BEECRYPT_SUBDIR)
428 AC_SUBST(WITH_BEECRYPT_INCLUDE)
429 AC_SUBST(WITH_BEECRYPT_LIB)
430
431 AC_CHECK_FUNC(setreuid, [], [
432     AC_CHECK_LIB(ucb, setreuid, [if echo $LIBS | grep -- -lucb >/dev/null ;then :; else LIBS="$LIBS -lc -lucb" USEUCB=y;fi])
433 ])
434
435 AC_CHECK_FUNC(rand, [], [
436     AC_CHECK_LIB(rand, rand, [])
437 ])
438
439 AC_CHECK_FUNC(getdomainname, [], [
440     AC_CHECK_LIB(nsl, getdomainname)
441 ])
442 AC_CHECK_FUNC(socket, [], [
443     AC_CHECK_LIB(socket, socket)
444 ])
445
446 AC_CHECK_HEADERS(error.h)
447 AC_CHECK_FUNCS(error)
448
449 AC_CHECK_HEADERS(poll.h)
450
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 dnl ------------------ with    internal db
476 AC_DEFINE(HAVE_DB3_DB_H, 1, [Define if you have the <db3/db.h> header file])
477 WITH_DB_SUBDIR=db3
478 WITH_INTERNAL_DB=1
479 DBLIBSRCS="db3.c"
480
481 AC_SUBST(WITH_DB_SUBDIR)
482 AC_SUBST(WITH_INTERNAL_DB)
483
484 DBLIBSRCS="$DBLIBSRCS"
485 DBLIBOBJS=`echo $DBLIBSRCS | sed -e "s/\.c/\.lo/g"`
486
487 AC_SUBST(DBLIBSRCS)
488 AC_SUBST(DBLIBOBJS)
489
490 dnl AmigaOS and IXEmul have a fork() dummy
491   case "$target" in
492     m68k-*-amigaos ) 
493         echo "Building for AmigaOS: using vfork() instead of fork()"; 
494         CFLAGS="$CFLAGS -Dfork=vfork" 
495         ;;
496   esac
497
498 if test -z "${WITH_ZLIB_LIB}" ; then
499 for zlib in z gz ; do
500    AC_CHECK_LIB(${zlib}, gzread, 
501         [LIBS="$LIBS -l${zlib}"; break], 
502         [if test ${zlib} = gz; then 
503             AC_MSG_ERROR([sorry rpm requires libz.a or libgz.a (from the zlib package)]) 
504          fi]
505                )
506 done
507
508 dnl zlib-1.0.4 has not gzseek
509 AC_CHECK_LIB(${zlib}, gzseek, [AC_DEFINE(HAVE_GZSEEK, 1, [Define as 1 if your zlib has gzseek()])])
510 fi
511
512 AC_CHECK_LIB(bz2, bzread, [LIBS="$LIBS -lbz2"], 
513    AC_CHECK_LIB(bz2, BZ2_bzread, [
514      WITH_BZIP2=1
515      LIBS="$LIBS -lbz2"
516      AC_DEFINE(HAVE_BZ2_1_0, 1, [Define as 1 if you bzip2 1.0]) ], 
517      WITH_BZIP2=0))
518 AC_SUBST(WITH_BZIP2)
519
520 AM_GNU_GETTEXT
521 dnl TVM:
522 dnl horrible *temporary* hack to make sure that if we found gettext() in
523 dnl -lintl that we add -lintl *back* to $LIBS.
524 dnl
525 if test X$gt_cv_func_gettext_libintl = Xyes ; then
526     LIBS="-lintl $LIBS"
527 fi
528
529 dnl Checks for header files we can live without.
530 AC_HEADER_STDC
531 AC_HEADER_MAJOR
532 AC_HEADER_DIRENT
533 AC_HEADER_TIME
534
535 AC_CHECK_HEADERS(fcntl.h getopt.h grp.h memory.h netdb.h pwd.h utime.h)
536
537 AC_CHECK_HEADERS(sys/ipc.h sys/socket.h sys/select.h)
538 AC_CHECK_HEADERS(sys/types.h sys/stdtypes.h)
539 AC_CHECK_HEADERS(sys/mman.h sys/resource.h sys/utsname.h sys/wait.h)
540
541 AC_CHECK_HEADERS(netinet/in_systm.h)
542 AC_CHECK_HEADERS(machine/types.h)
543 AC_CHECK_HEADERS(mntent.h sys/mnttab.h sys/systemcfg.h)
544 AC_CHECK_HEADERS(sys/mount.h sys/mntctl.h sys/param.h sys/vmount.h)
545 AC_CHECK_HEADERS(bzlib.h libio.h zlib.h)
546 AC_CHECK_HEADERS(err.h mcheck.h)
547 AC_CHECK_HEADERS(pthread.h)
548
549 dnl popt w float/double needs.
550 AC_CHECK_HEADERS(float.h)
551
552 AC_CHECK_HEADERS(glob.h)
553
554 dnl statfs portability fiddles.
555 dnl
556 dnl We should really emulate/steal sections of the statfs and struct statfs
557 dnl checks from GNU fileutils.
558 dnl
559 AC_MSG_CHECKING(for struct statfs)
560 dnl
561 dnl this is easier than nesting AC_TRY_COMPILEs...
562 dnl
563 found_struct_statfs=no
564
565 if test X$found_struct_statfs = Xno ; then
566 dnl Solaris 2.6+ wants to use statvfs
567 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
568 #ifdef HAVE_SYS_TYPES_H
569 #include <sys/types.h>
570 #endif
571 #include <sys/statvfs.h> ]], [[struct statvfs sfs;]])],[AC_MSG_RESULT(in sys/statvfs.h)
572         AC_DEFINE(STATFS_IN_SYS_STATVFS, 1,
573                 [statfs in <sys/statvfs.h> (for solaris 2.6+ systems)])
574         found_struct_statfs=yes],[])
575 fi
576
577 if test X$found_struct_statfs = Xno ; then
578 dnl first try including sys/vfs.h
579 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
580 #ifdef HAVE_SYS_TYPES_H
581 #include <sys/types.h>
582 #endif
583 #include <sys/vfs.h> ]], [[struct statfs sfs;]])],[AC_MSG_RESULT(in sys/vfs.h)
584         AC_DEFINE(STATFS_IN_SYS_VFS, 1, [statfs in <sys/vfs.h> (for linux systems)])
585         found_struct_statfs=yes],[])
586 fi
587
588 if test X$found_struct_statfs = Xno ; then
589 dnl ...next try including sys/mount.h
590 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
591 #ifdef HAVE_SYS_TYPES_H
592 #include <sys/types.h>
593 #endif
594 #ifdef HAVE_SYS_PARAM_H
595 #include <sys/param.h>
596 #endif
597 #include <sys/mount.h> ]], [[struct statfs sfs;]])],[AC_MSG_RESULT(in sys/mount.h)
598         AC_DEFINE(STATFS_IN_SYS_MOUNT, 1, [statfs in <sys/mount.h> (for Digital Unix 4.0D systems)])
599         found_struct_statfs=yes],[])
600 fi
601
602 if test X$found_struct_statfs = Xno ; then
603 dnl ...still no joy.  Try sys/statfs.h
604 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
605 #ifdef HAVE_SYS_TYPES_H
606 #include <sys/types.h>
607 #endif
608 #include <sys/statfs.h> ]], [[struct statfs sfs;]])],[AC_MSG_RESULT(in sys/statfs.h)
609         AC_DEFINE(STATFS_IN_SYS_STATFS, 1, [statfs in <sys/statfs.h> (for Irix 6.4 systems)])
610         found_struct_statfs=yes],[])
611 fi
612
613 if test X$found_struct_statfs = Xno ; then
614 dnl ...no luck.  Warn the user of impending doom.
615 AC_MSG_WARN(not found)
616 fi
617
618 dnl
619 dnl if we found the struct, see if it has the f_bavail member.  Some OSes
620 dnl don't, including IRIX 6.5+
621 dnl
622 if test X$found_struct_statfs = Xyes ; then
623 AC_MSG_CHECKING(for f_bavail member in struct statfs)
624 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
625 #ifdef HAVE_SYS_TYPES_H
626 #include <sys/types.h>
627 #endif
628 #if STATFS_IN_SYS_STATVFS
629 # include <sys/statvfs.h>
630   typedef struct statvfs STATFS_t;
631 #else
632   typedef struct statfs STATFS_t;
633 # if STATFS_IN_SYS_VFS
634 #  include <sys/vfs.h>
635 # elif STATFS_IN_SYS_MOUNT
636 #  include <sys/mouht.h>
637 # elif STATFS_IN_SYS_STATFS
638 #  include <sys/statfs.h>
639 # endif
640 #endif ]], [[STATFS_t sfs;
641         sfs.f_bavail = 0;]])],[AC_MSG_RESULT(yes)
642         AC_DEFINE(STATFS_HAS_F_BAVAIL, 1, [Define if struct statfs has the f_bavail member])],[AC_MSG_RESULT(no)
643 ])
644 fi
645
646 if test X$found_struct_statfs = Xyes ; then
647 dnl
648 dnl now check to see if we have the 4-argument variant of statfs()
649 dnl this pretty much requires AC_RUN_IFELSE([AC_LANG_SOURCE([[]])],[],[],[])
650 dnl
651 AC_MSG_CHECKING([if statfs() requires 4 arguments])
652 AC_RUN_IFELSE([AC_LANG_SOURCE([[
653 #ifdef HAVE_SYS_TYPES_H
654 #include <sys/types.h>
655 #endif
656 #ifdef STATFS_IN_SYS_VFS
657 #include <sys/vfs.h>
658 #elif STATFS_IN_SYS_MOUNT
659 #include <sys/mouht.h>
660 #elif STATFS_IN_SYS_STATFS
661 #include <sys/statfs.h>
662 #endif
663 main() {
664         struct statfs sfs;
665         exit (statfs(".", &sfs, sizeof(sfs), 0));
666 }
667 ]])],[AC_MSG_RESULT(yes)
668         AC_DEFINE(STAT_STATFS4, 1, [Define if the statfs() call takes 4 arguments])],[AC_MSG_RESULT(no)],[AC_MSG_RESULT(no)
669 ])
670 fi
671
672 AC_C_INLINE
673
674 dnl look for libc features
675 PROVIDES_ERRNO=no
676 AC_MSG_CHECKING(if <netdb.h> defines h_errno)
677 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[printf("%d",h_errno)]])],[PROVIDES_ERRNO=yes],[])
678 AC_MSG_RESULT($PROVIDES_ERRNO)
679 if test $PROVIDES_ERRNO = yes; then
680         AC_DEFINE(HAVE_HERRNO, 1, [ Define as 1 if <netdb.h> defines h_errno])
681 fi
682
683 dnl If a system doesn't have S_IFSOCK, define it as 0 which will
684 dnl make S_ISSOCK always return false (nice, eh?)
685 AC_MSG_CHECKING(if <sys/stat.h> defines S_IFSOCK)
686 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[printf("%d", S_IFSOCK)]])],[HAS_S_IFSOCK=yes],[HAS_S_IFSOCK=no])
687 AC_MSG_RESULT($HAS_S_IFSOCK)
688 if test $HAS_S_IFSOCK = yes; then
689         AC_DEFINE(HAVE_S_IFSOCK, 1, [Define as 1 if <sys/stat.h> defines S_IFSOCK])
690 fi
691
692 dnl Some Unix's are missing S_ISLNK, S_ISSOCK
693 AC_MSG_CHECKING(if <sys/stat.h> defines S_ISLNK)
694 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[printf("%d", S_ISLNK(0755))]])],[HAS_S_ISLNK=yes],[HAS_S_ISLNK=no])
695 AC_MSG_RESULT($HAS_S_ISLNK)
696 if test $HAS_S_ISLNK = yes; then
697         AC_DEFINE(HAVE_S_ISLNK, 1, [Define as 1 if <sys/stat.h> defines S_ISLNK])
698 fi
699
700 AC_MSG_CHECKING(if <sys/stat.h> defines S_ISSOCK)
701 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[printf("%d", S_ISSOCK(0755))]])],[HAS_S_ISSOCK=yes],[HAS_S_ISSOCK=no])
702 AC_MSG_RESULT($HAS_S_ISSOCK)
703 if test $HAS_S_ISSOCK = yes; then
704         AC_DEFINE(HAVE_S_ISSOCK, 1, [Define as 1 if <sys/stat.h> defines S_ISSOCK])
705 fi
706
707 AC_MSG_CHECKING(if timezone is defined)
708 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[printf("%ld", timezone)]])],[HAS_TIMEZONE=yes],[HAS_TIMEZONE=no])
709 AC_MSG_RESULT($HAS_TIMEZONE)
710
711 dnl Check for missing typedefs
712 AC_TYPE_MODE_T
713 AC_TYPE_OFF_T
714 AC_TYPE_PID_T
715 AC_TYPE_SIZE_T
716
717 dnl Checks for library functions.
718 AC_FUNC_ALLOCA
719 AC_FUNC_VPRINTF
720
721 dnl XXX AC_FUNC_MEMCMP
722 dnl XXX AC_FUNC_MMAP
723 dnl XXX AC_TYPE_SIGNAL
724 dnl XXX AC_FUNC_STRCOLL
725 dnl XXX AC_FUNC_STRFTIME
726 dnl XXX AC_FUNC_UTIME_NULL
727 dnl XXX AC_FUNC_FORK([])
728 dnl XXX AC_CHECK_FUNCS(gethostname mkdir mkfifo rmdir select uname)
729
730 AC_CHECK_FUNCS(basename getcwd getwd inet_aton mtrace putenv realpath setenv)
731 AC_CHECK_FUNCS(stpcpy stpncpy strcspn)
732 AC_CHECK_FUNCS(strdup strerror strtol strtoul strspn strstr)
733
734 AC_CHECK_FUNCS(__secure_getenv)
735
736 AC_CHECK_FUNCS(regcomp)
737
738 AC_CHECK_FUNCS(ftok)
739
740 AC_CHECK_FUNCS(mkstemp)
741
742 dnl
743 dnl XXX Regex replacement isn't known to be needed yet.
744 dnl
745 dnl AC_ARG_WITH(regex, [  --with-regex            use the GNU regex library ],
746 dnl     [rpm_cv_regex=yes],
747 dnl     [AC_CHECK_FUNCS(regcomp, rpm_cv_regex=no, rpm_cv_regex=yes)])
748 dnl 
749 dnl if test $rpm_cv_regex = no ; then
750 dnl     AC_MSG_CHECKING(whether the regexp library is broken)
751 dnl     AC_RUN_IFELSE([AC_LANG_SOURCE([[
752 dnl #include <unistd.h>
753 dnl #include <regex.h>
754 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])
755 dnl     AC_MSG_RESULT([$rpm_cv_regex_broken])
756 dnl     if test $rpm_cv_regex_broken = yes ; then
757 dnl         echo "   --> using the included GNU regex instead." >&AS_MESSAGE_FD([])
758 dnl         rpm_cv_regex=yes
759 dnl     fi
760 dnl fi
761 dnl 
762 dnl if test $rpm_cv_regex = yes; then
763 dnl     AC_DEFINE(USE_GNU_REGEX, 1)
764 dnl     AC_LIBOBJ(regex)
765 dnl fi
766
767 dnl
768 dnl XXX Glob *is* broken on linux with libc5, solaris and possibly aix when
769 dnl %files gets something like
770 dnl     /usr/*/locale/*/LC_MESSAGES/*.mo
771 dnl (Note: more than one asterisk in glob pattern.)
772 dnl
773 AC_ARG_WITH(glob, [  --with-glob             use the internal GNU glob ],
774     [rpm_cv_glob=yes],
775     [AC_CHECK_FUNCS(glob, rpm_cv_glob=no, rpm_cv_glob=yes)])
776
777 if test $rpm_cv_glob = no ; then
778     AC_CACHE_CHECK([for GNU extensions to glob], rpm_cv_glob_ext, [
779     rm -f t
780     mkdir t
781     mkdir t/p
782     touch t/p/foo.8
783     AC_RUN_IFELSE([AC_LANG_SOURCE([[
784 #include <unistd.h>
785 #include <sys/stat.h>
786 #include <glob.h>
787 main() {
788   glob_t gl ;
789   gl.gl_stat = stat;
790   exit(glob("t/*/*.8", GLOB_PERIOD, NULL, &gl) || gl.gl_pathc < 1);
791 } ]])],[rpm_cv_glob_ext=yes],[rpm_cv_glob_ext=no],[rpm_cv_glob_ext=no])
792     rm -r t
793     ])
794     if test "$rpm_cv_glob_ext" = no ; then
795         echo "    --> using the included GNU glob instead." >&AS_MESSAGE_FD([])
796         rpm_cv_glob=yes
797     fi
798 fi
799
800 if test "$rpm_cv_glob" = yes; then
801     AC_DEFINE(USE_GNU_GLOB, 1, [Use the included glob.c?])
802     AC_LIBOBJ(glob)
803     AC_LIBOBJ(fnmatch)
804 fi
805 dnl
806 dnl Auto-detect which python bindings should be built.
807 dnl
808 withval=auto
809 AC_ARG_WITH(python, [  --with-python           build rpm python bindings ])
810
811 WITH_PYTHON_VERSION=$withval
812 if test $withval = auto ; then
813
814 AC_MSG_CHECKING(for python 2.3)
815 AC_RUN_IFELSE([AC_LANG_SOURCE([[
816 #include <python2.3/Python.h>
817 main() {
818   exit(strncmp("2.3", PY_VERSION, 3));
819 } ]])],[withval=yes],[withval=no],[withval=yes])
820   AC_MSG_RESULT($withval)
821   if test $withval = yes ; then
822     WITH_PYTHON_VERSION="2.3"
823   else
824   
825     AC_MSG_CHECKING(for python 2.2)
826     AC_RUN_IFELSE([AC_LANG_SOURCE([[
827   #include <python2.2/Python.h>
828   main() {
829     exit(strncmp("2.2", PY_VERSION, 3));
830   } ]])],[withval=yes],[withval=no],[withval=yes])
831     AC_MSG_RESULT($withval)
832     if test $withval = yes ; then
833       WITH_PYTHON_VERSION="2.2"
834     else
835   
836       AC_MSG_CHECKING(for python 1.5.2)
837       AC_RUN_IFELSE([AC_LANG_SOURCE([[
838   #include <python1.5/Python.h>
839   main() {
840     exit(strcmp("1.5.2", PY_VERSION));
841   } ]])],[withval=yes],[withval=no],[withval=yes])
842       AC_MSG_RESULT($withval)
843       if test $withval = yes ; then
844         WITH_PYTHON_VERSION="1.5"
845       fi
846     fi
847   fi
848
849 fi
850
851 if test "$WITH_PYTHON_VERSION" != no ; then
852   WITH_PYTHON_SUBDIR=python
853   WITH_PYTHON_SUBPACKAGE=1
854 else
855   WITH_PYTHON_SUBDIR=
856   WITH_PYTHON_SUBPACKAGE=0
857 fi
858 AC_SUBST(WITH_PYTHON_SUBDIR)
859 AC_SUBST(WITH_PYTHON_SUBPACKAGE)
860 AC_SUBST(WITH_PYTHON_VERSION)
861
862 AC_PATH_PROG(__DOXYGEN, doxygen, no, $PATH)
863 dnl
864 dnl Auto-detect whether doxygen generated API docs should be included.
865 dnl
866 withval=auto
867 AC_ARG_WITH(apidocs, [  --with-apidocs          build rpm API docs ])
868
869 if test $withval = auto -a $__DOXYGEN != no ; then
870   withval=yes
871 elif test $withval = yes -a $__DOXYGEN = no ; then
872   AC_MSG_ERROR(--> rpm API docs needs doxygen in PATH)
873 fi
874
875 WITH_SELINUX_LIB=
876 withval=yes
877 AC_ARG_WITH(selinux, [  --with-selinux          build with selinux support ])
878 if test $withval != no ; then
879   AC_DEFINE(WITH_SELINUX, 1, [Build with selinux support?])
880   WITH_SELINUX_LIB="-lselinux"
881 fi
882 AC_SUBST(WITH_SELINUX_LIB)
883
884 if test $withval = yes; then
885   WITH_APIDOCS_TARGET=apidocs
886   WITH_APIDOCS=1
887 else
888   WITH_APIDOCS=0
889 fi
890 AC_SUBST(WITH_APIDOCS_TARGET)
891 AC_SUBST(WITH_APIDOCS)
892
893 withval=no
894 AC_ARG_WITH(dmalloc, [  --with-dmalloc          build with dmalloc debugging support ])
895 if test $withval = yes ; then
896   AC_DEFINE(DMALLOC, 1, [Build with dmalloc support?])
897   LIBS="$LIBS -ldmalloc"
898 fi
899
900 withval=no
901 AC_ARG_WITH(efence, [  --with-efence           build with efence debugging support ])
902 if test $withval = yes ; then
903   AC_DEFINE(EFENCE, 1, [Build with libefence support?])
904   LIBS="$LIBS -lefence"
905 fi
906
907 AC_CHECK_FUNCS(setlocale)
908
909 dnl XXX Solaris <= 2.6 only permits 8 chars in password.
910 AC_CHECK_FUNCS(getpassphrase)
911
912 AC_CHECK_FUNC(getmntent, AC_DEFINE(HAVE_GETMNTENT, 1, [Define if you have the getmntent() function]), [
913   AC_CHECK_FUNC(mntctl, AC_DEFINE(HAVE_MNTCTL, 1, [Define as 1 if you have mntctl() (only aix?)]),[
914     AC_CHECK_FUNC(getmntinfo_r, AC_DEFINE(HAVE_GETMNTINFO_R, 1, [Define as 1 if you have getmntinfo_r() (only osf?)]), [
915       AC_CHECK_LIB(c_r, getmntinfo_r, [LIBS="$LIBS -lc_r"; 
916                                         AC_DEFINE(HAVE_GETMNTINFO_R, 1, [Define as 1 if you have getmntinfo_r() (only osf?)])], [
917                  AC_DEFINE([USE_GETMNTENT], 1, [Defined if getmntent replacement is used])
918                  AC_LIBOBJ(getmntent)])])])])
919
920 AC_CHECK_FUNC(lchown,
921    [__CHOWN_RHF="%{__chown} -Rhf"
922     __CHGRP_RHF="%{__chgrp} -Rhf"
923     AC_DEFINE(HAVE_LCHOWN, 1, [Define as 1 if you have lchown()])],
924    [__CHOWN_RHF="%{__chown} -Rf"
925     __CHGRP_RHF="%{__chgrp} -Rf"
926     dnl Does chown() follow symlinks? This should be a good enough test.
927     AC_MSG_CHECKING(whether chown() follows symlinks)
928     AC_ARG_ENABLE([broken-chown],
929     [  --enable-broken-chown   this system's chown follows symbolic links], 
930             result=$enableval, result=unknown)
931     if echo "$build" | egrep "(aix)|(hpux)|(linux)" > /dev/null ; then
932         result=yes
933     elif echo "$build" | egrep "(nextstep)" > /dev/null ; then
934         result=no
935     fi
936     if test $result = unknown; then
937         if test `${__ID} | cut -f2 -d\= | cut -f1 -d\(` = 0; then
938             rm -f foo bar
939             touch foo
940             ln -s foo bar
941             ${__CHOWN} 10 bar
942             if test `ls -l foo | awk '{print $3}'` != "root"; then
943                 result=yes
944             else
945                 result=no
946             fi
947             ${__RM} -f foo bar
948         else
949             AC_MSG_CHECKING((cannot check by non-root user))
950             result=no
951         fi
952     fi
953
954     AC_MSG_RESULT($result)
955     if test $result = yes; then
956             AC_DEFINE(CHOWN_FOLLOWS_SYMLINK, 1, [Define as 1 if chown() follows symlinks and you don't have lchown()])
957     fi])
958 AC_SUBST(__CHOWN_RHF)
959 AC_SUBST(__CHGRP_RHF)
960
961 dnl
962 dnl figure out what root's primary group is
963 dnl
964 AC_MSG_CHECKING(root's primary group)
965 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
966 #include <sys/types.h>
967 #include <pwd.h>
968 #include <grp.h>
969
970 int main()
971 {
972         struct passwd *root = NULL;
973         struct group *roots_group = NULL;
974         FILE * tempfile = NULL;
975
976         root = getpwuid( (uid_t) 0 );
977         if (root != NULL) {
978                 roots_group = getgrgid(root->pw_gid);
979                 if (roots_group != NULL) {
980                         tempfile = fopen("conftest_rootg", "w");
981                         if (tempfile != NULL) {
982                                 fprintf(tempfile, "%s\n", roots_group->gr_name);
983                                 fclose(tempfile);
984                                 exit(0);
985                         }
986                 }
987         }
988
989         exit(1);
990 }]])],[ROOT_GROUP=`cat conftest_rootg`],[ROOT_GROUP="root"],[ROOT_GROUP="root"
991 ])
992 AC_MSG_RESULT($ROOT_GROUP)
993 AC_SUBST(ROOT_GROUP)
994
995 if test "x$varprefix" = "x"; then
996     # For /usr and /usr/local, we want the 'var' directory to go
997     # in /var and /var/local respectively. For everything else, 
998     # just put the 'var' directory in prefix/var.
999     case $prefix in
1000         /usr | /usr/local )
1001             varprefix=`echo $prefix | sed 's/usr/var/'` ;;
1002         NONE)
1003             varprefix=`echo $ac_default_prefix | sed 's/usr/var/'` ;;
1004         *) 
1005             varprefix=$prefix/var ;;
1006     esac        
1007 fi
1008 AC_SUBST(varprefix)
1009
1010 if test "x$tmpdir" = "x"; then
1011     if test -d $varprefix/tmp; then
1012         tmpdir=$varprefix/tmp
1013     else
1014         if test -d /var/tmp; then
1015             tmpdir=/var/tmp
1016         else
1017             tmpdir=/tmp
1018         fi
1019     fi
1020 fi
1021 AC_SUBST(tmpdir)
1022
1023 if echo "$build_os" | grep sco > /dev/null; then
1024         echo "hacking things up for sco"
1025         AC_DEFINE(NEED_STRINGS_H, 1, [Define as one if we need to include <strings.h> (along with <string.h>)])
1026         AC_DEFINE(HAVE_STRUCT_MNTTAB, 1,
1027         [Define as 1 if you have "struct mnttab" (only sco?)])
1028 elif echo "$build_os" | grep sunos > /dev/null; then
1029         echo "hacking things up for sunos"
1030         CFLAGS="$CFLAGS -D__USE_FIXED_PROTOTYPES__"
1031         AC_DEFINE(NEED_STRINGS_H, 1, [Define as one if we need to include <strings.h> (along with <string.h>)])
1032         AC_DEFINE(NEED_MYREALLOC, 1, [Define as 1 if we need myrealloc])
1033         AC_LIBOBJ(myrealloc)
1034 fi
1035
1036 #
1037 # get rid of the 4-th tuple, if config.guess returned "linux-gnu" for build_os
1038 #
1039 if echo "$build_os" | grep '.*-gnulibc1' > /dev/null ; then
1040         build_os=`echo "${build_os}" | sed 's/-gnulibc1$//'`
1041 fi
1042 if echo "$build_os" | grep '.*-gnu' > /dev/null ; then
1043         build_os=`echo "${build_os}" | sed 's/-gnu$//'`
1044 fi
1045
1046 changequote(<, >)
1047 build_os_exact="${build_os}"
1048 build_os_major=`echo "${build_os}" | sed 's/\..*$//'`
1049 build_os_noversion=`echo "${build_os}" | sed 's/[0-9]*\..*$//'`
1050 changequote([, ])
1051
1052 rm -f ./find-provides
1053 if test -f ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.prov ; then
1054         echo "using ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.prov for automatic provides generation"
1055     ln -s ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.prov ./find-provides
1056 elif test -f ${srcdir}/autodeps/${build_os_exact}.prov ; then
1057         echo "using ${srcdir}/autodeps/${build_os_exact}.prov for automatic provides generation"
1058     ln -s ${srcdir}/autodeps/${build_os_exact}.prov ./find-provides
1059 elif test -f ${srcdir}/autodeps/${build_os_major}.prov ; then
1060         echo "using ${srcdir}/autodeps/${build_os_major}.prov for automatic provides generation"
1061     ln -s ${srcdir}/autodeps/${build_os_major}.prov ./find-provides
1062 elif test -f ${srcdir}/autodeps/${build_os_noversion}.prov ; then
1063         echo "using ${srcdir}/autodeps/${build_os_noversion}.prov for automatic provides generation"
1064     ln -s ${srcdir}/autodeps/${build_os_noversion}.prov ./find-provides
1065 else
1066     echo "*** no default provides information is available for ${build_os_noversion}"
1067     ln -s ${srcdir}/autodeps/none ./find-provides
1068 fi
1069
1070 rm -f ./find-requires
1071 if test -f ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.req ; then
1072         echo "using ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.req for automatic requires generation"
1073     ln -s ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.req ./find-requires
1074 elif test -f ${srcdir}/autodeps/${build_os_exact}.req ; then
1075         echo "using ${srcdir}/autodeps/${build_os_exact}.req for automatic requires generation"
1076     ln -s ${srcdir}/autodeps/${build_os_exact}.req ./find-requires
1077 elif test -f ${srcdir}/autodeps/${build_os_major}.req ; then
1078         echo "using ${srcdir}/autodeps/${build_os_major}.req for automatic requires generation"
1079     ln -s ${srcdir}/autodeps/${build_os_major}.req ./find-requires
1080 elif test -f ${srcdir}/autodeps/${build_os_noversion}.req ; then
1081         echo "using ${srcdir}/autodeps/${build_os_noversion}.req for automatic requires generation"
1082     ln -s ${srcdir}/autodeps/${build_os_noversion}.req ./find-requires
1083 else
1084     echo "*** no default requires information is available for ${build_os_noversion}"
1085     ln -s ${srcdir}/autodeps/none ./find-requires
1086 fi
1087
1088 dnl XXX Choose /usr/lib or /usr/lib64 for library installs.
1089 MARK64=
1090 case "${target_cpu}" in
1091 x86_64*|ppc64*|powerpc64*|sparc64*|s390x*)      MARK64=64 ;;
1092 esac
1093 AC_SUBST(MARK64)
1094
1095 dnl Determine the canonical arch-vendor-os for the build machine
1096 autorelocate_path='%{nil}'
1097 case "${build_cpu}" in
1098 *86)            RPMCANONCOLOR=0; RPMCANONARCH=i386 ;;
1099 ia32e*)         RPMCANONCOLOR=3; RPMCANONARCH=ia32e ;;
1100 amd64*)         RPMCANONCOLOR=3; RPMCANONARCH=amd64 ;;
1101 x86_64*)        RPMCANONCOLOR=3; RPMCANONARCH=x86_64 ;;
1102 alpha*)         RPMCANONCOLOR=0; RPMCANONARCH=alpha ;;
1103 sparc64*)       RPMCANONCOLOR=3; RPMCANONARCH=sparc64 ;;
1104 sparc*)         RPMCANONCOLOR=3; RPMCANONARCH=sparc ;;
1105 ia64*)          RPMCANONCOLOR=2; RPMCANONARCH=ia64;
1106                 autorelocate_path='/emul/%%{ARCH}-%%{OS}' ;;
1107 s390x*)         RPMCANONCOLOR=3; RPMCANONARCH=s390x ;;
1108 s390*)          RPMCANONCOLOR=0; RPMCANONARCH=s390 ;;
1109 powerpc64*|ppc64*)      RPMCANONCOLOR=3; RPMCANONARCH=ppc64 ;;
1110 powerpc*|ppc*)  RPMCANONCOLOR=0; RPMCANONARCH=ppc ;;
1111 armv3l*)        RPMCANONCOLOR=0; RPMCANONARCH=armv3l ;;
1112 armv4l*)        RPMCANONCOLOR=0; RPMCANONARCH=armv4l ;;
1113 armv4b*)        RPMCANONCOLOR=0; RPMCANONARCH=armv4b ;;
1114 arm*)           RPMCANONCOLOR=0; RPMCANONARCH="${build_cpu}" ;;
1115 mipsel*)        RPMCANONCOLOR=0; RPMCANONARCH=mipsel ;;
1116 mips*)          RPMCANONCOLOR=0; RPMCANONARCH=mips ;;
1117 m68k*)          RPMCANONCOLOR=0; RPMCANONARCH=m68k ;;
1118 *)              RPMCANONCOLOR=0; RPMCANONARCH=unknown ;;
1119 esac
1120 case "${build_os_noversion}" in
1121 mint)           RPMCANONARCH=m68kmint ;;
1122 esac
1123 RPMCANONVENDOR="$build_vendor"
1124 case "${build_vendor}" in
1125 unknown|pc|ibm|redhat|pld|mandrake|conectiva|lvr|yellowdog|caos)
1126         test -f /etc/redhat-release &&          RPMCANONVENDOR=redhat
1127         test -f /etc/pld-release &&             RPMCANONVENDOR=pld
1128         test -f /etc/mandrake-release &&        RPMCANONVENDOR=mandrake
1129         test -f /etc/conectiva-release &&       RPMCANONVENDOR=conectiva
1130         test -f /etc/lvr-release &&             RPMCANONVENDOR=lvr
1131         test -f /etc/yellowdog-release &&       RPMCANONVENDOR=yellowdog
1132         test -f /etc/caos-release &&            RPMCANONVENDOR=caos
1133         ;;
1134 esac
1135 RPMCANONOS="$build_os_noversion"
1136 AC_SUBST(RPMCANONCOLOR)
1137 AC_SUBST(autorelocate_path)
1138 AC_SUBST(RPMCANONARCH)
1139 AC_SUBST(RPMCANONVENDOR)
1140 AC_SUBST(RPMCANONOS)
1141
1142 if test X"$prefix" = XNONE ; then
1143     usrprefix="$ac_default_prefix"
1144 else
1145     usrprefix=$prefix
1146 fi
1147 LOCALEDIR="`echo ${usrprefix}/share/locale`"
1148 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR",
1149         [Full path to rpm locale directory (usually /usr/share/locale)])
1150 AC_SUBST(LOCALEDIR)
1151 LIBDIR="`echo $libdir | sed 's-/lib$-/%{_lib}-'`"
1152 AC_SUBST(LIBDIR)
1153 RPMCONFIGDIR="`echo ${usrprefix}/lib/rpm`"
1154 AC_DEFINE_UNQUOTED(RPMCONFIGDIR, "$RPMCONFIGDIR",
1155         [Full path to rpm global configuration directory (usually /usr/lib/rpm)])
1156 AC_SUBST(RPMCONFIGDIR)
1157
1158 SYSCONFIGDIR="`echo /etc/rpm`"
1159 AC_DEFINE_UNQUOTED(SYSCONFIGDIR, "$SYSCONFIGDIR",
1160         [Full path to rpm system configuration directory (usually /etc/rpm)])
1161 AC_SUBST(SYSCONFIGDIR)
1162
1163 MACROFILES="${RPMCONFIGDIR}/macros:${RPMCONFIGDIR}/%{_target_platform}/macros:${SYSCONFIGDIR}/macros:${SYSCONFIGDIR}/macros.specspo:${SYSCONFIGDIR}/macros.db1:${SYSCONFIGDIR}/%{_target_platform}/macros:~/.rpmmacros"
1164 AC_DEFINE_UNQUOTED(MACROFILES, "$MACROFILES",
1165         [Colon separated paths of macro files to read.])
1166 AC_SUBST(MACROFILES)
1167
1168 LIBRPMRC_FILENAME="${RPMCONFIGDIR}/rpmrc"
1169 AC_DEFINE_UNQUOTED(LIBRPMRC_FILENAME, "$LIBRPMRC_FILENAME",
1170         [Full path to rpmrc configuration file (usually /usr/lib/rpm/rpmrc)])
1171 AC_SUBST(LIBRPMRC_FILENAME)
1172
1173 VENDORRPMRC_FILENAME="${RPMCONFIGDIR}/${RPMCANONVENDOR}/rpmrc"
1174 AC_DEFINE_UNQUOTED(VENDORRPMRC_FILENAME, "$VENDORRPMRC_FILENAME",
1175        [Full path to vendor rpmrc configuration file (usually /usr/lib/rpm/vendor/rpmrc)])
1176 AC_SUBST(VENDORRPMRC_FILENAME)
1177
1178 LIBRPMALIAS_FILENAME="${RPMCONFIGDIR}/rpmpopt-${VERSION}"
1179 AC_DEFINE_UNQUOTED(LIBRPMALIAS_FILENAME, "$LIBRPMALIAS_FILENAME",
1180         [Full path to rpmpopt configuration file (usually /usr/lib/rpm/rpmpopt)])
1181 AC_SUBST(LIBRPMALIAS_FILENAME)
1182 FINDREQUIRES="${RPMCONFIGDIR}/find-requires"
1183 AC_DEFINE_UNQUOTED(FINDREQUIRES, "$FINDREQUIRES",
1184         [Full path to find-requires script (usually /usr/lib/rpm/find-requires)])
1185 AC_SUBST(FINDREQUIRES)
1186 FINDPROVIDES="${RPMCONFIGDIR}/find-provides"
1187 AC_DEFINE_UNQUOTED(FINDPROVIDES, "$FINDPROVIDES",
1188         [Full path to find-provides script (usually /usr/lib/rpm/find-provides)])
1189 AC_SUBST(FINDPROVIDES)
1190
1191 testdir="`pwd`/tests"
1192 dnl AC_DEFINE_UNQUOTED(testdir, "$testdir")
1193 AC_SUBST(testdir)
1194
1195 AC_SUBST(INCPATH)
1196 AC_SUBST(LIBMISC)
1197
1198 AC_SUBST(RPM)
1199
1200 AC_SUBST(OBJDUMP)
1201
1202 dnl XXX this causes popt to depend on zlib et al
1203 dnl # XXX Propagate -lucb to popt ...
1204 dnl export LIBS INCPATH CONFIG_SITE
1205
1206 AC_CONFIG_SUBDIRS(popt beecrypt zlib elfutils file db3)
1207
1208 AC_CONFIG_FILES([ Doxyfile Makefile rpmrc macros platform rpmpopt rpm.spec
1209         rpmio/Makefile rpmdb/Makefile lib/Makefile build/Makefile
1210         scripts/Makefile scripts/brp-redhat
1211         scripts/macros.perl scripts/macros.php scripts/macros.python
1212         tools/Makefile
1213         tests/Makefile tests/rpmrc tests/macros tests/hello-test/Makefile
1214         misc/Makefile intl/Makefile po/Makefile.in
1215         doc/Makefile
1216         doc/manual/Makefile
1217         doc/fr/Makefile
1218         doc/ja/Makefile
1219         doc/ko/Makefile
1220         doc/pl/Makefile
1221         doc/ru/Makefile
1222         doc/sk/Makefile
1223         python/Makefile
1224         python/rpmdb/Makefile
1225         python/rpmdb/test/Makefile
1226         lua/Makefile
1227   ])
1228 AC_CONFIG_COMMANDS([default],[[ echo timestamp > popt/stamp-h.in
1229         echo timestamp > stamp-h.in
1230   
1231 ]],[[]])
1232 AC_OUTPUT