summaryrefslogtreecommitdiffstats
path: root/scripts/create_svnignore
blob: 299160d2ca80cd80a1143314983ecced9688761b (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/sh
# This script makes a preliminary svn:ignore in the current dir by
# adding some standard stuff according to Makefile.am.
# License: GPL

addignore() {
	if ! test -f svnignore.tmp; then
	   svn pg svn:ignore . | sed -e "s, *,," | grep -v '^$' > svnignore.tmp
	   addedsomething=0
	fi
	if ! grep -q "^$1\$" svnignore.tmp; then
	  echo "$1" >> svnignore.tmp && echo "added $1 to svn:ignore"
	  sort -u -o svnignore.tmp svnignore.tmp
	  addedsomething=1
	fi
}

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

handledir() {
	(
	cd $1
	trap "rm svnignore.tmp" 1 2 15
	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 | egrep '_PROGRAMS|_LTLIBRARIES|_LIBRARIES' | sed -e 's/.*=\s*//;s/#.*//;s/\$([^)]*)//'`
		if test -n "$bins"; then
			addignore ".libs"
			addignore ".deps"
			for prog in $bins; do
				addignore "$prog"
			done
		fi
		grep -q LIBRARIES Makefile.am && addignore ".libs"
		grep -q METASOURCES Makefile.am && addignore "*.tqmoc"
		fgrep -q .skel Makefile.am && addignore "*.kidl"
		fgrep -q .skel Makefile.am && addignore "*_skel.c*"
		fgrep -q .stub Makefile.am && addignore "*_stub.cpp"
		if fgrep -q .ui Makefile.am; then
			uis=`ls -1 *.ui 2>/dev/null`
			for ui in $uis; do
				addignore ${ui/.ui/.h}
				addignore ${ui/.ui/.cpp}
			done
		fi
		
		grep -q "^include.*/Doxyfile.am$" Makefile.am && addignore "Doxyfile"

		if test "$addedsomething" = 1; then
		    svn propset svn:ignore -F svnignore.tmp .
		fi
		rm svnignore.tmp
	else
		echo "Skipping $1"
	fi
	)
}


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