Ralf Wildenhues wrote: > *_LDFLAGS are for libtool libraries and programs, but not for static > libraries.
Ah, right, I forgot about this. Sorry. > I recommend that if libgnu.a needs symbols from other libraries, then it > should provide a macro $(LIBGNULIB) or so, that programs can use to link > against, and that it should then contain those additional libraries. > This way, it is possible for the program to link against shared > libraries of those Nice suggestion. I implemented it through the patch below. When you build a libgnu without libtool, you now have a predefined Makefile variable LIBGNU_LIBDEPS and a predefined Makefile variable LIBGNU_LTLIBDEPS available. They contain the -L, -l, -rpath options for linking with the dependencies of libgnu.a. Use LIBGNU_LTLIBDEPS for executables that you link with libtool, and LIBGNU_LIBDEPS for executables that you link without libtool. Nevertheless, packages that build many executables may not want to use these variables, since they may add too many link dependencies. But for packages with only one executable these two Makefile variables are perfect. Bruno 2006-09-09 Bruno Haible <[EMAIL PROTECTED]> * gnulib-tool (func_emit_lib_Makefile_am): Eliminate lib_LDFLAGS assignments if building a library without libtool. (func_emit_tests_Makefile_am): Likewise. Handle lib_* variables as in func_emit_lib_Makefile_am. (func_import): When building a static library libfoo.a, arrange to define variables LIBFOO_LIBDEPS and LIBFOO_LTLIBDEPS. (func_create_testdir): Likewise. * modules/gc (configure.ac, Makefile.am): If building statically, augment gl_libdeps and gl_ltlibdeps instead of lib_LDFLAGS. * modules/iconvme (configure.ac, Makefile.am): Likewise. * modules/striconv (configure.ac, Makefile.am): Likewise. Based on a suggestion by Ralf Wildenhues. diff -c -3 -r1.158 gnulib-tool *** gnulib-tool 7 Sep 2006 13:00:56 -0000 1.158 --- gnulib-tool 9 Sep 2006 18:34:23 -0000 *************** *** 1043,1051 **** --- 1043,1053 ---- if test "$libtool" = true; then libext=la perhapsLT=LT + sed_eliminate_LDFLAGS= else libext=a perhapsLT= + sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d' fi echo "## Process this file with automake to produce Makefile.in." func_emit_copyright_notice *************** *** 1066,1071 **** --- 1068,1074 ---- func_get_automake_snippet "$module" | sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \ -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' | + sed -e "$sed_eliminate_LDFLAGS" | sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' | sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \ -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' *************** *** 1096,1102 **** echo echo "${libname}_${libext}_SOURCES =" echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@" ! echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)" if test -z "$makefile_name"; then echo "noinst_HEADERS =" # Automake versions < 1.9b create an empty pkgdatadir at installation time --- 1099,1107 ---- echo echo "${libname}_${libext}_SOURCES =" echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@" ! if test "$libtool" = true; then ! echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)" ! fi if test -z "$makefile_name"; then echo "noinst_HEADERS =" # Automake versions < 1.9b create an empty pkgdatadir at installation time *************** *** 1148,1153 **** --- 1153,1165 ---- else libext=a fi + if test "$libtool" = true; then + libext=la + sed_eliminate_LDFLAGS= + else + libext=a + sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d' + fi testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'` echo "## Process this file with automake to produce Makefile.in." func_emit_copyright_notice *************** *** 1161,1167 **** for module in $modules; do func_verify_tests_module if test -n "$module"; then ! func_get_automake_snippet "$module" > amsnippet.tmp # Skip the contents if its entirely empty. if grep '[^ ]' amsnippet.tmp > /dev/null ; then echo "## begin gnulib module $module" --- 1173,1187 ---- for module in $modules; do func_verify_tests_module if test -n "$module"; then ! { ! func_get_automake_snippet "$module" | ! sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \ ! -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' | ! sed -e "$sed_eliminate_LDFLAGS" | ! sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' | ! sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \ ! -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' ! } > amsnippet.tmp # Skip the contents if its entirely empty. if grep '[^ ]' amsnippet.tmp > /dev/null ; then echo "## begin gnulib module $module" *************** *** 1816,1823 **** --- 1836,1847 ---- echo "[" if test "$libtool" = true; then echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])" + echo " gl_cond_libtool=true" else echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])" + echo " gl_cond_libtool=false" + echo " gl_libdeps=" + echo " gl_ltlibdeps=" fi if test "$auxdir" != "build-aux"; then sed_replace_build_aux=' *************** *** 1845,1850 **** --- 1869,1883 ---- fi fi done + # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is + # created using libtool, because libtool already handles the dependencies. + if test "$libtool" != true; then + libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'` + echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\"" + echo " AC_SUBST([${libname_upper}_LIBDEPS])" + echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\"" + echo " AC_SUBST([${libname_upper}_LTLIBDEPS])" + fi echo "])" echo echo "# This macro records the list of files which have been installed by" *************** *** 2089,2096 **** --- 2122,2133 ---- fi if test "$libtool" = true; then echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])" + echo "gl_cond_libtool=true" else echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])" + echo "gl_cond_libtool=false" + echo "gl_libdeps=" + echo "gl_ltlibdeps=" fi # Wrap the set of autoconf snippets into an autoconf macro that is then # invoked. This is needed because autoconf does not support AC_REQUIRE *************** *** 2128,2133 **** --- 2165,2179 ---- | sed -e "$sed_replace_build_aux" fi done + # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is + # created using libtool, because libtool already handles the dependencies. + if test "$libtool" != true; then + libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'` + echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\"" + echo " AC_SUBST([${libname_upper}_LIBDEPS])" + echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\"" + echo " AC_SUBST([${libname_upper}_LTLIBDEPS])" + fi echo "])" echo "gl_INIT" echo *************** *** 2184,2191 **** --- 2230,2241 ---- fi if test "$libtool" = true; then echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])" + echo "gl_cond_libtool=true" else echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])" + echo "gl_cond_libtool=false" + echo "gl_libdeps=" + echo "gl_ltlibdeps=" fi # Wrap the set of autoconf snippets into an autoconf macro that is then # invoked. This is needed because autoconf does not support AC_REQUIRE *************** *** 2213,2218 **** --- 2263,2277 ---- | sed -e "$sed_replace_build_aux" fi done + # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is + # created using libtool, because libtool already handles the dependencies. + if test "$libtool" != true; then + libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'` + echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\"" + echo " AC_SUBST([${libname_upper}_LIBDEPS])" + echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\"" + echo " AC_SUBST([${libname_upper}_LTLIBDEPS])" + fi echo "])" echo "gl_INIT" echo diff -c -3 -r1.6 gc *** modules/gc 6 Sep 2006 14:08:38 -0000 1.6 --- modules/gc 9 Sep 2006 18:34:24 -0000 *************** *** 12,24 **** configure.ac: gl_GC Makefile.am: EXTRA_DIST += gc.h if GL_COND_LIBTOOL lib_LDFLAGS += $(LTLIBGCRYPT) - else - lib_LDFLAGS += $(LIBGCRYPT) endif Include: --- 12,26 ---- configure.ac: gl_GC + if test $gl_cond_libtool = false; then + gl_ltlibdeps="$gl_ltlibdeps $LTLIBGCRYPT" + gl_libdeps="$gl_libdeps $LIBGCRYPT" + fi Makefile.am: EXTRA_DIST += gc.h if GL_COND_LIBTOOL lib_LDFLAGS += $(LTLIBGCRYPT) endif Include: diff -c -3 -r1.2 iconvme *** modules/iconvme 6 Sep 2006 14:08:38 -0000 1.2 --- modules/iconvme 9 Sep 2006 18:34:24 -0000 *************** *** 12,24 **** configure.ac: gl_ICONVME Makefile.am: lib_SOURCES += iconvme.h iconvme.c if GL_COND_LIBTOOL lib_LDFLAGS += $(LTLIBICONV) - else - lib_LDFLAGS += $(LIBICONV) endif Include: --- 12,26 ---- configure.ac: gl_ICONVME + if test $gl_cond_libtool = false; then + gl_ltlibdeps="$gl_ltlibdeps $LTLIBICONV" + gl_libdeps="$gl_libdeps $LIBICONV" + fi Makefile.am: lib_SOURCES += iconvme.h iconvme.c if GL_COND_LIBTOOL lib_LDFLAGS += $(LTLIBICONV) endif Include: diff -c -3 -r1.1 striconv *** modules/striconv 6 Sep 2006 12:21:39 -0000 1.1 --- modules/striconv 9 Sep 2006 18:34:24 -0000 *************** *** 11,23 **** c-strcase configure.ac: Makefile.am: lib_SOURCES += striconv.h striconv.c if GL_COND_LIBTOOL lib_LDFLAGS += $(LTLIBICONV) - else - lib_LDFLAGS += $(LIBICONV) endif Include: --- 11,25 ---- c-strcase configure.ac: + if test $gl_cond_libtool = false; then + gl_ltlibdeps="$gl_ltlibdeps $LTLIBICONV" + gl_libdeps="$gl_libdeps $LIBICONV" + fi Makefile.am: lib_SOURCES += striconv.h striconv.c if GL_COND_LIBTOOL lib_LDFLAGS += $(LTLIBICONV) endif Include: