patch-quiet.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/sh
  2. #
  3. # patch-quiet.sh: Shell script to rewrite Makefiles using libtool to be less verbose
  4. #
  5. if [ "$1" = "" ]; then
  6. echo "Usage: patch-quiet.sh <path to Makefile>"
  7. exit 1
  8. fi
  9. src=$1
  10. if head -n1 $src | grep -q '# Postprocessed with patch-quiet\.sh'; then
  11. # already handled
  12. exit 0
  13. fi
  14. echo "# Postprocessed with patch-quiet.sh" > $src.tmp && cat $src >> $src.tmp && cp $src.tmp $src && rm -f $src.tmp
  15. # Try to find GNU sed
  16. SED="sed"
  17. sed --version >/dev/null 2>&1
  18. if [ $? -ne 0 ] ; then
  19. gsed --version > /dev/null 2>&1 && SED="gsed"
  20. fi
  21. # compile
  22. ${SED} -e 's/^\t\(if \)\?$(COMPILE)/\t$(if $(V),,@echo -e "CC\\t$@";) \1$(COMPILE)/g' < $src > $src.tmp && cp $src.tmp $src && rm -f $src.tmp
  23. ${SED} -e 's/^\t\(if \)\?$(LTCOMPILE)/\t$(if $(V),,@echo -e "CC\\t$@";) \1$(LTCOMPILE)/g' < $src > $src.tmp && cp $src.tmp $src && rm -f $src.tmp
  24. ${SED} -e 's/^\t\(if \)\?$(LTCXXCOMPILE)/\t$(if $(V),,@echo -e "CC\\t$@";) \1$(LTCXXCOMPILE)/g' < $src > $src.tmp && cp $src.tmp $src && rm -f $src.tmp
  25. ${SED} -e 's/^\t\(if \)\?$(LIBTOOL)/\t$(if $(V),,@echo -e "CC\\t$@";) \1$(LIBTOOL)/g' < $src > $src.tmp && cp $src.tmp $src && rm -f $src.tmp
  26. # link
  27. # automake defines multiple symbols ending with LINK
  28. ${SED} -e 's/^\t$(\(.*LINK\))/\t$(if $(V),,@echo -e "LD\\t$@";) $(\1)/g' < $src > $src.tmp && cp $src.tmp $src && rm -f $src.tmp
  29. #sed -e 's/LINK = $(LIBTOOL)/LINK = $(if $(V),,@echo -e "LD\\t$@";) $(LIBTOOL)/g' < $src > $src.tmp && cp $src.tmp $src && rm -f $src.tmp
  30. # CC
  31. ${SED} -e 's/^\t\(if \)\?$(CC)/\t$(if $(V),,@echo -e "CC\\t$@";) \1$(CC)/g' < $src > $src.tmp && cp $src.tmp $src && rm -f $src.tmp
  32. # mv
  33. ${SED} -e 's/^\tmv -f/\t$(if $(V),,@)mv -f/g' < $src > $src.tmp && cp $src.tmp $src && rm -f $src.tmp
  34. ${SED} -e 's/^am__mv = /&$(if $(V),,@)/' < $src > $src.tmp && cp $src.tmp $src && rm -f $src.tmp
  35. # libtool messages
  36. ${SED} -e 's/\$(LIBTOOL)/$(LIBTOOL) $(if $(V),,--quiet)/g' < $src > $src.tmp && cp $src.tmp $src && rm -f $src.tmp
  37. # This causes this script to be rerun if Makefile.am changes
  38. ${SED} -e 's/am__depfiles_maybe = depfiles/& quiet/g' < $src > $src.tmp && cp $src.tmp $src && rm -f $src.tmp