permit multiline comments and strings in macros
[bpt/coccinelle.git] / ctl / Makefile
1 # Copyright 2012, INRIA
2 # Julia Lawall, Gilles Muller
3 # Copyright 2010-2011, INRIA, University of Copenhagen
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
25 ifneq ($(MAKECMDGOALS),distclean)
26 include ../Makefile.config
27 endif
28
29 TARGET=ctl
30
31 SRC=flag_ctl.ml ast_ctl.ml pretty_print_ctl.ml ctl_engine.ml wrapper_ctl.ml
32
33 SYSLIBS=str.cma unix.cma
34 LIBS=../commons/commons.cma ../globals/globals.cma
35
36 INCLUDES=-I ../commons -I ../commons/ocamlextra -I ../globals
37
38
39 #The Caml compilers.
40 #for warning: -w A
41 #for profiling: -p -inline 0 with OCAMLOPT
42 OCAMLCFLAGS ?= -g
43 OPTFLAGS ?= -g
44 OCAMLC_CMD=$(OCAMLC) $(OCAMLCFLAGS) $(INCLUDES)
45 OCAMLOPT_CMD=$(OCAMLOPT) $(OPTFLAGS) $(INCLUDES)
46 OCAMLDEP_CMD=$(OCAMLDEP) $(INCLUDES)
47 OCAMLMKTOP_CMD=$(OCAMLMKTOP) -g -custom $(INCLUDES)
48
49 LIB=$(TARGET).cma
50 OPTLIB=$(LIB:.cma=.cmxa)
51
52 OBJS = $(SRC:.ml=.cmo)
53 OPTOBJS = $(SRC:.ml=.cmx)
54
55
56 ifneq ($(FEATURE_OCAMLBUILD),yes)
57 all: $(LIB)
58 all.opt:
59 @$(MAKE) $(OPTLIB) BUILD_OPT=yes
60
61 $(TARGET).top: $(LIB) test_ctl.cmo
62 $(OCAMLMKTOP_CMD) -o $(TARGET).top $(SYSLIBS) $(LIBS) $(OBJS) test_ctl.cmo
63
64 $(LIB): $(OBJS)
65 $(OCAMLC_CMD) -a -o $(LIB) $(OBJS)
66
67 $(OPTLIB): $(OPTOBJS)
68 $(OCAMLOPT_CMD) -a -o $(OPTLIB) $(OPTOBJS)
69
70 clean::
71 rm -f $(LIB) $(OPTLIB) $(LIB:.cma=.a) $(TARGET).top
72 else
73 all:
74 cd .. && $(OCAMLBUILD) ctl/ctl.cma
75
76 all.opt:
77 cd .. && $(OCAMLBUILD) ctl/ctl.cmxa
78
79 clean::
80 cd .. && $(OCAMLBUILD) -clean
81 rm -f test_ctl
82
83 test_ctl:
84 cd .. && $(OCAMLBUILD) ctl/test_ctl.byte
85 cp ../_build/ctl/test_ctl.byte test_ctl
86 endif
87
88
89 .SUFFIXES:
90 .SUFFIXES: .ml .mli .cmo .cmi .cmx
91
92 .ml.cmo:
93 $(OCAMLC_CMD) -c $<
94
95 .mli.cmi:
96 $(OCAMLC_CMD) -c $<
97
98 .ml.cmx:
99 $(OCAMLOPT_CMD) -c $<
100
101
102 # clean rule for other files
103 clean::
104 rm -f *.cm[iox] *.o *.annot
105 rm -f *~ .*~ #*#
106 rm -f .depend
107
108 distclean: clean
109
110 .PHONEY: depend
111 .depend depend:
112 $(OCAMLDEP_CMD) *.mli *.ml > .depend
113
114 ifneq ($(MAKECMDGOALS),clean)
115 ifneq ($(MAKECMDGOALS),distclean)
116 ifneq ($(FEATURE_OCAMLBUILD),yes)
117 -include .depend
118 endif
119 endif
120 endif
121
122 include ../Makefile.common