- implement filelists.xml processing for file dependencies
[apt.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2
3 AC_PREREQ(2.54)
4 AC_INIT([apt],[0.5.15lorg3])
5 dnl Check the archs, we want the target type.
6 AC_CONFIG_AUX_DIR([buildlib])
7 AC_CANONICAL_HOST
8 AC_CONFIG_SRCDIR([configure.in])
9 AM_INIT_AUTOMAKE([foreign subdir-objects dist-bzip2 1.7])
10 AM_MAINTAINER_MODE
11
12 AC_CONFIG_HEADER([include/config.h:buildlib/config.h.in])
13
14 AC_PROG_LIBTOOL
15
16 dnl Check our C compiler
17 AC_PROG_CC
18 AM_PROG_CC_C_O
19 AC_ISC_POSIX
20
21 dnl Check for other programs
22 AC_PROG_CXX
23 AC_PROG_CPP
24
25 dnl Checks for sockets
26 SAVE_LIBS="$LIBS"
27 LIBS=""
28 AC_SEARCH_LIBS(gethostbyname,nsl)
29 AC_SEARCH_LIBS(connect,socket)
30 SOCKETLIBS="$LIBS"
31 AC_SUBST(SOCKETLIBS)
32 LIBS="$SAVE_LIBS"
33  
34 dnl Checks for pthread -- disabled due to glibc bugs jgg
35 dnl AC_CHECK_LIB(pthread, pthread_create,[AC_DEFINE(HAVE_PTHREAD) PTHREADLIB="-lpthread"])
36 AC_SUBST(PTHREADLIB)
37 dnl if test "$PTHREADLIB" != "-lpthread"; then
38 dnl   AC_MSG_ERROR(failed: I need posix threads, pthread)
39 dnl fi
40
41 dnl Check for RPM executable path
42 AC_PATH_PROG(RPM_PATH,rpm,none)
43 if test "$RPM_PATH" = "none"; then
44    AC_MSG_ERROR([RPM executable was not found in your system])
45 else
46    AC_DEFINE_UNQUOTED([HAVE_RPM],1,[Define if RPM backend is available])
47
48    dnl Check for RPM version
49    AC_MSG_CHECKING(for RPM version)
50    RPM_VERSION_RAW=`LANG= LC_ALL= $RPM_PATH --version | sed 's/^RPM version //'`
51    RPM_VERSION_MAJOR=`echo $RPM_VERSION_RAW | cut -d. -f1`
52    RPM_VERSION_MINOR=`echo $RPM_VERSION_RAW | cut -d. -f2`
53    RPM_VERSION_MICRO=`echo $RPM_VERSION_RAW | cut -d. -f3`
54    if test -z "$RPM_VERSION_MAJOR" -o -z "$RPM_VERSION_MINOR"; then
55       AC_MSG_ERROR([can't parse RPM version])
56    fi
57    if test -z "$RPM_VERSION_MICRO"; then
58       RPM_VERSION_MICRO=0
59    fi
60    AC_DEFINE_UNQUOTED([RPM_VERSION_MAJOR],$RPM_VERSION_MAJOR,[RPM major version])
61    AC_DEFINE_UNQUOTED([RPM_VERSION_MINOR],$RPM_VERSION_MINOR,[RPM minor version])
62    AC_DEFINE_UNQUOTED([RPM_VERSION_MICRO],$RPM_VERSION_MICRO,[RPM micro version])
63    AC_DEFINE_UNQUOTED([RPM_VERSION],
64       [((RPM_VERSION_MAJOR<<16)|(RPM_VERSION_MINOR<<8)|RPM_VERSION_MICRO)],
65       [Define to the RPM version])
66    AC_DEFINE_UNQUOTED([RPM_VERSION_RAW],"$RPM_VERSION_RAW",[RPM raw version])
67    AC_MSG_RESULT($RPM_VERSION_RAW)
68
69    dnl Check for RPM libraries and headers
70
71    AC_CHECK_LIB(bz2,BZ2_bzopen, [],
72                 [AC_MSG_ERROR([Can't find libbz2 library])])
73    AC_CHECK_LIB(z,gzopen, [],
74                 [AC_MSG_ERROR([Can't find libz library])])
75    AC_CHECK_HEADERS(db1/db.h)
76
77    CPPFLAGS="$CPPFLAGS -I/usr/include/rpm"
78    AC_CHECK_HEADER(rpm/rpmlib.h, [],
79                    [AC_MSG_ERROR([Can't find rpmlib.h])])
80
81    if test $RPM_VERSION_MAJOR -lt 4; then
82       RPMLIBS="-lrpm -lz -lbz2 -lpopt"
83    else
84       AC_CHECK_LIB(rpmdb,rpmdbOpen,
85          [RPMDBLIBS="-lrpmdb"],
86          [RPMDBLIBS="-ldb-3.1"],
87          [-lrpm -lrpmio -lz -lbz2 -lpopt])
88       RPMLIBS="-lrpm $RPMDBLIBS -lrpmio -lz -lbz2 -lpopt"
89    fi
90    AC_MSG_CHECKING(for RPM libraries)
91    AC_MSG_RESULT($RPMLIBS)
92    AC_SUBST(RPMLIBS)
93 fi
94
95 dnl repomd support needs libxml2, not sure about the minimal version - I've
96 dnl only tested it with 2.6.20
97 PKG_CHECK_MODULES([LIBXML2],[libxml-2.0 >= 2.4])
98 RPMLIBS="$LIBXML2_LIBS $RPMLIBS"
99 CPPFLAGS="$LIBXML2_CFLAGS $CPPFLAGS"
100
101 dnl Can we use g++ hash_map?
102 AH_TEMPLATE(WITH_GNU_HASH_MAP,
103             [Define to 1 if you want to use the g++ hash_map extension.])
104 AC_MSG_CHECKING(for g++ hash_map extension)
105 AC_LANG_PUSH([C++])
106 AC_TRY_LINK(
107 [
108 #include <ext/hash_map>
109 using namespace __gnu_cxx;
110 ],[hash_map<char*,hash<char*> > HashMap;
111 ],[AC_DEFINE_UNQUOTED(WITH_GNU_HASH_MAP, 1) AC_MSG_RESULT(yes)
112 ],[AC_MSG_RESULT(no)])
113 AC_LANG_POP([C++])
114
115 dnl CNC:2003-03-20
116 AC_MSG_CHECKING(for --disable-scripts)
117 AC_ARG_ENABLE([scripts],
118               AC_HELP_STRING(--disable-scripts, disable the extension system),
119               [enable_scripts="$enableval"],[enable_scripts="yes"])
120 if test "$enable_scripts" != "no"; then
121   AC_MSG_RESULT(no)
122   AC_DEFINE(WITH_LUA, 1, 
123             [Define if you want to enable the extension system.]) 
124 else
125   AC_MSG_RESULT(yes)
126 fi
127 AM_CONDITIONAL(WITH_LUA, test "$enable_scripts" != "no")
128
129 dnl Before configuring libtool check for --enable-static-progs option
130 AC_MSG_CHECKING(for --enable-static-progs)
131 AC_ARG_ENABLE(static-progs,
132               AC_HELP_STRING([--enable-static-progs],
133                              [Build completely static (standalone) binaries.]),
134               [enable_static_progs="$enableval"],[enable_static_progs="no"])
135 AM_CONDITIONAL(COMPILE_STATIC, test "$enable_static_progs" = "yes")
136 if test "$enable_static_progs" = "yes" ; then
137   AC_MSG_RESULT(yes)
138 else
139   AC_MSG_RESULT(no)
140 fi
141
142 dnl Check for apt-shell dependencies
143 AC_CHECK_LIB(ncurses,tputs,
144   [AC_CHECK_HEADER(readline/readline.h,
145      [AC_CHECK_LIB(readline,rl_completion_matches,
146         [compile_aptshell=yes],,[-lncurses])])])
147 AM_CONDITIONAL(COMPILE_APTSHELL, test "$compile_aptshell" = "yes")
148
149 dnl Converts the ARCH to be something singular for this general CPU family
150 dnl This is often the dpkg architecture string.
151 AH_TEMPLATE(COMMON_CPU, [Define the common CPU])
152 AH_TEMPLATE(COMMON_OS, [Define the common OS])
153 AC_MSG_CHECKING(system architecture)
154 archset="`awk \" ! /^#|^\\\$/ { if(match(\\\"$host_cpu\\\",\\\"^\\\"\\\$1\\\"\\\$\\\")) {print \\\$2; exit}}\" $srcdir/buildlib/archtable`"
155 if test "x$archset" = "x"; then
156   AC_MSG_ERROR(failed: use --host=)
157 fi
158 AC_MSG_RESULT($archset)
159 AC_DEFINE_UNQUOTED(COMMON_CPU,"$archset")
160
161 dnl Get a common name for the host OS - this is primarily only for HURD and is
162 dnl non fatal if it fails
163 AC_MSG_CHECKING(system OS)
164 osset="`awk \" ! /^#|^\\\$/ {if (match(\\\"$host_vendor-$host_os\\\",\\\$1)) {print \\\$2; exit}}\" $srcdir/buildlib/ostable`"
165 AC_MSG_RESULT($osset)
166 AC_DEFINE_UNQUOTED(COMMON_OS,"$osset")
167
168 dnl We use C99 types if at all possible
169 AC_CACHE_CHECK([for C99 integer types],c9x_ints,[
170     AC_TRY_COMPILE([#include <inttypes.h>],
171                    [uint8_t Foo1;uint16_t Foo2;uint32_t Foo3;],
172                    c9x_ints=yes,c9x_ints=no)])
173 AM_CONDITIONAL(NEED_INTTYPES_H, test "$c9x_ints" = "no")
174
175 AC_C_BIGENDIAN
176
177 dnl Check the sizes etc. of the architecture
178 dnl Cross compilers can either get a real C library or preload the cache
179 dnl with their size values.
180 AC_CHECK_SIZEOF(char)
181 AC_CHECK_SIZEOF(int)
182 AC_CHECK_SIZEOF(short)
183 AC_CHECK_SIZEOF(long)
184
185 dnl Single Unix Spec statvfs
186 AC_CHECK_FUNC(statvfs,[have_statvfs=yes])
187 AM_CONDITIONAL(NEED_STATVFS_H, test "$have_statvfs" != "yes")
188
189 dnl Arg, linux and bsd put their statfs function in different places
190 AH_TEMPLATE(HAVE_VFS_H, [Define to 1 if sys/vfs.h is available])
191 AH_TEMPLATE(HAVE_MOUNT_H, [Define to 1 if sys/mount.h is available])
192 if test "$have_statvfs" != "yes"; then
193    AC_EGREP_HEADER(statfs,sys/vfs.h,[AC_DEFINE(HAVE_VFS_H)],[
194         AC_EGREP_HEADER(statfs,sys/mount.h,[AC_DEFINE(HAVE_MOUNT_H)],
195                         [AC_MSG_ERROR(failed: Need statvfs)])
196    ])
197 fi
198
199 dnl We should use the real timegm function if we have it.
200 AH_TEMPLATE(HAVE_TIMEGM, [Define to 1 if timegm is available])
201 AC_CHECK_FUNC(timegm,AC_DEFINE(HAVE_TIMEGM))
202 AC_SUBST(HAVE_TIMEGM)
203
204 dnl HP-UX sux..
205 AH_TEMPLATE(NEED_SOCKLEN_T_DEFINE, [Define to 1 if socket_t is missing])
206 AC_MSG_CHECKING(for missing socklen_t)
207 AC_EGREP_HEADER(socklen_t, sys/socket.h,[AC_MSG_RESULT(no)],[
208         AC_DEFINE(NEED_SOCKLEN_T_DEFINE)
209         NEED_SOCKLEN_T_DEFINE=yes
210         AC_MSG_RESULT(missing.)])
211 AC_SUBST(NEED_SOCKLEN_T_DEFINE)
212 AM_CONDITIONAL(NEED_NETDB_H, test "$NEED_SOCKLEN_T_DEFINE" = "yes")
213
214 dnl HP-UX needs -d_XOPEN_SOURCE_EXTENDED for h_errno
215 AC_MSG_CHECKING(for h_errno)
216 AC_EGREP_HEADER(h_errno, netdb.h, [AC_MSG_RESULT(normal)],
217    [CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
218     AC_EGREP_HEADER(h_errno, netdb.h, 
219        [AC_MSG_RESULT(needs _XOPEN_SOURCE_EXTENDED)],
220        [AC_MSG_ERROR("not found.")])
221    ])
222
223 dnl Check for debiandoc
224 dnl AC_PATH_PROG(DEBIANDOC_HTML,debiandoc2html)
225 dnl AC_PATH_PROG(DEBIANDOC_TEXT,debiandoc2text)
226
227 dnl Check for the SGML tools needed to build man pages
228 AC_PATH_PROG(DOCBOOK2MAN,docbook2man)
229 AC_MSG_CHECKING([for --disable-docs])
230 AC_ARG_ENABLE([docs],
231               AC_HELP_STRING([--disable-docs],
232                              [do not compile documentation]),
233               [enable_docs="$enableval"], [enable_docs="yes"])
234 if test "$enable_docs" != "no"; then
235         AC_MSG_RESULT(no)
236 else
237         AC_MSG_RESULT(yes)
238 fi
239 AM_CONDITIONAL(COMPILE_MANPAGES, test -n "$DOCBOOK2MAN" -a "$enable_docs" != "no")
240
241 AM_GNU_GETTEXT_VERSION([0.11.4])
242 AM_GNU_GETTEXT
243
244 dnl ah_NUM_PROCS
245 rc_GLIBC_VER
246 rc_LIBSTDCPP_VER
247 dnl ah_GCC3DEP
248
249 dnl Fix up intl/Makefile to point to the right config.h
250 AC_CONFIG_COMMANDS([fixintl],[
251         sed -e 's,\.\./config.h,$(top_builddir)/include/config.h,g' \
252             -e 's,^\(INCLUDES = .*\)$,\1 -I$(top_builddir)/include,g' \
253             intl/Makefile > intl/Makefile.tmp
254         mv -f intl/Makefile{.tmp,}
255 ])
256
257 AC_OUTPUT([
258           Makefile
259           buildlib/Makefile
260           intl/Makefile 
261           lua/Makefile
262           apt-pkg/Makefile
263           methods/Makefile
264           cmdline/Makefile
265           tools/Makefile
266           doc/Makefile
267           m4/Makefile 
268           po/Makefile.in
269           ])