>From 8ccf6c0c2fa4a56c684a037b2a4bc95bdac06d29 Mon Sep 17 00:00:00 2001 From: Benjamin Cama Date: Fri, 8 Nov 2013 18:51:41 +0100 Subject: [PATCH] Don't build a library if no code is compiled You still need to pass "--avoid dummy" not to pull the dummy package. --- gnulib-tool | 118 +++++++++++++++++++++++++++++++---------------------------- 1 files changed, 62 insertions(+), 56 deletions(-) diff --git a/gnulib-tool b/gnulib-tool index 669931c..fcc41f3 100755 --- a/gnulib-tool +++ b/gnulib-tool @@ -3317,6 +3317,10 @@ func_emit_lib_Makefile_am () echo "## end gnulib module $module" echo fi + # Check if we really need the library, as there might be no compiled code included + if ( cat "$tmp"/amsnippet1 ; func_get_include_directive "$module" ; func_get_link_directive "$module" ) | grep '[^ ]' > /dev/null; then + library_needed=yes + fi rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2 # Test whether there are some source files in subdirectories. for f in `func_get_filelist "$module"`; do @@ -3379,67 +3383,69 @@ func_emit_lib_Makefile_am () fi fi done - if test -n "$witness_c_macro"; then - cppflags_part1=" -D$witness_c_macro=1" - else - cppflags_part1= - fi - if $for_test; then - cppflags_part2=" -DGNULIB_STRICT_CHECKING=1" - else - cppflags_part2= - fi - if test -z "$makefile_name"; then + if test -n "$library_needed"; then + if test -n "$witness_c_macro"; then + cppflags_part1=" -D$witness_c_macro=1" + else + cppflags_part1= + fi + if $for_test; then + cppflags_part2=" -DGNULIB_STRICT_CHECKING=1" + else + cppflags_part2= + fi + if test -z "$makefile_name"; then + echo + echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2" + echo "AM_CFLAGS =" + else + if test -n "$cppflags_part1$cppflags_part2"; then + echo + echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2" + fi + fi echo - echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2" - echo "AM_CFLAGS =" - else - if test -n "$cppflags_part1$cppflags_part2"; then + if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \ + || { test -n "$makefile_name" \ + && test -f "$sourcebase/Makefile.am" \ + && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \ + }; then + # One of the snippets or the user's Makefile.am already specifies an + # installation location for the library. Don't confuse automake by saying + # it should not be installed. + : + else + # By default, the generated library should not be installed. + echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext" + fi + echo + echo "${libname}_${libext}_SOURCES =" + # Here we use $(LIBOBJS), not @address@hidden The value is the same. However, + # automake during its analysis looks for $(LIBOBJS), not for @address@hidden + echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)" + echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)" + echo "EXTRA_${libname}_${libext}_SOURCES =" + if test "$libtool" = true; then + echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)" + echo "${libname}_${libext}_LDFLAGS += -no-undefined" + # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining + # the link dependencies of all modules. + for module in $modules; do + func_verify_nontests_module + if test -n "$module"; then + func_get_link_directive "$module" + fi + done \ + | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \ + | LC_ALL=C sort -u \ + | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /' + fi + if test -n "$pobase"; then echo - echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2" + echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\"" fi fi echo - if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \ - || { test -n "$makefile_name" \ - && test -f "$sourcebase/Makefile.am" \ - && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \ - }; then - # One of the snippets or the user's Makefile.am already specifies an - # installation location for the library. Don't confuse automake by saying - # it should not be installed. - : - else - # By default, the generated library should not be installed. - echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext" - fi - echo - echo "${libname}_${libext}_SOURCES =" - # Here we use $(LIBOBJS), not @address@hidden The value is the same. However, - # automake during its analysis looks for $(LIBOBJS), not for @address@hidden - echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)" - echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)" - echo "EXTRA_${libname}_${libext}_SOURCES =" - if test "$libtool" = true; then - echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)" - echo "${libname}_${libext}_LDFLAGS += -no-undefined" - # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining - # the link dependencies of all modules. - for module in $modules; do - func_verify_nontests_module - if test -n "$module"; then - func_get_link_directive "$module" - fi - done \ - | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \ - | LC_ALL=C sort -u \ - | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /' - fi - echo - if test -n "$pobase"; then - echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\"" - echo - fi cat "$tmp"/allsnippets \ | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g' echo -- 1.7.2.5