summaryrefslogtreecommitdiffstats
path: root/scripts/create_cvsignore
blob: 2fb4c23edfdfa1539adf9c0d2a6e0a500b5104ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/sh
# This script makes a preliminary .cvsignore in the current dir by
# adding some standard stuff according to Makefile.am.
# License: GPL

addignore() {
	test -f .cvsignore || \
	( touch .cvsignore && echo "created new .cvsignore" && cvs add .cvsignore )
	grep -q "^$1\$" .cvsignore || \
	( echo "$1" >> .cvsignore && echo "added $1 to .cvsignore" )
}

recurse=0
if test $# -eq 1; then
	if test "$1" = "-r"; then
		recurse=1
	fi
fi

handledir() {
	(
	cd $1
	if test -f Makefile.am; then
		if test $recurse -eq 1; then
			echo "Entering $1"
		fi
		addignore Makefile
		addignore Makefile.in

		bins=`perl -p -e 's/\\\s*\n/ /g' Makefile.am | grep _PROGRAMS | sed -e 's/.*=\s*//;s/#.*//;s/\$([^)]*)//'`
		if test -n "$bins"; then
			for prog in $bins; do
				addignore "$prog"
			done
		fi
	else
		echo "Skipping $1"
	fi
	)
}


if test -f Makefile.am; then
	if test $recurse -eq 1; then
		find . -type d | grep -v CVS | sed -e 's,/$,,' | \
		while read dir; do
			handledir $dir
		done
	else
		handledir .
	fi
else
	echo "No Makefile.am found!"
fi