initial checkin of Makefile.common
[org.ibex.core.git] / Makefile.common
1 ###############################################################################
2 # Ibex common Makefile
3 #
4 #    includes boilerplate stuff and inter-project dependency resolution
5 #
6
7 realdefault: default
8
9 ### interproject deps #############################################################
10
11 cmd := find src -name \*.java -exec grep '^import org.ibex.' {} \;
12 cmd +=  | sed 's_import org\.ibex\.\([a-z]*\).*_ src/org/ibex/\1\n_'
13 cmd +=  | sort | uniq | (while read A; do test -e $$A || echo $$A; done)
14 $(eval upstream := $(shell $(cmd)))
15
16 repos: $(upstream)
17 repo/: ; mkdir repo
18 repo/%.ibex.org/: repo/
19         cd repo; darcs get --partial --verbose http://$*.ibex.org/
20 src/org/ibex/%/:  repo/%.ibex.org/
21         cd repo/$*.ibex.org; darcs pull -a --verbose http://$*.ibex.org/ 
22         cd src/org/ibex; ln -sf ../../../repo/$*.ibex.org/src $*
23
24
25 ### cleanup targets ##################################################################
26
27 clean:      ; rm -rf build
28 dist-clean: ; rm -rf build .compile
29
30
31 ### java->class compilation ##########################################################
32
33 javac := javac
34 java_sources := $(shell find src/org/ibex/*/ -name \*.java)
35
36 compile: .compile
37 .compile: $(sources)
38         make -s repos
39         $(javac) $(java_sources)
40         touch $@
41
42
43 ### proposing and checkins ##########################################################
44
45 propose-patch:
46         @darcs send --edit-description -o .darcspatch -T patches@xwt.org http://core.ibex.org/
47         @(echo "To: patches@xwt.org";\
48          SUB=`grep -A10000 New.patches .darcspatch | grep '^\\[' | cut -b 2- | tr \\\n , | sed s_,_,\ _g | sed "s_, *\\$$__"`;\
49          echo "Subject: $$SUB";\
50          echo;\
51          cat .darcspatch) | /usr/sbin/sendmail -bm -f $(USER)@xwt.org patches@xwt.org;
52         @rm .darcspatch 
53
54 commit: propose-patch
55         darcs push xwt@xwt.org:/var/www/org/ibex/core/
56
57
58 ### documentation ##########################################################
59
60 doc/%.pdf: build/class/org/ibex/util/XML.class build/class/org/ibex/doc/Doc.class
61         cd doc/$*; java -cp ../../build/class org.ibex.doc.Doc < $*.xml > $*.tex
62         cd doc/$*; pdflatex $*.tex
63         mv doc/$*/$*.pdf doc/$*.pdf
64         test `uname` == Darwin && open doc/$*.pdf