build: Remove hard requirement for GNU .init_array section support In case the support is not available, just stop building the libbsd-ctor.a library, which is a nice to have thing, but should not have been a hard requirement from the start. This should allow to build libbsd on non-glibc based systems using another libc.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
diff --git a/configure.ac b/configure.ac
index 1c1b962..c1da7d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -101,9 +101,8 @@ int main() { return rc; }
]
)]
)
-if test "$libbsd_cv_gnu_init_array_support" = no; then
- AC_MSG_ERROR([missing required GNU .init_array section support])
-fi
+AM_CONDITIONAL([BUILD_LIBBSD_CTOR],
+ [test "$libbsd_cv_gnu_init_array_support" = yes])
# Checks for library functions.
AC_MSG_CHECKING([for program_invocation_short_name])
diff --git a/src/Makefile.am b/src/Makefile.am
index b9ff0bc..3f3a0f6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -22,12 +22,17 @@ CLEANFILES = \
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = \
libbsd.pc \
- libbsd-ctor.pc \
libbsd-overlay.pc \
$(nil)
lib_LTLIBRARIES = libbsd.la
-lib_LIBRARIES = libbsd-ctor.a
+lib_LIBRARIES =
+
+if BUILD_LIBBSD_CTOR
+pkgconfig_DATA += libbsd-ctor.pc
+
+lib_LIBRARIES += libbsd-ctor.a
+endif
hash/md5hl.c: $(srcdir)/hash/helper.c
$(AM_V_at) $(MKDIR_P) hash
diff --git a/test/.gitignore b/test/.gitignore
index 60e0e69..e351ab1 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -4,4 +4,5 @@ funopen
headers
humanize
overlay
+proctitle-init
proctitle
diff --git a/test/Makefile.am b/test/Makefile.am
index 6ace5a6..c6e2daa 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -14,12 +14,19 @@ check_PROGRAMS = \
humanize \
fgetln \
funopen \
- proctitle \
+ proctitle-init \
$(nil)
+if BUILD_LIBBSD_CTOR
+check_PROGRAMS += proctitle
+endif
+
humanize_LDFLAGS = $(top_builddir)/src/libbsd.la
fgetln_LDFLAGS = $(top_builddir)/src/libbsd.la
funopen_LDFLAGS = $(top_builddir)/src/libbsd.la
+proctitle_init_SOURCES = proctitle.c
+proctitle_init_CPPFLAGS = $(AM_CPPFLAGS) -DTEST_USE_SETPROCTITLE_INIT=1
+proctitle_init_LDFLAGS = $(top_builddir)/src/libbsd.la
proctitle_LDFLAGS = \
-Wl,-u,libbsd_init_func \
$(top_builddir)/src/libbsd-ctor.a \
diff --git a/test/proctitle.c b/test/proctitle.c
index 56ea863..5f546c7 100644
--- a/test/proctitle.c
+++ b/test/proctitle.c
@@ -31,12 +31,16 @@
#include <string.h>
int
-main(int argc, char **argv)
+main(int argc, char **argv, char **envp)
{
const char newtitle_base[] = "test arg1 arg2";
char *newtitle_full;
char *envvar;
+#ifdef TEST_USE_SETPROCTITLE_INIT
+ setproctitle_init(argc, argv, envp);
+#endif
+
setproctitle("-test %s arg2", "arg1");
assert(strcmp(argv[0], newtitle_base) == 0);