Add bunch of missing includes to fix build with gcc 4.7
[apt.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2
3 AC_PREREQ(2.59)
4 AC_INIT([apt],[0.5.15lorg3.95],[apt-rpm@lists.laiskiainen.org])
5 dnl Check the archs, we want the target type.
6 AC_CONFIG_AUX_DIR([buildlib])
7 AC_CONFIG_MACRO_DIR([m4])
8 AC_CANONICAL_HOST
9 AC_CONFIG_SRCDIR([AUTHORS.RPM])
10 AM_INIT_AUTOMAKE([foreign subdir-objects dist-bzip2 1.9.5])
11
12 AC_CONFIG_HEADER([include/config.h:buildlib/config.h.in])
13 AC_CONFIG_HEADER([include/apt-pkg/aptconf.h:apt-pkg/aptconf.h.in])
14
15 dnl Check our C compiler
16 AC_PROG_CC
17 AM_PROG_CC_C_O
18 AC_ISC_POSIX
19
20 dnl Check for other programs
21 AC_PROG_CXX
22 AC_PROG_CPP
23
24 AC_PROG_LIBTOOL
25
26 dnl Checks for sockets
27 SAVE_LIBS="$LIBS"
28 LIBS=""
29 AC_SEARCH_LIBS(gethostbyname,nsl)
30 AC_SEARCH_LIBS(connect,socket)
31 SOCKETLIBS="$LIBS"
32 AC_SUBST(SOCKETLIBS)
33 LIBS="$SAVE_LIBS"
34  
35 dnl Checks for pthread -- disabled due to glibc bugs jgg
36 dnl AC_CHECK_LIB(pthread, pthread_create,[AC_DEFINE(HAVE_PTHREAD) PTHREADLIB="-lpthread"])
37 AC_SUBST(PTHREADLIB)
38 dnl if test "$PTHREADLIB" != "-lpthread"; then
39 dnl   AC_MSG_ERROR(failed: I need posix threads, pthread)
40 dnl fi
41
42 dnl Apt acquirer methods need bz2 and libz
43 AC_CHECK_LIB(bz2,BZ2_bzopen, [],
44         [AC_MSG_ERROR([Can't find libbz2 library])])
45 AC_CHECK_LIB(z,gzopen, [],
46         [AC_MSG_ERROR([Can't find libz library])])
47
48 dnl See if we have pkgconfig for rpm
49 PKG_CHECK_MODULES([RPM], [rpm], [
50       RPM_VERSION_RAW=`pkg-config --modversion rpm` 
51       AC_DEFINE_UNQUOTED([HAVE_RPM],1,[Define if RPM backend is available])
52       CPPFLAGS="$RPM_CFLAGS $CPPFLAGS"
53       LDFLAGS="$RPM_LIBS $LDFLAGS"
54    ]
55 )
56
57 AC_MSG_CHECKING(for RPM version)
58 RPM_VERSION_MAJOR=`echo $RPM_VERSION_RAW | cut -d. -f1`
59 RPM_VERSION_MINOR=`echo $RPM_VERSION_RAW | cut -d. -f2`
60 RPM_VERSION_MICRO=`echo $RPM_VERSION_RAW | cut -d. -f3`
61 if test -z "$RPM_VERSION_MAJOR" -o -z "$RPM_VERSION_MINOR"; then
62    AC_MSG_ERROR([can't parse RPM version])
63 fi
64 if test -z "$RPM_VERSION_MICRO"; then
65    RPM_VERSION_MICRO=0
66 fi
67 AC_DEFINE_UNQUOTED([RPM_VERSION_MAJOR],$RPM_VERSION_MAJOR,[RPM major version])
68 AC_DEFINE_UNQUOTED([RPM_VERSION_MINOR],$RPM_VERSION_MINOR,[RPM minor version])
69 AC_DEFINE_UNQUOTED([RPM_VERSION_MICRO],$RPM_VERSION_MICRO,[RPM micro version])
70 AC_DEFINE_UNQUOTED([RPM_VERSION],
71       [((RPM_VERSION_MAJOR<<16)|(RPM_VERSION_MINOR<<8)|RPM_VERSION_MICRO)],
72       [Define to the RPM version])
73 AC_DEFINE_UNQUOTED([RPM_VERSION_RAW],"$RPM_VERSION_RAW",[RPM raw version])
74 AC_MSG_RESULT($RPM_VERSION_RAW)
75
76 dnl Various rpm header checks..
77 AC_CHECK_HEADERS([rpm/rpmcallback.h rpm/rpmtypes.h rpm/rpmtd.h], [],
78    [AC_MSG_ERROR([Required rpm headers missing (rpm too old?)])])
79         
80 AC_MSG_CHECKING(for rpmTagVal)
81 AC_EGREP_HEADER(rpmTagVal, rpm/rpmtag.h,
82         [AC_MSG_RESULT(yes) AC_DEFINE(RPM_HAVE_RPMTAGVAL, 1, [rpmTagVal]) ],
83         [AC_MSG_RESULT(no) ])
84
85 AC_LANG_PUSH([C++])
86 AC_CHECK_HEADERS([tr1/unordered_map tr1/unordered_set])
87 AC_LANG_POP([C++])
88
89 dnl sqlite3
90 SAVE_LIBS="$LIBS"
91 LIBS=""
92 AC_SEARCH_LIBS([sqlite3_open], [sqlite3], [], [have_sqlite3="no"])
93 if test "x$have_sqlite3" != "xno"; then
94    AC_DEFINE([WITH_SQLITE3], [1], [yes])
95    SQLITE3LIBS="$LIBS"
96 fi
97 LIBS="$SAVE_LIBS"
98
99 AM_CONDITIONAL([WITH_SQLITE3], [test ! "x$have_sqlite3" = "no"])
100 AC_SUBST(SQLITE3LIBS)
101
102 dnl CNC:2003-03-20
103 AC_MSG_CHECKING(for --disable-scripts)
104 AC_ARG_ENABLE([scripts],
105               AS_HELP_STRING([--disable-scripts],[disable the lua script extension system]),
106               [enable_scripts="$enableval"],[enable_scripts="yes"])
107 if test "$enable_scripts" != "no"; then
108   AC_MSG_RESULT(no)
109   AC_DEFINE(APT_WITH_LUA, 1, 
110             [Define if you want to enable the extension system]) 
111 else
112   AC_MSG_RESULT(yes)
113 fi
114 # XXX We should optimally support both internal and system lua, with our 
115 # local extensions always built if lua enabled.
116 AM_CONDITIONAL(WITH_LUA, test "$enable_scripts" != "no")
117 AM_CONDITIONAL(WITH_LUAEXT, test "$enable_scripts" != "no")
118
119 dnl Repomd support
120 AC_MSG_CHECKING(for --disable-repomd)
121 AC_ARG_ENABLE([repomd],
122               AS_HELP_STRING([--disable-repomd],
123                              [disable repomd support]),
124               [enable_repomd="$enableval"],[enable_repomd="yes"])
125 if test "$enable_repomd" != "no"; then
126   AC_MSG_RESULT(no)
127   AC_DEFINE(APT_WITH_REPOMD, 1, [Define if you want to enable repomd support]) 
128   ## xmlReadFile is not available before 2.6.0
129   PKG_CHECK_MODULES([LIBXML2],[libxml-2.0 >= 2.6])
130   RPM_LIBS="$LIBXML2_LIBS $RPM_LIBS"
131   CPPFLAGS="$LIBXML2_CFLAGS $CPPFLAGS"
132   ## FIXME: Conditionalize this properly. We can support xml repomd without 
133   ## sqlite and repodb with libxml2 older than 2.6. In addition, rollback
134   ## will be using sqlite as well, we only want to check for it once.
135   RPM_LIBS="$RPM_LIBS $SQLITE3LIBS"
136 else
137   AC_MSG_RESULT(yes)
138 fi
139 AM_CONDITIONAL(WITH_REPOMD, test "$enable_repomd" != "no")
140
141 dnl Before configuring libtool check for --enable-static-progs option
142 AC_MSG_CHECKING(for --enable-static-progs)
143 AC_ARG_ENABLE(static-progs,
144               AS_HELP_STRING([--enable-static-progs],
145                              [build completely static (standalone) binaries]),
146               [enable_static_progs="$enableval"],[enable_static_progs="no"])
147 AM_CONDITIONAL(COMPILE_STATIC, test "$enable_static_progs" = "yes")
148 if test "$enable_static_progs" = "yes" ; then
149   AC_MSG_RESULT(yes)
150 else
151   AC_MSG_RESULT(no)
152 fi
153
154 dnl Check for apt-shell dependencies
155 AC_CHECK_LIB(ncurses,tputs,
156   [AC_CHECK_HEADER(readline/readline.h,
157      [AC_CHECK_LIB(readline,rl_completion_matches,
158         [compile_aptshell=yes],,[-lncurses])])])
159 AM_CONDITIONAL(COMPILE_APTSHELL, test "$compile_aptshell" = "yes")
160
161 dnl Converts the ARCH to be something singular for this general CPU family
162 dnl This is often the dpkg architecture string.
163 AH_TEMPLATE(COMMON_CPU, [Define the common CPU])
164 AH_TEMPLATE(COMMON_OS, [Define the common OS])
165 AC_MSG_CHECKING(system architecture)
166 archset="`awk \" ! /^#|^\\\$/ { if(match(\\\"$host_cpu\\\",\\\"^\\\"\\\$1\\\"\\\$\\\")) {print \\\$2; exit}}\" $srcdir/buildlib/archtable`"
167 if test "x$archset" = "x"; then
168   AC_MSG_ERROR(failed: use --host=)
169 fi
170 AC_MSG_RESULT($archset)
171 AC_DEFINE_UNQUOTED(COMMON_CPU,"$archset")
172
173 dnl Get a common name for the host OS - this is primarily only for HURD and is
174 dnl non fatal if it fails
175 AC_MSG_CHECKING(system OS)
176 osset="`awk \" ! /^#|^\\\$/ {if (match(\\\"$host_vendor-$host_os\\\",\\\$1)) {print \\\$2; exit}}\" $srcdir/buildlib/ostable`"
177 AC_MSG_RESULT($osset)
178 AC_DEFINE_UNQUOTED(COMMON_OS,"$osset")
179
180 dnl We use C99 types if at all possible
181 AC_CACHE_CHECK([for C99 integer types],apt_cv_c9x_ints,[
182     AC_TRY_COMPILE([#include <inttypes.h>],
183                    [uint8_t Foo1;uint16_t Foo2;uint32_t Foo3;],
184                    apt_cv_c9x_ints=yes,apt_cv_c9x_ints=no)])
185
186 AC_C_BIGENDIAN
187
188 dnl Check the sizes etc. of the architecture
189 dnl Cross compilers can either get a real C library or preload the cache
190 dnl with their size values.
191 AC_CHECK_SIZEOF(char)
192 AC_CHECK_SIZEOF(int)
193 AC_CHECK_SIZEOF(short)
194 AC_CHECK_SIZEOF(long)
195
196 dnl Single Unix Spec statvfs
197 AC_CHECK_FUNC(statvfs,[have_statvfs=yes])
198
199 dnl Arg, linux and bsd put their statfs function in different places
200 AH_TEMPLATE(HAVE_SYS_VFS_H, [Define to 1 if sys/vfs.h is available])
201 AH_TEMPLATE(HAVE_SYS_MOUNT_H, [Define to 1 if sys/mount.h is available])
202 if test "$have_statvfs" != "yes"; then
203    AC_EGREP_HEADER(statfs,sys/vfs.h,[AC_DEFINE(HAVE_SYS_VFS_H)],[
204         AC_EGREP_HEADER(statfs,sys/mount.h,[AC_DEFINE(HAVE_SYS_MOUNT_H)],
205                         [AC_MSG_ERROR(failed: Need statvfs)])
206    ])
207 fi
208
209 dnl We should use the real timegm function if we have it.
210 AH_TEMPLATE(HAVE_TIMEGM, [Define to 1 if timegm is available])
211 AC_CHECK_FUNC(timegm,AC_DEFINE(HAVE_TIMEGM))
212 AC_SUBST(HAVE_TIMEGM)
213
214 dnl HP-UX sux..
215 AH_TEMPLATE(NEED_SOCKLEN_T_DEFINE, [Define to 1 if socket_t is missing])
216 AC_MSG_CHECKING(for missing socklen_t)
217 AC_EGREP_HEADER(socklen_t, sys/socket.h,[AC_MSG_RESULT(no)],[
218         AC_DEFINE(NEED_SOCKLEN_T_DEFINE)
219         NEED_SOCKLEN_T_DEFINE=yes
220         AC_MSG_RESULT(missing.)])
221 AC_SUBST(NEED_SOCKLEN_T_DEFINE)
222
223 dnl HP-UX needs -d_XOPEN_SOURCE_EXTENDED for h_errno
224 AC_MSG_CHECKING(for h_errno)
225 AC_EGREP_HEADER(h_errno, netdb.h, [AC_MSG_RESULT(normal)],
226    [CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
227     AC_EGREP_HEADER(h_errno, netdb.h, 
228        [AC_MSG_RESULT(needs _XOPEN_SOURCE_EXTENDED)],
229        [AC_MSG_ERROR("not found.")])
230    ])
231
232 dnl Check for debiandoc
233 dnl AC_PATH_PROG(DEBIANDOC_HTML,debiandoc2html)
234 dnl AC_PATH_PROG(DEBIANDOC_TEXT,debiandoc2text)
235
236 AC_PATH_PROG([GPG],[gpg],[/usr/bin/gpg])
237
238 AM_GNU_GETTEXT_VERSION([0.14.5])
239 AM_GNU_GETTEXT([external])
240
241 dnl ah_NUM_PROCS
242 dnl rc_GLIBC_VER
243 dnl rc_LIBSTDCPP_VER
244 dnl ah_GCC3DEP
245
246 AC_CONFIG_FILES([
247           Makefile
248           luaext/Makefile
249           apt-pkg/Makefile
250           apt-pkg/libapt-pkg.pc
251           methods/Makefile
252           cmdline/Makefile
253           tools/Makefile
254           doc/Makefile
255           test/Makefile
256           po/Makefile.in
257           ])
258 AC_CONFIG_LINKS([include/apti18n.h:buildlib/gettext.h])
259
260 AS_IF([test "$apt_cv_c9x_ints" = "no"],[
261 AC_CONFIG_LINKS([include/inttypes.h:buildlib/inttypes.h])
262 ])
263
264 AS_IF([test "$have_statvfs" != "yes"],[
265 AC_CONFIG_LINKS([include/statvfs.h:buildlib/statvfs.h])
266 ])
267
268 AS_IF([test "$NEED_SOCKLEN_T_DEFINE" = "yes"],[
269 AC_CONFIG_LINKS([include/netdb.h:buildlib/netdb.h])
270 ])
271
272 AC_OUTPUT