add machinery to create merged Coq script GArrow.v
[coq-hetmet.git] / Makefile
1 coqc     := coqc -noglob
2 coqfiles := $(shell find src -name \*.v  | grep -v \\\#)
3 allfiles := $(coqfiles) $(shell find src -name \*.hs | grep -v \\\#)
4
5 default: build/CoqPass.hs
6
7 build/CoqPass.hs: $(allfiles)
8         make build/Makefile.coq
9         cd build; make -f Makefile.coq Extraction.vo
10         cat src/Extraction-prefix.hs                                     > build/CoqPass.hs
11         cat build/Extraction.hs | grep -v '^module' | grep -v '^import' >> build/CoqPass.hs
12
13 build/Makefile.coq: $(coqfiles) src/categories/src
14         mkdir -p build
15         rm -f build/*.v
16         rm -f build/*.d
17         cd build; ln -fs `find ../src -name \*.v` .
18         cd build; coq_makefile *.v > Makefile.coq
19
20 src/categories/src:
21         git submodule update --init src/categories
22         cd compiler/categories; git checkout master
23
24 clean:
25         rm -rf build
26
27 merged:
28         mkdir -p .temp
29         cd src; for A in *.v; do cat $$A  | grep -v '^Require Import' > ../.temp/`echo $$A | sed s_\\\\.v_._`; done
30         cd src/categories/src; for A in *.v; do cat $$A  | grep -v '^Require Import' > ../../../.temp/`echo $$A | sed s_\\\\.v_._`; done
31         cp src/Banner.v .temp/GArrows.v
32         cd .temp; grep '^Require Import ' ../src/All.v | sed 's_Require Import _echo;echo;echo;echo;echo;cat _' | bash >> GArrows.v
33         cd .temp; time $(coqc) -dont-load-proofs -verbose GArrows.v
34         echo
35         echo COMPILATION OK
36         echo
37
38
39 # this is for Adam's use only!
40 push: build/CoqPass.hs
41         git push http://git.megacz.com/coq-hetmet.git master
42         git add -f build/CoqPass.hs; \
43           git commit -m 'update baked-in CoqPass.hs' && \
44           (git push -f http://git.megacz.com/coq-hetmet.git master:coq-extraction-baked-in; \
45            git reset HEAD^)
46         rm -rf .temp
47         mkdir .temp
48         cd .temp; ln -s ../src/*.v .
49         cd .temp; for A in *.v; do \
50           echo Latexing $$A ... ;\
51           echo '\\documentclass[9pt,landscape]{article}' > $$A.tex; \
52           echo '\\usepackage[landscape]{geometry}'       >> $$A.tex; \
53           echo '\\usepackage[cm]{fullpage}'       >> $$A.tex; \
54           echo '\\usepackage{amsmath}'        >> $$A.tex; \
55           echo '\\usepackage{amssymb}'        >> $$A.tex; \
56           echo '\\usepackage{stmaryrd}'       >> $$A.tex; \
57           echo '\\usepackage{upgreek}'        >> $$A.tex; \
58           echo '\\usepackage{parskip}'        >> $$A.tex; \
59           echo '\\begin{document}'            >> $$A.tex; \
60           echo '{{\\tt{'           >> $$A.tex; \
61           echo ''           >> $$A.tex; \
62           java -jar ~/bin/unicode2tex.jar < ../src/$$A >> $$A.tex;\
63           echo '}}}'                           >> $$A.tex; \
64           echo '\\end{document}'              >> $$A.tex; \
65           pdflatex $$A.tex < /dev/null; done
66         ssh login.eecs.berkeley.edu -- 'rm public_html/coq-in-ghc/pdfs/*.pdf' ; true
67         scp .temp/*.pdf login.eecs.berkeley.edu:public_html/coq-in-ghc/pdfs/
68         rm -rf .temp