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