2019-03-14 17:28:10 +02:00
|
|
|
AC_INIT(nix-perl, m4_esyscmd([bash -c "echo -n $(cat ../.version)$VERSION_SUFFIX"]))
|
2016-08-12 16:44:01 +03:00
|
|
|
AC_CONFIG_SRCDIR(MANIFEST)
|
|
|
|
AC_CONFIG_AUX_DIR(../config)
|
|
|
|
|
2019-11-06 17:55:37 +02:00
|
|
|
CFLAGS=
|
|
|
|
CXXFLAGS=
|
2016-08-12 16:44:01 +03:00
|
|
|
AC_PROG_CC
|
|
|
|
AC_PROG_CXX
|
|
|
|
|
Apply OS checks to host platform, not build
Previously, the build system used uname(1) output when it wanted to
check the operating system it was being built for, which meant that it
didn't take into-account cross-compilation when the build and host
operating systems were different.
To fix this, instead of consulting uname output, we consult the host
triple, specifically the third "kernel" part.
For "kernel"s with stable ABIs, like Linux or Cygwin, we can use a
simple ifeq to test whether we're compiling for that system, but for
other platforms, like Darwin, FreeBSD, or Solaris, we have to use a
more complicated check to take into account the version numbers at the
end of the "kernel"s. I couldn't find a way to just strip these
version numbers in GNU Make without shelling out, which would be even
more ugly IMO. Because these checks differ between kernels, and the
patsubst ones are quite fiddly, I've added variables for each host OS
we might want to check to make them easier to reuse.
2021-06-01 10:58:21 +03:00
|
|
|
AC_CANONICAL_HOST
|
|
|
|
|
2016-08-12 16:44:01 +03:00
|
|
|
# Use 64-bit file system calls so that we can support files > 2 GiB.
|
|
|
|
AC_SYS_LARGEFILE
|
|
|
|
|
|
|
|
AC_DEFUN([NEED_PROG],
|
|
|
|
[
|
|
|
|
AC_PATH_PROG($1, $2)
|
|
|
|
if test -z "$$1"; then
|
|
|
|
AC_MSG_ERROR([$2 is required])
|
|
|
|
fi
|
|
|
|
])
|
|
|
|
|
|
|
|
NEED_PROG(perl, perl)
|
|
|
|
NEED_PROG(curl, curl)
|
|
|
|
NEED_PROG(bzip2, bzip2)
|
|
|
|
NEED_PROG(xz, xz)
|
|
|
|
|
|
|
|
# Test that Perl has the open/fork feature (Perl 5.8.0 and beyond).
|
|
|
|
AC_MSG_CHECKING([whether Perl is recent enough])
|
|
|
|
if ! $perl -e 'open(FOO, "-|", "true"); while (<FOO>) { print; }; close FOO or die;'; then
|
|
|
|
AC_MSG_RESULT(no)
|
|
|
|
AC_MSG_ERROR([Your Perl version is too old. Nix requires Perl 5.8.0 or newer.])
|
|
|
|
fi
|
|
|
|
AC_MSG_RESULT(yes)
|
|
|
|
|
|
|
|
|
|
|
|
# Figure out where to install Perl modules.
|
|
|
|
AC_MSG_CHECKING([for the Perl installation prefix])
|
|
|
|
perlversion=$($perl -e 'use Config; print $Config{version};')
|
|
|
|
perlarchname=$($perl -e 'use Config; print $Config{archname};')
|
|
|
|
AC_SUBST(perllibdir, [${libdir}/perl5/site_perl/$perlversion/$perlarchname])
|
|
|
|
AC_MSG_RESULT($perllibdir)
|
|
|
|
|
2021-11-28 00:02:04 +02:00
|
|
|
# Look for libsodium.
|
2021-01-06 18:56:53 +02:00
|
|
|
PKG_CHECK_MODULES([SODIUM], [libsodium], [CXXFLAGS="$SODIUM_CFLAGS $CXXFLAGS"])
|
2016-08-12 16:44:01 +03:00
|
|
|
|
2017-04-11 16:41:21 +03:00
|
|
|
# Check for the required Perl dependencies (DBI and DBD::SQLite).
|
2016-08-12 16:44:01 +03:00
|
|
|
perlFlags="-I$perllibdir"
|
|
|
|
|
|
|
|
AC_ARG_WITH(dbi, AC_HELP_STRING([--with-dbi=PATH],
|
|
|
|
[prefix of the Perl DBI library]),
|
|
|
|
perlFlags="$perlFlags -I$withval")
|
|
|
|
|
|
|
|
AC_ARG_WITH(dbd-sqlite, AC_HELP_STRING([--with-dbd-sqlite=PATH],
|
|
|
|
[prefix of the Perl DBD::SQLite library]),
|
|
|
|
perlFlags="$perlFlags -I$withval")
|
|
|
|
|
|
|
|
AC_MSG_CHECKING([whether DBD::SQLite works])
|
|
|
|
if ! $perl $perlFlags -e 'use DBI; use DBD::SQLite;' 2>&5; then
|
|
|
|
AC_MSG_RESULT(no)
|
|
|
|
AC_MSG_FAILURE([The Perl modules DBI and/or DBD::SQLite are missing.])
|
|
|
|
fi
|
|
|
|
AC_MSG_RESULT(yes)
|
|
|
|
|
|
|
|
AC_SUBST(perlFlags)
|
|
|
|
|
|
|
|
PKG_CHECK_MODULES([NIX], [nix-store])
|
|
|
|
|
2019-11-07 13:18:37 +02:00
|
|
|
NEED_PROG([NIX], [nix])
|
2016-08-12 16:44:01 +03:00
|
|
|
|
|
|
|
# Expand all variables in config.status.
|
|
|
|
test "$prefix" = NONE && prefix=$ac_default_prefix
|
|
|
|
test "$exec_prefix" = NONE && exec_prefix='${prefix}'
|
|
|
|
for name in $ac_subst_vars; do
|
|
|
|
declare $name="$(eval echo "${!name}")"
|
|
|
|
declare $name="$(eval echo "${!name}")"
|
|
|
|
declare $name="$(eval echo "${!name}")"
|
|
|
|
done
|
|
|
|
|
|
|
|
rm -f Makefile.config
|
2017-04-26 18:04:45 +03:00
|
|
|
ln -sfn ../mk mk
|
2016-08-12 16:44:01 +03:00
|
|
|
|
|
|
|
AC_CONFIG_FILES([])
|
|
|
|
AC_OUTPUT
|