makepkg: improve srcdir check and add pkgdir
[pacman-ng.git] / configure.ac
blob2a6ab08cbc9d33a31839d44246413947e95715bb
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3 # Minimum version of autoconf required
4 AC_PREREQ(2.62)
6 # UPDATING VERSION NUMBERS FOR RELEASES
8 # libalpm:
9 # current
10 #   The most recent interface number that this library implements.
11 # revision
12 #   The implementation number of the current interface.
13 # age
14 #   The difference between the newest and oldest interfaces that this library
15 #   implements. In other words, the library implements all the interface
16 #   numbers in the range from number current - age to current.
18 # 1. Start with version information of `0:0:0' for each libtool library.
19 # 2. Update the version information only immediately before a public release of
20 #    your software. More frequent updates are unnecessary, and only guarantee
21 #    that the current interface number gets larger faster.
22 # 3. If the library source code has changed at all since the last update, then
23 #    increment revision (`c:r:a' becomes `c:r+1:a').
24 # 4. If any interfaces have been added, removed, or changed since the last
25 #    update, increment current, and set revision to 0.
26 # 5. If any interfaces have been added since the last public release, then
27 #    increment age.
28 # 6. If any interfaces have been removed since the last public release, then
29 #    set age to 0.
31 # pacman:
32 #   Extreme huge major changes:
33 #     pacman_version_major += 1
34 #     pacman_version_minor = 0
35 #     pacman_version_micro = 0
37 #   Real releases:
38 #     pacman_version_minor += 1
39 #     pacman_version_micro = 0
41 #   Bugfix releases:
42 #     pacman_version_micro += 1
44 m4_define([lib_current], [5])
45 m4_define([lib_revision], [1])
46 m4_define([lib_age], [0])
48 m4_define([pacman_version_major], [3])
49 m4_define([pacman_version_minor], [4])
50 m4_define([pacman_version_micro], [1])
51 m4_define([pacman_version],
52           [pacman_version_major.pacman_version_minor.pacman_version_micro])
54 # Autoconf initialization
55 AC_INIT([pacman], [pacman_version], [pacman-dev@archlinux.org])
56 AC_CONFIG_SRCDIR([config.h.in])
57 AC_CONFIG_HEADERS([config.h])
59 AC_CANONICAL_HOST
60 AM_INIT_AUTOMAKE
62 LIB_VERSION=`expr lib_current - lib_age`.lib_age.lib_revision
63 LIB_VERSION_INFO="lib_current:lib_revision:lib_age"
65 # Set subsitution values for version stuff in Makefiles and anywhere else,
66 # and put LIB_VERSION in config.h
67 AC_SUBST(LIB_VERSION)
68 AC_SUBST(LIB_VERSION_INFO)
69 AC_DEFINE_UNQUOTED([LIB_VERSION], ["$LIB_VERSION"], [libalpm version number])
71 # Help line for root directory
72 AC_ARG_WITH(root-dir,
73         AS_HELP_STRING([--with-root-dir=path], [set the location of the root operating directory]),
74         [ROOTDIR=$withval], [ROOTDIR=/])
76 # Help line for package extension
77 AC_ARG_WITH(pkg-ext,
78         AS_HELP_STRING([--with-pkg-ext=ext], [set the file extension used by packages]),
79         [PKGEXT=$withval], [PKGEXT=.pkg.tar.gz])
81 # Help line for source package directory
82 AC_ARG_WITH(src-ext,
83         AS_HELP_STRING([--with-src-ext=ext], [set the file extension used by source packages]),
84         [SRCEXT=$withval], [SRCEXT=.src.tar.gz])
86 # Help line for buildscript filename
87 AC_ARG_WITH(buildscript,
88         AS_HELP_STRING([--with-buildscript=name], [set the build script name used by makepkg]),
89         [BUILDSCRIPT=$withval], [BUILDSCRIPT=PKGBUILD])
91 # Help line for using OpenSSL
92 AC_ARG_WITH(openssl,
93         AS_HELP_STRING([--with-openssl], [use OpenSSL crypto implementations instead of internal routines]),
94         [], [with_openssl=check])
96 # Help line for libfetch
97 AC_ARG_WITH(fetch,
98         AS_HELP_STRING([--with-fetch], [use libfetch as an internal downloader]),
99         [], [with_fetch=check])
101 # Help line for documentation
102 AC_ARG_ENABLE(doc,
103         AS_HELP_STRING([--disable-doc], [prevent make from looking at doc/ dir]),
104         [wantdoc=$enableval], [wantdoc=yes])
106 # Help line for doxygen
107 AC_ARG_ENABLE(doxygen,
108         AS_HELP_STRING([--enable-doxygen], [build your own API docs via Doxygen]),
109         [wantdoxygen=$enableval], [wantdoxygen=no])
111 # Help line for debug
112 AC_ARG_ENABLE(debug,
113         AS_HELP_STRING([--enable-debug], [enable debugging support]),
114         [debug=$enableval], [debug=no])
116 # Help line for using git version in pacman version string
117 AC_ARG_ENABLE(git-version,
118         AS_HELP_STRING([--enable-git-version],
119                 [enable use of git version in version string if available]),
120         [wantgitver=$enableval], [wantgitver=no])
122 # Checks for programs.
123 AC_PROG_AWK
124 AC_PROG_CC_C99
125 AC_PROG_INSTALL
126 AC_PROG_LN_S
127 AC_PROG_MAKE_SET
128 AC_PROG_LIBTOOL
129 AC_CHECK_PROGS([PYTHON], [python2.6 python2.5 python], [false])
131 # find installed gettext
132 AM_GNU_GETTEXT([external])
133 AM_GNU_GETTEXT_VERSION(0.13.1)
135 # Check for libarchive
136 AC_CHECK_LIB([archive], [archive_read_data], ,
137         AC_MSG_ERROR([libarchive is needed to compile pacman!]))
139 # Check for OpenSSL
140 AC_MSG_CHECKING(whether to link with libssl)
141 AS_IF([test "x$with_openssl" != "xno"],
142         [AC_MSG_RESULT(yes)
143         AC_CHECK_LIB([ssl], [MD5_Final], ,
144         [if test "x$with_openssl" != "xcheck"; then
145                 AC_MSG_FAILURE([--with-openssl was given, but -lssl was not found])
146         fi],
147         [-lcrypto])],
148         AC_MSG_RESULT(no))
149 AM_CONDITIONAL([HAVE_LIBSSL], [test "x$ac_cv_lib_ssl_MD5_Final" = "xyes"])
151 # Enable or disable usage of libfetch
152 AC_MSG_CHECKING(whether to link with libfetch)
153 AS_IF([test "x$with_fetch" != "xno"],
154         [AC_MSG_RESULT(yes)
155         AC_CHECK_LIB([fetch], [fetchParseURL], ,
156         [if test "x$with_fetch" != "xcheck"; then
157                 AC_MSG_FAILURE([--with-fetch was given, but -lfetch was not found])
158         fi],
159         [-lcrypto -ldl])
160         # Check if libfetch supports connnection caching which we use
161         AC_CHECK_DECL(fetchConnectionCacheInit, ,
162                 AC_MSG_ERROR([libfetch must be version 2.28 or greater]),
163                 [#include <fetch.h>])
164         ],
165         AC_MSG_RESULT(no))
166 AM_CONDITIONAL([HAVE_LIBFETCH], [test "x$ac_cv_lib_fetch_fetchParseURL" = "xyes"])
168 # Checks for header files.
169 AC_CHECK_HEADERS([fcntl.h glob.h libintl.h limits.h locale.h string.h strings.h sys/ioctl.h sys/param.h sys/statvfs.h sys/syslimits.h sys/time.h syslog.h wchar.h])
171 # Checks for typedefs, structures, and compiler characteristics.
172 AC_C_INLINE
173 AC_TYPE_MODE_T
174 AC_TYPE_OFF_T
175 AC_TYPE_PID_T
176 AC_TYPE_SIZE_T
177 AC_STRUCT_TM
178 AC_TYPE_UID_T
180 # Checks for library functions.
181 AC_FUNC_FORK
182 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
183 AC_FUNC_MKTIME
184 AC_TYPE_SIGNAL
185 AC_CHECK_FUNCS([geteuid realpath regcomp strcasecmp \
186                 strndup strrchr strsep swprintf \
187                 wcwidth uname])
189 # Enable large file support if available
190 AC_SYS_LARGEFILE
192 # Check if we can use symbol visibility support in GCC
193 GCC_VISIBILITY_CC
194 # Check if we have -fgnu89-inline flag
195 GCC_GNU89_INLINE_CC
197 # Host-dependant definitions
198 SIZECMD="stat -L -c %s"
199 SEDINPLACE="sed -i"
200 STRIP_BINARIES="--strip-all"
201 STRIP_SHARED="--strip-unneeded"
202 STRIP_STATIC="--strip-debug"
203 case "${host_os}" in
204         *bsd*)
205                 SIZECMD="stat -L -f %z"
206                 SEDINPLACE="sed -i ''"
207                 ;;
208         cygwin*)
209                 host_os_cygwin=yes
210                 CFLAGS="$CFLAGS -DCYGWIN"
211                 ;;
212         darwin*)
213                 host_os_darwin=yes
214                 SIZECMD="/usr/bin/stat -L -f %z"
215                 SEDINPLACE="/usr/bin/sed -i ''"
216                 STRIP_BINARIES=""
217                 STRIP_SHARED="-S"
218                 STRIP_STATIC="-S"
219                 ;;
220 esac
222 AM_CONDITIONAL([CYGWIN], test "x$host_os_cygwin" = "xyes")
223 AM_CONDITIONAL([DARWIN], test "x$host_os_darwin" = "xyes")
224 AC_PATH_PROGS([DUPATH], [du], [du], [/usr/bin$PATH_SEPARATOR/bin] )
225 AC_SUBST(SIZECMD)
226 AC_SUBST(SEDINPLACE)
227 AC_SUBST(STRIP_BINARIES)
228 AC_SUBST(STRIP_SHARED)
229 AC_SUBST(STRIP_STATIC)
231 # Check for architecture, used in default makepkg.conf
232 # (Note single space left after CARCHFLAGS)
233 case "${host}" in
234         i686-*)
235                 CARCH="i686"
236                 CARCHFLAGS="-march=i686 "
237                 ;;
238         x86_64-*)
239                 CARCH="x86_64"
240                 CARCHFLAGS="-march=x86-64 "
241                 ;;
242         ia64-*)
243                 CARCH="ia64"
244                 CARCHFLAGS="-march=ia64 "
245                 ;;
246         sparc-*)
247                 CARCH="sparc"
248                 CARCHFLAGS="-mcpu=v9 "
249                 ;;
250         ppc-* | powerpc-*)
251                 CARCH="ppc"
252                 CARCHFLAGS="-mcpu=750 "
253                 ;;
254         i386-*)
255                 CARCH="i386"
256                 CARCHFLAGS="-march=i386 "
257                 ;;
258         arm-*)
259                 CARCH="arm"
260                 CARCHFLAGS="-march=armv4 "
261                 ;;
262         *)
263                 AC_MSG_WARN([[Your architecture is unknown for makepkg.conf, consider adding it to configure.ac]])
264                 CARCH="unknown"
265                 CARCHFLAGS=""
266                 ;;
267 esac
269 # Now do some things common to all architectures
270 CHOST="${host}"
271 AC_SUBST(CARCH)
272 AC_SUBST(CARCHFLAGS)
273 AC_SUBST(CHOST)
275 # Check for documentation support and status
276 AC_CHECK_PROGS([ASCIIDOC], [asciidoc])
277 AC_MSG_CHECKING([for building documentation])
278 if test "x$wantdoc" = "xyes" ; then
279         if test $ASCIIDOC ; then
280                 AC_MSG_RESULT([yes, enabled by configure])
281         else
282                 asciidoc="(warning : asciidoc not installed)"
283                 AC_MSG_RESULT([yes $asciidoc])
284         fi
285         wantdoc=yes
286 else
287         AC_MSG_RESULT([no, disabled by configure])
288         wantdoc=no
290 AM_CONDITIONAL(WANT_DOC, test "x$wantdoc" = "xyes")
292 # Check for doxygen support and status
293 AC_CHECK_PROGS([DOXYGEN], [doxygen])
294 AC_MSG_CHECKING([for doxygen])
295 if test "x$wantdoxygen" = "xyes" ; then
296         if test $DOXYGEN ; then
297                 AC_MSG_RESULT([yes])
298                 usedoxygen=yes
299         else
300                 AC_MSG_RESULT([no, doxygen missing])
301                 usedoxygen=no
302         fi
303 else
304         AC_MSG_RESULT([no, disabled by configure])
305         usedoxygen=no
307 AM_CONDITIONAL(USE_DOXYGEN, test "x$usedoxygen" = "xyes")
309 # Enable or disable debug code
310 AC_MSG_CHECKING(for debug mode request)
311 if test "x$debug" = "xyes" ; then
312         AC_MSG_RESULT(yes)
313         AC_DEFINE([PACMAN_DEBUG], , [Enable debug code])
314         # Check for mcheck
315         AC_CHECK_HEADERS([mcheck.h])
316         # Check for -fstack-protector availability
317         GCC_STACK_PROTECT_LIB
318         GCC_STACK_PROTECT_CC
319         GCC_FORTIFY_SOURCE_CC
320         CFLAGS="$CFLAGS -g -Wall -Werror"
321 else
322         AC_MSG_RESULT(no)
323         CFLAGS="$CFLAGS -Wall"
326 # Enable or disable use of git version in pacman version string
327 AC_MSG_CHECKING(whether to use git version if available)
328 if test "x$wantgitver" = "xyes" ; then
329         AC_CHECK_PROGS([GIT], [git])
330         AC_CHECK_FILE([.git/], hasgitdir=yes)
331         if test $GIT -a "x$hasgitdir" = "xyes"; then
332                 AC_MSG_RESULT([yes])
333                 usegitver=yes
334                 AC_DEFINE([USE_GIT_VERSION], , [Use GIT version in version string])
335         else
336                 AC_MSG_RESULT([no, git or .git dir missing])
337                 usegitver=no
338         fi
339 else
340         AC_MSG_RESULT([no, disabled by configure])
341         usegitver=no
343 AM_CONDITIONAL(USE_GIT_VERSION, test "x$usegitver" = "xyes")
345 # Set root directory
346 AC_SUBST(ROOTDIR)
347 # Set package file extension
348 AC_SUBST(PKGEXT)
349 AC_DEFINE_UNQUOTED([PKGEXT], "$PKGEXT", [The file extension used by pacman packages])
350 # Set source package file extension
351 AC_SUBST(SRCEXT)
352 AC_DEFINE_UNQUOTED([SRCEXT], "$SRCEXT", [The file extension used by pacman source packages])
353 # Set makepkg build script name
354 AC_SUBST(BUILDSCRIPT)
355 AC_DEFINE_UNQUOTED([BUILDSCRIPT], "$BUILDSCRIPT", [The build script name used by makepkg])
357 # Configuration files
358 AC_CONFIG_FILES([
359 lib/libalpm/Makefile
360 lib/libalpm/po/Makefile.in
361 src/pacman/Makefile
362 src/util/Makefile
363 scripts/Makefile
364 doc/Makefile
365 etc/Makefile
366 po/Makefile.in
367 test/pacman/Makefile
368 test/pacman/tests/Makefile
369 test/util/Makefile
370 contrib/Makefile
371 Makefile
373 AC_OUTPUT
375 echo "
376 ${PACKAGE_NAME}:
378   Build information:
379     source code location   : ${srcdir}
380     prefix                 : ${prefix}
381     sysconfdir             : $(eval echo ${sysconfdir})
382        conf file           : $(eval echo ${sysconfdir})/pacman.conf
383     localstatedir          : $(eval echo ${localstatedir})
384        database dir        : $(eval echo ${localstatedir})/lib/pacman/
385        cache dir           : $(eval echo ${localstatedir})/cache/pacman/pkg/
386     compiler               : ${CC}
387     compiler flags         : ${CFLAGS}
388     defines                : ${DEFS}
390     Architecture           : ${CARCH}
391     Architecture flags     : ${CARCHFLAGS}
392     Host Type              : ${CHOST}
393     Filesize command       : ${SIZECMD}
394     In-place sed command   : ${SEDINPLACE}
396     libalpm version        : ${LIB_VERSION}
397     libalpm version info   : ${LIB_VERSION_INFO}
398     pacman version         : ${PACKAGE_VERSION}
399     using git version      : ${usegitver}
401   Directory and file information:
402     root working directory : ${ROOTDIR}
403     package extension      : ${PKGEXT}
404     source pkg extension   : ${SRCEXT}
405     build script name      : ${BUILDSCRIPT}
407   Compilation options:
408     Run make in doc/ dir   : ${wantdoc} ${asciidoc}
409     Doxygen support        : ${usedoxygen}
410     debug support          : ${debug}
413 # vim:set ts=2 sw=2 noet: