1 dnl configure.in for RPM
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
8 AM_CONFIG_HEADER(config.h)
9 AC_PREREQ(2.12) dnl Minimum Autoconf version required.
11 AM_INIT_AUTOMAKE(rpm, 2.90)
14 dnl XXX AM_MAINTAINER_MODE
16 dnl Set of available languages.
17 ALL_LINGUAS="cz de fi fr pt_BR ru sk sr sv tr"
21 dnl YYY AC_CANONICAL_SYSTEM
23 dnl Checks for programs.
25 if test "$ac_cv_prog_gcc" = yes; then
26 CFLAGS="$CFLAGS -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wno-char-subscripts"
30 AC_PROG_GCC_TRADITIONAL
34 dnl if CC is gcc, we can rebuild the dependencies (since the depend rule
35 dnl requires gcc). If it's not, don't rebuild dependencies -- use what was
38 if test X"$GCC" = Xyes ; then
39 TARGET="depend everything"
43 # let the top level Makefile know that we're done with `depend'
51 dnl This is a quick hack, to make it so that we can statically link the
52 dnl rpm binary on as many platforms as possible.
54 dnl a *much* better solution would be to use libtool to determine the proper
55 dnl way to statically link on your platform.
57 AC_MSG_CHECKING(what additional CFLAGS are needed to link statically)
58 if test X"$GCC" = Xyes ; then
60 *-*-hpux*) LDFLAGS_STATIC="-Wl,-a,archive_shared";; #works better
61 *-*-*) LDFLAGS_STATIC="-static";;
63 elif test X"$CC" = Xcc ; then
65 *-*-linux*) LDFLAGS_STATIC="-static";;
66 *-*-freebsd*) LDFLAGS_STATIC="-static";;
67 *-*-osf*) LDFLAGS_STATIC="-non_shared";;
68 *-*-aix*) LDFLAGS_STATIC="";; # -Wl,-bnso doesn't seem to work...
69 *-*-hpux*) LDFLAGS_STATIC="-Wl,-a,archive_shared";;
70 *-*-solaris*) LDFLAGS_STATIC="-B static";;
71 *-*-irix*) LDFLAGS_STATIC="";; #should be -non_shared, but can't
72 # link because of crt1.o then.
73 *-*-ultrix*) LDFLAGS_STATIC="";; #ultrix doesn't have shared libs.
74 *-*-*) LDFLAGS_STATIC=""
77 Unable to guess what option to pass to $CC to generate a static
78 executable. You will need to set the LDFLAGS_STATIC macro in Makefile.inc to
79 the appropriate argument(s) if you want to build a static rpm executable.
85 # just link it dynamically
88 AC_MSG_RESULT($LDFLAGS_STATIC)
90 if test -n "$LDFLAGS_STATIC"
92 AC_CHECKING(if we can link dynamically and still access the services switch)
93 AC_CHECK_LIB(c,gethostbyname,
94 AC_MSG_RESULT(will build static executable)
96 AC_MSG_RESULT(will have to link dynamically)
101 AC_MSG_CHECKING(POSIX chmod)
103 chmod 744 foo.chmodtest
104 chmod +X foo.chmodtest 2>/dev/null
105 a=`ls -l foo.chmodtest | awk '{print $1}'`
107 if test "$a" = "-rwxr-xr-x"; then
109 FIXPERMS=a+rX,g-w,o-w
111 AC_MSG_RESULT(no (tell your OS vendor about GNU fileutils))
116 dnl see if we have a mkdir that supports `-p'.
118 AC_PATH_PROGS(MKDIR, mkdir, mkdir)
119 AC_MSG_CHECKING(if $MKDIR supports -p)
121 $MKDIR -p conftest/a 2>/dev/null
122 if test $? = 0 ; then
123 rmdir conftest/a 2>/dev/null
124 if test $? = 0 ; then
130 rmdir conftest 2>/dev/null
131 if test $? = 0 ; then
140 if test X"$MKDIR_P" = X0 ; then
142 MKDIR_P="`echo ${prefix}/lib/rpm/mkinstalldirs`"
147 dnl substitute this into config.h, so the C source picks it up.
149 AC_DEFINE_UNQUOTED(MKDIR_P, "${MKDIR_P}")
157 dnl This test must precede tests of compiler characteristics like
158 dnl that for the inline keyword, since it may change the degree to
159 dnl which the compiler supports such features.
167 AC_CHECK_TOOL(AR, ar, :)
169 if test "$cross_compiling" != "yes"; then
170 MYPATH="/bin:/usr/bin:/usr/local/bin:$PATH:/opt/gnu/bin"
171 AC_MSG_CHECKING(for gzip location)
172 if test -z "$GZIPBIN"; then
176 if test -f $n/gzip; then
184 if test -z "$GZIPBIN"; then
187 AC_MSG_WARN(Can't find gzip, assuming $GZIPBIN)
189 AC_MSG_RESULT($GZIPBIN)
192 AC_MSG_CHECKING(for bzip2 location)
193 if test -z "$BZIP2BIN"; then
197 if test -f $n/bzip2; then
205 if test -z "$BZIP2BIN"; then
206 BZIP2BIN="/usr/bin/bzip2"
208 AC_MSG_WARN(Can't find bzip2, assuming $BZIP2BIN)
210 AC_MSG_RESULT($BZIP2BIN)
213 AC_MSG_CHECKING(old version of patch)
214 PATCHVERSION=`patch --version 2>&1`
216 if test "$PATCHVERSION" = "Patch version 2.1"; then
217 AC_DEFINE(HAVE_OLDPATCH_21)
218 AC_MSG_RESULT(patch older then 2.2 found)
220 AC_MSG_RESULT(patch later then 2.2 found)
228 *-*-solaris*) LIBS="$LIBS -L$l -R$l $*";;
229 *) LIBS="$LIBS -L$l $*";;
234 for dir in $prefix /usr/local
237 NONE|/usr) continue;;
239 if test X$localdone != X ; then continue; fi
244 AC_MSG_CHECKING(for $dir/lib in LIBS)
245 if test -d $dir/lib ; then
252 AC_MSG_CHECKING(for $dir/include in INCPATH)
253 if test -d $dir/include ; then
254 INCPATH="$INCPATH -I$dir/include"
261 AC_MSG_CHECKING(for /usr/ucblib in LIBS)
262 if test -d /usr/ucblib ; then
263 if test "$build" = "mips-sni-sysv4" ; then
264 addlib /usr/ccs/lib -lc
274 dnl Checks for libraries.
276 AC_CHECK_FUNC(strcasecmp, [], [
277 AC_CHECK_LIB(ucb, strcasecmp, [LIBS="$LIBS -lc -lucb" USEUCB=y])
279 AC_CHECK_FUNC(setreuid, [], [
280 AC_CHECK_LIB(ucb, setreuid, [if echo $LIBS | grep -- -lucb >/dev/null ;then :; else LIBS="$LIBS -lc -lucb" USEUCB=y;fi])
283 AC_CHECK_FUNC(rand, [], [
284 AC_CHECK_LIB(rand, rand, [LIBS="$LIBS -lm"])
287 AC_CHECK_FUNC(getdomainname, [], [
288 AC_CHECK_LIB(nsl, getdomainname, [LIBS="$LIBS -lnsl"])
290 AC_CHECK_FUNC(socket, [], [
291 AC_CHECK_LIB(socket, socket, [LIBS="$LIBS -lsocket"])
294 AC_CHECK_FUNC(dbopen, [],
295 AC_CHECK_LIB(db, dbopen, [], AC_MSG_WARN([sorry this package needs libdb.a
296 (from the db package)]))
299 AC_CHECK_FUNC(fork, [], [echo "using vfork() instead of fork()";
302 dnl AmigaOS and IXEmul have a fork() dummy
305 echo "Building for AmigaOS: using vfork() instead of fork()";
306 CFLAGS="$CFLAGS -Dfork=vfork"
312 for zlib in z gz ; do
313 AC_CHECK_LIB(${zlib}, gzread,
314 [LIBS="$LIBS -l${zlib}"; break],
315 [if test ${zlib} = gz; then
316 AC_MSG_WARN([sorry this package needs libz.a or libgz.a (from the zlib package)])
321 dnl XXX these are needed only by rpmgettext right now
322 AM_FUNC_ERROR_AT_LINE
324 dnl ==> AM_GNU_GETTEXT does this (and more)
325 dnl AC_CHECK_HEADERS(unistd.h limits.h locale.h malloc.h string.h sys/param.h)
329 dnl Checks for header files we can live without.
335 AC_CHECK_HEADERS(db_185.h fcntl.h getopt.h grp.h memory.h netdb.h pwd.h utime.h)
337 AC_CHECK_HEADERS(sys/socket.h sys/select.h)
338 AC_CHECK_HEADERS(sys/types.h sys/stdtypes.h)
339 AC_CHECK_HEADERS(sys/mman.h sys/resource.h sys/utsname.h sys/wait.h)
341 AC_CHECK_HEADERS(netinet/in_systm.h)
342 AC_CHECK_HEADERS(machine/types.h)
343 AC_CHECK_HEADERS(mntent.h sys/mnttab.h sys/systemcfg.h)
344 AC_CHECK_HEADERS(sys/mount.h sys/mntctl.h sys/vmount.h)
349 dnl look for libc features
351 AC_MSG_CHECKING(if <netdb.h> defines h_errno)
352 AC_TRY_LINK([#include <netdb.h>],printf("%d",h_errno),PROVIDES_ERRNO=yes)
353 AC_MSG_RESULT($PROVIDES_ERRNO)
354 if test $PROVIDES_ERRNO = yes; then
355 AC_DEFINE(HAVE_HERRNO)
358 dnl If a system doesn't have S_IFSOCK, define it as 0 which will
359 dnl make S_ISSOCK always return false (nice, eh?)
360 AC_MSG_CHECKING(if <sys/stat.h> defines S_IFSOCK)
361 AC_TRY_LINK([#include <sys/stat.h>],printf("%d", S_IFSOCK),
362 HAS_S_IFSOCK=yes,HAS_S_IFSOCK=no)
363 AC_MSG_RESULT($HAS_S_IFSOCK)
364 if test $HAS_S_IFSOCK = yes; then
365 AC_DEFINE(HAVE_S_IFSOCK)
368 dnl Some Unix's are missing S_ISLNK, S_ISSOCK
369 AC_MSG_CHECKING(if <sys/stat.h> defines S_ISLNK)
370 AC_TRY_LINK([#include <sys/stat.h>],printf("%d", S_ISLNK(0755)),
371 HAS_S_ISLNK=yes,HAS_S_ISLNK=no)
372 AC_MSG_RESULT($HAS_S_ISLNK)
373 if test $HAS_S_ISLNK = yes; then
374 AC_DEFINE(HAVE_S_ISLNK)
377 AC_MSG_CHECKING(if <sys/stat.h> defines S_ISSOCK)
378 AC_TRY_LINK([#include <sys/stat.h>],printf("%d", S_ISSOCK(0755)),
379 HAS_S_ISSOCK=yes,HAS_S_ISSOCK=no)
380 AC_MSG_RESULT($HAS_S_ISSOCK)
381 if test $HAS_S_ISSOCK = yes; then
382 AC_DEFINE(HAVE_S_ISSOCK)
385 AC_MSG_CHECKING(if timezone is defined)
386 AC_TRY_LINK([#include <time.h>],printf("%ld", timezone),
387 HAS_TIMEZONE=yes,HAS_TIMEZONE=no)
388 AC_MSG_RESULT($HAS_TIMEZONE)
390 dnl Check for missing typedefs
394 dnl Checks for library functions.
399 if test $ac_cv_func_fnmatch_works = no; then
400 LIBOBJS="$LIBOBJS fnmatch.o"
401 AC_DEFINE_UNQUOTED(fnmatch, rpl_fnmatch)
404 dnl XXX AC_FUNC_MEMCMP
406 dnl XXX AC_TYPE_SIGNAL
407 dnl XXX AC_FUNC_STRCOLL
408 dnl XXX AC_FUNC_STRFTIME
409 dnl XXX AC_FUNC_UTIME_NULL
410 dnl XXX AC_FUNC_VFORK
411 dnl XXX AC_CHECK_FUNCS(gethostname lchown mkdir mkfifo rmdir select uname)
413 AC_REPLACE_FUNCS(getcwd getwd glob inet_aton putenv realpath)
414 AC_REPLACE_FUNCS(strdup strerror strtol strtoul strspn strstr)
416 dnl XXX stpcpy/stpncpy needed by rpmgettext
417 AC_REPLACE_FUNCS(stpcpy stpncpy strcasecmp strncasecmp strcspn)
419 AC_CHECK_FUNCS(setlocale)
421 AC_CHECK_FUNC(getmntent, AC_DEFINE(HAVE_GETMNTENT), [
422 AC_CHECK_FUNC(mntctl, AC_DEFINE(HAVE_MNTCTL),[
423 AC_CHECK_FUNC(getmntinfo_r, AC_DEFINE(HAVE_GETMNTINFO_R), [
424 AC_CHECK_LIB(c_r, getmntinfo_r, [LIBS="$LIBS -lc_r";
425 AC_DEFINE(HAVE_GETMNTINFO_R)],
426 LIBOBJS="$LIBOBJS getmntent.o")])])])
428 AC_CHECK_FUNC(lchown, [LCHOWN=yes; AC_DEFINE(HAVE_LCHOWN)])
430 if test "$LCHOWN" = no; then
431 dnl Does chown() follow symlinks? This should be a good enough test.
432 AC_MSG_CHECKING(whether chown() follows symlinks)
433 AC_ARG_ENABLE([broken-chown],
434 [ --enable-broken-chown this system's chown follows symbolic links],
435 result=$enableval, result=unknown)
436 if echo "$build" | egrep "(aix)|(hpux)|(linux)" > /dev/null ; then
438 elif echo "$build" | egrep "(nextstep)" > /dev/null ; then
441 if test $result = unknown; then
442 if test `id | cut -f2 -d\= | cut -f1 -d\(` = 0; then
447 if test `ls -l foo | awk '{print $3}'` != "root"; then
454 AC_MSG_CHECKING((cannot check by non-root user))
459 AC_MSG_RESULT($result)
460 if test $result = yes; then
461 AC_DEFINE(CHOWN_FOLLOWS_SYMLINK)
467 dnl figure out what root's primary group is
469 AC_MSG_CHECKING(root's primary group)
470 AC_TRY_RUN([#include <stdio.h>
471 #include <sys/types.h>
477 struct passwd *root = NULL;
478 struct group *roots_group = NULL;
479 FILE * tempfile = NULL;
481 root = getpwuid( (uid_t) 0 );
483 roots_group = getgrgid(root->pw_gid);
484 if (roots_group != NULL) {
485 tempfile = fopen("conftest_rootg", "w");
486 if (tempfile != NULL) {
487 fprintf(tempfile, "%s\n", roots_group->gr_name);
495 }], ROOT_GROUP=`cat conftest_rootg`,
496 ROOT_GROUP="root",ROOT_GROUP="root"
498 AC_DEFINE_UNQUOTED(ROOT_GROUP, "$ROOT_GROUP")
499 AC_MSG_RESULT($ROOT_GROUP)
502 if test "x$varprefix" = "x"; then
503 varprefix=`echo $prefix | sed 's/usr/var/'`
504 test "x$prefix" = xNONE && varprefix=`echo $ac_default_prefix | sed 's/usr/var/'`
507 if test "x$tmpdir" = "x"; then
508 if test -d $varprefix/tmp; then
509 tmpdir=$varprefix/tmp
511 if test -d /var/tmp; then
519 if echo "$build_os" | grep sco > /dev/null; then
520 echo "hacking things up for sco"
521 AC_DEFINE(NEED_STRINGS_H)
522 AC_DEFINE(HAVE_STRUCT_MNTTAB)
523 elif echo "$build_os" | grep sunos > /dev/null; then
524 echo "hacking things up for sunos"
525 CFLAGS="$CFLAGS -D__USE_FIXED_PROTOTYPES__"
526 AC_DEFINE(NEED_STRINGS_H)
527 AC_DEFINE(NEED_MYREALLOC)
528 LIBOBJS="$LIBOBJS myrealloc.o"
529 elif echo "$build_os" | grep hpux > /dev/null; then
531 echo "hacking things up for hpux"
535 # get rid of the 4-th tuple, if config.guess returned "linux-gnu" for build_os
537 if echo "$build_os" | grep '.*-gnu' > /dev/null ; then
538 build_os=`echo "${build_os}" | sed 's/-gnu$//'`
542 build_os_exact="${build_os}"
543 build_os_major=`echo "${build_os}" | sed 's/\..*$//'`
544 build_os_noversion=`echo "${build_os}" | sed 's/[0-9]*\..*$//'`
547 rm -f ./find-provides.sh
548 if test -f ${srcdir}/autodeps/${build_os_exact}.prov ; then
549 echo "using ${srcdir}/autodeps/${build_os_exact}.prov for automatic provides generation"
550 ln -s ${srcdir}/autodeps/${build_os_exact}.prov ./find-provides.sh
551 elif test -f ${srcdir}/autodeps/${build_os_major}.prov ; then
552 echo "using ${srcdir}/autodeps/${build_os_major}.prov for automatic provides generation"
553 ln -s ${srcdir}/autodeps/${build_os_major}.prov ./find-provides.sh
554 elif test -f ${srcdir}/autodeps/${build_os_noversion}.prov ; then
555 echo "using ${srcdir}/autodeps/${build_os_noversion}.prov for automatic provides generation"
556 ln -s ${srcdir}/autodeps/${build_os_noversion}.prov ./find-provides.sh
558 echo "*** no default provides information is available for ${build_os_noversion}"
559 ln -s ${srcdir}/autodeps/none ./find-provides.sh
562 rm -f ./find-requires.sh
563 if test -f ${srcdir}/autodeps/${build_os_exact}.req ; then
564 echo "using ${srcdir}/autodeps/${build_os_exact}.req for automatic requires generation"
565 ln -s ${srcdir}/autodeps/${build_os_exact}.req ./find-requires.sh
566 elif test -f ${srcdir}/autodeps/${build_os_major}.req ; then
567 echo "using ${srcdir}/autodeps/${build_os_major}.req for automatic requires generation"
568 ln -s ${srcdir}/autodeps/${build_os_major}.req ./find-requires.sh
569 elif test -f ${srcdir}/autodeps/${build_os_noversion}.req ; then
570 echo "using ${srcdir}/autodeps/${build_os_noversion}.req for automatic requires generation"
571 ln -s ${srcdir}/autodeps/${build_os_noversion}.req ./find-requires.sh
573 echo "*** no default requires information is available for ${build_os_noversion}"
574 ln -s ${srcdir}/autodeps/none ./find-requires.sh
578 if test -n "$LIBOBJS" ; then
581 MISCPATH=misc/libmisc.a
584 RPMCONFIGDIR="`echo ${prefix}/lib/rpm`"
585 AC_DEFINE_UNQUOTED(RPMCONFIGDIR, "$RPMCONFIGDIR")
586 AC_SUBST(RPMCONFIGDIR)
587 LIBRPMRC_FILENAME="${RPMCONFIGDIR}/rpmrc"
588 AC_DEFINE_UNQUOTED(LIBRPMRC_FILENAME, "$LIBRPMRC_FILENAME")
589 AC_SUBST(LIBRPMRC_FILENAME)
590 LIBRPMALIAS_FILENAME="${RPMCONFIGDIR}/rpmpopt"
591 AC_DEFINE_UNQUOTED(LIBRPMALIAS_FILENAME, "$LIBRPMALIAS_FILENAME")
592 AC_SUBST(LIBRPMALIAS_FILENAME)
593 FINDREQUIRES="${RPMCONFIGDIR}/find-requires"
594 AC_DEFINE_UNQUOTED(FINDREQUIRES, "$FINDREQUIRES")
595 AC_SUBST(FINDREQUIRES)
596 FINDPROVIDES="${RPMCONFIGDIR}/find-provides"
597 AC_DEFINE_UNQUOTED(FINDPROVIDES, "$FINDPROVIDES")
598 AC_SUBST(FINDPROVIDES)
599 MACROFILES="${RPMCONFIGDIR}/macros"
600 AC_DEFINE_UNQUOTED(MACROFILES, "$MACROFILES")
620 AC_SUBST(LDFLAGS_STATIC)
622 # XXX Propagate -lucb to popt ...
625 AC_CONFIG_SUBDIRS(popt)
626 AC_OUTPUT([Makefile Makefile.inc lib-rpmrc macros lib/Makefile
627 build/Makefile tools/Makefile scripts/Makefile
628 misc/Makefile po/Makefile.in intl/Makefile],
629 [sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile])