permit multiline comments and strings in macros
[bpt/coccinelle.git] / tools / Makefile
CommitLineData
17ba0788
C
1# Copyright 2012, INRIA
2# Julia Lawall, Gilles Muller
3# Copyright 2010-2011, INRIA, University of Copenhagen
f537ebc4
C
4# Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix
5# Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
6# Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
7# This file is part of Coccinelle.
8#
9# Coccinelle is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, according to version 2 of the License.
12#
13# Coccinelle is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
20#
21# The authors reserve the right to distribute this or future versions of
22# Coccinelle under other licenses.
23
24
feec80c3
C
25ifneq ($(MAKECMDGOALS),distclean)
26include ../Makefile.config
27endif
0708f913 28
755320b0
C
29OCAMLCFLAGS ?= -g
30OPTFLAGS ?= -g
d6ce1786 31
abad11c5
C
32SYSLIBS = str.cma unix.cma bigarray.cma
33
34INCLUDE=-I ../commons -I ../extra -I ../parsing_c
35LIBS=../commons/commons.cma ../globals/globals.cma \
36 ../parsing_c/parsing_c.cma ../extra/extra.cma
37
38OCAMLC_CMD=$(OCAMLC) $(OCAMLCFLAGS) $(INCLUDE)
39OCAMLOPT_CMD=$(OCAMLOPT) $(OPTFLAGS) $(INCLUDE)
40OCAMLDEP_CMD=$(OCAMLDEP) $(INCLUDE)
41OCAMLMKTOP_CMD=$(OCAMLMKTOP) -g -custom $(INCLUDE)
42OCAMLYACC_CMD=$(OCAMLYACC) -v
43
34e49164 44
abad11c5
C
45PROGS=spp gitgrep splitpatch extract_c_and_res \
46 gitsort alloc_free bridge \
47 process_isoprofile
48 #generate_dependencies
49
50ifneq ($(FEATURE_OCAMLBUILD),yes)
51all: $(PROGS)
34e49164 52
d6ce1786
C
53all.opt:
54 @$(MAKE) $(PROGS) BUILD_OPT=yes
34e49164
C
55
56gitgrep: gitgrep.ml
feec80c3 57 $(OCAMLOPT) -o gitgrep str.cmxa gitgrep.ml
34e49164
C
58
59gitsort: gitsort.ml
feec80c3 60 $(OCAMLOPT) -o gitsort str.cmxa gitsort.ml
34e49164 61
abad11c5
C
62process_isoprofile: process_isoprofile.ml
63 $(OCAMLC) -g -o process_isoprofile str.cma process_isoprofile.ml
34e49164
C
64
65alloc_free: alloc_free.ml
feec80c3 66 $(OCAMLOPT) -o alloc_free str.cmxa alloc_free.ml
34e49164
C
67
68# more flexible version of alloc_free
69bridge: bridge.ml
feec80c3 70 $(OCAMLOPT) -o bridge str.cmxa dumper.mli dumper.ml bridge.ml
34e49164
C
71
72install_bridge: bridge
73 cp -f bridge /usr/local/bin
74
978fd7e5 75spp: spp.ml
feec80c3 76 $(OCAMLC_CMD) -o $@ $(SYSLIBS) $(INCLUDE) $(LIBS) $+
978fd7e5 77
c491d8ee 78splitpatch: splitpatch.cmo
feec80c3 79 $(OCAMLC_CMD) -o $@ $(SYSLIBS) $(INCLUDE) $+
34e49164
C
80
81extract_c_and_res: extract_c_and_res.cmo
feec80c3 82 $(OCAMLC_CMD) -o $@ $(SYSLIBS) $(INCLUDE) $(LIBS) $+
34e49164 83
34e49164 84generate_dependencies: generate_dependencies.cmo
feec80c3 85 $(OCAMLC_CMD) -o $@ $(SYSLIBS) $(INCLUDE) $(LIBS) $+
abad11c5
C
86else
87.PHONY: $(PROGS) $(PROGS:%.opt) isoprof
88
89all: $(PROGS)
90all.opt: $(PROGS:%=%.opt)
91
92$(PROGS):
93 cd .. && $(OCAMLBUILD) tools/$@.byte
94 cp ../_build/tools/$@.byte $@
95
96$(PROGS:%=%.opt):
97 cd .. && $(OCAMLBUILD) tools/$(@:%.opt=%).native
98 cp ../_build/tools/$(@:%.opt=%).native $(@:%.opt=%)
99
100clean::
101 cd .. && $(OCAMLBUILD) -clean
102 rm -f $(PROGS)
103endif
104
105isoprof: process_isoprofile
106 cp process_isoprofile isoprof
107
34e49164 108
34e49164
C
109.SUFFIXES: .ml .mli .cmo .cmi .cmx
110
111.ml.cmo:
feec80c3 112 $(OCAMLC_CMD) -c $<
34e49164 113.mli.cmi:
feec80c3 114 $(OCAMLC_CMD) -c $<
34e49164 115.ml.cmx:
feec80c3 116 $(OCAMLOPT_CMD) -c $<
34e49164 117
abad11c5
C
118clean::
119 rm -f $(PROGS) isoprof
34e49164 120 rm -f *.cm[ioxa] *.o *.a *.cmxa *.annot
feec80c3 121 rm -f .depend
34e49164 122
feec80c3 123distclean: clean
34e49164 124
feec80c3
C
125.PHONEY: depend
126.depend depend: beforedepend
127 ocamldep $(INCLUDE) *.mli *.ml > .depend
b1b2de81 128
feec80c3
C
129ifneq ($(MAKECMDGOALS),clean)
130ifneq ($(MAKECMDGOALS),distclean)
34e49164 131-include .depend
feec80c3
C
132endif
133endif
d6ce1786
C
134
135include ../Makefile.common