Replace bunch of rpm version checks with feature checks to get this to
[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.93],[apt-rpm@lists.laiskiainen.org])
5 dnl Check the archs, we want the target type.
6 AC_CONFIG_AUX_DIR([buildlib])
7 AC_CANONICAL_HOST
8 AC_CONFIG_SRCDIR([AUTHORS.RPM])
9 AM_INIT_AUTOMAKE([foreign subdir-objects dist-bzip2 1.9.5])
10 AM_MAINTAINER_MODE
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 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    AC_CHECK_HEADER(rpm/rpmlib.h, [],
78                    [AC_MSG_ERROR([Can't find rpmlib.h])])
79    AC_CHECK_HEADERS([rpm/rpmsx.h rpm/misc.h rpm/rpmcallback.h, rpm/rpmcb.h,
80                      rpm/rpmmessages.h])
81
82    if test $RPM_VERSION_MAJOR -lt 4; then
83       RPMLIBS="-lrpm -lz -lbz2 -lpopt"
84    else
85       AC_CHECK_LIB(rpmdb,rpmdbOpen,
86          [RPMDBLIBS="-lrpmdb"],
87          [RPMDBLIBS="-ldb-3.1"],
88          [-lrpm -lrpmio -lz -lbz2 -lpopt])
89       RPMLIBS="-lrpm $RPMDBLIBS -lrpmio -lz -lbz2 -lpopt"
90    fi
91    AC_MSG_CHECKING(for RPM libraries)
92    AC_MSG_RESULT($RPMLIBS)
93    AC_SUBST(RPMLIBS)
94 fi
95
96 dnl Various rpm variant capability checks
97 AC_MSG_CHECKING(for rpmdsGetconf)
98 AC_EGREP_HEADER(rpmdsGetconf, rpm/rpmds.h,
99         [AC_MSG_RESULT(yes) AC_DEFINE(RPM_HAVE_DSGETCONF, 1, [rpmdsGetconf]) ],
100         [AC_MSG_RESULT(no) ])
101
102 AC_MSG_CHECKING(for rpmdsRpmlib)
103 AC_EGREP_HEADER(rpmdsRpmlib, rpm/rpmds.h,
104         [AC_MSG_RESULT(yes) AC_DEFINE(RPM_HAVE_DSRPMLIB, 1, [rpmdsRpmlib]) ],
105         [AC_MSG_RESULT(no) ])
106         
107 AC_MSG_CHECKING(for fdigests)
108 AC_EGREP_HEADER(RPMTRANS_FLAG_NOFDIGESTS, rpm/rpmlib.h
109         [AC_MSG_RESULT(yes) AC_DEFINE(RPM_HAVE_FDIGESTS, 1, [fdigests]) ],
110         [AC_MSG_RESULT(no) ])
111
112 dnl Can we use g++ hash_map?
113 AH_TEMPLATE(APT_WITH_GNU_HASH_MAP,
114             [Define to 1 if you want to use the g++ hash_map extension])
115 AC_MSG_CHECKING(for g++ hash_map extension)
116 AC_LANG_PUSH([C++])
117 AC_TRY_LINK(
118 [
119 #include <ext/hash_map>
120 using namespace __gnu_cxx;
121 ],[hash_map<char*,hash<char*> > HashMap;
122 ],[AC_DEFINE_UNQUOTED(APT_WITH_GNU_HASH_MAP, 1) AC_MSG_RESULT(yes)
123 ],[AC_MSG_RESULT(no)])
124 AC_LANG_POP([C++])
125
126 dnl sqlite3
127 SAVE_LIBS="$LIBS"
128 LIBS=""
129 AC_SEARCH_LIBS([sqlite3_open], [sqlite3], [], [have_sqlite3="no"])
130 if test "x$have_sqlite3" != "xno"; then
131    AC_DEFINE([WITH_SQLITE3], [1], [yes])
132    SQLITE3LIBS="$LIBS"
133 fi
134 LIBS="$SAVE_LIBS"
135
136 AM_CONDITIONAL([WITH_SQLITE3], [test ! "x$have_sqlite3" = "no"])
137 AC_SUBST(SQLITE3LIBS)
138
139 dnl CNC:2003-03-20
140 AC_MSG_CHECKING(for --disable-scripts)
141 AC_ARG_ENABLE([scripts],
142               AS_HELP_STRING([--disable-scripts],[disable the lua script extension system]),
143               [enable_scripts="$enableval"],[enable_scripts="yes"])
144 if test "$enable_scripts" != "no"; then
145   AC_MSG_RESULT(no)
146   AC_DEFINE(APT_WITH_LUA, 1, 
147             [Define if you want to enable the extension system]) 
148 else
149   AC_MSG_RESULT(yes)
150 fi
151 AM_CONDITIONAL(WITH_LUA, test "$enable_scripts" != "no")
152
153 dnl SELinux support
154 AC_MSG_CHECKING(for --disable-selinux)
155 AC_ARG_ENABLE([selinux],
156               AS_HELP_STRING([--disable-selinux],
157                              [disable SELinux support]),
158               [enable_selinux="$enableval"],[enable_selinux="yes"])
159 if test "$enable_selinux" != "no"; then
160   AC_MSG_RESULT(no)
161   AC_DEFINE(WITH_SELINUX, 1, 
162             [Define if you want to enable SELinux support]) 
163 else
164   AC_MSG_RESULT(yes)
165 fi
166 AM_CONDITIONAL(WITH_SELINUX, test "$enable_selinux" != "no")
167
168
169 dnl Repomd support
170 AC_MSG_CHECKING(for --disable-repomd)
171 AC_ARG_ENABLE([repomd],
172               AS_HELP_STRING([--disable-repomd],
173                              [disable repomd support]),
174               [enable_repomd="$enableval"],[enable_repomd="yes"])
175 if test "$enable_repomd" != "no"; then
176   AC_MSG_RESULT(no)
177   AC_DEFINE(APT_WITH_REPOMD, 1, [Define if you want to enable repomd support]) 
178   ## xmlReadFile is not available before 2.6.0
179   PKG_CHECK_MODULES([LIBXML2],[libxml-2.0 >= 2.6])
180   RPMLIBS="$LIBXML2_LIBS $RPMLIBS"
181   CPPFLAGS="$LIBXML2_CFLAGS $CPPFLAGS"
182   ## FIXME: Conditionalize this properly. We can support xml repomd without 
183   ## sqlite and repodb with libxml2 older than 2.6. In addition, rollback
184   ## will be using sqlite as well, we only want to check for it once.
185   RPMLIBS="$RPMLIBS $SQLITE3LIBS"
186 else
187   AC_MSG_RESULT(yes)
188 fi
189 AM_CONDITIONAL(WITH_REPOMD, test "$enable_repomd" != "no")
190
191 dnl Before configuring libtool check for --enable-static-progs option
192 AC_MSG_CHECKING(for --enable-static-progs)
193 AC_ARG_ENABLE(static-progs,
194               AS_HELP_STRING([--enable-static-progs],
195                              [build completely static (standalone) binaries]),
196               [enable_static_progs="$enableval"],[enable_static_progs="no"])
197 AM_CONDITIONAL(COMPILE_STATIC, test "$enable_static_progs" = "yes")
198 if test "$enable_static_progs" = "yes" ; then
199   AC_MSG_RESULT(yes)
200 else
201   AC_MSG_RESULT(no)
202 fi
203
204 dnl Check for apt-shell dependencies
205 AC_CHECK_LIB(ncurses,tputs,
206   [AC_CHECK_HEADER(readline/readline.h,
207      [AC_CHECK_LIB(readline,rl_completion_matches,
208         [compile_aptshell=yes],,[-lncurses])])])
209 AM_CONDITIONAL(COMPILE_APTSHELL, test "$compile_aptshell" = "yes")
210
211 dnl Converts the ARCH to be something singular for this general CPU family
212 dnl This is often the dpkg architecture string.
213 AH_TEMPLATE(COMMON_CPU, [Define the common CPU])
214 AH_TEMPLATE(COMMON_OS, [Define the common OS])
215 AC_MSG_CHECKING(system architecture)
216 archset="`awk \" ! /^#|^\\\$/ { if(match(\\\"$host_cpu\\\",\\\"^\\\"\\\$1\\\"\\\$\\\")) {print \\\$2; exit}}\" $srcdir/buildlib/archtable`"
217 if test "x$archset" = "x"; then
218   AC_MSG_ERROR(failed: use --host=)
219 fi
220 AC_MSG_RESULT($archset)
221 AC_DEFINE_UNQUOTED(COMMON_CPU,"$archset")
222
223 dnl Get a common name for the host OS - this is primarily only for HURD and is
224 dnl non fatal if it fails
225 AC_MSG_CHECKING(system OS)
226 osset="`awk \" ! /^#|^\\\$/ {if (match(\\\"$host_vendor-$host_os\\\",\\\$1)) {print \\\$2; exit}}\" $srcdir/buildlib/ostable`"
227 AC_MSG_RESULT($osset)
228 AC_DEFINE_UNQUOTED(COMMON_OS,"$osset")
229
230 dnl We use C99 types if at all possible
231 AC_CACHE_CHECK([for C99 integer types],c9x_ints,[
232     AC_TRY_COMPILE([#include <inttypes.h>],
233                    [uint8_t Foo1;uint16_t Foo2;uint32_t Foo3;],
234                    c9x_ints=yes,c9x_ints=no)])
235
236 AC_C_BIGENDIAN
237
238 dnl Check the sizes etc. of the architecture
239 dnl Cross compilers can either get a real C library or preload the cache
240 dnl with their size values.
241 AC_CHECK_SIZEOF(char)
242 AC_CHECK_SIZEOF(int)
243 AC_CHECK_SIZEOF(short)
244 AC_CHECK_SIZEOF(long)
245
246 dnl Single Unix Spec statvfs
247 AC_CHECK_FUNC(statvfs,[have_statvfs=yes])
248
249 dnl Arg, linux and bsd put their statfs function in different places
250 AH_TEMPLATE(HAVE_SYS_VFS_H, [Define to 1 if sys/vfs.h is available])
251 AH_TEMPLATE(HAVE_SYS_MOUNT_H, [Define to 1 if sys/mount.h is available])
252 if test "$have_statvfs" != "yes"; then
253    AC_EGREP_HEADER(statfs,sys/vfs.h,[AC_DEFINE(HAVE_SYS_VFS_H)],[
254         AC_EGREP_HEADER(statfs,sys/mount.h,[AC_DEFINE(HAVE_SYS_MOUNT_H)],
255                         [AC_MSG_ERROR(failed: Need statvfs)])
256    ])
257 fi
258
259 dnl We should use the real timegm function if we have it.
260 AH_TEMPLATE(HAVE_TIMEGM, [Define to 1 if timegm is available])
261 AC_CHECK_FUNC(timegm,AC_DEFINE(HAVE_TIMEGM))
262 AC_SUBST(HAVE_TIMEGM)
263
264 dnl HP-UX sux..
265 AH_TEMPLATE(NEED_SOCKLEN_T_DEFINE, [Define to 1 if socket_t is missing])
266 AC_MSG_CHECKING(for missing socklen_t)
267 AC_EGREP_HEADER(socklen_t, sys/socket.h,[AC_MSG_RESULT(no)],[
268         AC_DEFINE(NEED_SOCKLEN_T_DEFINE)
269         NEED_SOCKLEN_T_DEFINE=yes
270         AC_MSG_RESULT(missing.)])
271 AC_SUBST(NEED_SOCKLEN_T_DEFINE)
272
273 dnl HP-UX needs -d_XOPEN_SOURCE_EXTENDED for h_errno
274 AC_MSG_CHECKING(for h_errno)
275 AC_EGREP_HEADER(h_errno, netdb.h, [AC_MSG_RESULT(normal)],
276    [CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
277     AC_EGREP_HEADER(h_errno, netdb.h, 
278        [AC_MSG_RESULT(needs _XOPEN_SOURCE_EXTENDED)],
279        [AC_MSG_ERROR("not found.")])
280    ])
281
282 dnl Check for debiandoc
283 dnl AC_PATH_PROG(DEBIANDOC_HTML,debiandoc2html)
284 dnl AC_PATH_PROG(DEBIANDOC_TEXT,debiandoc2text)
285
286 AC_PATH_PROG([GPG],[gpg],[/usr/bin/gpg])
287
288 AM_GNU_GETTEXT_VERSION([0.14.5])
289 AM_GNU_GETTEXT([external])
290
291 dnl ah_NUM_PROCS
292 dnl rc_GLIBC_VER
293 dnl rc_LIBSTDCPP_VER
294 dnl ah_GCC3DEP
295
296 AC_CONFIG_FILES([
297           Makefile
298           lua/Makefile
299           apt-pkg/Makefile
300           apt-pkg/libapt-pkg.pc
301           methods/Makefile
302           cmdline/Makefile
303           tools/Makefile
304           doc/Makefile
305           test/Makefile
306           po/Makefile.in
307           ])
308 AC_CONFIG_LINKS([include/apti18n.h:buildlib/gettext.h])
309
310 AS_IF([test "$c9x_ints" = "no"],[
311 AC_CONFIG_LINKS([include/inttypes.h:buildlib/inttypes.h])
312 ])
313
314 AS_IF([test "$have_statvfs" != "yes"],[
315 AC_CONFIG_LINKS([include/statvfs.h:buildlib/statvfs.h])
316 ])
317
318 AS_IF([test "$NEED_SOCKLEN_T_DEFINE" = "yes"],[
319 AC_CONFIG_LINKS([include/netdb.h:buildlib/netdb.h])
320 ])
321
322 AC_OUTPUT