Mercurial > ~dholland > hg > ag > index.cgi
comparison mk/testsubdir-rules.sh @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 #!/bin/sh | |
2 # testsubdir-rules.sh - generate make rules for testsubdir.mk | |
3 # usage: testsubdir-rules.sh "subdirs" > rules.mk | |
4 | |
5 if [ $# != 1 ]; then | |
6 echo "$0: usage: $0 'subdirs'" 1>&2 | |
7 exit 1 | |
8 fi | |
9 | |
10 SUBDIRS="$1" | |
11 | |
12 echo "$SUBDIRS" | tr ' ' '\n' | awk ' | |
13 { dirs[++ndirs] = $1; } | |
14 END { | |
15 printf "all:\n"; | |
16 for (i=1;i<=ndirs;i++) dodir("run-tests", 1, dirs[i]); | |
17 for (i=1;i<=ndirs;i++) dodir("show-diffs", 1, dirs[i]); | |
18 simpletarget("show-diffs", "", 0); | |
19 simpletarget("run-tests", "", 1); | |
20 simpletarget("rules", "-subdirs", 1); | |
21 simpletarget("clean", "-subdirs", 1); | |
22 simpletarget("distclean", "-subdirs", 1); | |
23 } | |
24 function simpletarget(target, suffix, show) { | |
25 printf "%s%s:\n", target, suffix; | |
26 for (i=1;i<=ndirs;i++) dodir(target, show, dirs[i]); | |
27 } | |
28 function dodir(target, show, dir) { | |
29 if (show) { | |
30 printf "\t@echo \"%s ===> $(_SUBDIR_)%s\"\n", target, dir; | |
31 } | |
32 printf "\t@cd %s && $(MAKE) %s", dir, target; | |
33 printf " _SUBDIR_=$(_SUBDIR_)%s/\n", dir; | |
34 } | |
35 ' | |
36 | |
37 echo ".PHONY: all run-tests show-diffs" | |
38 echo ".PHONY: rules-subdirs clean-subdirs distclean-subdirs" | |
39 | |
40 echo 'distclean-here:' | |
41 for D in $SUBDIRS; do | |
42 echo $D | awk ' | |
43 { | |
44 printf "\t@echo \" [RMDIR] %s\"\n", $1; | |
45 printf "\t@-rm -f %s/Makefile %s/rules.mk %s/depend.mk\n",$1,$1,$1; | |
46 printf "\t@-rmdir %s\n", $1; | |
47 } | |
48 ' | |
49 done |