2010-12-17 11:13:04 +01:00
|
|
|
# Process this file with autoconf to produce a configure script.
|
|
|
|
|
|
|
|
AC_PREREQ([2.67])
|
|
|
|
AC_INIT([libbsd], m4_esyscmd([./get-version]), [libbsd@lists.freedesktop.org])
|
2017-06-07 23:09:40 +02:00
|
|
|
AC_CONFIG_SRCDIR([src/strlcpy.c])
|
2010-12-17 11:13:04 +01:00
|
|
|
AC_CONFIG_AUX_DIR([build-aux])
|
|
|
|
AC_CONFIG_MACRO_DIR([m4])
|
|
|
|
|
2013-10-10 09:49:04 +02:00
|
|
|
AM_INIT_AUTOMAKE([1.9 foreign nostdinc subdir-objects no-dist-gzip dist-xz])
|
2010-12-17 11:13:04 +01:00
|
|
|
|
|
|
|
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
|
|
|
|
[AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
|
|
|
|
|
2013-07-12 22:15:58 +02:00
|
|
|
LIBBSD_ABI_MAJOR=0
|
2021-02-07 00:23:43 +01:00
|
|
|
LIBBSD_ABI_MINOR=11
|
2021-02-09 06:14:25 +01:00
|
|
|
LIBBSD_ABI_PATCH=3
|
2013-07-12 22:15:58 +02:00
|
|
|
|
|
|
|
LIBBSD_ABI="$LIBBSD_ABI_MAJOR:$LIBBSD_ABI_MINOR:$LIBBSD_ABI_PATCH"
|
|
|
|
AC_SUBST([LIBBSD_ABI])
|
|
|
|
|
2012-06-03 07:39:42 +02:00
|
|
|
# Check and store if we got user supplied variables
|
|
|
|
user_CFLAGS=${CFLAGS-unset}
|
|
|
|
|
2010-12-17 11:13:04 +01:00
|
|
|
# Checks for operating system services and capabilities.
|
|
|
|
AC_USE_SYSTEM_EXTENSIONS
|
|
|
|
AC_SYS_LARGEFILE
|
|
|
|
|
|
|
|
LT_INIT
|
|
|
|
|
2019-11-16 00:04:18 +01:00
|
|
|
AC_CACHE_CHECK([if ld supports --version-script flag],
|
|
|
|
[libbsd_cv_version_script], [
|
|
|
|
echo "{ global: symbol; local: *; };" >conftest.map
|
|
|
|
save_LDFLAGS=$LDFLAGS
|
|
|
|
LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
|
|
|
|
AC_LINK_IFELSE([
|
|
|
|
AC_LANG_PROGRAM([], [])
|
|
|
|
], [
|
|
|
|
libbsd_cv_version_script=yes
|
|
|
|
], [
|
|
|
|
libbsd_cv_version_script=no
|
|
|
|
])
|
|
|
|
LDFLAGS="$save_LDFLAGS"
|
|
|
|
rm -f conftest.map
|
|
|
|
]
|
|
|
|
)
|
|
|
|
AM_CONDITIONAL([HAVE_LINKER_VERSION_SCRIPT],
|
|
|
|
[test "x$libbsd_cv_version_script" = "xyes"])
|
|
|
|
|
2010-12-17 11:13:04 +01:00
|
|
|
# Checks for programs.
|
|
|
|
AC_PROG_CC
|
|
|
|
AC_PROG_INSTALL
|
|
|
|
AC_PROG_LN_S
|
|
|
|
|
2012-06-03 07:39:42 +02:00
|
|
|
# Set default compiler variables
|
2021-02-19 06:55:17 +01:00
|
|
|
AS_IF([test "$user_CFLAGS" = unset], [
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wall])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wextra])
|
|
|
|
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wbad-function-cast])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wc99-c11-compat])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wcast-align])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wdeclaration-after-statement])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wdocumentation])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wduplicated-branches])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wduplicated-cond])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wformat -Wformat-security])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wformat=2])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Winit-self])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wlogical-not-parentheses])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wlogical-op])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wmissing-declarations])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wmissing-format-attribute])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wmissing-prototypes])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wnested-externs])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wno-missing-field-initializers])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wno-nonnull-compare])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wno-tautological-constant-out-of-range-compare])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wno-unused-parameter])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wnull-dereference])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wold-style-definition])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wpointer-arith])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wregister])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wrestrict])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wshadow])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wshift-negative-value])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wsizeof-array-argument])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wstrict-prototypes])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wswitch-bool])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wvla])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-Wwrite-strings])
|
|
|
|
|
|
|
|
CFLAGS="$CFLAGS $LIBBSD_COMPILER_FLAGS"
|
|
|
|
])
|
2012-06-03 07:39:42 +02:00
|
|
|
|
2010-12-17 11:13:04 +01:00
|
|
|
# Checks for libraries.
|
2015-11-16 01:12:24 +01:00
|
|
|
AC_CHECK_LIB([testu01], [unif01_CreateExternGenBits],
|
|
|
|
[TESTU01_LIBS="-ltestu01"])
|
|
|
|
AC_SUBST([TESTU01_LIBS])
|
|
|
|
AM_CONDITIONAL([HAVE_LIBTESTU01],
|
|
|
|
[test "x$ac_cv_lib_testu01_unif01_CreateExternGenBits" = "xyes"])
|
2010-12-17 11:13:04 +01:00
|
|
|
|
2021-02-07 00:09:30 +01:00
|
|
|
saved_LIBS="$LIBS"
|
2021-02-09 05:57:37 +01:00
|
|
|
AC_SEARCH_LIBS([dlsym], [dl], [
|
|
|
|
AS_IF([test "x$ac_cv_search_dlsym" != "xnone required"], [
|
|
|
|
LIBBSD_LIBS="$LIBBSD_LIBS $ac_cv_search_dlsym"
|
|
|
|
])
|
|
|
|
], [
|
|
|
|
AC_MSG_ERROR([cannot find required dlsym function])
|
|
|
|
])
|
2021-02-07 00:09:30 +01:00
|
|
|
AC_SEARCH_LIBS([MD5Update], [md], [
|
2021-02-09 06:02:46 +01:00
|
|
|
AS_IF([test "x$ac_cv_search_MD5Update" != "xnone required"], [
|
2021-02-09 06:04:38 +01:00
|
|
|
LIBBSD_LIBS="$LIBBSD_LIBS $ac_cv_search_MD5Update"
|
2021-02-07 00:09:30 +01:00
|
|
|
])
|
|
|
|
], [
|
2021-02-09 06:02:46 +01:00
|
|
|
AC_MSG_ERROR([cannot find required MD5 functions in libc or libmd])
|
|
|
|
])
|
|
|
|
AC_SEARCH_LIBS([SHA512Update], [md], [
|
|
|
|
AS_IF([test "x$ac_cv_search_SHA512Update" != "xnone required"], [
|
2021-02-09 06:04:38 +01:00
|
|
|
LIBBSD_LIBS="$LIBBSD_LIBS $ac_cv_search_SHA512Update"
|
2021-02-09 06:02:46 +01:00
|
|
|
])
|
|
|
|
], [
|
|
|
|
AC_MSG_ERROR([cannot find required SHA-2 functions in libc or libmd])
|
2021-02-07 00:09:30 +01:00
|
|
|
])
|
|
|
|
LIBS="$saved_LIBS"
|
|
|
|
|
2018-06-14 20:38:32 +02:00
|
|
|
is_windows=no
|
2016-02-12 22:56:09 +01:00
|
|
|
AS_CASE([$host_os],
|
2017-06-09 05:14:24 +02:00
|
|
|
[*-gnu*], [
|
2017-06-09 04:52:45 +02:00
|
|
|
# In old glibc versions (< 2.17) clock_gettime() is in librt.
|
2016-02-12 22:56:09 +01:00
|
|
|
saved_LIBS="$LIBS"
|
2019-08-06 23:11:50 +02:00
|
|
|
AC_SEARCH_LIBS([clock_gettime], [rt], [
|
|
|
|
AS_IF([test "x$ac_cv_search_clock_gettime" != "xnone required"], [
|
2021-02-09 06:04:38 +01:00
|
|
|
LIBBSD_LIBS="$LIBBSD_LIBS $ac_cv_search_clock_gettime"
|
2019-08-06 23:11:50 +02:00
|
|
|
])
|
|
|
|
])
|
2016-02-12 22:56:09 +01:00
|
|
|
LIBS="$saved_LIBS"
|
2017-01-10 04:33:15 +01:00
|
|
|
],
|
2017-06-09 05:14:24 +02:00
|
|
|
[*-musl*], [
|
2017-01-10 04:33:15 +01:00
|
|
|
# Upstream refuses to define this, we will do it ourselves then.
|
|
|
|
AC_DEFINE([__MUSL__], [1], [Define to 1 if we are building for musl])
|
|
|
|
],
|
2018-06-14 20:38:32 +02:00
|
|
|
[mingw*], [
|
|
|
|
is_windows=yes
|
|
|
|
],
|
2016-02-12 22:56:09 +01:00
|
|
|
)
|
2018-06-14 20:38:32 +02:00
|
|
|
AM_CONDITIONAL([OS_WINDOWS], [test "x$is_windows" = "xyes"])
|
2016-02-12 22:56:09 +01:00
|
|
|
|
2010-12-17 11:13:04 +01:00
|
|
|
# Checks for header files.
|
2021-02-06 23:43:12 +01:00
|
|
|
AC_CHECK_HEADERS([sys/ndir.h sys/dir.h ndir.h dirent.h pwd.h grp.h])
|
2010-12-17 11:13:04 +01:00
|
|
|
|
|
|
|
# Checks for typedefs, structures, and compiler characteristics.
|
|
|
|
AC_C_INLINE
|
2013-05-25 17:11:53 +02:00
|
|
|
AC_C_TYPEOF
|
2010-12-17 11:13:04 +01:00
|
|
|
AC_TYPE_INT64_T
|
|
|
|
AC_TYPE_MODE_T
|
|
|
|
AC_TYPE_OFF_T
|
|
|
|
AC_TYPE_PID_T
|
2017-06-09 04:52:45 +02:00
|
|
|
AC_TYPE_UID_T
|
2010-12-17 11:13:04 +01:00
|
|
|
AC_TYPE_SIZE_T
|
|
|
|
AC_TYPE_SSIZE_T
|
|
|
|
|
2011-12-31 08:39:44 +01:00
|
|
|
AC_CHECK_DECL([F_CLOSEM],
|
|
|
|
[AC_DEFINE([HAVE_FCNTL_CLOSEM], [1],
|
|
|
|
[Define to 1 if you have fcntl(F_CLOSEM)])],
|
|
|
|
[],
|
|
|
|
[#include <limits.h>
|
|
|
|
#include <fcntl.h>])
|
|
|
|
|
2013-05-29 02:23:56 +02:00
|
|
|
AC_CACHE_CHECK(
|
|
|
|
[for GNU .init_array section support],
|
|
|
|
[libbsd_cv_gnu_init_array_support],
|
|
|
|
[AC_RUN_IFELSE(
|
|
|
|
[AC_LANG_SOURCE(
|
|
|
|
[[
|
|
|
|
static int rc = 1;
|
|
|
|
static void init(int argc) { if (argc == 1) rc = 0; }
|
2018-06-18 00:36:44 +02:00
|
|
|
void (*init_func)(int argc) __attribute__((__section__(".init_array"))) = init;
|
2013-05-29 02:23:56 +02:00
|
|
|
int main() { return rc; }
|
|
|
|
]]
|
|
|
|
)],
|
|
|
|
[libbsd_cv_gnu_init_array_support=yes],
|
|
|
|
[libbsd_cv_gnu_init_array_support=no],
|
|
|
|
[AC_PREPROC_IFELSE(
|
|
|
|
[AC_LANG_SOURCE(
|
|
|
|
[[
|
|
|
|
/* Look for a known libc that supports .init_array with the GNU extension
|
|
|
|
* to pass main() arguments to the init functions. */
|
|
|
|
#include <stdlib.h>
|
|
|
|
#if defined __GLIBC_PREREQ
|
|
|
|
# if __GLIBC_PREREQ(2, 4)
|
|
|
|
/* glibc supports GNU .init_array since 2.4. */
|
|
|
|
# else
|
|
|
|
# error glibc does not support GNU .init_array
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
/*
|
|
|
|
* Basic SysV ABI .init_array support, init functions do not get arguments:
|
|
|
|
* - Bionic since its inception.
|
|
|
|
* - uClibc since 0.9.29.
|
|
|
|
*/
|
|
|
|
# error unknown whether libc supports GNU .init_array
|
|
|
|
#endif
|
|
|
|
]]
|
|
|
|
)],
|
|
|
|
[libbsd_cv_gnu_init_array_support=yes],
|
|
|
|
[libbsd_cv_gnu_init_array_support=no])
|
|
|
|
]
|
|
|
|
)]
|
|
|
|
)
|
2014-07-20 01:48:20 +02:00
|
|
|
AM_CONDITIONAL([BUILD_LIBBSD_CTOR],
|
|
|
|
[test "$libbsd_cv_gnu_init_array_support" = yes])
|
2013-05-29 02:23:56 +02:00
|
|
|
|
2010-12-17 11:13:04 +01:00
|
|
|
# Checks for library functions.
|
2012-01-03 08:58:01 +01:00
|
|
|
AC_MSG_CHECKING([for program_invocation_short_name])
|
|
|
|
AC_LINK_IFELSE(
|
|
|
|
[AC_LANG_PROGRAM([[#include <errno.h>]],
|
|
|
|
[[const char *p = program_invocation_short_name;]])],
|
|
|
|
[AC_DEFINE([HAVE_PROGRAM_INVOCATION_SHORT_NAME], [1],
|
|
|
|
[Define to 1 if you have program_invocation_short_name])
|
|
|
|
AC_MSG_RESULT([yes])],
|
|
|
|
[AC_MSG_RESULT([no])])
|
|
|
|
|
2011-07-06 16:29:26 +02:00
|
|
|
AC_MSG_CHECKING([for __progname])
|
|
|
|
AC_LINK_IFELSE(
|
2016-08-28 17:13:20 +02:00
|
|
|
[AC_LANG_PROGRAM([[extern char *__progname;]],
|
|
|
|
[[printf("%s", __progname);]])],
|
2011-07-06 16:29:26 +02:00
|
|
|
[AC_DEFINE([HAVE___PROGNAME], [1], [Define to 1 if you have __progname])
|
|
|
|
AC_MSG_RESULT([yes])],
|
|
|
|
[AC_MSG_RESULT([no])])
|
|
|
|
|
2019-08-06 23:16:42 +02:00
|
|
|
AC_MSG_CHECKING([for __register_atfork])
|
|
|
|
AC_LINK_IFELSE(
|
|
|
|
[AC_LANG_PROGRAM([[
|
|
|
|
#include <stddef.h>
|
|
|
|
extern void *__dso_handle;
|
|
|
|
extern int __register_atfork(void (*)(void), void(*)(void), void (*)(void), void *);
|
|
|
|
]], [[
|
|
|
|
__register_atfork(NULL, NULL, NULL, __dso_handle);
|
|
|
|
]])],
|
|
|
|
[AC_DEFINE([HAVE___REGISTER_ATFORK], [1],
|
|
|
|
[Define to 1 if you have __register_atfork])
|
|
|
|
AC_MSG_RESULT([yes])],
|
2021-02-09 06:04:38 +01:00
|
|
|
[LIBBSD_LIBS="$LIBBSD_LIBS -pthread"
|
2019-08-06 23:16:42 +02:00
|
|
|
AC_MSG_RESULT([no])
|
|
|
|
])
|
|
|
|
|
2015-09-23 19:39:47 +02:00
|
|
|
AC_CHECK_FUNCS([clearenv dirfd fopencookie __fpurge \
|
2015-09-23 19:39:47 +02:00
|
|
|
getauxval getentropy getexecname getline \
|
2014-11-02 00:23:00 +01:00
|
|
|
pstat_getproc sysconf])
|
2017-06-09 04:52:45 +02:00
|
|
|
AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xtrue"])
|
2010-12-17 11:13:04 +01:00
|
|
|
|
2021-02-09 06:04:38 +01:00
|
|
|
AC_SUBST([LIBBSD_LIBS])
|
|
|
|
|
2010-12-17 11:13:04 +01:00
|
|
|
AC_CONFIG_FILES([
|
|
|
|
Makefile
|
|
|
|
include/Makefile
|
|
|
|
man/Makefile
|
|
|
|
src/Makefile
|
|
|
|
src/libbsd.pc
|
2013-07-11 12:25:54 +02:00
|
|
|
src/libbsd-ctor.pc
|
2010-12-17 11:13:04 +01:00
|
|
|
src/libbsd-overlay.pc
|
2012-03-23 10:43:33 +01:00
|
|
|
test/Makefile
|
2010-12-17 11:13:04 +01:00
|
|
|
])
|
|
|
|
AC_CONFIG_HEADERS([config.h])
|
|
|
|
AC_OUTPUT
|