585606b0b30d01a8b9fa225858acf411cca382bc
[platform/upstream/rpm.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_CONFIG_HEADER(config.h)
9
10 dnl default to not using NLS
11 XGETTEXT=""
12 LIBINTL=""
13 PO=""
14 GETTEXTSTUB="gettextstub.o"
15
16 AC_CANONICAL_SYSTEM
17
18 dnl Checks for programs.
19 AC_PROG_CC
20 AC_PROG_CPP
21 AC_PROG_GCC_TRADITIONAL
22 AC_PROG_INSTALL
23
24 AC_MSG_CHECKING(checking for POSIX chmod...)
25 touch foo.chmodtest
26 chmod 744 foo.chmodtest
27 chmod +X foo.chmodtest 2>/dev/null
28 a=`ls -l foo.chmodtest | awk '{print $1}'`
29 rm -f foo.chmodtest
30 if test "$a" = "-rwxr-xr-x"; then
31     AC_MSG_RESULT(yes)
32     FIXPERMS=a+rX,g-w,o-w 
33 else
34     AC_MSG_RESULT(no (tell your OS vendor about GNU fileutils))
35     FIXPERMS=a+r,g-w,o-w 
36 fi
37
38 AC_AIX
39 AC_MINIX
40 AC_ISC_POSIX
41
42 AC_PROG_AWK
43 AC_PROG_LN_S
44 AC_PROG_MAKE_SET
45 AC_PROG_RANLIB
46
47 AC_CHECK_TOOL(AR, ar, :)
48
49 if test "$cross_compiling" != "yes"; then
50     AC_MSG_CHECKING(checking for GNU cpio...)
51     if test -z "$CPIOBIN"; then
52             oldifs="$IFS"
53             IFS=:
54             for n in $PATH:/opt/gnu/bin; do
55                     if test -f $n/cpio; then
56                             $n/cpio --quiet -o < /dev/null >/dev/null 2>/dev/null
57                             if test "$?" = "0"; then
58                                     CPIOBIN="$n/cpio";
59                             fi
60                     fi
61             done
62             IFS="$oldifs"
63     fi
64
65     if test -z "$CPIOBIN"; then
66             AC_MSG_RESULT(no)
67             AC_MSG_WARN(RPM will not work without GNU cpio 2.4.2 or later.)
68             CPIOBIN="cpio"
69     else
70             AC_MSG_RESULT(yes)
71     fi
72
73     AC_MSG_CHECKING(checking for GNU gzip...)
74     if test -z "$GZIPBIN"; then
75             oldifs="$IFS"
76             IFS=:
77             for n in $PATH:/opt/gnu/bin; do
78                     if test -f $n/gzip; then
79                             GZIPBIN="$n/gzip";
80                     fi
81             done
82             IFS="$oldifs"
83     fi
84
85     if test -z "$GZIPBIN"; then
86             GZIPBIN="gzip"
87             AC_MSG_RESULT(no)
88             AC_MSG_WARN(RPM will not work without GNU gzip.)
89     else
90             AC_MSG_RESULT(yes)
91     fi
92 fi
93
94 topdir=`pwd`
95
96 if test $prefix != "/usr" -a $prefix != "/usr/local"; then
97         echo $ac_n "checking for $prefix/lib... $ac_c"
98         if test -d $prefix/lib ; then
99                LIBS="$LIBS -L$prefix/lib"
100                
101                echo "yes"
102         else
103                echo "no"
104         fi
105
106         echo $ac_n "checking for $prefix/include... $ac_c"
107         if test -d $prefix/include ; then
108                INCPATH="$INCPATH -I$prefix/include"
109                
110                echo "yes"
111         else
112                echo "no"
113         fi
114 fi
115
116 AC_MSG_CHECKING(checking for /usr/local/lib...)
117 if test -d /usr/local/lib ; then
118         LIBS="$LIBS -L/usr/local/lib"
119         
120         AC_MSG_RESULT(yes)
121 else
122         AC_MSG_RESULT(no)
123 fi
124
125 AC_MSG_CHECKING(checking for /usr/local/include...)
126 if test -d /usr/local/include ; then
127         INCPATH="$INCPATH -I/usr/local/include"
128         AC_MSG_RESULT(yes)
129 else
130         AC_MSG_RESULT(no)
131 fi
132
133 AC_MSG_CHECKING(checking for /usr/ucblib...)
134 if test -d /usr/ucblib ; then
135         LIBS="$LIBS -L/usr/ucblib"
136         
137         AC_MSG_RESULT(yes)
138 else
139         AC_MSG_RESULT(no)
140 fi
141
142 dnl Checks for libraries.
143
144 AC_CHECK_FUNC(strcasecmp, [], [
145     AC_CHECK_LIB(ucb, strcasecmp, [LIBS="-lucb $LIBS"])
146 ])
147
148 dnl
149 dnl handle --disable-nls
150 dnl
151 AC_ARG_ENABLE([nls],
152 [  --disable-nls           do not use National Language Support], 
153         USE_NLS=$enableval, USE_NLS=yes)
154
155 if test "$USE_NLS" != "no"; then
156     AC_CHECK_FUNC(gettext, [HAVEGETTEXT="yes"], 
157       AC_CHECK_LIB(intl, gettext, [LIBINTL="-lintl" HAVEGETTEXT="y"], 
158                    AC_MSG_WARN([sorry this package needs libintl.a (from the 
159     gettext package)])
160                  )
161                 )
162
163     AC_CHECK_PROG(XGETTEXT, xgettext, xgettext)
164
165     if test "$XGETTEXT" != ""; then 
166         if xgettext --help 2>&1 | grep illegal >/dev/null ; then
167             echo "xgettext isn't GNU version"
168             XGETTEXT=""
169         fi
170     fi
171
172     if test "$XGETTEXT" != "" -a "$HAVEGETTEXT" != ""; then
173         echo "xgettext and gettext() exist; will build i18n support"
174         PO=po
175         GETTEXTSTUB=""
176     else
177         echo "xgettext and libintl.a don't both exist; will not build i18n support"
178     fi
179 else
180     echo "user specificed no gettext; will not build i18n support"
181 fi
182
183 AC_CHECK_FUNC(getdomainname, [], [
184     AC_CHECK_LIB(nsl, getdomainname, [LIBS="-lnsl $LIBS"])
185 ])
186 AC_CHECK_FUNC(socket, [], [
187     AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"])
188 ])
189
190 AC_CHECK_FUNC(dbopen, [],
191   AC_CHECK_LIB(db, dbopen, [], AC_MSG_WARN([sorry this package needs libdb.a 
192 (from the db package)]))
193            )
194
195 AC_CHECK_FUNC(fork, [], [echo "using vfork() instead of fork()";
196         MISCOBJS=fakefork.o])
197
198 dnl AmigaOS and IXEmul have a fork() dummy
199     case "$target" in
200         m68k-*-amigaos ) 
201                 echo "Building for AmigaOS: using vfork() instead of fork()"; 
202                 CFLAGS="$CFLAGS -Dfork=vfork" 
203                 ;;
204 esac
205
206
207 ZLIB=
208 for zlib in z gz ; do
209    AC_CHECK_LIB(${zlib}, gzread, 
210         [LIBS="-l${zlib} $LIBS"; break], 
211         [if test ${zlib} = gz; then 
212             AC_MSG_WARN([sorry this package needs libz.a or libgz.a (from the zlib package)]) 
213          fi]
214                )
215 done
216
217 dnl Checks for header files we can live without.
218 AC_HEADER_STDC
219 AC_HEADER_MAJOR
220 AC_CHECK_HEADERS(netinet/in_systm.h limits.h)
221 AC_CHECK_HEADERS(alloca.h dirent.h sys/socket.h sys/select.h)
222 AC_CHECK_HEADERS(machine/types.h string.h)
223 AC_CHECK_HEADERS(mntent.h sys/mnttab.h)
224 AC_CHECK_HEADERS(glob.h,,MISCOBJS="$MISCOBJS glob.o")
225 AC_CHECK_HEADERS(fnmatch.h,,MISCOBJS="$MISCOBJS fnmatch.o")
226
227 if test "$PO" = po; then
228     AC_CHECK_HEADERS(libintl.h)
229 fi
230
231 AC_C_BIGENDIAN
232
233 dnl look for libc features
234 PROVIDES_ERRNO=no
235 AC_MSG_CHECKING(if <netdb.h> defines h_errno...)
236 AC_TRY_LINK([#include <netdb.h>],printf("%d",h_errno),PROVIDES_ERRNO=yes)
237 AC_MSG_RESULT($PROVIDES_ERRNO)
238 if test $PROVIDES_ERRNO = yes; then
239         AC_DEFINE(HAVE_HERRNO)
240 fi
241
242 dnl If a system doesn't have S_IFSOCK, define it as 0 which will
243 dnl make S_ISSOCK always return false (nice, eh?)
244 AC_MSG_CHECKING(if <sys/stat.h> defines S_IFSOCK...)
245 AC_TRY_LINK([#include <sys/stat.h>],printf("%d", S_IFSOCK),
246         HAS_S_IFSOCK=yes,HAS_S_IFSOCK=no)
247 AC_MSG_RESULT($HAS_S_IFSOCK)
248 if test $HAS_S_IFSOCK = yes; then
249         AC_DEFINE(HAVE_S_IFSOCK)
250 fi
251
252 dnl Some Unix's are missing S_ISLNK, S_ISSOCK
253 AC_MSG_CHECKING(if <sys/stat.h> defines S_ISLNK...)
254 AC_TRY_LINK([#include <sys/stat.h>],printf("%d", S_ISLNK(0755)),
255         HAS_S_ISLNK=yes,HAS_S_ISLNK=no)
256 AC_MSG_RESULT($HAS_S_ISLNK)
257 if test $HAS_S_ISLNK = yes; then
258         AC_DEFINE(HAVE_S_ISLNK)
259 fi
260
261 AC_MSG_CHECKING(if <sys/stat.h> defines S_ISSOCK...)
262 AC_TRY_LINK([#include <sys/stat.h>],printf("%d", S_ISSOCK(0755)),
263         HAS_S_ISSOCK=yes,HAS_S_ISSOCK=no)
264 AC_MSG_RESULT($HAS_S_ISSOCK)
265 if test $HAS_S_ISSOCK = yes; then
266         AC_DEFINE(HAVE_S_ISSOCK)
267 fi
268
269 AC_MSG_CHECKING(if timezone is defined...)
270 AC_TRY_LINK([#include <time.h>],printf("%ld", timezone),
271       HAS_TIMEZONE=yes,HAS_TIMEZONE=no)
272 AC_MSG_RESULT($HAS_TIMEZONE)
273 if test $HAS_TIMEZONE = no; then
274       AC_DEFINE(NEED_TIMEZONE)
275 fi
276
277 dnl Checks for library functions.
278 AC_CHECK_FUNC(inet_aton, AC_DEFINE(HAVE_INET_ATON), MISCOBJS="$MISCOBJS inet_aton.o")
279 AC_CHECK_FUNC(realpath, AC_DEFINE(HAVE_REALPATH), MISCOBJS="$MISCOBJS realpath.o")
280 AC_CHECK_FUNC(getmntent, AC_DEFINE(HAVE_GETMNTENT), MISCOBJS="$MISCOBJS getmntent.o")
281 AC_CHECK_FUNC(mntctl, AC_DEFINE(HAVE_MNTCTL))
282 AC_CHECK_FUNC(strerror, [], MISCOBJS="$MISCOBJS strerror.o")
283 AC_CHECK_FUNC(strtol, [], MISCOBJS="$MISCOBJS strtol.o")
284 AC_CHECK_FUNC(strtoul, [], MISCOBJS="$MISCOBJS strtoul.o")
285 LCHOWN=no
286 AC_CHECK_FUNC(lchown, [LCHOWN=yes; AC_DEFINE(HAVE_LCHOWN)])
287
288 if test "$LCHOWN" = no; then 
289     dnl Does chown() follow symlinks? This should be a good enough test.
290     AC_MSG_CHECKING(whether chown() follows symlinks...)
291     AC_ARG_ENABLE([broken-chown],
292     [  --enable-broken-chown  this system's chown follows symbolic links], 
293             result=yes, result=unknown)
294     if echo "$build" | grep "aix" > /dev/null ; then
295         result=yes
296     fi
297     if test $result = unknown; then
298         if test `id | cut -f 2 -d \= | cut -f 1 -d \(` = 0; then
299             rm -f foo bar
300             touch foo
301             ln -s foo bar
302             chown 10 bar
303             if test `ls -l foo | awk '{print $3}'` != "root"; then
304                 result=yes
305             else
306                 result=no
307             fi
308             rm -f foo bar
309         else
310             AC_MSG_CHECKING((cannot check by non-root user))
311             result=no
312         fi
313     fi
314
315     AC_MSG_RESULT($result)
316     if test $result = yes; then
317             AC_DEFINE(CHOWN_FOLLOWS_SYMLINK)
318     fi
319 fi
320
321 if test -n "$MISCOBJS"; then
322         LIBMISC=-lmisc
323 fi
324
325 if test "x$varprefix" = "x"; then
326     varprefix=`echo $prefix | sed 's/usr/var/'`
327     test "x$prefix" = xNONE && varprefix=`echo $ac_default_prefix | sed 's/usr/var/'`
328 fi
329
330 if test "x$tmpdir" = "x"; then
331     if test -d $varprefix/tmp; then
332         tmpdir=$varprefix/tmp
333     else
334         if test -d /var/tmp; then
335             tmpdir=/var/tmp
336         else
337             tmpdir=/tmp
338         fi
339     fi
340 fi
341
342 # Solaris 2.5.1 seems to confuse things
343 if echo "$build" | grep "solaris2.5" > /dev/null ; then
344         echo "Hacking things up for Solaris 2.5.x"
345         build_os="solaris"
346 fi
347
348 RPM=rpm
349 # Solaris needs -ldl to use -lnsl, and it can't build static
350 # binaries if you use -ldl
351 if echo "$build_os" | grep solaris >/dev/null; then
352         echo "hacking things up for solaris"
353         RPM=rpm.shared
354         LIBDL=-ldl
355 elif echo "$build_os" | grep sco > /dev/null; then
356         echo "hacking things up for sco"
357         RPM=rpm.shared
358         AC_DEFINE(NEED_STRINGS_H)
359 elif echo "$build_os" | grep sunos > /dev/null; then
360         echo "hacking things up for sunos"
361         CFLAGS="$CFLAGS -D__USE_FIXED_PROTOTYPES__"
362         AC_DEFINE(NEED_STRINGS_H)
363         AC_DEFINE(NEED_MYREALLOC)
364         MISCOBJS="$MISCOBJS myrealloc.o"
365 elif echo "$build_os" | grep hpux > /dev/null; then
366         RPM=rpm.shared
367         echo "hacking things up for hpux"
368 fi
369
370 rm -f ./find-provides.sh
371 if test -f autodeps/${build_os}.prov ; then
372         echo "using autodeps/$build_os.prov for automatic provides generation"
373         ln -s autodeps/${build_os}.prov ./find-provides.sh
374 else
375         echo "*** no default provides information is available for $build_os"
376         ln -s autodeps/none ./find-provides.sh
377 fi
378
379 rm -f ./find-requires.sh
380 if test -f autodeps/${build_os}.req ; then
381         echo "using autodeps/$build_os.req for automatic requires generation"
382         ln -s autodeps/$build_os.req ./find-requires.sh
383 else
384         echo "*** no default requires information is available for $build_os"
385         ln -s autodeps/none ./find-requires.sh
386 fi
387
388 AC_SUBST(MISCOBJS)
389 AC_SUBST(INCPATH)
390 AC_SUBST(LIBMISC)
391 AC_SUBST(LIBINTL)
392 AC_SUBST(varprefix)
393 AC_SUBST(tmpdir)
394 AC_SUBST(topdir)
395 AC_SUBST(INTLDEF)
396 AC_SUBST(XGETTEXT)
397 AC_SUBST(LIBINTL)
398 AC_SUBST(LIBS)
399 AC_SUBST(LIBDL)
400 AC_SUBST(PO)
401 AC_SUBST(GETTEXTSTUB)
402 AC_SUBST(RPM)
403 AC_SUBST(CPIOBIN)
404 AC_SUBST(GZIPBIN)
405 AC_SUBST(FIXPERMS)
406
407 AC_OUTPUT(Makefile Makefile.inc lib-rpmrc lib/Makefile build/Makefile tools/Makefile po/Makefile misc/Makefile)