forked from darealshinji/dcaenc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autogen.sh
executable file
·54 lines (44 loc) · 1.23 KB
/
autogen.sh
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
#!/bin/sh
autogen () {
# autogen command(s)
mkdir -p build-aux
autoreconf -i -f
}
# force the deletion of these files and/or directories
#forcedelete="some-file1.ext some-file2.ext some/directory/"
cleanscript="autogen-cleanup.sh"
if [ -f $cleanscript ]; then
echo "warning: autogen clean-up script found!"
echo "run \`./$cleanscript' first"
exit 1
fi
find . > .autogen_sh_before
autogen
find . > .autogen_sh_after
diff -u .autogen_sh_before .autogen_sh_after | grep '^+\./' | sed 's|^+||g' | \
grep -v '^\.\/git\/' | \
grep -v '^\.\/hg\/' | \
grep -v '^\.\/svn\/' | \
grep -v '^\.\/bzr\/' | \
grep -v '^\.\/\.autogen_sh_' > .autogen_sh_files
cat <<EOF> $cleanscript
#!/bin/sh
# this script was automatically generated by $(basename $0)
if [ -f Makefile ] || [ -f GNUmakefile ]; then
(make maintainer-clean 2>/dev/null ||
make distclean 2>/dev/null ||
make clean 2>/dev/null) || true
fi
set -v
EOF
chmod a+x $cleanscript
for f in $(tac .autogen_sh_files); do
if [ -d $f ]; then
echo "rmdir $f 2>/dev/null || true" >> $cleanscript
else
echo "rm -f $f" >> $cleanscript
fi
done
echo "rm -rf $forcedelete" >> $cleanscript
echo "rm -f $cleanscript" >> $cleanscript
rm -f .autogen_sh_before .autogen_sh_after .autogen_sh_files