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