Coccinelle release 1.0.0-rc13
[bpt/coccinelle.git] / engine / 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 ##############################################################################
26 # Variables
27 ##############################################################################
28 #TARGET=matcher
29 ifneq ($(MAKECMDGOALS),distclean)
30 include ../Makefile.config
31 endif
32
33 TARGET=cocciengine
34 CTLTARGET=engine
35
36 SRC= flag_matcher.ml lib_engine.ml pretty_print_engine.ml \
37 check_exhaustive_pattern.ml \
38 check_reachability.ml \
39 c_vs_c.ml isomorphisms_c_c.ml \
40 cocci_vs_c.ml pattern_c.ml transformation_c.ml \
41 asttomember.ml asttoctl2.ml ctltotex.ml \
42 postprocess_transinfo.ml ctlcocci_integration.ml
43
44 INCLUDES = -I ../commons -I ../commons/ocamlextra -I ../globals \
45 -I ../ctl -I ../parsing_cocci -I ../parsing_c
46 LIBS=../commons/commons.cma ../globals/globals.cma \
47 ../ctl/ctl.cma ../parsing_c/parsing_c.cma ../parsing_cocci/cocci_parser.cma
48
49 SYSLIBS= str.cma unix.cma
50
51
52 # just to test asttoctl
53 # CTLSOURCES = lib_engine.ml pretty_print_engine.ml asttoctl.ml ctltotex.ml \
54 # main.ml
55
56 ##############################################################################
57 # Generic variables
58 ##############################################################################
59
60 #for warning: -w A
61 #for profiling: -p -inline 0 with OCAMLOPT
62 OCAMLCFLAGS ?= -g -dtypes
63 OPTFLAGS ?= -g -dtypes
64
65 OCAMLC_CMD=$(OCAMLC) -thread $(OCAMLCFLAGS) $(INCLUDES)
66 OCAMLOPT_CMD=$(OCAMLOPT) -thread $(OPTFLAGS) $(INCLUDES)
67 OCAMLDEP_CMD=$(OCAMLDEP) $(INCLUDESDEP)
68 OCAMLMKTOP_CMD=$(OCAMLMKTOP) -g -custom $(INCLUDES)
69
70 OBJS = $(SRC:.ml=.cmo)
71 OPTOBJS = $(SRC:.ml=.cmx)
72
73
74 ##############################################################################
75 # Top rules
76 ##############################################################################
77 all: $(TARGET).cma
78 all.opt:
79 @$(MAKE) $(TARGET).cmxa BUILD_OPT=yes
80
81 $(TARGET).cma: $(OBJS)
82 $(OCAMLC_CMD) -a -o $(TARGET).cma $(OBJS)
83
84 $(TARGET).cmxa: $(OPTOBJS) $(LIBS:.cma=.cmxa)
85 $(OCAMLOPT_CMD) -a -o $(TARGET).cmxa $(OPTOBJS)
86
87 $(TARGET).top: $(OBJS) $(LIBS)
88 $(OCAMLMKTOP_CMD) -o $(TARGET).top $(SYSLIBS) $(LIBS) $(OBJS)
89
90 clean::
91 rm -f $(TARGET).top
92
93
94
95 ##############################################################################
96 # Pad's rules
97 ##############################################################################
98
99 ##############################################################################
100 # Generic rules
101 ##############################################################################
102
103 .SUFFIXES: .ml .mli .cmo .cmi .cmx
104
105 .ml.cmo:
106 $(OCAMLC_CMD) -c $<
107 .mli.cmi:
108 $(OCAMLC_CMD) -c $<
109 .ml.cmx:
110 $(OCAMLOPT_CMD) -c $<
111
112 .ml.mldepend:
113 $(OCAMLC_CMD) -i $<
114
115 clean::
116 rm -f *.cm[ioxa] *.o *.a *.cmxa *.annot
117 rm -f *~ .*~ gmon.out #*#
118 rm -f .depend
119
120 distclean: clean
121
122 .PHONEY: depend
123 .depend depend:
124 $(OCAMLDEP_CMD) *.mli *.ml > .depend
125
126 ifneq ($(MAKECMDGOALS),clean)
127 ifneq ($(MAKECMDGOALS),distclean)
128 -include .depend
129 endif
130 endif
131
132 include ../Makefile.common