The module description and macros of relocatable-prog still has a problem: It compiles relocatable.c both as part of lib_SOURCES and as an AC_LIBOBJ. This leads to a link error when creating a shared library. This fixes it.
2007-03-04 Bruno Haible <[EMAIL PROTECTED]> Compile relocatable.c only if --enable-relocatable is specified. * m4/relocatable-lib.m4 (gl_RELOCATABLE_LIBRARY_BODY): Renamed from gl_RELOCATABLE_LIBRARY. (gl_RELOCATABLE_LIBRARY, gl_RELOCATABLE_LIBRARY_SEPARATE): New macros. * m4/relocatable.m4 (gl_RELOCATABLE): Invoke gl_RELOCATABLE_LIBRARY. (gl_RELOCATABLE_BODY): Require gl_RELOCATABLE_LIBRARY_BODY instead of gl_RELOCATABLE_LIBRARY. * modules/relocatable-lib (configure.ac): Invoke gl_RELOCATABLE_LIBRARY. (Makefile.am): Remove lib_SOURCES. * modules/relocatable-lib-lgpl (configure.ac): Invoke gl_RELOCATABLE_LIBRARY. (Makefile.am): Remove lib_SOURCES. * modules/relocatable-prog (Makefile.am): Don't compile relocatable.c always. * modules/relocatable-prog-wrapper (configure.ac): Invoke gl_RELOCATABLE_LIBRARY_SEPARATE instead of gl_RELOCATABLE_LIBRARY. *** m4/relocatable-lib.m4 3 Mar 2007 17:49:27 -0000 1.2 --- m4/relocatable-lib.m4 4 Mar 2007 15:21:52 -0000 *************** *** 1,4 **** ! # relocatable-lib.m4 serial 2 dnl Copyright (C) 2003, 2005-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, --- 1,4 ---- ! # relocatable-lib.m4 serial 3 dnl Copyright (C) 2003, 2005-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, *************** *** 9,14 **** --- 9,21 ---- dnl Support for relocatable libraries. AC_DEFUN([gl_RELOCATABLE_LIBRARY], [ + AC_REQUIRE([gl_RELOCATABLE_LIBRARY_BODY]) + if test $RELOCATABLE = yes; then + AC_LIBOBJ([relocatable]) + fi + ]) + AC_DEFUN([gl_RELOCATABLE_LIBRARY_BODY], + [ AC_REQUIRE([gl_RELOCATABLE_NOP]) dnl Easier to put this here once, instead of into the DEFS of each Makefile. if test "X$prefix" = "XNONE"; then *************** *** 24,29 **** --- 31,43 ---- fi ]) + dnl Like gl_RELOCATABLE_LIBRARY, except prepare for separate compilation + dnl (no AC_LIBOBJ). + AC_DEFUN([gl_RELOCATABLE_LIBRARY_SEPARATE], + [ + AC_REQUIRE([gl_RELOCATABLE_LIBRARY_BODY]) + ]) + dnl Support for relocatable packages for which it is a nop. AC_DEFUN([gl_RELOCATABLE_NOP], [ *** m4/relocatable.m4 3 Mar 2007 17:49:27 -0000 1.3 --- m4/relocatable.m4 4 Mar 2007 15:21:52 -0000 *************** *** 1,4 **** ! # relocatable.m4 serial 9 dnl Copyright (C) 2003, 2005-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, --- 1,4 ---- ! # relocatable.m4 serial 10 dnl Copyright (C) 2003, 2005-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, *************** *** 13,21 **** AC_DEFUN([gl_RELOCATABLE], [ AC_REQUIRE([gl_RELOCATABLE_BODY]) ! if test $RELOCATABLE = yes; then ! AC_LIBOBJ([relocatable]) ! fi : ${RELOCATABLE_CONFIG_H_DIR='$(top_builddir)'} RELOCATABLE_SRC_DIR="\$(top_srcdir)/$gl_source_base" RELOCATABLE_BUILD_DIR="\$(top_builddir)/$gl_source_base" --- 13,19 ---- AC_DEFUN([gl_RELOCATABLE], [ AC_REQUIRE([gl_RELOCATABLE_BODY]) ! gl_RELOCATABLE_LIBRARY : ${RELOCATABLE_CONFIG_H_DIR='$(top_builddir)'} RELOCATABLE_SRC_DIR="\$(top_srcdir)/$gl_source_base" RELOCATABLE_BUILD_DIR="\$(top_builddir)/$gl_source_base" *************** *** 32,38 **** dnl macro's setting of INSTALL_PROGRAM to persist. AC_BEFORE([AC_PROG_INSTALL],[gl_RELOCATABLE_BODY]) AC_REQUIRE([AC_LIB_LIBPATH]) ! AC_REQUIRE([gl_RELOCATABLE_LIBRARY]) is_noop=no use_elf_origin_trick=no if test $RELOCATABLE = yes; then --- 30,36 ---- dnl macro's setting of INSTALL_PROGRAM to persist. AC_BEFORE([AC_PROG_INSTALL],[gl_RELOCATABLE_BODY]) AC_REQUIRE([AC_LIB_LIBPATH]) ! AC_REQUIRE([gl_RELOCATABLE_LIBRARY_BODY]) is_noop=no use_elf_origin_trick=no if test $RELOCATABLE = yes; then *** modules/relocatable-lib 3 Mar 2007 23:29:59 -0000 1.2 --- modules/relocatable-lib 4 Mar 2007 15:21:52 -0000 *************** *** 12,20 **** xalloc configure.ac: Makefile.am: - lib_SOURCES += relocatable.c Include: "relocatable.h" --- 12,20 ---- xalloc configure.ac: + gl_RELOCATABLE_LIBRARY Makefile.am: Include: "relocatable.h" *** modules/relocatable-lib-lgpl 3 Mar 2007 23:28:49 -0000 1.1 --- modules/relocatable-lib-lgpl 4 Mar 2007 15:21:52 -0000 *************** *** 11,20 **** Depends-on: configure.ac: Makefile.am: DEFS += -DNO_XMALLOC - lib_SOURCES += relocatable.c Include: "relocatable.h" --- 11,20 ---- Depends-on: configure.ac: + gl_RELOCATABLE_LIBRARY Makefile.am: DEFS += -DNO_XMALLOC Include: "relocatable.h" *** modules/relocatable-prog 3 Mar 2007 23:43:00 -0000 1.2 --- modules/relocatable-prog 4 Mar 2007 15:21:52 -0000 *************** *** 26,32 **** Makefile.am: DEFS += -DEXEEXT=\"$(EXEEXT)\" ! lib_SOURCES += relocatable.c progreloc.c Include: #include "relocatable.h" --- 26,32 ---- Makefile.am: DEFS += -DEXEEXT=\"$(EXEEXT)\" ! lib_SOURCES += progreloc.c Include: #include "relocatable.h" *** modules/relocatable-prog-wrapper 3 Mar 2007 23:59:53 -0000 1.2 --- modules/relocatable-prog-wrapper 4 Mar 2007 15:21:52 -0000 *************** *** 43,49 **** gl_FUNC_READLINK_SEPARATE gl_CANONICALIZE_LGPL_SEPARATE gl_ALLOCSA ! gl_RELOCATABLE_LIBRARY gl_FUNC_SETENV_SEPARATE gl_FUNC_STRERROR_SEPARATE --- 43,49 ---- gl_FUNC_READLINK_SEPARATE gl_CANONICALIZE_LGPL_SEPARATE gl_ALLOCSA ! gl_RELOCATABLE_LIBRARY_SEPARATE gl_FUNC_SETENV_SEPARATE gl_FUNC_STRERROR_SEPARATE