Hi!
[tools/librpm-tizen.git] / configure.in
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(rpm.c)
8 AC_CANONICAL_SYSTEM
9
10 AM_INIT_AUTOMAKE(rpm, 3.1)
11 AM_CONFIG_HEADER(config.h)
12
13 AC_PREREQ(2.12)         dnl Minimum Autoconf version required.
14
15 dnl XXX AM_MAINTAINER_MODE
16
17 dnl Set of available languages.
18 ALL_LINGUAS="cs de fi fr ja pl pt_BR ru sk sl sr sv tr"
19
20 LIBOBJS=
21
22 dnl Checks for programs.
23 AC_ARG_PROGRAM
24 AC_PROG_CC
25 if test "$ac_cv_prog_gcc" = yes; then
26     CFLAGS="$CFLAGS -D_GNU_SOURCE -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wno-char-subscripts"
27 fi
28
29 AC_PROG_CPP
30 AC_PROG_GCC_TRADITIONAL
31 AC_PROG_INSTALL
32
33 dnl
34 dnl This now uses libtool. Put
35 dnl     LDFLAGS_STATIC="-all"
36 dnl to attempt static executables using libtool. Otherwise
37 dnl     LDFLAGS_STATIC=""
38 dnl
39 AC_MSG_CHECKING(flag used by libtool to link rpm)
40 if test X"$GCC" = Xyes ; then
41         case "$target" in
42                 *-*-solaris*)   LDFLAGS_STATIC="";;
43                 *-*-hpux*)      LDFLAGS_STATIC="";;
44                 *-*-*)          LDFLAGS_STATIC="-all";;
45         esac
46 elif test X"$CC" = Xcc ; then
47         case "$target" in
48                 *-*-linux*)     LDFLAGS_STATIC="-all";;
49                 *-*-freebsd*)   LDFLAGS_STATIC="-all";;
50                 *-*-osf*)       LDFLAGS_STATIC="-all";;
51                 *-*-aix*)       LDFLAGS_STATIC="";;  # -Wl,-bnso doesn't seem to work...
52                 *-*-hpux*)      LDFLAGS_STATIC="";;
53                 *-*-solaris*)   LDFLAGS_STATIC="";;
54                 *-*-irix*)      LDFLAGS_STATIC="";;  #should be -non_shared, but can't
55                                                                                         # link because of crt1.o then.
56                 *-*-ultrix*)    LDFLAGS_STATIC="-all";;  #ultrix doesn't have shared libs.
57                 *-*-*)          LDFLAGS_STATIC=""
58 AC_MSG_WARN([
59
60 Unable to guess what option to pass to $CC to generate a static
61 executable.  You will need to set the LDFLAGS_STATIC macro in Makefile.inc to
62 the appropriate argument(s) if you want to build a static rpm executable.
63
64 ])
65                 ;;
66         esac
67 else
68         # just link it dynamically
69         LDFLAGS_STATIC=""
70 fi
71 LDFLAGS_STATIC="${LDFLAGS} ${LDFLAGS_STATIC}-static"    # libtool format
72 AC_MSG_RESULT($LDFLAGS_STATIC)
73 AC_SUBST(LDFLAGS_STATIC)
74
75 dnl
76 dnl look for POSIX chmod attributes
77 dnl
78 AC_MSG_CHECKING(POSIX chmod)
79 touch foo.chmodtest
80 chmod 744 foo.chmodtest
81 chmod +X foo.chmodtest 2>/dev/null
82 a=`ls -l foo.chmodtest | awk '{print $1}'`
83 rm -f foo.chmodtest
84 if test "$a" = "-rwxr-xr-x"; then
85     AC_MSG_RESULT(yes)
86     FIXPERMS=a+rX,g-w,o-w 
87 else
88     AC_MSG_RESULT(no (tell your OS vendor about GNU fileutils))
89     FIXPERMS=a+r,g-w,o-w 
90 fi
91 AC_SUBST(FIXPERMS)
92
93 dnl
94 dnl see if we have a mkdir that supports `-p'.
95 dnl
96 AC_PATH_PROGS(MKDIR, mkdir, mkdir)
97 AC_MSG_CHECKING(if $MKDIR supports -p)
98 rm -rf conftest
99 $MKDIR -p conftest/a 2>/dev/null
100 if test $? = 0 ; then
101         rmdir conftest/a 2>/dev/null
102         if test $? = 0  ; then
103                 :
104         else
105                 MKDIR_P=0
106         fi
107
108         rmdir conftest 2>/dev/null
109         if test $? = 0 ; then
110                 MKDIR_P="$MKDIR -p"
111         else
112                 MKDIR_P=0
113         fi
114 else
115         MKDIR_P=0
116 fi
117
118 if test X"$MKDIR_P" = X0 ; then
119         AC_MSG_RESULT(no)
120         MKDIR_P="`echo ${prefix}/lib/rpm/mkinstalldirs`"
121 else
122         AC_MSG_RESULT(yes)
123 fi
124 dnl
125 dnl substitute this into config.h, so the C source picks it up.
126 dnl
127 AC_DEFINE_UNQUOTED(MKDIR_P, "${MKDIR_P}")
128 AC_SUBST(MKDIR_P)
129
130 AC_AIX
131 AC_MINIX
132 AC_ISC_POSIX
133
134 dnl This test must precede tests of compiler characteristics like
135 dnl that for the inline keyword, since it may change the degree to
136 dnl which the compiler supports such features.
137 AM_C_PROTOTYPES
138
139 AC_PROG_AWK
140 AC_PROG_LN_S
141 AC_PROG_MAKE_SET
142
143 dnl AM_DISABLE_SHARED
144 AM_PROG_LIBTOOL
145
146 AC_CHECK_TOOL(AR, ar, :)
147
148 if test "$cross_compiling" != "yes"; then
149 dnl
150 dnl Set search path for common programs
151 dnl
152     MYPATH="/bin:/usr/bin:/usr/local/bin:$PATH:/sbin:/usr/sbin:/usr/local/sbin:/opt/gnu/bin"
153
154 dnl
155 dnl Find some common programs
156 dnl
157     AC_PATH_PROG(BZIP2BIN, bzip2, /usr/bin/bzip2, $MYPATH)
158     AC_PATH_PROG(__CAT, cat, /bin/cat, $MYPATH)
159     AC_PATH_PROG(__CHGRP, chgrp, /bin/chgrp, $MYPATH)
160     AC_PATH_PROG(__CHMOD, chmod, /bin/chmod, $MYPATH)
161     AC_PATH_PROG(__CHOWN, chown, /bin/chown, $MYPATH)
162     AC_PATH_PROG(__CP, cp, /bin/cp, $MYPATH)
163     AC_PATH_PROG(__CPIO, cpio, /bin/cpio, $MYPATH)
164     AC_PATH_PROG(GZIPBIN, gzip, /bin/gzip, $MYPATH)
165     AC_PATH_PROG(__GREP, grep, /bin/grep, $MYPATH)
166
167     AC_PATH_PROG(__ID, id, /usr/bin/id, $MYPATH)
168     AC_MSG_CHECKING(checking whether id supports -u)
169     if `${__ID} -u 2>&1 > /dev/null` ; then
170         __ID_U="%{__id} -u"
171         AC_MSG_RESULT(yes)
172     else
173 dnl XXX Watchout for square brackets fed to m4.
174         __ID_U="%{__id} | %{__sed} 's/[[^=]]*=\\\\([[0-9]][[0-9]]*\\\\).*$/\\\\1/'"
175         AC_MSG_RESULT(no)
176     fi
177     AC_SUBST(__ID_U)
178
179     AC_PATH_PROG(__INSTALL, install, /usr/bin/install, $MYPATH)
180     AC_PATH_PROG(__MAKE, make, /usr/bin/make, $MYPATH)
181     AC_PATH_PROG(__MKDIR, mkdir, /bin/mkdir, $MYPATH)
182     AC_PATH_PROG(__MV, mv, /bin/mv, $MYPATH)
183     AC_PATH_PROG(__PATCH, patch, /usr/bin/patch, $MYPATH)
184     AC_MSG_CHECKING(old version of patch)
185     PATCHVERSION=`patch --version 2>&1`
186
187     if test "$PATCHVERSION" = "Patch version 2.1"; then
188         AC_DEFINE(HAVE_OLDPATCH_21)
189         AC_MSG_RESULT(patch older then 2.2 found)
190     else
191         AC_MSG_RESULT(patch later then 2.2 found)
192     fi
193
194     AC_PATH_PROG(__PERL, perl, /usr/bin/perl, $MYPATH)
195     AC_PATH_PROG(PGPBIN, pgp, /usr/bin/pgp, $MYPATH)
196     AC_PATH_PROG(__RM, rm, /bin/rm, $MYPATH)
197     AC_PATH_PROG(__RSH, rsh, /usr/bin/rsh, $MYPATH)
198     AC_PATH_PROG(__SED, sed, /bin/sed, $MYPATH)
199     AC_PATH_PROG(__SSH, ssh, /usr/bin/ssh, $MYPATH)
200     AC_PATH_PROG(__TAR, tar, /bin/tar, $MYPATH)
201
202     AC_PATH_PROG(__LD, ld, /usr/bin/ld, $MYPATH)
203     AC_PATH_PROG(__NM, nm, /usr/bin/nm, $MYPATH)
204     AC_PATH_PROG(__OBJCOPY, objcopy, /usr/bin/objcopy, $MYPATH)
205     AC_PATH_PROG(__OBJDUMP, objdump, /usr/bin/objdump, $MYPATH)
206     AC_PATH_PROG(__STRIP, strip, /usr/bin/strip, $MYPATH)
207 fi
208
209 addlib() {
210   l=$1
211   shift
212   case "$target" in 
213     *-*-solaris*)       LIBS="$LIBS -L$l -R$l $*";;
214     *)          LIBS="$LIBS -L$l $*";;
215   esac
216 }
217
218 localdone=
219 for dir in $prefix /usr/local
220 do
221         case $dir in
222         NONE|/usr)      continue;;
223         /usr/local)
224                 if test X$localdone != X ; then continue; fi
225                 localdone="$dir"
226                 ;;
227         esac
228
229         AC_MSG_CHECKING(for $dir/lib in LIBS)
230         if test -d $dir/lib ; then
231                 addlib $dir/lib
232                 AC_MSG_RESULT(yes)
233         else
234                 AC_MSG_RESULT(no)
235         fi
236
237         AC_MSG_CHECKING(for $dir/include in INCPATH)
238         if test -d $dir/include ; then
239                 INCPATH="$INCPATH -I$dir/include"
240                 AC_MSG_RESULT(yes)
241         else
242                 AC_MSG_RESULT(no)
243         fi
244 done
245
246 AC_MSG_CHECKING(for /usr/ucblib in LIBS)
247 if test -d /usr/ucblib ; then
248         if test "$build" = "mips-sni-sysv4" ; then
249                 addlib /usr/ccs/lib -lc
250         fi
251
252         addlib /usr/ucblib
253         
254         AC_MSG_RESULT(yes)
255 else
256         AC_MSG_RESULT(no)
257 fi
258
259 dnl
260 dnl Check for features
261 dnl
262
263 ### use option --disable-v1-packages to turn off support for rpm-1.x packages
264 AC_MSG_CHECKING(if you want support for rpm-1.0 packages)
265 AC_ARG_ENABLE(v1-packages,
266         [  --disable-v1-packages[=no]   disable support for rpm-1.x packages],
267         [with_v1_packages=$enableval],
268         [with_v1_packages=yes])
269 AC_MSG_RESULT($with_v1_packages)
270 test "$with_v1_packages" = yes && AC_DEFINE(ENABLE_V1_PACKAGES)
271
272 ### use option --enable-v4-packages to turn on support for rpm-4.x packages
273 AC_MSG_CHECKING(if you want experimental rpm-4.0 packages)
274 AC_ARG_ENABLE(v4-packages,
275         [  --enable-v4-packages[=no]    [experimental] support for rpm-4.x packages],
276         [with_v4_packages=$enableval],
277         [with_v4_packages=no])
278 AC_MSG_RESULT($with_v4_packages)
279 test "$with_v4_packages" = yes && AC_DEFINE(ENABLE_V4_PACKAGES)
280
281 dnl Checks for libraries.
282
283 AC_CHECK_FUNC(strcasecmp, [], [
284     AC_CHECK_LIB(ucb, strcasecmp, [LIBS="$LIBS -lc -lucb" USEUCB=y])
285 ])
286 AC_CHECK_FUNC(setreuid, [], [
287     AC_CHECK_LIB(ucb, setreuid, [if echo $LIBS | grep -- -lucb >/dev/null ;then :; else LIBS="$LIBS -lc -lucb" USEUCB=y;fi])
288 ])
289
290 AC_CHECK_FUNC(rand, [], [
291     AC_CHECK_LIB(rand, rand, [LIBS="$LIBS -lm"])
292 ])
293
294 AC_CHECK_FUNC(getdomainname, [], [
295     AC_CHECK_LIB(nsl, getdomainname, [LIBS="$LIBS -lnsl"])
296 ])
297 AC_CHECK_FUNC(socket, [], [
298     AC_CHECK_LIB(socket, socket, [LIBS="$LIBS -lsocket"])
299 ])
300
301 dnl Better not use fchmod at all.
302 AC_CHECK_FUNC(fchmod)
303
304 dnl Temporary hack for MiNT.  Some functions (writev, snprintf) are
305 dnl not in the libc but in libport (for political reasons).  This check
306 dnl can hopefully be removed soon.  Please use the default action
307 dnl for this macro (not LIBS=...), otherwise the check for dbopen
308 dnl will fail.
309 AC_CHECK_LIB(port, writev)
310
311 DBLIBOBJS=""
312 dnl Check for Berkeley db3 API.
313 AC_CHECK_FUNC(db_create, [DBLIBOBJS="$DBLIBOBJS db3.c"],
314   AC_CHECK_LIB(db, db_create, [LIBS="$LIBS -ldb"; DBLIBOBJS="$DBLIBOBJS db3.c"],
315     AC_CHECK_LIB(db-3.0, db_create, [DBLIBOBJS="$DBLIBOBJS db3.c"]))
316 )
317 dnl Check for Berkeley db2 API.
318 dnl AC_CHECK_FUNC(db_open, [DBLIBOBJS="$DBLIBOBJS db2.c"],
319 dnl   AC_CHECK_LIB(db, db_open, [LIBS="$LIBS -ldb"; DBLIBOBJS="$DBLIBOBJS db2.c"])
320 dnl )
321 dnl Check for Berkeley db1 API retrofit to db2/db3 database.
322 dnl AC_CHECK_FUNC(dbopen, [DBLIBOBJS="$DBLIBOBJS db1.c"],
323 dnl     AC_CHECK_LIB(db, dbopen, [DBLIBOBJS="$DBLIBOBJS db1.c"])
324 dnl )
325 dnl Check for Berkeley db1 API in glibc.
326 AC_CHECK_LIB(db1, dbopen, [DBLIBOBJS="$DBLIBOBJS db0.c"])
327
328 if test X"$DBLIBOBJS" = X; then
329     AC_MSG_ERROR([sorry rpm requires libdb.a or libdb1.a (from the Berkeley db package)]) 
330 fi
331 dnl AC_DEFINE_UNQUOTED(DBLIBOBJS, "$DBLIBOBJS")
332 AC_SUBST(DBLIBOBJS)
333
334 for dbi in $DBLIBOBJS; do
335   case $dbi in
336   db3.c) AC_DEFINE(USE_DB3) ;;
337   db2.c) AC_DEFINE(USE_DB2) ;;
338   db1.c) AC_DEFINE(USE_DB1) ;;
339   db0.c) AC_DEFINE(USE_DB0) ;;
340   esac
341 done
342
343 AC_CHECK_FUNC(fork, [], [echo "using vfork() instead of fork()";
344         LIBOBJS=fakefork.o])
345
346 dnl AmigaOS and IXEmul have a fork() dummy
347     case "$target" in
348         m68k-*-amigaos ) 
349                 echo "Building for AmigaOS: using vfork() instead of fork()"; 
350                 CFLAGS="$CFLAGS -Dfork=vfork" 
351                 ;;
352 esac
353
354
355 for zlib in z gz ; do
356    AC_CHECK_LIB(${zlib}, gzread, 
357         [LIBS="$LIBS -l${zlib}"; break], 
358         [if test ${zlib} = gz; then 
359             AC_MSG_ERROR([sorry rpm requires libz.a or libgz.a (from the zlib package)]) 
360          fi]
361                )
362 done
363
364 dnl zlib-1.0.4 has not gzseek
365 AC_CHECK_LIB(${zlib}, gzseek, [AC_DEFINE(HAVE_GZSEEK)])
366
367 for bz2lib in bz2 ; do
368    AC_CHECK_LIB(${bz2lib}, bzread, 
369         [LIBS="$LIBS -l${bz2lib}"; break], 
370         [if test ${bz2lib} = bz2; then 
371             AC_MSG_WARN([rpm needs libbz2.a (from the bzip2 package)]) 
372          fi]
373                )
374 done
375
376 dnl Red Hat 4.x has not personality
377 AC_CHECK_FUNCS(personality)
378
379 dnl XXX these are needed only by rpmgettext right now
380 AM_FUNC_ERROR_AT_LINE
381
382 dnl ==> AM_GNU_GETTEXT does this (and more)
383 dnl AC_CHECK_HEADERS(unistd.h limits.h locale.h malloc.h string.h sys/param.h)
384
385 AM_GNU_GETTEXT
386 dnl TVM:
387 dnl horrible *temporary* hack to make sure that if we found gettext() in
388 dnl -lintl that we add -lintl *back* to $LIBS.
389 dnl
390 if test X$gt_cv_func_gettext_libintl = Xyes ; then
391     LIBS="-lintl $LIBS"
392 fi
393
394 dnl Checks for header files we can live without.
395 AC_HEADER_STDC
396 AC_HEADER_MAJOR
397 AC_HEADER_DIRENT
398 AC_HEADER_TIME
399
400 AC_CHECK_HEADERS(db_185.h db1/db.h db3/db.h)
401 AC_CHECK_HEADERS(fcntl.h getopt.h grp.h memory.h netdb.h pwd.h utime.h)
402
403 AC_CHECK_HEADERS(sys/socket.h sys/select.h)
404 AC_CHECK_HEADERS(sys/types.h sys/stdtypes.h)
405 AC_CHECK_HEADERS(sys/mman.h sys/resource.h sys/utsname.h sys/wait.h)
406
407 AC_CHECK_HEADERS(netinet/in_systm.h)
408 AC_CHECK_HEADERS(machine/types.h)
409 AC_CHECK_HEADERS(mntent.h sys/mnttab.h sys/systemcfg.h)
410 AC_CHECK_HEADERS(sys/mount.h sys/mntctl.h sys/param.h sys/vmount.h)
411 AC_CHECK_HEADERS(bzlib.h libio.h zlib.h)
412 AC_CHECK_HEADERS(err.h mcheck.h)
413
414 dnl whether or not we should try build rpmconvert, which is used to convert
415 dnl rpm databases from rpm 1.x to rpm 2.x or later.  It requires the gdbm
416 dnl library and header file.
417 BUILD_RPMCONVERT=yes
418 AC_CHECK_HEADERS(gdbm.h,BUILD_RPMCONVERT=yes,BUILD_RPMCONVERT=no)
419 AC_MSG_CHECKING(if rpmconvert should be built)
420 if test X"$BUILD_RPMCONVERT" = X"yes"; then
421     BUILD_RPMCONVERT=rpmconvert
422     AC_MSG_RESULT(yes)
423 else
424     BUILD_RPMCONVERT=
425     AC_MSG_RESULT(no)
426 fi
427 AC_SUBST(BUILD_RPMCONVERT)
428
429 dnl whether or not we should try to build rpmgettext/rpmputtext.
430 if test X"$USE_NLS" = Xyes; then
431     BUILD_RPMNLSTOOLS="rpmgettext rpmputtext"
432     if test X"$USE_INCLUDED_LIBINTL" = Xyes; then
433         INCPATH="-I\$(top_builddir)/intl $INCPATH"
434     fi
435 else
436     BUILD_RPMNLSTOOLS=
437 fi
438 AC_SUBST(BUILD_RPMNLSTOOLS)
439
440 AC_CHECK_HEADERS(glob.h)
441
442 dnl statfs portability fiddles.
443 dnl
444 dnl We should really emulate/steal sections of the statfs and struct statfs
445 dnl checks from GNU fileutils.
446 dnl
447 AC_MSG_CHECKING(for struct statfs)
448 dnl
449 dnl this is easier than nesting AC_TRY_COMPILEs...
450 dnl
451 found_struct_statfs=no
452
453 if test X$found_struct_statfs = Xno ; then
454 dnl Solaris 2.6+ wants to use statvfs
455 AC_TRY_COMPILE([
456 #ifdef HAVE_SYS_TYPES_H
457 #include <sys/types.h>
458 #endif
459 #include <sys/statvfs.h> ],
460         [struct statvfs sfs;],
461         [AC_MSG_RESULT(in sys/statvfs.h)
462         AC_DEFINE(STATFS_IN_SYS_STATVFS)
463         found_struct_statfs=yes],
464 )
465 fi
466
467 if test X$found_struct_statfs = Xno ; then
468 dnl first try including sys/vfs.h
469 AC_TRY_COMPILE([
470 #ifdef HAVE_SYS_TYPES_H
471 #include <sys/types.h>
472 #endif
473 #include <sys/vfs.h> ],
474         [struct statfs sfs;],
475         [AC_MSG_RESULT(in sys/vfs.h)
476         AC_DEFINE(STATFS_IN_SYS_VFS)
477         found_struct_statfs=yes],
478 )
479 fi
480
481 if test X$found_struct_statfs = Xno ; then
482 dnl ...next try including sys/mount.h
483 AC_TRY_COMPILE([
484 #ifdef HAVE_SYS_TYPES_H
485 #include <sys/types.h>
486 #endif
487 #ifdef HAVE_SYS_PARAM_H
488 #include <sys/param.h>
489 #endif
490 #include <sys/mount.h> ],
491         [struct statfs sfs;],
492         [AC_MSG_RESULT(in sys/mount.h)
493         AC_DEFINE(STATFS_IN_SYS_MOUNT)
494         found_struct_statfs=yes],
495 )
496 fi
497
498 if test X$found_struct_statfs = Xno ; then
499 dnl ...still no joy.  Try sys/statfs.h
500 AC_TRY_COMPILE([
501 #ifdef HAVE_SYS_TYPES_H
502 #include <sys/types.h>
503 #endif
504 #include <sys/statfs.h> ],
505         [struct statfs sfs;],
506         [AC_MSG_RESULT(in sys/statfs.h)
507         AC_DEFINE(STATFS_IN_SYS_STATFS)
508         found_struct_statfs=yes],
509 )
510 fi
511
512 if test X$found_struct_statfs = Xno ; then
513 dnl ...no luck.  Warn the user of impending doom.
514 AC_MSG_WARN(not found)
515 fi
516
517 dnl
518 dnl if we found the struct, see if it has the f_bavail member.  Some OSes
519 dnl don't, including IRIX 6.5+
520 dnl
521 if test X$found_struct_statfs = Xyes ; then
522 AC_MSG_CHECKING(for f_bavail member in struct statfs)
523 AC_TRY_COMPILE([
524 #ifdef HAVE_SYS_TYPES_H
525 #include <sys/types.h>
526 #endif
527 #if STATFS_IN_SYS_STATVFS
528 # include <sys/statvfs.h>
529   typedef struct statvfs STATFS_t;
530 #else
531   typedef struct statfs STATFS_t;
532 # if STATFS_IN_SYS_VFS
533 #  include <sys/vfs.h>
534 # elif STATFS_IN_SYS_MOUNT
535 #  include <sys/mouht.h>
536 # elif STATFS_IN_SYS_STATFS
537 #  include <sys/statfs.h>
538 # endif
539 #endif ],
540         [STATFS_t sfs;
541         sfs.f_bavail = 0;],
542         [AC_MSG_RESULT(yes)
543         AC_DEFINE(STATFS_HAS_F_BAVAIL)],
544         [AC_MSG_RESULT(no)]
545 )
546 fi
547
548 if test X$found_struct_statfs = Xyes ; then
549 dnl
550 dnl now check to see if we have the 4-argument variant of statfs()
551 dnl this pretty much requires AC_TRY_RUN
552 dnl
553 AC_MSG_CHECKING([if statfs() requires 4 arguments])
554 AC_TRY_RUN([
555 #ifdef HAVE_SYS_TYPES_H
556 #include <sys/types.h>
557 #endif
558 #ifdef STATFS_IN_SYS_VFS
559 #include <sys/vfs.h>
560 #elif STATFS_IN_SYS_MOUNT
561 #include <sys/mouht.h>
562 #elif STATFS_IN_SYS_STATFS
563 #include <sys/statfs.h>
564 #endif
565 main() {
566         struct statfs sfs;
567         exit (statfs(".", &sfs, sizeof(sfs), 0));
568 }
569 ],
570         [AC_MSG_RESULT(yes)
571         AC_DEFINE(STAT_STATFS4)],
572         [AC_MSG_RESULT(no)],
573         [AC_MSG_RESULT(no)]
574 )
575 fi
576
577 AC_C_INLINE
578
579 dnl look for libc features
580 PROVIDES_ERRNO=no
581 AC_MSG_CHECKING(if <netdb.h> defines h_errno)
582 AC_TRY_LINK([#include <netdb.h>],printf("%d",h_errno),PROVIDES_ERRNO=yes)
583 AC_MSG_RESULT($PROVIDES_ERRNO)
584 if test $PROVIDES_ERRNO = yes; then
585         AC_DEFINE(HAVE_HERRNO)
586 fi
587
588 dnl If a system doesn't have S_IFSOCK, define it as 0 which will
589 dnl make S_ISSOCK always return false (nice, eh?)
590 AC_MSG_CHECKING(if <sys/stat.h> defines S_IFSOCK)
591 AC_TRY_LINK([#include <sys/stat.h>],printf("%d", S_IFSOCK),
592         HAS_S_IFSOCK=yes,HAS_S_IFSOCK=no)
593 AC_MSG_RESULT($HAS_S_IFSOCK)
594 if test $HAS_S_IFSOCK = yes; then
595         AC_DEFINE(HAVE_S_IFSOCK)
596 fi
597
598 dnl Some Unix's are missing S_ISLNK, S_ISSOCK
599 AC_MSG_CHECKING(if <sys/stat.h> defines S_ISLNK)
600 AC_TRY_LINK([#include <sys/stat.h>],printf("%d", S_ISLNK(0755)),
601         HAS_S_ISLNK=yes,HAS_S_ISLNK=no)
602 AC_MSG_RESULT($HAS_S_ISLNK)
603 if test $HAS_S_ISLNK = yes; then
604         AC_DEFINE(HAVE_S_ISLNK)
605 fi
606
607 AC_MSG_CHECKING(if <sys/stat.h> defines S_ISSOCK)
608 AC_TRY_LINK([#include <sys/stat.h>],printf("%d", S_ISSOCK(0755)),
609         HAS_S_ISSOCK=yes,HAS_S_ISSOCK=no)
610 AC_MSG_RESULT($HAS_S_ISSOCK)
611 if test $HAS_S_ISSOCK = yes; then
612         AC_DEFINE(HAVE_S_ISSOCK)
613 fi
614
615 AC_MSG_CHECKING(if timezone is defined)
616 AC_TRY_LINK([#include <time.h>],printf("%ld", timezone),
617       HAS_TIMEZONE=yes,HAS_TIMEZONE=no)
618 AC_MSG_RESULT($HAS_TIMEZONE)
619
620 dnl Check for missing typedefs
621 AC_TYPE_MODE_T
622 AC_TYPE_PID_T
623
624 dnl Checks for library functions.
625 AC_FUNC_ALLOCA
626 AC_FUNC_VPRINTF
627
628 AC_FUNC_FNMATCH
629 if test $ac_cv_func_fnmatch_works = no; then
630    LIBOBJS="$LIBOBJS fnmatch.o"
631    AC_DEFINE_UNQUOTED(fnmatch, rpl_fnmatch)
632 fi
633
634 dnl XXX AC_FUNC_MEMCMP
635 dnl XXX AC_FUNC_MMAP
636 dnl XXX AC_TYPE_SIGNAL
637 dnl XXX AC_FUNC_STRCOLL
638 dnl XXX AC_FUNC_STRFTIME
639 dnl XXX AC_FUNC_UTIME_NULL
640 dnl XXX AC_FUNC_VFORK
641 dnl XXX AC_CHECK_FUNCS(gethostname mkdir mkfifo rmdir select uname)
642
643 AC_CHECK_FUNCS(basename getcwd getwd inet_aton mtrace putenv realpath setenv)
644 AC_CHECK_FUNCS(stpcpy stpncpy strcasecmp strncasecmp strcspn)
645 AC_CHECK_FUNCS(strdup strerror strtol strtoul strspn strstr)
646
647 AC_CHECK_FUNCS(regcomp)
648
649 dnl
650 dnl XXX Regex replacement isn't known to be needed yet.
651 dnl
652 dnl AC_ARG_WITH(regex, [  --with-regex            use the GNU regex library ],
653 dnl     [rpm_cv_regex=yes],
654 dnl     [AC_CHECK_FUNCS(regcomp, rpm_cv_regex=no, rpm_cv_regex=yes)])
655 dnl 
656 dnl if test $rpm_cv_regex = no ; then
657 dnl     AC_MSG_CHECKING(whether the regexp library is broken)
658 dnl     AC_TRY_RUN([
659 dnl #include <unistd.h>
660 dnl #include <regex.h>
661 dnl main() { regex_t blah ; exit(regcomp(&blah, "foo.*bar", REG_NOSUB) || regexec (&blah, "foobar", 0, NULL, 0)); }],
662 dnl     rpm_cv_regex_broken=no, rpm_cv_regex_broken=yes, rpm_cv_regex_broken=yes)
663 dnl     AC_MSG_RESULT([$rpm_cv_regex_broken])
664 dnl     if test $rpm_cv_regex_broken = yes ; then
665 dnl         echo "   --> using the included GNU regex instead." >&AC_FD_MSG
666 dnl         rpm_cv_regex=yes
667 dnl     fi
668 dnl fi
669 dnl 
670 dnl if test $rpm_cv_regex = yes; then
671 dnl     AC_DEFINE(USE_GNU_REGEX)
672 dnl     LIBOBJS="$LIBOBJS regex.o"
673 dnl fi
674
675 dnl
676 dnl XXX Glob *is* broken on linux with libc5, solaris and possibly aix when
677 dnl %files gets something like
678 dnl     /usr/*/locale/*/LC_MESSAGES/*.mo
679 dnl (Note: more than one asterisk in glob pattern.)
680 dnl The next version of rpm is going to need GNU extensions anyways, so ...
681 dnl
682 AC_ARG_WITH(glob, [  --with-glob             use the internal GNU glob ],
683     [rpm_cv_glob=yes],
684     [AC_CHECK_FUNCS(glob, rpm_cv_glob=no, rpm_cv_glob=yes)])
685
686 if test $rpm_cv_glob = no ; then
687     AC_MSG_CHECKING(for GNU extensions to glob)
688     AC_TRY_RUN([
689 #include <unistd.h>
690 #include <sys/stat.h>
691 #include <glob.h>
692 main() {
693   glob_t gl ;
694   gl.gl_stat = stat;
695   exit(glob("doc/*/*.8", 0, NULL, &gl) || gl.gl_pathc < 1);
696 } ],
697     rpm_cv_glob_ext=yes, rpm_cv_glob_ext=no, rpm_cv_glob_ext=no)
698     AC_MSG_RESULT([$rpm_cv_glob_ext])
699     if test $rpm_cv_glob_ext = no ; then
700             echo "    --> using the included GNU glob instead." >&AC_FD_MSG
701             rpm_cv_glob=yes
702     fi
703 fi
704
705 if test $rpm_cv_glob = yes; then
706     AC_DEFINE(USE_GNU_GLOB)
707     LIBOBJS="$LIBOBJS glob.o fnmatch.o"
708 fi
709
710 AC_CHECK_FUNCS(setlocale)
711
712 dnl XXX Solaris <= 2.6 only permits 8 chars in password.
713 AC_CHECK_FUNCS(getpassphrase)
714
715 AC_CHECK_FUNC(getmntent, AC_DEFINE(HAVE_GETMNTENT), [
716   AC_CHECK_FUNC(mntctl, AC_DEFINE(HAVE_MNTCTL),[
717     AC_CHECK_FUNC(getmntinfo_r, AC_DEFINE(HAVE_GETMNTINFO_R), [
718       AC_CHECK_LIB(c_r, getmntinfo_r, [LIBS="$LIBS -lc_r"; 
719                                         AC_DEFINE(HAVE_GETMNTINFO_R)],
720                  LIBOBJS="$LIBOBJS getmntent.o")])])])
721
722 AC_CHECK_FUNC(lchown,
723    [__CHOWN_RHF="%{__chown} -Rhf"
724     __CHGRP_RHF="%{__chgrp} -Rhf"
725     AC_DEFINE(HAVE_LCHOWN)],
726    [__CHOWN_RHF="%{__chown} -Rf"
727     __CHGRP_RHF="%{__chgrp} -Rf"
728     dnl Does chown() follow symlinks? This should be a good enough test.
729     AC_MSG_CHECKING(whether chown() follows symlinks)
730     AC_ARG_ENABLE([broken-chown],
731     [  --enable-broken-chown   this system's chown follows symbolic links], 
732             result=$enableval, result=unknown)
733     if echo "$build" | egrep "(aix)|(hpux)|(linux)" > /dev/null ; then
734         result=yes
735     elif echo "$build" | egrep "(nextstep)" > /dev/null ; then
736         result=no
737     fi
738     if test $result = unknown; then
739         if test `${__ID} | cut -f2 -d\= | cut -f1 -d\(` = 0; then
740             rm -f foo bar
741             touch foo
742             ln -s foo bar
743             ${__CHOWN} 10 bar
744             if test `ls -l foo | awk '{print $3}'` != "root"; then
745                 result=yes
746             else
747                 result=no
748             fi
749             ${__RM} -f foo bar
750         else
751             AC_MSG_CHECKING((cannot check by non-root user))
752             result=no
753         fi
754     fi
755
756     AC_MSG_RESULT($result)
757     if test $result = yes; then
758             AC_DEFINE(CHOWN_FOLLOWS_SYMLINK)
759     fi])
760 AC_SUBST(__CHOWN_RHF)
761 AC_SUBST(__CHGRP_RHF)
762
763 dnl
764 dnl figure out what root's primary group is
765 dnl
766 AC_MSG_CHECKING(root's primary group)
767 AC_TRY_RUN([#include <stdio.h>
768 #include <sys/types.h>
769 #include <pwd.h>
770 #include <grp.h>
771
772 int main()
773 {
774         struct passwd *root = NULL;
775         struct group *roots_group = NULL;
776         FILE * tempfile = NULL;
777
778         root = getpwuid( (uid_t) 0 );
779         if (root != NULL) {
780                 roots_group = getgrgid(root->pw_gid);
781                 if (roots_group != NULL) {
782                         tempfile = fopen("conftest_rootg", "w");
783                         if (tempfile != NULL) {
784                                 fprintf(tempfile, "%s\n", roots_group->gr_name);
785                                 fclose(tempfile);
786                                 exit(0);
787                         }
788                 }
789         }
790
791         exit(1);
792 }], ROOT_GROUP=`cat conftest_rootg`,
793         ROOT_GROUP="root",ROOT_GROUP="root"
794 )
795 AC_MSG_RESULT($ROOT_GROUP)
796 AC_SUBST(ROOT_GROUP)
797
798 if test "x$varprefix" = "x"; then
799     varprefix=`echo $prefix | sed 's/usr/var/'`
800     test "x$prefix" = xNONE && varprefix=`echo $ac_default_prefix | sed 's/usr/var/'`
801 fi
802 AC_SUBST(varprefix)
803
804 if test "x$tmpdir" = "x"; then
805     if test -d $varprefix/tmp; then
806         tmpdir=$varprefix/tmp
807     else
808         if test -d /var/tmp; then
809             tmpdir=/var/tmp
810         else
811             tmpdir=/tmp
812         fi
813     fi
814 fi
815 AC_SUBST(tmpdir)
816
817 if echo "$build_os" | grep sco > /dev/null; then
818         echo "hacking things up for sco"
819         AC_DEFINE(NEED_STRINGS_H)
820         AC_DEFINE(HAVE_STRUCT_MNTTAB)
821 elif echo "$build_os" | grep sunos > /dev/null; then
822         echo "hacking things up for sunos"
823         CFLAGS="$CFLAGS -D__USE_FIXED_PROTOTYPES__"
824         AC_DEFINE(NEED_STRINGS_H)
825         AC_DEFINE(NEED_MYREALLOC)
826         LIBOBJS="$LIBOBJS myrealloc.o"
827 fi
828
829 #
830 # get rid of the 4-th tuple, if config.guess returned "linux-gnu" for build_os
831 #
832 if echo "$build_os" | grep '.*-gnulibc1' > /dev/null ; then
833         build_os=`echo "${build_os}" | sed 's/-gnulibc1$//'`
834 fi
835 if echo "$build_os" | grep '.*-gnu' > /dev/null ; then
836         build_os=`echo "${build_os}" | sed 's/-gnu$//'`
837 fi
838
839 changequote(<, >)
840 build_os_exact="${build_os}"
841 build_os_major=`echo "${build_os}" | sed 's/\..*$//'`
842 build_os_noversion=`echo "${build_os}" | sed 's/[0-9]*\..*$//'`
843 changequote([, ])
844
845 rm -f ./find-provides
846 if test -f ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.prov ; then
847         echo "using ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.prov for automatic provides generation"
848     ln -s ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.prov ./find-provides
849 elif test -f ${srcdir}/autodeps/${build_os_exact}.prov ; then
850         echo "using ${srcdir}/autodeps/${build_os_exact}.prov for automatic provides generation"
851     ln -s ${srcdir}/autodeps/${build_os_exact}.prov ./find-provides
852 elif test -f ${srcdir}/autodeps/${build_os_major}.prov ; then
853         echo "using ${srcdir}/autodeps/${build_os_major}.prov for automatic provides generation"
854     ln -s ${srcdir}/autodeps/${build_os_major}.prov ./find-provides
855 elif test -f ${srcdir}/autodeps/${build_os_noversion}.prov ; then
856         echo "using ${srcdir}/autodeps/${build_os_noversion}.prov for automatic provides generation"
857     ln -s ${srcdir}/autodeps/${build_os_noversion}.prov ./find-provides
858 else
859     echo "*** no default provides information is available for ${build_os_noversion}"
860     ln -s ${srcdir}/autodeps/none ./find-provides
861 fi
862
863 rm -f ./find-requires
864 if test -f ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.req ; then
865         echo "using ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.req for automatic requires generation"
866     ln -s ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.req ./find-requires
867 elif test -f ${srcdir}/autodeps/${build_os_exact}.req ; then
868         echo "using ${srcdir}/autodeps/${build_os_exact}.req for automatic requires generation"
869     ln -s ${srcdir}/autodeps/${build_os_exact}.req ./find-requires
870 elif test -f ${srcdir}/autodeps/${build_os_major}.req ; then
871         echo "using ${srcdir}/autodeps/${build_os_major}.req for automatic requires generation"
872     ln -s ${srcdir}/autodeps/${build_os_major}.req ./find-requires
873 elif test -f ${srcdir}/autodeps/${build_os_noversion}.req ; then
874         echo "using ${srcdir}/autodeps/${build_os_noversion}.req for automatic requires generation"
875     ln -s ${srcdir}/autodeps/${build_os_noversion}.req ./find-requires
876 else
877     echo "*** no default requires information is available for ${build_os_noversion}"
878     ln -s ${srcdir}/autodeps/none ./find-requires
879 fi
880
881 dnl Determine the canonical arch-vendor-os for the build machine
882 case "${build_cpu}" in
883 i386|i486|i586|i686|ix86)       RPMCANONARCH=i386 ;;
884 alpha*)         RPMCANONARCH=alpha ;;
885 sparc*)         RPMCANONARCH=sparc ;;
886 powerpc*)       RPMCANONARCH=ppc ;;
887 armv4l*)        RPMCANONARCH=armv4l ;;
888 armv4b*)        RPMCANONARCH=armv4b ;;
889 arm*)           RPMCANONARCH=arm ;;
890 *)              RPMCANONARCH=unknown ;;
891 esac
892 case "${build_os_noversion}" in
893 mint)           RPMCANONARCH=m68kmint ;;
894 esac
895 RPMCANONVENDOR="$build_vendor"
896 case "${build_vendor}" in
897 unknown|pc|redhat|pld)
898         test -f /etc/redhat-release && RPMCANONVENDOR=redhat
899         test -f /etc/pld-release && RPMCANONVENDOR=pld
900         ;;
901 esac
902 RPMCANONOS="$build_os_noversion"
903 AC_SUBST(RPMCANONARCH)
904 AC_SUBST(RPMCANONVENDOR)
905 AC_SUBST(RPMCANONOS)
906
907 if test -n "$LIBOBJS" ; then
908     LIBMISC='$(top_builddir)/misc/libmisc.a'
909 fi
910 AC_SUBST(LIBOBJS)
911 AC_SUBST(LIBMISC)
912
913 if test X"$prefix" = XNONE ; then
914     usrprefix="$ac_default_prefix"
915 else
916     usrprefix=$prefix
917 fi
918 LOCALEDIR="`echo ${usrprefix}/share/locale`"
919 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR")
920 AC_SUBST(LOCALEDIR)
921 LIBDIR="`echo $libdir | sed 's-/lib$-/%{_lib}-'`"
922 AC_SUBST(LIBDIR)
923 RPMCONFIGDIR="`echo ${usrprefix}/lib/rpm`"
924 AC_DEFINE_UNQUOTED(RPMCONFIGDIR, "$RPMCONFIGDIR")
925 AC_SUBST(RPMCONFIGDIR)
926 SYSCONFIGDIR="`echo /etc/rpm`"
927 AC_DEFINE_UNQUOTED(SYSCONFIGDIR, "$SYSCONFIGDIR")
928 AC_SUBST(SYSCONFIGDIR)
929 LIBRPMRC_FILENAME="${RPMCONFIGDIR}/rpmrc"
930 AC_DEFINE_UNQUOTED(LIBRPMRC_FILENAME, "$LIBRPMRC_FILENAME")
931 AC_SUBST(LIBRPMRC_FILENAME)
932 LIBRPMALIAS_FILENAME="${RPMCONFIGDIR}/rpmpopt"
933 AC_DEFINE_UNQUOTED(LIBRPMALIAS_FILENAME, "$LIBRPMALIAS_FILENAME")
934 AC_SUBST(LIBRPMALIAS_FILENAME)
935 FINDREQUIRES="${RPMCONFIGDIR}/find-requires"
936 AC_DEFINE_UNQUOTED(FINDREQUIRES, "$FINDREQUIRES")
937 AC_SUBST(FINDREQUIRES)
938 FINDPROVIDES="${RPMCONFIGDIR}/find-provides"
939 AC_DEFINE_UNQUOTED(FINDPROVIDES, "$FINDPROVIDES")
940 AC_SUBST(FINDPROVIDES)
941 MACROFILES="${RPMCONFIGDIR}/macros"
942 AC_DEFINE_UNQUOTED(MACROFILES, "$MACROFILES")
943 AC_SUBST(MACROFILES)
944 TOP_SOURCEDIR="`pwd`"
945 AC_DEFINE_UNQUOTED(TOP_SOURCEDIR, "$TOP_SOURCEDIR")
946 AC_SUBST(TOP_SOURCEDIR)
947
948 testdir="`pwd`/tests"
949 dnl AC_DEFINE_UNQUOTED(testdir, "$testdir")
950 AC_SUBST(testdir)
951
952 if test -n "$LIBOBJS"; then
953     INCPATH="-I\$(top_builddir)/misc $INCPATH"
954 fi
955 AC_SUBST(INCPATH)
956
957 AC_SUBST(LIBS)
958
959 AC_SUBST(RPM)
960
961 dnl XXX this causes popt to depend on zlib et al
962 dnl # XXX Propagate -lucb to popt ...
963 dnl export LIBS INCPATH CONFIG_SITE
964
965 AC_CONFIG_SUBDIRS(popt)
966 AC_OUTPUT([Doxyfile Makefile rpmrc macros platform rpmpopt scripts/brp-redhat
967         lib/Makefile build/Makefile tools/Makefile scripts/Makefile
968         tests/Makefile tests/rpmrc tests/macros tests/hello-test/Makefile
969         misc/Makefile po/Makefile.in intl/Makefile
970         doc/Makefile doc/manual/Makefile
971         doc/ja/Makefile doc/pl/Makefile doc/ru/Makefile
972         python/Makefile perl/Makefile perl/Makefile.PL],
973         [echo timestamp > popt/stamp-h.in
974         echo timestamp > stamp-h.in])
975 dnl     touch Makefile.in
976 dnl     sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile])
977