fix: fp.subDir was incorrectly set to NULL in sparse chroot's.
[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.0.4)
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 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:/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 dnl Solaris prefers /usr/xpg4/bin/id
166     AC_PATH_PROG(__ID, id, /usr/bin/id, $MYPATH)
167     AC_PATH_PROG(__INSTALL, install, /usr/bin/install, $MYPATH)
168     AC_PATH_PROG(__MAKE, make, /usr/bin/make, $MYPATH)
169     AC_PATH_PROG(__MKDIR, mkdir, /bin/mkdir, $MYPATH)
170     AC_PATH_PROG(__MV, mv, /bin/mv, $MYPATH)
171     AC_PATH_PROG(__PATCH, patch, /usr/bin/patch, $MYPATH)
172     AC_MSG_CHECKING(old version of patch)
173     PATCHVERSION=`patch --version 2>&1`
174
175     if test "$PATCHVERSION" = "Patch version 2.1"; then
176         AC_DEFINE(HAVE_OLDPATCH_21)
177         AC_MSG_RESULT(patch older then 2.2 found)
178     else
179         AC_MSG_RESULT(patch later then 2.2 found)
180     fi
181
182     AC_PATH_PROG(PGPBIN, pgp, /usr/bin/pgp, $MYPATH)
183     AC_PATH_PROG(__RM, rm, /bin/rm, $MYPATH)
184     AC_PATH_PROG(__RSH, rsh, /usr/bin/rsh, $MYPATH)
185     AC_PATH_PROG(__SSH, ssh, /usr/bin/ssh, $MYPATH)
186     AC_PATH_PROG(__TAR, tar, /bin/tar, $MYPATH)
187
188     AC_PATH_PROG(__OBJCOPY, objcopy, /usr/bin/objcopy, $MYPATH)
189     AC_PATH_PROG(__OBJDUMP, objdump, /usr/bin/objdump, $MYPATH)
190     AC_PATH_PROG(__STRIP, strip, /usr/bin/strip, $MYPATH)
191 fi
192
193 addlib() {
194   l=$1
195   shift
196   case "$target" in 
197     *-*-solaris*)       LIBS="$LIBS -L$l -R$l $*";;
198     *)          LIBS="$LIBS -L$l $*";;
199   esac
200 }
201
202 localdone=
203 for dir in $prefix /usr/local
204 do
205         case $dir in
206         NONE|/usr)      continue;;
207         /usr/local)
208                 if test X$localdone != X ; then continue; fi
209                 localdone="$dir"
210                 ;;
211         esac
212
213         AC_MSG_CHECKING(for $dir/lib in LIBS)
214         if test -d $dir/lib ; then
215                 addlib $dir/lib
216                 AC_MSG_RESULT(yes)
217         else
218                 AC_MSG_RESULT(no)
219         fi
220
221         AC_MSG_CHECKING(for $dir/include in INCPATH)
222         if test -d $dir/include ; then
223                 INCPATH="$INCPATH -I$dir/include"
224                 AC_MSG_RESULT(yes)
225         else
226                 AC_MSG_RESULT(no)
227         fi
228 done
229
230 AC_MSG_CHECKING(for /usr/ucblib in LIBS)
231 if test -d /usr/ucblib ; then
232         if test "$build" = "mips-sni-sysv4" ; then
233                 addlib /usr/ccs/lib -lc
234         fi
235
236         addlib /usr/ucblib
237         
238         AC_MSG_RESULT(yes)
239 else
240         AC_MSG_RESULT(no)
241 fi
242
243 dnl
244 dnl Check for features
245 dnl
246
247 ### use option --disable-v1-packages to turn off support for rpm-1.x packages
248 AC_MSG_CHECKING(if you want support for rpm-1.0 packages)
249 AC_ARG_ENABLE(v1-packages,
250         [  --disable-v1-packages[=no]   disable support for rpm-1.x packages],
251         [with_v1_packages=$enableval],
252         [with_v1_packages=yes])
253 AC_MSG_RESULT($with_v1_packages)
254 test "$with_v1_packages" = yes && AC_DEFINE(ENABLE_V1_PACKAGES)
255
256 ### use option --enable-v4-packages to turn on support for rpm-4.x packages
257 AC_MSG_CHECKING(if you want experimental rpm-4.0 packages)
258 AC_ARG_ENABLE(v4-packages,
259         [  --enable-v4-packages[=no]    [experimental] support for rpm-4.x packages],
260         [with_v4_packages=$enableval],
261         [with_v4_packages=no])
262 AC_MSG_RESULT($with_v4_packages)
263 test "$with_v4_packages" = yes && AC_DEFINE(ENABLE_V4_PACKAGES)
264
265 dnl Checks for libraries.
266
267 AC_CHECK_FUNC(strcasecmp, [], [
268     AC_CHECK_LIB(ucb, strcasecmp, [LIBS="$LIBS -lc -lucb" USEUCB=y])
269 ])
270 AC_CHECK_FUNC(setreuid, [], [
271     AC_CHECK_LIB(ucb, setreuid, [if echo $LIBS | grep -- -lucb >/dev/null ;then :; else LIBS="$LIBS -lc -lucb" USEUCB=y;fi])
272 ])
273
274 AC_CHECK_FUNC(rand, [], [
275     AC_CHECK_LIB(rand, rand, [LIBS="$LIBS -lm"])
276 ])
277
278 AC_CHECK_FUNC(getdomainname, [], [
279     AC_CHECK_LIB(nsl, getdomainname, [LIBS="$LIBS -lnsl"])
280 ])
281 AC_CHECK_FUNC(socket, [], [
282     AC_CHECK_LIB(socket, socket, [LIBS="$LIBS -lsocket"])
283 ])
284
285 dnl Better not use fchmod at all.
286 AC_CHECK_FUNC(fchmod)
287
288
289 dnl Temporary hack for MiNT.  Some functions (writev, snprintf) are
290 dnl not in the libc but in libport (for political reasons).  This check
291 dnl can hopefully be removed soon.  Please use the default action
292 dnl for this macro (not LIBS=...), otherwise the check for dbopen
293 dnl will fail.
294 AC_CHECK_LIB(port, writev)
295
296 AC_CHECK_FUNC(dbopen, [],
297   AC_CHECK_LIB(db1, dbopen, [LIBS="$LIBS -ldb1"],
298     AC_CHECK_LIB(db, dbopen, [LIBS="$LIBS -ldb"],
299        AC_MSG_WARN([sorry this package needs libdb.a (from the db package)])))
300            )
301
302 AC_CHECK_FUNC(fork, [], [echo "using vfork() instead of fork()";
303         LIBOBJS=fakefork.o])
304
305 dnl AmigaOS and IXEmul have a fork() dummy
306     case "$target" in
307         m68k-*-amigaos ) 
308                 echo "Building for AmigaOS: using vfork() instead of fork()"; 
309                 CFLAGS="$CFLAGS -Dfork=vfork" 
310                 ;;
311 esac
312
313
314 for zlib in z gz ; do
315    AC_CHECK_LIB(${zlib}, gzread, 
316         [LIBS="$LIBS -l${zlib}"; break], 
317         [if test ${zlib} = gz; then 
318             AC_MSG_WARN([sorry rpm needs libz.a or libgz.a (from the zlib package)]) 
319          fi]
320                )
321 done
322
323 for bz2lib in bz2 ; do
324    AC_CHECK_LIB(${bz2lib}, bzread, 
325         [LIBS="$LIBS -l${bz2lib}"; break], 
326         [if test ${bz2lib} = bz2; then 
327             AC_MSG_WARN([sorry rpm needs libbz2.a (from the bzip2 package)]) 
328          fi]
329                )
330 done
331
332 dnl XXX these are needed only by rpmgettext right now
333 AM_FUNC_ERROR_AT_LINE
334
335 dnl ==> AM_GNU_GETTEXT does this (and more)
336 dnl AC_CHECK_HEADERS(unistd.h limits.h locale.h malloc.h string.h sys/param.h)
337
338 AM_GNU_GETTEXT
339 dnl TVM:
340 dnl horrible *temporary* hack to make sure that if we found gettext() in
341 dnl -lintl that we add -lintl *back* to $LIBS.
342 dnl
343 if test X$gt_cv_func_gettext_libintl = Xyes ; then
344     LIBS="-lintl $LIBS"
345 fi
346
347 dnl Checks for header files we can live without.
348 AC_HEADER_STDC
349 AC_HEADER_MAJOR
350 AC_HEADER_DIRENT
351 AC_HEADER_TIME
352
353 AC_CHECK_HEADERS(db_185.h db1/db.h)
354 AC_CHECK_HEADERS(fcntl.h getopt.h grp.h memory.h netdb.h pwd.h utime.h)
355
356 AC_CHECK_HEADERS(sys/socket.h sys/select.h)
357 AC_CHECK_HEADERS(sys/types.h sys/stdtypes.h)
358 AC_CHECK_HEADERS(sys/mman.h sys/resource.h sys/utsname.h sys/wait.h)
359
360 AC_CHECK_HEADERS(netinet/in_systm.h)
361 AC_CHECK_HEADERS(machine/types.h)
362 AC_CHECK_HEADERS(mntent.h sys/mnttab.h sys/systemcfg.h)
363 AC_CHECK_HEADERS(sys/mount.h sys/mntctl.h sys/vmount.h)
364 AC_CHECK_HEADERS(bzlib.h libio.h zlib.h)
365 AC_CHECK_HEADERS(err.h mcheck.h)
366
367 dnl whether or not we should try build rpmconvert, which is used to convert
368 dnl rpm databases from rpm 1.x to rpm 2.x or later.  It requires the gdbm
369 dnl library and header file.
370 BUILD_RPMCONVERT=yes
371 AC_CHECK_HEADERS(gdbm.h,BUILD_RPMCONVERT=yes,BUILD_RPMCONVERT=no)
372 AC_MSG_CHECKING(if rpmconvert should be built)
373 if test X"$BUILD_RPMCONVERT" = X"yes"; then
374     BUILD_RPMCONVERT=rpmconvert
375     AC_MSG_RESULT(yes)
376 else
377     BUILD_RPMCONVERT=
378     AC_MSG_RESULT(no)
379 fi
380 AC_SUBST(BUILD_RPMCONVERT)
381
382 dnl whether or not we should try to build rpmgettext/rpmputtext.
383 if test X"$USE_NLS" = Xyes; then
384     BUILD_RPMNLSTOOLS="rpmgettext rpmputtext"
385     if test X"$USE_INCLUDED_LIBINTL" = Xyes; then
386         INCPATH="$INCPATH -I\$(top_builddir)/intl"
387     fi
388 else
389     BUILD_RPMNLSTOOLS=
390 fi
391 AC_SUBST(BUILD_RPMNLSTOOLS)
392
393 AC_CHECK_HEADERS(glob.h)
394
395 dnl statfs portability fiddles.
396 dnl
397 dnl We should really emulate/steal sections of the statfs and struct statfs
398 dnl checks from GNU fileutils.
399 dnl
400 AC_MSG_CHECKING(for struct statfs)
401 dnl
402 dnl this is easier than nesting AC_TRY_COMPILEs...
403 dnl
404 found_struct_statfs=no
405
406 if test X$found_struct_statfs = Xno ; then
407 dnl Solaris 2.6+ wants to use statvfs
408 AC_TRY_COMPILE([
409 #ifdef HAVE_SYS_TYPES_H
410 #include <sys/types.h>
411 #endif
412 #include <sys/statvfs.h> ],
413         [struct statvfs sfs;],
414         [AC_MSG_RESULT(in sys/statvfs.h)
415         AC_DEFINE(STATFS_IN_SYS_STATVFS)
416         found_struct_statfs=yes],
417 )
418 fi
419
420 if test X$found_struct_statfs = Xno ; then
421 dnl first try including sys/vfs.h
422 AC_TRY_COMPILE([
423 #ifdef HAVE_SYS_TYPES_H
424 #include <sys/types.h>
425 #endif
426 #include <sys/vfs.h> ],
427         [struct statfs sfs;],
428         [AC_MSG_RESULT(in sys/vfs.h)
429         AC_DEFINE(STATFS_IN_SYS_VFS)
430         found_struct_statfs=yes],
431 )
432 fi
433
434 if test X$found_struct_statfs = Xno ; then
435 dnl ...next try including sys/mount.h
436 AC_TRY_COMPILE([
437 #ifdef HAVE_SYS_TYPES_H
438 #include <sys/types.h>
439 #endif
440 #include <sys/mount.h> ],
441         [struct statfs sfs;],
442         [AC_MSG_RESULT(in sys/mount.h)
443         AC_DEFINE(STATFS_IN_SYS_MOUNT)
444         found_struct_statfs=yes],
445 )
446 fi
447
448 if test X$found_struct_statfs = Xno ; then
449 dnl ...still no joy.  Try sys/statfs.h
450 AC_TRY_COMPILE([
451 #ifdef HAVE_SYS_TYPES_H
452 #include <sys/types.h>
453 #endif
454 #include <sys/statfs.h> ],
455         [struct statfs sfs;],
456         [AC_MSG_RESULT(in sys/statfs.h)
457         AC_DEFINE(STATFS_IN_SYS_STATFS)
458         found_struct_statfs=yes],
459 )
460 fi
461
462 if test X$found_struct_statfs = Xno ; then
463 dnl ...no luck.  Warn the user of impending doom.
464 AC_MSG_WARN(not found)
465 fi
466
467 dnl
468 dnl if we found the struct, see if it has the f_bavail member.  Some OSes
469 dnl don't, including IRIX 6.5+
470 dnl
471 if test X$found_struct_statfs = Xyes ; then
472 AC_MSG_CHECKING(for f_bavail member in struct statfs)
473 AC_TRY_COMPILE([
474 #ifdef HAVE_SYS_TYPES_H
475 #include <sys/types.h>
476 #endif
477 #if STATFS_IN_SYS_STATVFS
478 # include <sys/statvfs.h>
479   typedef struct statvfs STATFS_t;
480 #else
481   typedef struct statfs STATFS_t;
482 # if STATFS_IN_SYS_VFS
483 #  include <sys/vfs.h>
484 # elif STATFS_IN_SYS_MOUNT
485 #  include <sys/mouht.h>
486 # elif STATFS_IN_SYS_STATFS
487 #  include <sys/statfs.h>
488 # endif
489 #endif ],
490         [STATFS_t sfs;
491         sfs.f_bavail = 0;],
492         [AC_MSG_RESULT(yes)
493         AC_DEFINE(STATFS_HAS_F_BAVAIL)],
494         [AC_MSG_RESULT(no)]
495 )
496 fi
497
498 if test X$found_struct_statfs = Xyes ; then
499 dnl
500 dnl now check to see if we have the 4-argument variant of statfs()
501 dnl this pretty much requires AC_TRY_RUN
502 dnl
503 AC_MSG_CHECKING([if statfs() requires 4 arguments])
504 AC_TRY_RUN([
505 #ifdef HAVE_SYS_TYPES_H
506 #include <sys/types.h>
507 #endif
508 #ifdef STATFS_IN_SYS_VFS
509 #include <sys/vfs.h>
510 #elif STATFS_IN_SYS_MOUNT
511 #include <sys/mouht.h>
512 #elif STATFS_IN_SYS_STATFS
513 #include <sys/statfs.h>
514 #endif
515 main() {
516         struct statfs sfs;
517         exit (statfs(".", &sfs, sizeof(sfs), 0));
518 }
519 ],
520         [AC_MSG_RESULT(yes)
521         AC_DEFINE(STAT_STATFS4)],
522         [AC_MSG_RESULT(no)],
523         [AC_MSG_RESULT(no)]
524 )
525 fi
526
527 AC_C_INLINE
528
529 dnl look for libc features
530 PROVIDES_ERRNO=no
531 AC_MSG_CHECKING(if <netdb.h> defines h_errno)
532 AC_TRY_LINK([#include <netdb.h>],printf("%d",h_errno),PROVIDES_ERRNO=yes)
533 AC_MSG_RESULT($PROVIDES_ERRNO)
534 if test $PROVIDES_ERRNO = yes; then
535         AC_DEFINE(HAVE_HERRNO)
536 fi
537
538 dnl If a system doesn't have S_IFSOCK, define it as 0 which will
539 dnl make S_ISSOCK always return false (nice, eh?)
540 AC_MSG_CHECKING(if <sys/stat.h> defines S_IFSOCK)
541 AC_TRY_LINK([#include <sys/stat.h>],printf("%d", S_IFSOCK),
542         HAS_S_IFSOCK=yes,HAS_S_IFSOCK=no)
543 AC_MSG_RESULT($HAS_S_IFSOCK)
544 if test $HAS_S_IFSOCK = yes; then
545         AC_DEFINE(HAVE_S_IFSOCK)
546 fi
547
548 dnl Some Unix's are missing S_ISLNK, S_ISSOCK
549 AC_MSG_CHECKING(if <sys/stat.h> defines S_ISLNK)
550 AC_TRY_LINK([#include <sys/stat.h>],printf("%d", S_ISLNK(0755)),
551         HAS_S_ISLNK=yes,HAS_S_ISLNK=no)
552 AC_MSG_RESULT($HAS_S_ISLNK)
553 if test $HAS_S_ISLNK = yes; then
554         AC_DEFINE(HAVE_S_ISLNK)
555 fi
556
557 AC_MSG_CHECKING(if <sys/stat.h> defines S_ISSOCK)
558 AC_TRY_LINK([#include <sys/stat.h>],printf("%d", S_ISSOCK(0755)),
559         HAS_S_ISSOCK=yes,HAS_S_ISSOCK=no)
560 AC_MSG_RESULT($HAS_S_ISSOCK)
561 if test $HAS_S_ISSOCK = yes; then
562         AC_DEFINE(HAVE_S_ISSOCK)
563 fi
564
565 AC_MSG_CHECKING(if timezone is defined)
566 AC_TRY_LINK([#include <time.h>],printf("%ld", timezone),
567       HAS_TIMEZONE=yes,HAS_TIMEZONE=no)
568 AC_MSG_RESULT($HAS_TIMEZONE)
569
570 dnl Check for missing typedefs
571 AC_TYPE_MODE_T
572 AC_TYPE_PID_T
573
574 dnl Checks for library functions.
575 AC_FUNC_ALLOCA
576 AC_FUNC_VPRINTF
577
578 AC_FUNC_FNMATCH
579 if test $ac_cv_func_fnmatch_works = no; then
580    LIBOBJS="$LIBOBJS fnmatch.o"
581    AC_DEFINE_UNQUOTED(fnmatch, rpl_fnmatch)
582 fi
583
584 dnl XXX AC_FUNC_MEMCMP
585 dnl XXX AC_FUNC_MMAP
586 dnl XXX AC_TYPE_SIGNAL
587 dnl XXX AC_FUNC_STRCOLL
588 dnl XXX AC_FUNC_STRFTIME
589 dnl XXX AC_FUNC_UTIME_NULL
590 dnl XXX AC_FUNC_VFORK
591 dnl XXX AC_CHECK_FUNCS(gethostname mkdir mkfifo rmdir select uname)
592
593 AC_CHECK_FUNCS(basename getcwd getwd inet_aton mtrace putenv realpath)
594 AC_CHECK_FUNCS(stpcpy stpncpy strcasecmp strncasecmp strcspn)
595 AC_CHECK_FUNCS(strdup strerror strtol strtoul strspn strstr)
596
597 AC_CHECK_FUNCS(regcomp glob)
598
599 dnl
600 dnl XXX Regex replacement isn't known to be needed yet.
601 dnl
602 dnl AC_ARG_WITH(regex, [  --with-regex            use the GNU regex library ],
603 dnl     [rpm_cv_regex=yes],
604 dnl     [AC_CHECK_FUNCS(regcomp, rpm_cv_regex=no, rpm_cv_regex=yes)])
605 dnl 
606 dnl if test $rpm_cv_regex = no ; then
607 dnl     AC_MSG_CHECKING(whether the regexp library is broken)
608 dnl     AC_TRY_RUN([
609 dnl #include <unistd.h>
610 dnl #include <regex.h>
611 dnl main() { regex_t blah ; exit(regcomp(&blah, "foo.*bar", REG_NOSUB) || regexec (&blah, "foobar", 0, NULL, 0)); }],
612 dnl     rpm_cv_regex_broken=no, rpm_cv_regex_broken=yes, rpm_cv_regex_broken=yes)
613 dnl     AC_MSG_RESULT([$rpm_cv_regex_broken])
614 dnl     if test $rpm_cv_regex_broken = yes ; then
615 dnl         echo "   --> using the included GNU regex instead." >&AC_FD_MSG
616 dnl         rpm_cv_regex=yes
617 dnl     fi
618 dnl fi
619 dnl 
620 dnl if test $rpm_cv_regex = yes; then
621 dnl     AC_DEFINE(USE_GNU_REGEX)
622 dnl     LIBOBJS="$LIBOBJS regex.o"
623 dnl fi
624
625 dnl
626 dnl XXX Glob may be broken on solaris and aix when %files gets something like
627 dnl     /usr/share/locale/*/LC_MESSAGES/*.mo
628 dnl (Note: two asterisks in glob pattern.)
629 dnl
630 dnl AC_ARG_WITH(glob, [  --with-glob             use the internal GNU glob ],
631 dnl     [rpm_cv_glob=yes],
632 dnl     [AC_CHECK_FUNCS(glob, rpm_cv_glob=no, rpm_cv_glob=yes)])
633 dnl 
634 dnl if test $rpm_cv_glob = no ; then
635 dnl     AC_MSG_CHECKING(whether the glob library is broken)
636 dnl     AC_TRY_RUN([
637 dnl #include <unistd.h>
638 dnl #include <glob.h>
639 dnl main() { glob_t blah ; exit(glob("doc/*/*.8", 0, NULL, &blah) || blah.gl_pathc < 1); } ],
640 dnl     rpm_cv_glob_broken=no, rpm_cv_glob_broken=yes, rpm_cv_glob_broken=yes)
641 dnl     AC_MSG_RESULT([$rpm_cv_glob_broken])
642 dnl     if test $rpm_cv_glob_broken = yes ; then
643 dnl         echo "    --> using the included GNU glob instead." >&AC_FD_MSG
644 dnl         rpm_cv_glob=yes
645 dnl     fi
646 dnl fi
647 dnl
648 dnl if test $rpm_cv_glob = yes; then
649 dnl     AC_DEFINE(USE_GNU_GLOB)
650 dnl     LIBOBJS="$LIBOBJS glob.o"
651 dnl fi
652
653 AC_CHECK_FUNCS(setlocale)
654
655 dnl XXX Solaris <= 2.6 only permits 8 chars in password.
656 AC_CHECK_FUNCS(getpassphrase)
657
658 AC_CHECK_FUNC(getmntent, AC_DEFINE(HAVE_GETMNTENT), [
659   AC_CHECK_FUNC(mntctl, AC_DEFINE(HAVE_MNTCTL),[
660     AC_CHECK_FUNC(getmntinfo_r, AC_DEFINE(HAVE_GETMNTINFO_R), [
661       AC_CHECK_LIB(c_r, getmntinfo_r, [LIBS="$LIBS -lc_r"; 
662                                         AC_DEFINE(HAVE_GETMNTINFO_R)],
663                  LIBOBJS="$LIBOBJS getmntent.o")])])])
664
665 LCHOWN=no
666 AC_CHECK_FUNC(lchown, [LCHOWN=yes; AC_DEFINE(HAVE_LCHOWN)])
667 if test "$LCHOWN" = no; then 
668     dnl Does chown() follow symlinks? This should be a good enough test.
669     AC_MSG_CHECKING(whether chown() follows symlinks)
670     AC_ARG_ENABLE([broken-chown],
671     [  --enable-broken-chown   this system's chown follows symbolic links], 
672             result=$enableval, result=unknown)
673     if echo "$build" | egrep "(aix)|(hpux)|(linux)" > /dev/null ; then
674         result=yes
675     elif echo "$build" | egrep "(nextstep)" > /dev/null ; then
676         result=no
677     fi
678     if test $result = unknown; then
679         if test `id | cut -f2 -d\= | cut -f1 -d\(` = 0; then
680             rm -f foo bar
681             touch foo
682             ln -s foo bar
683             chown 10 bar
684             if test `ls -l foo | awk '{print $3}'` != "root"; then
685                 result=yes
686             else
687                 result=no
688             fi
689             rm -f foo bar
690         else
691             AC_MSG_CHECKING((cannot check by non-root user))
692             result=no
693         fi
694     fi
695
696     AC_MSG_RESULT($result)
697     if test $result = yes; then
698             AC_DEFINE(CHOWN_FOLLOWS_SYMLINK)
699     fi
700 fi
701
702
703 dnl
704 dnl figure out what root's primary group is
705 dnl
706 AC_MSG_CHECKING(root's primary group)
707 AC_TRY_RUN([#include <stdio.h>
708 #include <sys/types.h>
709 #include <pwd.h>
710 #include <grp.h>
711
712 int main()
713 {
714         struct passwd *root = NULL;
715         struct group *roots_group = NULL;
716         FILE * tempfile = NULL;
717
718         root = getpwuid( (uid_t) 0 );
719         if (root != NULL) {
720                 roots_group = getgrgid(root->pw_gid);
721                 if (roots_group != NULL) {
722                         tempfile = fopen("conftest_rootg", "w");
723                         if (tempfile != NULL) {
724                                 fprintf(tempfile, "%s\n", roots_group->gr_name);
725                                 fclose(tempfile);
726                                 exit(0);
727                         }
728                 }
729         }
730
731         exit(1);
732 }], ROOT_GROUP=`cat conftest_rootg`,
733         ROOT_GROUP="root",ROOT_GROUP="root"
734 )
735 AC_MSG_RESULT($ROOT_GROUP)
736 AC_SUBST(ROOT_GROUP)
737
738 if test "x$varprefix" = "x"; then
739     varprefix=`echo $prefix | sed 's/usr/var/'`
740     test "x$prefix" = xNONE && varprefix=`echo $ac_default_prefix | sed 's/usr/var/'`
741 fi
742 AC_SUBST(varprefix)
743
744 if test "x$tmpdir" = "x"; then
745     if test -d $varprefix/tmp; then
746         tmpdir=$varprefix/tmp
747     else
748         if test -d /var/tmp; then
749             tmpdir=/var/tmp
750         else
751             tmpdir=/tmp
752         fi
753     fi
754 fi
755 AC_SUBST(tmpdir)
756
757 if echo "$build_os" | grep sco > /dev/null; then
758         echo "hacking things up for sco"
759         AC_DEFINE(NEED_STRINGS_H)
760         AC_DEFINE(HAVE_STRUCT_MNTTAB)
761 elif echo "$build_os" | grep sunos > /dev/null; then
762         echo "hacking things up for sunos"
763         CFLAGS="$CFLAGS -D__USE_FIXED_PROTOTYPES__"
764         AC_DEFINE(NEED_STRINGS_H)
765         AC_DEFINE(NEED_MYREALLOC)
766         LIBOBJS="$LIBOBJS myrealloc.o"
767 fi
768
769 #
770 # get rid of the 4-th tuple, if config.guess returned "linux-gnu" for build_os
771 #
772 if echo "$build_os" | grep '.*-gnulibc1' > /dev/null ; then
773         build_os=`echo "${build_os}" | sed 's/-gnulibc1$//'`
774 fi
775 if echo "$build_os" | grep '.*-gnu' > /dev/null ; then
776         build_os=`echo "${build_os}" | sed 's/-gnu$//'`
777 fi
778
779 changequote(<, >)
780 build_os_exact="${build_os}"
781 build_os_major=`echo "${build_os}" | sed 's/\..*$//'`
782 build_os_noversion=`echo "${build_os}" | sed 's/[0-9]*\..*$//'`
783 changequote([, ])
784
785 rm -f ./find-provides
786 if test -f ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.prov ; then
787         echo "using ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.prov for automatic provides generation"
788     ln -s ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.prov ./find-provides
789 elif test -f ${srcdir}/autodeps/${build_os_exact}.prov ; then
790         echo "using ${srcdir}/autodeps/${build_os_exact}.prov for automatic provides generation"
791     ln -s ${srcdir}/autodeps/${build_os_exact}.prov ./find-provides
792 elif test -f ${srcdir}/autodeps/${build_os_major}.prov ; then
793         echo "using ${srcdir}/autodeps/${build_os_major}.prov for automatic provides generation"
794     ln -s ${srcdir}/autodeps/${build_os_major}.prov ./find-provides
795 elif test -f ${srcdir}/autodeps/${build_os_noversion}.prov ; then
796         echo "using ${srcdir}/autodeps/${build_os_noversion}.prov for automatic provides generation"
797     ln -s ${srcdir}/autodeps/${build_os_noversion}.prov ./find-provides
798 else
799     echo "*** no default provides information is available for ${build_os_noversion}"
800     ln -s ${srcdir}/autodeps/none ./find-provides
801 fi
802
803 rm -f ./find-requires
804 if test -f ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.req ; then
805         echo "using ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.req for automatic requires generation"
806     ln -s ${srcdir}/autodeps/${build_cpu}-${build_os_exact}.req ./find-requires
807 elif test -f ${srcdir}/autodeps/${build_os_exact}.req ; then
808         echo "using ${srcdir}/autodeps/${build_os_exact}.req for automatic requires generation"
809     ln -s ${srcdir}/autodeps/${build_os_exact}.req ./find-requires
810 elif test -f ${srcdir}/autodeps/${build_os_major}.req ; then
811         echo "using ${srcdir}/autodeps/${build_os_major}.req for automatic requires generation"
812     ln -s ${srcdir}/autodeps/${build_os_major}.req ./find-requires
813 elif test -f ${srcdir}/autodeps/${build_os_noversion}.req ; then
814         echo "using ${srcdir}/autodeps/${build_os_noversion}.req for automatic requires generation"
815     ln -s ${srcdir}/autodeps/${build_os_noversion}.req ./find-requires
816 else
817     echo "*** no default requires information is available for ${build_os_noversion}"
818     ln -s ${srcdir}/autodeps/none ./find-requires
819 fi
820
821 dnl Determine the canonical arch-vendor-os for the build machine
822 case "${build_cpu}" in
823 i386|i486|i586|i686|ix86)       RPMCANONARCH=i386 ;;
824 alpha*)         RPMCANONARCH=alpha ;;
825 sparc*)         RPMCANONARCH=sparc ;;
826 powerpc*)       RPMCANONARCH=ppc ;;
827 armv4l*)        RPMCANONARCH=armv4l ;;
828 armv4b*)        RPMCANONARCH=armv4b ;;
829 arm*)           RPMCANONARCH=arm ;;
830 *)              RPMCANONARCH=unknown ;;
831 esac
832 case "${build_os_noversion}" in
833 mint)           RPMCANONARCH=m68kmint ;;
834 esac
835 RPMCANONVENDOR="$build_vendor"
836 case "${build_vendor}" in
837 unknown|pc)     test -f /etc/redhat-release && RPMCANONVENDOR=redhat ;;
838 esac
839 RPMCANONOS="$build_os_noversion"
840 AC_SUBST(RPMCANONARCH)
841 AC_SUBST(RPMCANONVENDOR)
842 AC_SUBST(RPMCANONOS)
843
844 if test -n "$LIBOBJS" ; then
845     LIBMISC='$(top_builddir)/misc/libmisc.a'
846 fi
847 AC_SUBST(LIBOBJS)
848 AC_SUBST(LIBMISC)
849
850 if test X"$prefix" = XNONE ; then
851     usrprefix="$ac_default_prefix"
852 else
853     usrprefix=$prefix
854 fi
855 LOCALEDIR="`echo ${usrprefix}/share/locale`"
856 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR")
857 AC_SUBST(LOCALEDIR)
858 RPMCONFIGDIR="`echo ${usrprefix}/lib/rpm`"
859 AC_DEFINE_UNQUOTED(RPMCONFIGDIR, "$RPMCONFIGDIR")
860 AC_SUBST(RPMCONFIGDIR)
861 SYSCONFIGDIR="`echo /etc/rpm`"
862 AC_DEFINE_UNQUOTED(SYSCONFIGDIR, "$SYSCONFIGDIR")
863 AC_SUBST(SYSCONFIGDIR)
864 LIBRPMRC_FILENAME="${RPMCONFIGDIR}/rpmrc"
865 AC_DEFINE_UNQUOTED(LIBRPMRC_FILENAME, "$LIBRPMRC_FILENAME")
866 AC_SUBST(LIBRPMRC_FILENAME)
867 LIBRPMALIAS_FILENAME="${RPMCONFIGDIR}/rpmpopt"
868 AC_DEFINE_UNQUOTED(LIBRPMALIAS_FILENAME, "$LIBRPMALIAS_FILENAME")
869 AC_SUBST(LIBRPMALIAS_FILENAME)
870 FINDREQUIRES="${RPMCONFIGDIR}/find-requires"
871 AC_DEFINE_UNQUOTED(FINDREQUIRES, "$FINDREQUIRES")
872 AC_SUBST(FINDREQUIRES)
873 FINDPROVIDES="${RPMCONFIGDIR}/find-provides"
874 AC_DEFINE_UNQUOTED(FINDPROVIDES, "$FINDPROVIDES")
875 AC_SUBST(FINDPROVIDES)
876 MACROFILES="${RPMCONFIGDIR}/macros"
877 AC_DEFINE_UNQUOTED(MACROFILES, "$MACROFILES")
878 AC_SUBST(MACROFILES)
879
880 testdir="`pwd`/tests"
881 dnl AC_DEFINE_UNQUOTED(testdir, "$testdir")
882 AC_SUBST(testdir)
883
884 if test -n "$LIBOBJS"; then
885     INCPATH="$INCPATH -I\$(top_builddir)/misc"
886 fi
887 AC_SUBST(INCPATH)
888
889 AC_SUBST(LIBS)
890
891 AC_SUBST(RPM)
892
893 dnl XXX this causes popt to depend on zlib et al
894 dnl # XXX Propagate -lucb to popt ...
895 dnl export LIBS INCPATH CONFIG_SITE
896
897 AC_CONFIG_SUBDIRS(popt)
898 AC_OUTPUT([Makefile rpmrc macros lib/Makefile
899         build/Makefile tools/Makefile scripts/Makefile
900         tests/Makefile tests/rpmrc tests/macros tests/hello-test/Makefile
901         misc/Makefile po/Makefile.in intl/Makefile
902         doc/Makefile doc/manual/Makefile
903         doc/ja/Makefile doc/pl/Makefile doc/ru/Makefile
904         python/Makefile],
905         [echo timestamp > popt/stamp-h.in
906         echo timestamp > stamp-h.in])
907 dnl     touch Makefile.in
908 dnl     sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile])
909