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])
|
|
|
|
|
2022-12-13 03:31:38 +01:00
|
|
|
AM_INIT_AUTOMAKE(
|
|
|
|
[1.11]
|
2022-12-13 03:35:05 +01:00
|
|
|
[-Wall]
|
2022-12-13 03:31:38 +01:00
|
|
|
[foreign]
|
|
|
|
[nostdinc]
|
|
|
|
[subdir-objects]
|
|
|
|
[no-dist-gzip dist-xz]
|
|
|
|
)
|
2022-12-13 03:10:28 +01:00
|
|
|
AM_SILENT_RULES([yes])
|
2010-12-17 11:13:04 +01:00
|
|
|
|
2024-02-21 02:05:57 +01:00
|
|
|
SOVERSION_MAJOR=0
|
|
|
|
SOVERSION_MINOR=11
|
|
|
|
SOVERSION_PATCH=8
|
2013-07-12 22:15:58 +02:00
|
|
|
|
2024-02-21 02:05:57 +01:00
|
|
|
SOVERSION="$SOVERSION_MAJOR:$SOVERSION_MINOR:$SOVERSION_PATCH"
|
|
|
|
AC_SUBST([SOVERSION])
|
2013-07-12 22:15:58 +02:00
|
|
|
|
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
|
|
|
|
|
2022-12-13 03:34:37 +01:00
|
|
|
AM_PROG_AR
|
2010-12-17 11:13:04 +01:00
|
|
|
LT_INIT
|
2023-05-26 23:50:10 +02:00
|
|
|
LIBBSD_LINKER_VERSION_SCRIPT
|
2019-11-16 00:04:18 +01:00
|
|
|
|
2024-02-20 04:13:59 +01:00
|
|
|
## Select library ABI to expose.
|
|
|
|
|
2023-04-07 23:43:55 +02:00
|
|
|
is_windows=no
|
2024-02-20 04:13:59 +01:00
|
|
|
|
|
|
|
need_arc4random=yes
|
|
|
|
need_bsd_getopt=yes
|
|
|
|
need_err=yes
|
|
|
|
need_errc=yes
|
|
|
|
need_fpurge=yes
|
|
|
|
need_funopen=yes
|
2024-02-21 02:29:15 +01:00
|
|
|
need_md5=yes
|
2024-02-20 04:13:59 +01:00
|
|
|
need_name_from_id=yes
|
|
|
|
need_nlist=yes
|
|
|
|
need_progname=yes
|
|
|
|
need_strl=yes
|
|
|
|
need_strmode=yes
|
|
|
|
need_wcsl=yes
|
|
|
|
|
2023-04-07 23:43:55 +02:00
|
|
|
AS_CASE([$host_os],
|
2024-02-20 04:13:59 +01:00
|
|
|
[*-gnu*], [
|
|
|
|
# On glibc >= 2.38, strlcpy() and strlcat() got added,
|
|
|
|
# so these could then be dropped on the next SOVERSION bump.
|
|
|
|
#need_strl=no
|
|
|
|
need_err=no
|
|
|
|
],
|
|
|
|
[*-musl*], [
|
|
|
|
# On musl >= 0.9.7, optreset got implemented, so bsd_getopt() can then
|
|
|
|
# be dropped on the next SOVERSION bump.
|
|
|
|
#need_bsd_getopt=no
|
|
|
|
need_err=no
|
|
|
|
# On musl >= 1.1.19, fopencookie() got implemented, and because we were
|
|
|
|
# checking for its presence to decide whether to build funopen(), it got
|
|
|
|
# included in builds even when previously it had not been included, which
|
|
|
|
# is partially an ABI issue, but given that disabling it now would be
|
|
|
|
# worse, we'll ignore this as this is only a problem with downgrades. And
|
|
|
|
# enable it explicitly
|
|
|
|
need_funopen=yes
|
|
|
|
# On musl >= 0.5.0, strlcpy() and strlcat() were already implemented,
|
|
|
|
# so these can then be dropped on the next SOVERSION bump.
|
|
|
|
#need_strl=no
|
|
|
|
],
|
|
|
|
[darwin*], [
|
|
|
|
# On macOS these are provided by the system, and libbsd has never built
|
|
|
|
# there, so we can avoid providing these with no ABI breakage.
|
|
|
|
need_arc4random=no
|
|
|
|
need_bsd_getopt=no
|
|
|
|
need_err=no
|
|
|
|
need_errc=no
|
|
|
|
need_fpurge=no
|
|
|
|
# On macOS we do not have fopencookie(), and cannot implement it.
|
|
|
|
need_funopen=no
|
|
|
|
need_md5=no
|
|
|
|
need_name_from_id=no
|
|
|
|
need_nlist=no
|
|
|
|
need_progname=no
|
|
|
|
need_strl=no
|
|
|
|
need_strmode=no
|
|
|
|
need_transparent_libmd=no
|
|
|
|
need_wcsl=no
|
|
|
|
],
|
2023-04-07 23:43:55 +02:00
|
|
|
[mingw*], [
|
|
|
|
is_windows=yes
|
|
|
|
],
|
|
|
|
)
|
2024-02-20 04:13:59 +01:00
|
|
|
|
2023-04-07 23:43:55 +02:00
|
|
|
AM_CONDITIONAL([OS_WINDOWS], [test "x$is_windows" = "xyes"])
|
|
|
|
|
2010-12-17 11:13:04 +01:00
|
|
|
# Checks for programs.
|
2022-01-23 18:54:33 +01:00
|
|
|
AC_CHECK_TOOL([OBJDUMP], [objdump])
|
2010-12-17 11:13:04 +01:00
|
|
|
AC_PROG_CC
|
2021-08-17 02:59:59 +02:00
|
|
|
AC_PROG_SED
|
2010-12-17 11:13:04 +01:00
|
|
|
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"
|
2021-02-20 22:23:40 +01:00
|
|
|
|
|
|
|
AC_ARG_ENABLE([sanitize],
|
|
|
|
[AS_HELP_STRING([--enable-sanitize], [enable compiler sanitizer support])],
|
|
|
|
[
|
|
|
|
LIBBSD_COMPILER_FLAGS=''
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-fsanitize=address])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-fsanitize=leak])
|
|
|
|
LIBBSD_CHECK_COMPILER_FLAG([-fsanitize=undefined])
|
|
|
|
|
|
|
|
CFLAGS="$CFLAGS $LIBBSD_COMPILER_FLAGS"
|
|
|
|
LDFLAGS="$LDFLAGS $LIBBSD_COMPILER_FLAGS"
|
|
|
|
])
|
2021-02-19 06:55:17 +01:00
|
|
|
])
|
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],
|
2022-12-13 03:31:38 +01:00
|
|
|
[TESTU01_LIBS="-ltestu01"])
|
2015-11-16 01:12:24 +01:00
|
|
|
AC_SUBST([TESTU01_LIBS])
|
|
|
|
AM_CONDITIONAL([HAVE_LIBTESTU01],
|
2022-12-13 03:31:38 +01:00
|
|
|
[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"
|
2024-02-20 04:28:01 +01:00
|
|
|
AS_IF([test "$need_md5" = "yes"], [
|
|
|
|
AC_SEARCH_LIBS([MD5Update], [md], [
|
|
|
|
AS_IF([test "x$ac_cv_search_MD5Update" != "xnone required"], [
|
|
|
|
MD5_LIBS="$MD5_LIBS $ac_cv_search_MD5Update"
|
|
|
|
need_transparent_libmd=yes
|
|
|
|
])
|
|
|
|
], [
|
|
|
|
AC_MSG_ERROR([cannot find required MD5 functions in libc or libmd])
|
2021-02-07 00:09:30 +01:00
|
|
|
])
|
2021-02-09 06:02:46 +01:00
|
|
|
])
|
2024-02-20 04:28:01 +01:00
|
|
|
AS_IF([test "$need_arc4random" = "yes"], [
|
|
|
|
AC_CHECK_FUNCS([getentropy])
|
|
|
|
|
|
|
|
AS_IF([test "$ac_cv_func_getentropy" != "yes"], [
|
|
|
|
AC_SEARCH_LIBS([SHA512Update], [md], [
|
|
|
|
AS_IF([test "x$ac_cv_search_SHA512Update" != "xnone required"], [
|
|
|
|
LIBBSD_LIBS="$SHA512_LIBS $ac_cv_search_SHA512Update"
|
|
|
|
])
|
|
|
|
], [
|
|
|
|
AC_MSG_ERROR([cannot find required SHA-2 functions in libc or libmd])
|
|
|
|
])
|
2021-02-09 06:02:46 +01:00
|
|
|
])
|
2021-02-07 00:09:30 +01:00
|
|
|
])
|
|
|
|
LIBS="$saved_LIBS"
|
|
|
|
|
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
|
|
|
],
|
2023-04-18 03:56:16 +02:00
|
|
|
[aix*], [
|
|
|
|
saved_LIBS="$LIBS"
|
|
|
|
AC_SEARCH_LIBS([perfstat_cpu_total], [perfstat], [
|
|
|
|
AS_IF([test "x$ac_cv_search_perfstat_cpu_total" != "xnone required"], [
|
|
|
|
LIBBSD_LIBS="$LIBBSD_LIBS $ac_cv_search_perfstat_cpu_total"
|
|
|
|
])
|
|
|
|
])
|
|
|
|
LIBS="$saved_LIBS"
|
|
|
|
],
|
2016-02-12 22:56:09 +01:00
|
|
|
)
|
|
|
|
|
2010-12-17 11:13:04 +01:00
|
|
|
# Checks for header files.
|
2022-12-13 03:31:38 +01:00
|
|
|
AC_CHECK_HEADERS([\
|
|
|
|
sys/ndir.h \
|
|
|
|
sys/dir.h \
|
|
|
|
ndir.h \
|
|
|
|
dirent.h \
|
|
|
|
pwd.h \
|
|
|
|
grp.h \
|
2023-04-01 12:46:49 +02:00
|
|
|
stdio_ext.h \
|
2023-04-22 20:23:08 +02:00
|
|
|
procinfo.h \
|
2022-12-13 03:31:38 +01:00
|
|
|
])
|
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
|
|
|
|
|
2022-12-13 03:31:38 +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>
|
|
|
|
]])
|
2011-12-31 08:39:44 +01:00
|
|
|
|
2023-04-01 12:41:42 +02:00
|
|
|
AC_CHECK_DECLS([environ], [], [], [[
|
|
|
|
#include <unistd.h>
|
|
|
|
]])
|
|
|
|
|
2023-05-26 23:55:40 +02:00
|
|
|
LIBBSD_HAS_GNU_INIT_ARRAY
|
2013-05-29 02:23:56 +02:00
|
|
|
|
2010-12-17 11:13:04 +01:00
|
|
|
# Checks for library functions.
|
2024-02-20 04:40:32 +01:00
|
|
|
LIBBSD_CHECK_PROGNAME
|
|
|
|
LIBBSD_CHECK_REGISTER_ATFORK
|
2019-08-06 23:16:42 +02:00
|
|
|
|
2022-12-13 03:31:38 +01:00
|
|
|
AC_CHECK_FUNCS([\
|
|
|
|
clearenv \
|
|
|
|
dirfd \
|
2023-04-10 23:10:40 +02:00
|
|
|
flock \
|
2022-12-13 03:31:38 +01:00
|
|
|
fopencookie \
|
|
|
|
__fpurge \
|
2023-04-06 23:05:27 +02:00
|
|
|
funopen \
|
2022-12-13 03:31:38 +01:00
|
|
|
getauxval \
|
|
|
|
getentropy \
|
|
|
|
getexecname \
|
|
|
|
getline \
|
2023-04-10 23:11:33 +02:00
|
|
|
open_memstream \
|
2022-12-13 03:31:38 +01:00
|
|
|
pstat_getproc \
|
|
|
|
sysconf \
|
2023-04-04 23:59:05 +02:00
|
|
|
uid_from_user \
|
|
|
|
gid_from_group \
|
|
|
|
user_from_uid \
|
|
|
|
group_from_gid \
|
2022-12-13 03:31:38 +01:00
|
|
|
])
|
2023-04-06 23:05:27 +02:00
|
|
|
|
2022-11-23 23:42:49 +01:00
|
|
|
AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xyes"])
|
2023-04-04 23:59:05 +02:00
|
|
|
|
|
|
|
AM_CONDITIONAL([NEED_ARC4RANDOM], [test "x$need_arc4random" = "xyes"])
|
2023-04-18 03:58:24 +02:00
|
|
|
AM_CONDITIONAL([NEED_BSD_GETOPT], [test "x$need_bsd_getopt" = "xyes"])
|
2024-02-17 05:25:01 +01:00
|
|
|
AM_CONDITIONAL([NEED_ERR], [test "x$need_err" = "xyes"])
|
|
|
|
AM_CONDITIONAL([NEED_ERRC], [test "x$need_errc" = "xyes"])
|
2023-04-22 22:47:10 +02:00
|
|
|
AM_CONDITIONAL([NEED_PROGNAME], [test "x$need_progname" = "xyes"])
|
2023-04-04 23:59:05 +02:00
|
|
|
AM_CONDITIONAL([NEED_TRANSPARENT_LIBMD], [test "x$need_transparent_libmd" = "xyes"])
|
|
|
|
AM_CONDITIONAL([NEED_MD5], [test "x$need_md5" = "xyes"])
|
|
|
|
AM_CONDITIONAL([NEED_NLIST], [test "x$need_nlist" = "xyes"])
|
|
|
|
AM_CONDITIONAL([NEED_STRL], [test "x$need_strl" = "xyes"])
|
2023-04-23 02:05:04 +02:00
|
|
|
AM_CONDITIONAL([NEED_WCSL], [test "x$need_wcsl" = "xyes"])
|
2023-04-04 23:59:05 +02:00
|
|
|
AM_CONDITIONAL([NEED_STRMODE], [test "x$need_strmode" = "xyes"])
|
2024-02-12 00:06:56 +01:00
|
|
|
AM_CONDITIONAL([NEED_NAME_FROM_ID], [test "x$need_name_from_id" = "xyes"])
|
2023-04-04 23:59:05 +02:00
|
|
|
AM_CONDITIONAL([NEED_FPURGE], [test "x$need_fpurge" = "xyes"])
|
2023-04-06 23:05:27 +02:00
|
|
|
AM_CONDITIONAL([NEED_FUNOPEN], [test "x$need_funopen" = "xyes"])
|
|
|
|
AS_IF([test "x$need_funopen" = "xno" && \
|
|
|
|
test "x$ac_cv_func_funopen" != "xyes" && \
|
|
|
|
test "x$ac_cv_func_fopencookie" = "xyes"], [
|
|
|
|
AC_MSG_WARN([[can implement funopen() now based on newly added fopencooke(), report upstream]])
|
|
|
|
])
|
2010-12-17 11:13:04 +01:00
|
|
|
|
2021-11-28 22:40:58 +01:00
|
|
|
AC_SUBST([MD5_LIBS])
|
2021-02-09 06:04:38 +01:00
|
|
|
AC_SUBST([LIBBSD_LIBS])
|
|
|
|
|
2010-12-17 11:13:04 +01:00
|
|
|
AC_CONFIG_FILES([
|
2022-12-13 03:31:38 +01:00
|
|
|
Makefile
|
|
|
|
include/Makefile
|
|
|
|
man/Makefile
|
|
|
|
src/Makefile
|
|
|
|
src/libbsd.pc
|
|
|
|
src/libbsd-ctor.pc
|
|
|
|
src/libbsd-overlay.pc
|
|
|
|
test/Makefile
|
2010-12-17 11:13:04 +01:00
|
|
|
])
|
|
|
|
AC_CONFIG_HEADERS([config.h])
|
|
|
|
AC_OUTPUT
|