]> matita.cs.unibo.it Git - pkg-cerco/acc.git/blob - Makefile.generic
Package description and copyright added.
[pkg-cerco/acc.git] / Makefile.generic
1 # -*- Makefile -*-
2 BTARGET  = $(TARGET).byte
3 JTARGET  = $(TARGET).js
4 OTARGET  = $(TARGET).native
5 BLTARGET = $(TARGET).cma
6 BNTARGET = $(TARGET).cmxa
7 STARGET  = $(shell if `which ocamlopt`; then \
8                    echo $(OTARGET);          \
9               else echo $(BTARGET); fi)
10
11 PREFIX ?= /usr/local
12
13 TESTDIR  = tests
14
15 #########################
16 ## Tools configuration ##
17 #########################
18
19 # Menhir can be told to produce a parser that explains what
20 # it is doing. 
21 ifeq ($(DEBUGPARSING), yes)
22   MENHIROPT=-yaccflag --explain -yaccflag --trace
23 else
24   MENHIROPT=-yaccflag --explain 
25 endif
26
27 # In Emacs, use classic display to enable error jumping.
28 TERM = $(shell echo $$TERM)
29 ifeq ($(TERM), dumb)
30  OCAMLBUILD = $(OCAMLBUILDCMD) -use-ocamlfind -cflag "-dtypes" -tag debug -classic-display -no-hygiene $(MENHIROPT)
31 else
32  OCAMLBUILD = $(OCAMLBUILDCMD) -use-ocamlfind -no-hygiene $(MENHIROPT) -lflags -I,`pwd`/lib
33 endif
34
35 ifeq ($(PROFILE), 1)
36   OCAMLBUILD += -tag profile
37 endif
38
39
40 OCAMLDOC = ocamldoc
41 HEADACHE = headache
42
43 #########
44 # Rules #
45 #########
46
47 .PHONY: configure all-generic byte opt doc clean dist install uninstall headers clear
48
49 all-generic: configure clear $(STARGET) $(TARGET) 
50
51 $(TARGET):
52         ln -s $(STARGET) $(TARGET)
53
54 clear:
55         @ rm -f $(STARGET)
56
57 opt: $(OTARGET)
58
59 byte: $(BTARGET)
60
61 %:
62         @ $(OCAMLBUILD) src/$@
63
64 $(JTARGET): 
65         @ $(OCAMLBUILD) -use-ocamlfind -tag "use-nums" -tag "package(js_of_ocaml)" src/$(BTARGET)
66         js_of_ocaml $(BTARGET)
67
68 byte-debug:
69         $(OCAMLBUILD) -tag debug src/$(BTARGET)
70
71 ifeq ($(strip $(PREFIX)),)
72 install uninstall:
73         @echo "Cannot (un)install $(EXECUTABLE): the PREFIX variable is undefined." && false
74 else
75 install: $(EXECUTABLE)
76         mkdir -p $(PREFIX)/bin/
77         install $(STARGET) $(PREFIX)/bin/$(TARGET)
78 uninstall:
79         /bin/rm -f $(PREFIX)/bin/$(TARGET)
80 endif
81
82 #######################
83 # Administrative part #
84 #######################
85
86 headers:
87         for i in src/*.ml src/*.mli src/*.mly; do \
88            $(HEADACHE) -h admin/header -c admin/headache.cfg $$i; \
89         done
90
91 clean:
92         @ $(OCAMLBUILD) -clean
93         make -C cparser clean 
94         make -C $(TESTDIR) clean
95         find -name '*~' -exec rm '{}' \;
96         rm -fr config.log config.status *~ $(TARGET) $(PACKAGE) $(PACKAGE).tar.gz
97
98 doc: byte
99         $(OCAMLBUILD) $(TARGET).docdir/index.html
100         mkdir -p doc/html
101         rm -f $(TARGET).docdir/style.css 2> /dev/null
102         mv $(TARGET).docdir/* doc/html
103         rm $(TARGET).docdir
104
105 dist:
106         rm -fr $(PACKAGE)
107         mkdir $(PACKAGE)
108         for i in `cat distributed_files` doc/html/*.html; do    \
109           if test -f $$i; then                                  \
110             cp -fr --parents $$i $(PACKAGE);                    \
111           else                                                  \
112             mkdir -p $$i;                                       \
113           fi;                                                   \
114         done
115         tar cvfz $(PACKAGE).tar.gz $(PACKAGE)
116
117 check: all
118         $(MAKE) -C $(TESTDIR) check