Include sys/socket.h if it's available
[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)
222 AC_CHECK_HEADERS(machine/types.h string.h)
223 AC_CHECK_HEADERS(glob.h,,MISCOBJS="$MISCOBJS glob.o")
224 AC_CHECK_HEADERS(fnmatch.h,,MISCOBJS="$MISCOBJS fnmatch.o")
225
226 if test "$PO" = po; then
227     AC_CHECK_HEADERS(libintl.h)
228 fi
229
230 AC_C_BIGENDIAN
231
232 dnl look for libc features
233 PROVIDES_ERRNO=no
234 AC_MSG_CHECKING(if <netdb.h> defines h_errno...)
235 AC_TRY_LINK([#include <netdb.h>],printf("%d",h_errno),PROVIDES_ERRNO=yes)
236 AC_MSG_RESULT($PROVIDES_ERRNO)
237 if test $PROVIDES_ERRNO = yes; then
238         AC_DEFINE(HAVE_HERRNO)
239 fi
240
241 dnl If a system doesn't have S_IFSOCK, define it as 0 which will
242 dnl make S_ISSOCK always return false (nice, eh?)
243 AC_MSG_CHECKING(if <sys/stat.h> defines S_IFSOCK...)
244 AC_TRY_LINK([#include <sys/stat.h>],printf("%d", S_IFSOCK),
245         HAS_S_IFSOCK=yes,HAS_S_IFSOCK=no)
246 AC_MSG_RESULT($HAS_S_IFSOCK)
247 if test $HAS_S_IFSOCK = yes; then
248         AC_DEFINE(HAVE_S_IFSOCK)
249 fi
250
251 dnl Some Unix's are missing S_ISLNK, S_ISSOCK
252 AC_MSG_CHECKING(if <sys/stat.h> defines S_ISLNK...)
253 AC_TRY_LINK([#include <sys/stat.h>],printf("%d", S_ISLNK(0755)),
254         HAS_S_ISLNK=yes,HAS_S_ISLNK=no)
255 AC_MSG_RESULT($HAS_S_ISLNK)
256 if test $HAS_S_ISLNK = yes; then
257         AC_DEFINE(HAVE_S_ISLNK)
258 fi
259
260 AC_MSG_CHECKING(if <sys/stat.h> defines S_ISSOCK...)
261 AC_TRY_LINK([#include <sys/stat.h>],printf("%d", S_ISSOCK(0755)),
262         HAS_S_ISSOCK=yes,HAS_S_ISSOCK=no)
263 AC_MSG_RESULT($HAS_S_ISSOCK)
264 if test $HAS_S_ISSOCK = yes; then
265         AC_DEFINE(HAVE_S_ISSOCK)
266 fi
267
268 dnl Checks for library functions.
269 AC_CHECK_FUNC(inet_aton, AC_DEFINE(HAVE_INET_ATON), MISCOBJS="$MISCOBJS inet_aton.o")
270 AC_CHECK_FUNC(realpath, AC_DEFINE(HAVE_REALPATH), MISCOBJS="$MISCOBJS realpath.o")
271 AC_CHECK_FUNC(strerror, [], MISCOBJS="$MISCOBJS strerror.o")
272 AC_CHECK_FUNC(strtol, [], MISCOBJS="$MISCOBJS strtol.o")
273 AC_CHECK_FUNC(strtoul, [], MISCOBJS="$MISCOBJS strtoul.o")
274
275 if test -n "$MISCOBJS"; then
276         LIBMISC=-lmisc
277 fi
278
279 if test "x$varprefix" = "x"; then
280     varprefix=`echo $prefix | sed 's/usr/var/'`
281     test "x$prefix" = xNONE && varprefix=`echo $ac_default_prefix | sed 's/usr/var/'`
282 fi
283
284 if test "x$tmpdir" = "x"; then
285     if test -d $varprefix/tmp; then
286         tmpdir=$varprefix/tmp
287     else
288         if test -d /var/tmp; then
289             tmpdir=/var/tmp
290         else
291             tmpdir=/tmp
292         fi
293     fi
294 fi
295
296 if echo "$build" | egrep 'solaris|hpux10|sco' >/dev/null ; then
297         # Solaris needs -ldl to use -lnsl, and it can't build static
298         # binaries if you use -ldl
299         RPM=rpm.shared
300         if echo "$build" | grep solaris >/dev/null; then
301                 echo "hacking things up for solaris"
302                 LIBDL=-ldl
303         elif echo "$build" | grep sco > /dev/null; then
304                 echo "hacking things up for sco"
305                 AC_DEFINE(NEED_STRINGS_H)
306         else
307                 echo "hacking things up for hpux"
308         fi
309 else
310         RPM=rpm
311 fi
312
313 rm -f ./find-provides.sh
314 if test -f autodeps/${build_os}.prov ; then
315         echo "using autodeps/$build_os.prov for automatic provides generation"
316         ln -s autodeps/${build_os}.prov ./find-provides.sh
317 else
318         echo "*** no default provides information is available for $build_os"
319         ln -s autodeps/none ./find-provides.sh
320 fi
321
322 rm -f ./find-requires.sh
323 if test -f autodeps/${build_os}.req ; then
324         echo "using autodeps/$build_os.req for automatic requires generation"
325         ln -s autodeps/$build_os.req ./find-requires.sh
326 else
327         echo "*** no default requires information is available for $build_os"
328         ln -s autodeps/none ./find-requires.sh
329 fi
330
331 AC_SUBST(MISCOBJS)
332 AC_SUBST(INCPATH)
333 AC_SUBST(LIBMISC)
334 AC_SUBST(LIBINTL)
335 AC_SUBST(varprefix)
336 AC_SUBST(tmpdir)
337 AC_SUBST(topdir)
338 AC_SUBST(INTLDEF)
339 AC_SUBST(XGETTEXT)
340 AC_SUBST(LIBINTL)
341 AC_SUBST(LIBS)
342 AC_SUBST(LIBDL)
343 AC_SUBST(PO)
344 AC_SUBST(GETTEXTSTUB)
345 AC_SUBST(RPM)
346 AC_SUBST(CPIOBIN)
347 AC_SUBST(GZIPBIN)
348 AC_SUBST(FIXPERMS)
349
350 AC_OUTPUT(Makefile Makefile.inc lib-rpmrc lib/Makefile build/Makefile tools/Makefile po/Makefile misc/Makefile)