Skip to content
Snippets Groups Projects
Forked from Core Modules / dune-common
4372 commits behind the upstream repository.
addsourcescheck 797 B
#!/bin/bash

#
# patch the include statement into all Makefile.am files
#

set -e

# always start in $top_srcdir
if ! test -f configure.ac; then
  echo "Wrong Directory"
  echo "run from \$top_srcdir"
  exit 1
fi

# list of files to patch
FILES=`find . -name Makefile.am`
# snippet to patch into Makefile.am
SNIP='include $(top_srcdir)/am/sourcescheck'
# create the grep regexp from the snip
REGEXP="^$(echo $SNIP | sed -e 's/[\$\/\(\)]/./g')\$"
# enable / disable verbose mode
VERBOSE=0

for f in $FILES; do
	# only patch files that don't have the patch yet
	if ! grep -q "$REGEXP" $f; then
		echo patching $f
		# normalize end of file
		while test "$(tail -1 $f)" != ""; do
			echo >> $f
		done
		echo $SNIP >> $f
	else
		if test x$VERBOSE = x1; then
		    echo $f already patched
		fi
	fi
done