merge from the lp:~mvo/apt/mvo branch
[ntk/apt.git] / configure.in
1 ad
2 dnl Process this file with autoconf to produce a configure script.
3 dnl The ONLY thing this is used for is to configure for different
4 dnl linux architectures and configurations, it is not used to make the
5 dnl code more portable
6
7 dnl You MUST have an environment that has all the POSIX functions and
8 dnl some of the more populare bsd/sysv ones (like select). You'll also
9 dnl need a C++ compiler that is semi-standard conformant, exceptions are
10 dnl not used but STL is.
11
12 dnl 'make -f Makefile startup' will generate the configure file from
13 dnl configure.in correctly and can be run at any time
14
15 AC_PREREQ(2.50)
16 AC_INIT(configure.in)
17 AC_CONFIG_AUX_DIR(buildlib)
18 AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in)
19
20 PACKAGE="apt"
21 PACKAGE_VERSION="0.9.1"
22 AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
23 AC_DEFINE_UNQUOTED(PACKAGE_VERSION,"$PACKAGE_VERSION")
24 AC_SUBST(PACKAGE)
25 AC_SUBST(PACKAGE_VERSION)
26
27 dnl Check the archs, we want the target type.
28 AC_CANONICAL_SYSTEM
29
30 dnl Check our C compiler
31 AC_CHECK_TOOL_PREFIX
32 AC_PROG_CC
33 AC_ISC_POSIX
34
35 dnl check for large file support and enable it if possible
36 dnl do this early as other stuff might depend on it
37 AC_SYS_LARGEFILE
38
39 dnl Check for other programs
40 AC_PROG_CXX
41 AC_PROG_CPP
42 AC_PROG_RANLIB
43 AC_CHECK_TOOL(AR,ar,"ar")
44
45 dnl Checks for sockets
46 SAVE_LIBS="$LIBS"
47 LIBS=""
48 AC_SEARCH_LIBS(gethostbyname,nsl)
49 AC_SEARCH_LIBS(connect,socket)
50 SOCKETLIBS="$LIBS"
51 AC_SUBST(SOCKETLIBS)
52 LIBS="$SAVE_LIBS"
53
54 dnl Checks for pthread -- disabled due to glibc bugs jgg
55 dnl AC_CHECK_LIB(pthread, pthread_create,[AC_DEFINE(HAVE_PTHREAD) PTHREADLIB="-lpthread"])
56 AC_SUBST(PTHREADLIB)
57 dnl if test "$PTHREADLIB" != "-lpthread"; then
58 dnl AC_MSG_ERROR(failed: I need posix threads, pthread)
59 dnl fi
60
61 dnl Check for BDB
62 saveLIBS="$LIBS"
63 LIBS="$LIBS -ldb"
64
65 AC_CHECK_HEADER(db.h,
66 [AC_MSG_CHECKING(if we can link against BerkeleyDB)
67 AC_LINK_IFELSE(
68 [AC_LANG_PROGRAM(
69 [#include <db.h>],
70 [int r, s, t; db_version(&r, &s, &t);]
71 )],
72 [AC_DEFINE(HAVE_BDB)
73 BDBLIB="-ldb"
74 AC_MSG_RESULT(yes)],
75 [BDBLIB=""
76 AC_MSG_RESULT(no)]
77 )]
78 )
79
80 LIBS="$saveLIBS"
81
82 AC_CHECK_LIB(curl, curl_easy_init,
83 [AC_CHECK_HEADER(curl/curl.h,
84 curl_ok=yes,
85 curl_ok=no)],
86 AC_MSG_ERROR([failed: I need CURL due https support]),
87 )
88
89 AC_SUBST(BDBLIB)
90
91 HAVE_ZLIB=no
92 AC_CHECK_LIB(z, gzopen,
93 [AC_CHECK_HEADER(zlib.h, [HAVE_ZLIB=yes], AC_MSG_ERROR([failed: zlib.h not found]))],
94 AC_MSG_ERROR([failed: Need libz]))
95 AC_SUBST(HAVE_ZLIB)
96 if test "x$HAVE_ZLIB" = "xyes"; then
97 AC_DEFINE(HAVE_ZLIB)
98 fi
99
100 HAVE_BZ2=no
101 AC_CHECK_LIB(bz2, BZ2_bzopen,[AC_CHECK_HEADER(bzlib.h, [HAVE_BZ2=yes], [])], [])
102 AC_SUBST(HAVE_BZ2)
103 if test "x$HAVE_BZ2" = "xyes"; then
104 AC_DEFINE(HAVE_BZ2)
105 fi
106
107 dnl Converts the ARCH to be something singular for this general CPU family
108 dnl This is often the dpkg architecture string.
109 dnl First check against the full canonical canoncial-system-type in $target
110 dnl and if that fails, just look for the cpu
111 AC_MSG_CHECKING(debian architecture)
112 archset="`dpkg-architecture -qDEB_HOST_ARCH`"
113 if test "x$archset" = "x"; then
114 AC_MSG_ERROR([failed: use --host= or output from dpkg-architecture])
115 fi
116 AC_MSG_RESULT($archset)
117 AC_DEFINE_UNQUOTED(COMMON_ARCH,"$archset")
118
119 dnl We use C99 types if at all possible
120 AC_CACHE_CHECK([for C99 integer types],apt_cv_c9x_ints,[
121 AC_TRY_COMPILE([#include <inttypes.h>],
122 [uint8_t Foo1;uint16_t Foo2;uint32_t Foo3;],
123 apt_cv_c9x_ints=yes,apt_cv_c9x_ints=no)])
124
125 dnl Single Unix Spec statvfs
126 AC_CHECK_FUNC(statvfs,[HAVE_STATVFS=yes])
127 AC_SUBST(HAVE_STATVFS)
128
129 dnl Arg, linux and bsd put their statfs function in different places
130 if test x"$HAVE_STATVFS" != x"yes"; then
131 AC_EGREP_HEADER(statfs,sys/vfs.h,[AC_DEFINE(HAVE_VFS_H)],[
132 AC_EGREP_HEADER(statfs,sys/mount.h,[AC_DEFINE(HAVE_MOUNT_H)],[AC_MSG_ERROR(failed: Need statvfs)])
133 ])
134 fi
135
136 AC_CHECK_MEMBERS([struct statfs.f_type],,,
137 [$ac_includes_default
138 #include <sys/vfs.h>])
139
140 dnl We should use the real timegm function if we have it.
141 AC_CHECK_FUNC(timegm,AC_DEFINE(HAVE_TIMEGM))
142 AC_SUBST(HAVE_TIMEGM)
143
144 dnl Check the sizes etc. of the architecture
145 dnl This is stupid, it should just use the AC macros like it does below
146 dnl Cross compilers can either get a real C library or preload the cache
147 dnl with their size values.
148 changequote(,)
149 archline="`awk \" ! /^#|^\\\$/ {if (match(\\\"$archset\\\",\\\$1)) {print; exit}}\" $srcdir/buildlib/sizetable | cut -f 2- -d ' '`"
150 if test "x$archline" != "x"; then
151 changequote([,])
152 set $archline
153 if test "$1" = "little"; then
154 ac_cv_c_bigendian=no
155 else
156 ac_cv_c_bigendian=yes
157 fi
158 size_char=$2
159 size_int=$3
160 size_short=$4
161 size_long=$5
162 fi
163
164 dnl I wonder what AC_C_BIGENDIAN does if you cross compile...
165 dnl This is probably bogus, as above we only care if we have to build our own
166 dnl C9x types.
167 if test "$cross_compiling" = "yes" -a "x$archline" = "x"; then
168 AC_MSG_ERROR(When cross compiling, architecture must be present in sizetable)
169 fi
170 AC_C_BIGENDIAN
171
172 dnl We do not need this if we have inttypes!
173 HAVE_C9X=yes
174 if test x"$apt_cv_c9x_ints" = x"no"; then
175 AC_CHECK_SIZEOF(char,$size_char)
176 AC_CHECK_SIZEOF(int,$size_int)
177 AC_CHECK_SIZEOF(short,$size_short)
178 AC_CHECK_SIZEOF(long,$size_long)
179
180 HAVE_C9X=
181 AC_SUBST(HAVE_C9X)
182 fi
183
184 dnl HP-UX sux..
185 AC_MSG_CHECKING(for missing socklen_t)
186 AC_EGREP_HEADER(socklen_t, sys/socket.h,[AC_MSG_RESULT(no)],[
187 AC_DEFINE(NEED_SOCKLEN_T_DEFINE)
188 NEED_SOCKLEN_T_DEFINE=yes
189 AC_MSG_RESULT(missing.)])
190 AC_SUBST(NEED_SOCKLEN_T_DEFINE)
191
192 dnl HP-UX needs -d_XOPEN_SOURCE_EXTENDED for h_errno
193 AC_MSG_CHECKING(for h_errno)
194 AC_EGREP_HEADER(h_errno, netdb.h, [AC_MSG_RESULT(normal)],
195 [CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
196 AC_EGREP_HEADER(h_errno, netdb.h,
197 [AC_MSG_RESULT(needs _XOPEN_SOURCE_EXTENDED)],
198 [AC_MSG_ERROR("not found.")])
199 ])
200
201 dnl Check for debiandoc
202 AC_PATH_PROG(DEBIANDOC_HTML,debiandoc2html)
203 AC_PATH_PROG(DEBIANDOC_TEXT,debiandoc2text)
204
205 dnl Check for doxygen
206 AC_PATH_PROG(DOXYGEN, doxygen)
207
208 dnl Check for the XSLTProc tool needed to build man pages together with po4a
209 AC_PATH_PROG(XSLTPROC,xsltproc)
210
211 dnl Check for the po4a tool needed to build man pages
212 AC_PATH_PROG(PO4A,po4a)
213
214 dnl Check for graphviz
215 AC_CHECK_PROG([HAVE_DOT], [dot], [YES], [NO])
216 AC_PATH_PROG([DOT], [dot], [])
217 DOTDIR=$(dirname $DOT)
218 AC_SUBST(DOTDIR)
219
220 ah_NUM_PROCS
221 ah_GCC3DEP
222
223 dnl It used to be that the user could select translations and that could get
224 dnl passed to the makefiles, but now that can only work if you use special
225 dnl gettext approved makefiles, so this feature is unsupported by this.
226 ALL_LINGUAS="bg bs ca cs cy da de dz el es eu fi fr gl hu it ja ko ku nb nl nn pl pt_BR pt ro ru sk sl sv th tl uk vi zn_CN zh_TW"
227 AM_GNU_GETTEXT(external)
228 if test x"$USE_NLS" = "xyes"; then
229 AC_DEFINE(USE_NLS)
230 fi
231 AC_SUBST(USE_NLS)
232 AC_PATH_PROG(BASH, bash)
233
234 AC_OUTPUT(environment.mak:buildlib/environment.mak.in makefile:buildlib/makefile.in doc/Doxyfile:doc/Doxyfile.in,make -s dirs)