pkg: store size, installed size and installed time info in blob buffer
[oweals/opkg-lede.git] / configure.ac
1 # Process this file with autoconf to produce a configure script
2 AC_INIT([opkg], [0.1.8])
3 AC_CONFIG_SRCDIR([libopkg/pkg.c])
4
5 AC_CONFIG_AUX_DIR([conf])
6 AC_CONFIG_MACRO_DIR([m4])
7
8 AM_INIT_AUTOMAKE
9 AM_CONFIG_HEADER(libopkg/config.h)
10
11 AC_CANONICAL_HOST
12 AC_GNU_SOURCE 
13
14 # Disable C++/Fortran checks
15 define([AC_LIBTOOL_LANG_CXX_CONFIG], [:])
16 define([AC_LIBTOOL_LANG_F77_CONFIG], [:])
17
18
19 for top_builddir in . .. ../.. $ac_auxdir $ac_auxdir/..; do
20   test -f $top_builddir/configure && break
21 done
22
23 # large file support can be useful for gpgme
24 AC_SYS_LARGEFILE
25
26
27 # Checks for programs
28 AC_PROG_AWK
29 AC_PROG_CC
30 AC_PROG_INSTALL
31 AC_PROG_LN_S
32 AM_PROG_INSTALL_STRIP
33 AC_PROG_LIBTOOL
34 PKG_PROG_PKG_CONFIG([0.20])
35
36 # Checks for libraries
37
38 dnl extra argument: --enable-pathfinder
39 AC_ARG_ENABLE(pathfinder,
40               AC_HELP_STRING([--enable-pathfinder], [Enable libpathfinder support.
41       [[default=no]] ]),
42     [want_pathfinder="$enableval"], [want_pathfinder="no"])
43 dnl Check for libpathfinder
44 if test "x$want_pathfinder" = "xyes"; then
45   PKG_CHECK_MODULES([PATHFINDER], [pathfinder-openssl dbus-1 openssl])
46   if test -n "$PATHFINDER_CFLAGS$PATHFINDER_LIBS"; then
47     AC_DEFINE(HAVE_PATHFINDER, 1, [we have pathfinder])
48   fi
49   AC_SUBST(PATHFINDER_CFLAGS)
50   AC_SUBST(PATHFINDER_LIBS)
51 fi
52 AM_CONDITIONAL(HAVE_PATHFINDER, test "x$want_pathfinder" = "xyes")
53
54 # check for libcurl
55 AC_ARG_ENABLE(curl,
56               AC_HELP_STRING([--enable-curl], [Enable downloading with curl
57       [[default=yes]] ]),
58     [want_curl="$enableval"], [want_curl="yes"])
59
60 if test "x$want_curl" = "xyes"; then
61   PKG_CHECK_MODULES(CURL, [libcurl])
62   AC_DEFINE(HAVE_CURL, 1, [Define if you want CURL support])
63 fi
64
65 # check for sha256
66 AC_ARG_ENABLE(sha256,
67               AC_HELP_STRING([--enable-sha256], [Enable sha256sum check
68       (sha256.{c,h} are GPLv3 licensed) [[default=no]] ]),
69     [want_sha256="$enableval"], [want_sha256="no"])
70
71 AC_ARG_ENABLE(md5,
72               AC_HELP_STRING([--enable-md5], [Enable md5sum check
73       (md5.{c,h} are GPLv3 licensed) [[default=no]] ]),
74     [want_md5="$enableval"], [want_md5="yes"])
75
76 if test "x$want_sha256" = "xyes"; then
77   AC_DEFINE(HAVE_SHA256, 1, [Define if you want sha256 support])
78 fi
79 if test "x$want_md5" = "xyes"; then
80   AC_DEFINE(HAVE_MD5, 1, [Define if you want md5 support])
81 fi
82 AM_CONDITIONAL(HAVE_SHA256, test "x$want_sha256" = "xyes")
83 AM_CONDITIONAL(HAVE_MD5, test "x$want_md5" = "xyes")
84
85 # check for openssl
86 AC_ARG_ENABLE(openssl,
87               AC_HELP_STRING([--enable-openssl], [Enable signature checking with OpenSSL
88       [[default=no]] ]),
89     [want_openssl="$enableval"], [want_openssl="no"])
90
91 if test "x$want_openssl" = "xyes"; then
92   AC_DEFINE(HAVE_OPENSSL, 1, [Define if you want OpenSSL support])
93   NEED_SSL_LIBS="yes"
94 fi
95
96 # check for libssl-curl
97 AC_ARG_ENABLE(ssl-curl,
98               AC_HELP_STRING([--enable-ssl-curl], [Enable certificate authentication with curl
99                               [[default="yes"]] ]),
100                               [want_sslcurl="$enableval"], [want_sslcurl="yes"])
101
102 if test "x$want_curl" = "xyes" -a "x$want_sslcurl" = "xyes"; then
103   AC_DEFINE(HAVE_CURL, 1, [Define if you want CURL support])
104   AC_DEFINE(HAVE_SSLCURL, 1, [Define if you want certificate authentication with curl])
105   NEED_SSL_LIBS="yes"
106 fi
107
108 if test "x$NEED_SSL_LIBS" = "xyes"; then
109   AC_MSG_CHECKING([if openssl is available])
110
111   PKG_CHECK_MODULES(OPENSSL, openssl, [:], [:])
112   if test "x$OPENSSL_LIBS" != "x"; then
113           AC_MSG_RESULT(yes)
114   else
115           OPENSSL_LIBS="-lcrypto -lssl"
116           dnl If pkg-config fails, run compile/link test.
117           AC_TRY_LINK([
118 #include <openssl/opensslv.h>
119 ], [
120 return OPENSSL_VERSION_NUMBER; ],
121           [
122             AC_MSG_RESULT(yes)
123
124           ], [
125             AC_MSG_RESULT(no)
126             AC_MSG_ERROR(OpenSSL not found)
127           ])
128   fi
129   AC_SUBST(OPENSSL_LIBS)
130 fi
131
132
133 dnl **********
134 dnl GPGME
135 dnl **********
136
137 AC_ARG_ENABLE(gpg,
138     AC_HELP_STRING([--enable-gpg], [Enable signature checking with gpgme
139       [[default=yes]] ]),
140     [want_gpgme="$enableval"], [want_gpgme="yes"])
141
142 if test "x$want_gpgme" = "xyes"; then
143   ok="no"
144   min_gpgme_version=1.0.0
145   AC_PATH_PROG(GPGME_CONFIG, gpgme-config, "failed")
146   if test $GPGME_CONFIG != "failed" ; then
147         AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version)
148         req_major=`echo $min_gpgme_version | \
149                    sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
150         req_minor=`echo $min_gpgme_version | \
151                    sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
152         req_micro=`echo $min_gpgme_version | \
153                    sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
154         gpgme_config_version=`$GPGME_CONFIG --version`
155         major=`echo $gpgme_config_version | \
156                    sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
157         minor=`echo $gpgme_config_version | \
158                    sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
159         micro=`echo $gpgme_config_version | \
160                    sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
161
162           if test "$major" -eq "$req_major"; then
163              if test "$minor" -ge "$req_minor"; then
164                if test "$micro" -ge "$req_micro"; then
165                  ok="yes"
166                fi
167              fi
168           fi
169   fi
170
171   if test $ok = "yes"; then
172     GPGME_CFLAGS=`$GPGME_CONFIG --cflags`
173     GPGME_LIBS=`$GPGME_CONFIG --libs`
174     AC_MSG_RESULT(yes)
175     AC_DEFINE(HAVE_GPGME, 1, [Define if you want GPG support])
176   else
177     AC_MSG_ERROR(GPGME $min_gpgme_version or later needed)
178   fi
179 fi
180
181 AC_ARG_ENABLE(usign,
182     AC_HELP_STRING([--enable-usign], [Enable signature checking with usign
183       [[default=yes]] ]),
184     [want_usign="$enableval"], [want_usign="yes"])
185
186 if test "x$want_usign" = "xyes"; then
187   AC_DEFINE(HAVE_USIGN, 1, [Define if you want usign support])
188 fi
189
190 AC_SUBST(GPGME_CFLAGS)
191 AC_SUBST(GPGME_LIBS)
192
193
194 # Checks for header files
195 AC_HEADER_DIRENT
196 AC_HEADER_STDC
197 AC_HEADER_SYS_WAIT
198 AC_CHECK_HEADERS([errno.h fcntl.h memory.h regex.h stddef.h stdlib.h string.h strings.h unistd.h utime.h])
199
200 # Checks for typedefs, structures, and compiler characteristics.
201 AC_C_CONST
202 AC_TYPE_UID_T
203 AC_TYPE_MODE_T
204 AC_TYPE_OFF_T
205 AC_TYPE_PID_T
206 AC_TYPE_SIZE_T
207 AC_CHECK_MEMBERS([struct stat.st_rdev])
208
209 # Checks endianness
210 AC_C_BIGENDIAN(BIGENDIAN_CFLAGS="-DWORDS_BIGENDIAN=1",)
211 AC_SUBST(BIGENDIAN_CFLAGS)
212
213 # Don't do annoying tests that don't work when cross-compiling, just trust them.
214 # The AC_FUNC_MEMCMP test doesn't work during a cross-compile, disable.
215 # AC_FUNC_MEMCMP
216 # The AC_FUNC_STAT test doesn't work during a cross-compile, disable.
217 # AC_FUNC_STAT
218
219 # Checks for library functions
220 AC_FUNC_CHOWN
221 AC_FUNC_FORK
222 AC_TYPE_SIGNAL
223 AC_FUNC_UTIME_NULL
224 AC_FUNC_VPRINTF
225 AC_CHECK_FUNCS([memmove memset mkdir regcomp strchr strcspn strdup strerror strndup strrchr strstr strtol strtoul sysinfo utime])
226
227 opkglibdir=
228 AC_ARG_WITH(opkglibdir,
229 [  --with-opkglibdir=DIR   specifies directory to put status and info files.
230                           "/opkg" is always added so if you want your files 
231                           to be in /var/lib/opkg instead of /usr/lib/opkg
232                           you should indicate 
233                           --with-opkglibdir=/var/lib ],
234 [case "${withval}" in
235 yes)    AC_MSG_ERROR(bad value ${withval} given for opkg libs directories ) ;;
236 no)     ;;
237 *)      opkglibdir=$with_opkglibdir ;;
238 esac])
239
240 # Default local prefix if it is empty
241 if test x$opkglibdir = x; then
242         opkglibdir=/usr/lib
243 fi
244
245 opkgetcdir=
246 AC_ARG_WITH(opkgetcdir,
247 [  --with-opkgetcdir=DIR   specifies directory for opkg.conf file,
248                            "/opkg" is always added so if you want your files
249                            to be in /usr/etc/opkg instead of /etc/opkg
250                            you should indicate
251                            --with-opkgetcdir=/usr/etc ],
252 [case "${withval}" in
253 yes)    AC_MSG_ERROR(bad value ${withval} given for opkg.conf directory ) ;;
254 no)     ;;
255 *)      opkgetcdir=$with_opkgetcdir ;;
256 esac])
257
258 # Default local prefix if it is empty
259 if test x$opkgetcdir = x; then
260         opkgetcdir=/etc
261 fi
262
263 opkglockfile=
264 AC_ARG_WITH(opkglockfile,
265 [  --with-opkglockfile=FILE specifies the file used to make sure there is only
266                            one instance of opkg runnning.
267                            Defaults to ${opkglibdir}/opkg/lock, i.e.
268                            /usr/lib/opkg/lock ],
269 [case "${withval}" in
270 yes)    AC_MSG_ERROR(bad value ${withval} given for opkg lock file ) ;;
271 no)     ;;
272 *)      opkglockfile=$with_opkglockfile ;;
273 esac])
274
275 # Default if empty
276 if test x$opkglockfile = x; then
277         opkglockfile=${opkglibdir}/opkg/lock
278 fi
279
280 dnl Some special cases for the wow64 build
281 if test "x$want_gpgme" = "xyes"
282 then
283         if test "x$want_openssl" = "xyes"
284         then
285         AC_MSG_ERROR([--enable-gpg and --enable-openssl are mutually exclusive.
286 Use --disable-gpg if you want OpenSSL smime signatures])
287         fi
288 fi
289
290 CLEAN_DATE=`date +"%B %Y" | tr -d '\n'`
291
292 AC_SUBST(opkglibdir)
293 AC_SUBST(opkgetcdir)
294 AC_SUBST(opkglockfile)
295 AC_SUBST([CLEAN_DATE])
296
297 AC_OUTPUT(
298     Makefile
299     libopkg/Makefile
300     tests/Makefile
301     src/Makefile
302     libbb/Makefile
303     utils/Makefile
304     utils/update-alternatives
305     libopkg.pc
306     man/Makefile
307     man/opkg-cl.1
308     man/opkg-key.1
309     )