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