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