mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-10-15 15:16:53 +02:00
build: Refactor GNU .init_array support check into a new m4 function
This commit is contained in:
44
configure.ac
44
configure.ac
@@ -184,49 +184,7 @@ AC_CHECK_DECLS([environ], [], [], [[
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
]])
|
]])
|
||||||
|
|
||||||
AC_CACHE_CHECK([for GNU .init_array section support],
|
LIBBSD_HAS_GNU_INIT_ARRAY
|
||||||
[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; }
|
|
||||||
void (*init_func)(int argc) __attribute__((__section__(".init_array"), __used__)) = init;
|
|
||||||
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
|
|
||||||
])
|
|
||||||
])
|
|
||||||
])
|
|
||||||
AM_CONDITIONAL([BUILD_LIBBSD_CTOR],
|
|
||||||
[test "$libbsd_cv_gnu_init_array_support" = yes])
|
|
||||||
|
|
||||||
# Checks for library functions.
|
# Checks for library functions.
|
||||||
AC_MSG_CHECKING([for program_invocation_short_name])
|
AC_MSG_CHECKING([for program_invocation_short_name])
|
||||||
|
@@ -22,3 +22,51 @@ AC_DEFUN([LIBBSD_CHECK_COMPILER_FLAG], [
|
|||||||
])
|
])
|
||||||
AS_VAR_POPDEF([libbsd_varname_cache])
|
AS_VAR_POPDEF([libbsd_varname_cache])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
# LIBBSD_HAS_GNU_INIT_ARRAY
|
||||||
|
# -------------------------
|
||||||
|
AC_DEFUN([LIBBSD_HAS_GNU_INIT_ARRAY], [
|
||||||
|
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; }
|
||||||
|
void (*init_func)(int argc) __attribute__((__section__(".init_array"), __used__)) = init;
|
||||||
|
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
|
||||||
|
])
|
||||||
|
])
|
||||||
|
])
|
||||||
|
AM_CONDITIONAL([BUILD_LIBBSD_CTOR],
|
||||||
|
[test "$libbsd_cv_gnu_init_array_support" = yes])
|
||||||
|
])
|
||||||
|
Reference in New Issue
Block a user