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.
This commit is contained in:
Guillem Jover 2014-07-20 01:48:20 +02:00
parent faa005cb32
commit e8d3d04177
5 changed files with 23 additions and 7 deletions

View File

@ -101,9 +101,8 @@ int main() { return rc; }
] ]
)] )]
) )
if test "$libbsd_cv_gnu_init_array_support" = no; then AM_CONDITIONAL([BUILD_LIBBSD_CTOR],
AC_MSG_ERROR([missing required GNU .init_array section support]) [test "$libbsd_cv_gnu_init_array_support" = yes])
fi
# Checks for library functions. # Checks for library functions.
AC_MSG_CHECKING([for program_invocation_short_name]) AC_MSG_CHECKING([for program_invocation_short_name])

View File

@ -22,12 +22,17 @@ CLEANFILES = \
pkgconfigdir = $(libdir)/pkgconfig pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = \ pkgconfig_DATA = \
libbsd.pc \ libbsd.pc \
libbsd-ctor.pc \
libbsd-overlay.pc \ libbsd-overlay.pc \
$(nil) $(nil)
lib_LTLIBRARIES = libbsd.la 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 hash/md5hl.c: $(srcdir)/hash/helper.c
$(AM_V_at) $(MKDIR_P) hash $(AM_V_at) $(MKDIR_P) hash

1
test/.gitignore vendored
View File

@ -4,4 +4,5 @@ funopen
headers headers
humanize humanize
overlay overlay
proctitle-init
proctitle proctitle

View File

@ -14,12 +14,19 @@ check_PROGRAMS = \
humanize \ humanize \
fgetln \ fgetln \
funopen \ funopen \
proctitle \ proctitle-init \
$(nil) $(nil)
if BUILD_LIBBSD_CTOR
check_PROGRAMS += proctitle
endif
humanize_LDFLAGS = $(top_builddir)/src/libbsd.la humanize_LDFLAGS = $(top_builddir)/src/libbsd.la
fgetln_LDFLAGS = $(top_builddir)/src/libbsd.la fgetln_LDFLAGS = $(top_builddir)/src/libbsd.la
funopen_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 = \ proctitle_LDFLAGS = \
-Wl,-u,libbsd_init_func \ -Wl,-u,libbsd_init_func \
$(top_builddir)/src/libbsd-ctor.a \ $(top_builddir)/src/libbsd-ctor.a \

View File

@ -31,12 +31,16 @@
#include <string.h> #include <string.h>
int int
main(int argc, char **argv) main(int argc, char **argv, char **envp)
{ {
const char newtitle_base[] = "test arg1 arg2"; const char newtitle_base[] = "test arg1 arg2";
char *newtitle_full; char *newtitle_full;
char *envvar; char *envvar;
#ifdef TEST_USE_SETPROCTITLE_INIT
setproctitle_init(argc, argv, envp);
#endif
setproctitle("-test %s arg2", "arg1"); setproctitle("-test %s arg2", "arg1");
assert(strcmp(argv[0], newtitle_base) == 0); assert(strcmp(argv[0], newtitle_base) == 0);