libopkg: print error messages to stderr
[project/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 if test "x$want_sha256" = "xyes"; then
72 AC_DEFINE(HAVE_SHA256, 1, [Define if you want sha256 support])
73 fi
74 AM_CONDITIONAL(HAVE_SHA256, test "x$want_sha256" = "xyes")
75
76 # check for openssl
77 AC_ARG_ENABLE(openssl,
78 AC_HELP_STRING([--enable-openssl], [Enable signature checking with OpenSSL
79 [[default=no]] ]),
80 [want_openssl="$enableval"], [want_openssl="no"])
81
82 if test "x$want_openssl" = "xyes"; then
83 AC_DEFINE(HAVE_OPENSSL, 1, [Define if you want OpenSSL support])
84 NEED_SSL_LIBS="yes"
85 fi
86
87 # check for libssl-curl
88 AC_ARG_ENABLE(ssl-curl,
89 AC_HELP_STRING([--enable-ssl-curl], [Enable certificate authentication with curl
90 [[default="yes"]] ]),
91 [want_sslcurl="$enableval"], [want_sslcurl="yes"])
92
93 if test "x$want_curl" = "xyes" -a "x$want_sslcurl" = "xyes"; then
94 AC_DEFINE(HAVE_CURL, 1, [Define if you want CURL support])
95 AC_DEFINE(HAVE_SSLCURL, 1, [Define if you want certificate authentication with curl])
96 NEED_SSL_LIBS="yes"
97 fi
98
99 if test "x$NEED_SSL_LIBS" = "xyes"; then
100 AC_MSG_CHECKING([if openssl is available])
101
102 PKG_CHECK_MODULES(OPENSSL, openssl, [:], [:])
103 if test "x$OPENSSL_LIBS" != "x"; then
104 AC_MSG_RESULT(yes)
105 else
106 OPENSSL_LIBS="-lcrypto -lssl"
107 dnl If pkg-config fails, run compile/link test.
108 AC_TRY_LINK([
109 #include <openssl/opensslv.h>
110 ], [
111 return OPENSSL_VERSION_NUMBER; ],
112 [
113 AC_MSG_RESULT(yes)
114
115 ], [
116 AC_MSG_RESULT(no)
117 AC_MSG_ERROR(OpenSSL not found)
118 ])
119 fi
120 AC_SUBST(OPENSSL_LIBS)
121 fi
122
123
124 dnl **********
125 dnl GPGME
126 dnl **********
127
128 AC_ARG_ENABLE(gpg,
129 AC_HELP_STRING([--enable-gpg], [Enable signature checking with gpgme
130 [[default=yes]] ]),
131 [want_gpgme="$enableval"], [want_gpgme="yes"])
132
133 if test "x$want_gpgme" = "xyes"; then
134 ok="no"
135 min_gpgme_version=1.0.0
136 AC_PATH_PROG(GPGME_CONFIG, gpgme-config, "failed")
137 if test $GPGME_CONFIG != "failed" ; then
138 AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version)
139 req_major=`echo $min_gpgme_version | \
140 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
141 req_minor=`echo $min_gpgme_version | \
142 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
143 req_micro=`echo $min_gpgme_version | \
144 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
145 gpgme_config_version=`$GPGME_CONFIG --version`
146 major=`echo $gpgme_config_version | \
147 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
148 minor=`echo $gpgme_config_version | \
149 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
150 micro=`echo $gpgme_config_version | \
151 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
152
153 if test "$major" -eq "$req_major"; then
154 if test "$minor" -ge "$req_minor"; then
155 if test "$micro" -ge "$req_micro"; then
156 ok="yes"
157 fi
158 fi
159 fi
160 fi
161
162 if test $ok = "yes"; then
163 GPGME_CFLAGS=`$GPGME_CONFIG --cflags`
164 GPGME_LIBS=`$GPGME_CONFIG --libs`
165 AC_MSG_RESULT(yes)
166 AC_DEFINE(HAVE_GPGME, 1, [Define if you want GPG support])
167 else
168 AC_MSG_ERROR(GPGME $min_gpgme_version or later needed)
169 fi
170 fi
171
172 AC_SUBST(GPGME_CFLAGS)
173 AC_SUBST(GPGME_LIBS)
174
175
176 # Checks for header files
177 AC_HEADER_DIRENT
178 AC_HEADER_STDC
179 AC_HEADER_SYS_WAIT
180 AC_CHECK_HEADERS([errno.h fcntl.h memory.h regex.h stddef.h stdlib.h string.h strings.h unistd.h utime.h])
181
182 # Checks for typedefs, structures, and compiler characteristics.
183 AC_C_CONST
184 AC_TYPE_UID_T
185 AC_TYPE_MODE_T
186 AC_TYPE_OFF_T
187 AC_TYPE_PID_T
188 AC_TYPE_SIZE_T
189 AC_CHECK_MEMBERS([struct stat.st_rdev])
190
191 # Checks endianness
192 AC_C_BIGENDIAN(BIGENDIAN_CFLAGS="-DWORDS_BIGENDIAN=1",)
193 AC_SUBST(BIGENDIAN_CFLAGS)
194
195 # Don't do annoying tests that don't work when cross-compiling, just trust them.
196 # The AC_FUNC_MEMCMP test doesn't work during a cross-compile, disable.
197 # AC_FUNC_MEMCMP
198 # The AC_FUNC_STAT test doesn't work during a cross-compile, disable.
199 # AC_FUNC_STAT
200
201 # Checks for library functions
202 AC_FUNC_CHOWN
203 AC_FUNC_FORK
204 AC_TYPE_SIGNAL
205 AC_FUNC_UTIME_NULL
206 AC_FUNC_VPRINTF
207 AC_CHECK_FUNCS([memmove memset mkdir regcomp strchr strcspn strdup strerror strndup strrchr strstr strtol strtoul sysinfo utime])
208
209 opkglibdir=
210 AC_ARG_WITH(opkglibdir,
211 [ --with-opkglibdir=DIR specifies directory to put status and info files.
212 "/opkg" is always added so if you want your files
213 to be in /var/lib/opkg instead of /usr/lib/opkg
214 you should indicate
215 --with-opkglibdir=/var/lib ],
216 [case "${withval}" in
217 yes) AC_MSG_ERROR(bad value ${withval} given for opkg libs directories ) ;;
218 no) ;;
219 *) opkglibdir=$with_opkglibdir ;;
220 esac])
221
222 # Default local prefix if it is empty
223 if test x$opkglibdir = x; then
224 opkglibdir=/usr/lib
225 fi
226
227 opkgetcdir=
228 AC_ARG_WITH(opkgetcdir,
229 [ --with-opkgetcdir=DIR specifies directory for opkg.conf file,
230 "/opkg" is always added so if you want your files
231 to be in /usr/etc/opkg instead of /etc/opkg
232 you should indicate
233 --with-opkgetcdir=/usr/etc ],
234 [case "${withval}" in
235 yes) AC_MSG_ERROR(bad value ${withval} given for opkg.conf directory ) ;;
236 no) ;;
237 *) opkgetcdir=$with_opkgetcdir ;;
238 esac])
239
240 # Default local prefix if it is empty
241 if test x$opkgetcdir = x; then
242 opkgetcdir=/etc
243 fi
244
245 opkglockfile=
246 AC_ARG_WITH(opkglockfile,
247 [ --with-opkglockfile=FILE specifies the file used to make sure there is only
248 one instance of opkg runnning.
249 Defaults to ${opkglibdir}/opkg/lock, i.e.
250 /usr/lib/opkg/lock ],
251 [case "${withval}" in
252 yes) AC_MSG_ERROR(bad value ${withval} given for opkg lock file ) ;;
253 no) ;;
254 *) opkglockfile=$with_opkglockfile ;;
255 esac])
256
257 # Default if empty
258 if test x$opkglockfile = x; then
259 opkglockfile=${opkglibdir}/opkg/lock
260 fi
261
262 dnl Some special cases for the wow64 build
263 if test "x$want_gpgme" = "xyes"
264 then
265 if test "x$want_openssl" = "xyes"
266 then
267 AC_MSG_ERROR([--enable-gpg and --enable-openssl are mutually exclusive.
268 Use --disable-gpg if you want OpenSSL smime signatures])
269 fi
270 fi
271
272 CLEAN_DATE=`date +"%B %Y" | tr -d '\n'`
273
274 AC_SUBST(opkglibdir)
275 AC_SUBST(opkgetcdir)
276 AC_SUBST(opkglockfile)
277 AC_SUBST([CLEAN_DATE])
278
279 AC_OUTPUT(
280 Makefile
281 libopkg/Makefile
282 tests/Makefile
283 src/Makefile
284 libbb/Makefile
285 utils/Makefile
286 utils/update-alternatives
287 libopkg.pc
288 man/Makefile
289 man/opkg-cl.1
290 man/opkg-key.1
291 )