- Try to do better pretty printing when array elements are individually
[bpt/coccinelle.git] / python / 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 #############################################################################
27 # Configuration section
28 #############################################################################
29 ifneq ($(MAKECMDGOALS),distclean)
30 include ../Makefile.config
31 endif
32
33 ##############################################################################
34 # Variables
35 ##############################################################################
36 TARGET=coccipython
37
38 OCAMLCFLAGS ?= -g
39 OPTFLAGS ?= -g
40
41 SOURCES= pycocci_aux.ml $(PYCOCCI_FILE) pycocci.ml
42
43 INCLUDEDIRS_LOCAL = ../commons ../commons/ocamlextra ../globals \
44 ../parsing_c ../parsing_cocci
45
46 INCLUDEDIRS = $(INCLUDEDIRS_LOCAL) $(PYCAMLDIR)
47
48 SYSLIBS = str.cma unix.cma pycaml.cma
49 LIBS=../commons/commons.cma ../globals/globals.cma
50
51 ##############################################################################
52 # Generic variables
53 ##############################################################################
54
55 INCLUDES=$(INCLUDEDIRS:%=-I %) $(INCLUDESEXTRA)
56 INCLUDES_DEPEND=$(INCLUDEDIRS_LOCAL:%=-I %) $(INCLUDESEXTRA)
57
58 ##############################################################################
59 # Generic ocaml variables
60 ##############################################################################
61
62 # The Caml compilers.
63 OCAMLC_CMD=$(OCAMLC) $(OCAMLCFLAGS) $(INCLUDES)
64 OCAMLOPT_CMD=$(OCAMLOPT) $(OPTFLAGS) $(INCLUDES)
65 OCAMLDEP_CMD=$(OCAMLDEP) $(INCLUDES_DEPEND)
66 OCAMLMKTOP_CMD=$(OCAMLMKTOP) -g -custom $(INCLUDES)
67
68 ##############################################################################
69 # Top rules
70 ##############################################################################
71
72 EXEC=$(TARGET).byte
73 LIB=$(TARGET).cma
74 OPTLIB=$(LIB:.cma=.cmxa)
75
76 CTLEXEC=$(CTLTARGET)
77
78 OBJS = $(SOURCES:.ml=.cmo)
79 OPTOBJS = $(OBJS:.cmo=.cmx)
80
81 CTLOBJS = $(CTLSOURCES:.ml=.cmo)
82 CTLOPTOBJS = $(CTLOBJS:.cmo=.cmx)
83
84 ifneq ($(FEATURE_OCAMLBUILD),yes)
85 all: $(LIB)
86
87 all.opt:
88 @$(MAKE) $(OPTLIB) BUILD_OPT=yes
89
90 ctl: $(CTLEXEC)
91
92
93 $(LIB): $(OBJS)
94 $(OCAMLC_CMD) -a -o $(LIB) $(OBJS)
95
96 clean::
97 rm -f $(TARGET).cma $(TARGET).a $(TARGET).o $(TARGET).cmxa
98
99
100 $(OPTLIB): $(OPTOBJS)
101 $(OCAMLOPT_CMD) -a -o $(OPTLIB) $(OPTOBJS)
102
103
104 $(EXEC): $(OBJS) main.cmo $(LIBS)
105 $(OCAMLC_CMD) -o $(EXEC) $(SYSLIBS) $(LIBS) $(OBJS) main.cmo
106
107 $(CTLEXEC): $(CTLOBJS) $(LIBS)
108 $(OCAMLC_CMD) -o $(CTLEXEC) $(SYSLIBS) $(LIBS) $(CTLOBJS)
109 else
110 all:
111 cd .. && $(OCAMLBUILD) python/python.cma
112 all.opt:
113 cd .. && $(OCAMLBUILD) python/python.cmxa
114 clean::
115 cd .. && $(OCAMLBUILD) -clean
116 endif
117
118 clean::
119 rm -f $(OPTLIB) $(LIB:.cma=.a)
120 rm -f $(TARGET)
121 rm -f $(TARGET).byte
122 rm -f $(CTLTARGET)
123 rm -f .depend
124 rm -f coccipython.cmxa coccipython.a
125
126 distclean::
127 $(MAKE) -C coccilib $@
128 rm -f pycocci.ml
129 rm -f *.cm[ioxa] *.o *.annot
130
131 ##############################################################################
132 # Generic ocaml rules
133 ##############################################################################
134
135 .SUFFIXES:
136 .SUFFIXES: .ml .mli .cmo .cmi .cmx
137
138 .ml.cmo:
139 $(OCAMLC_CMD) -c $<
140
141 .mli.cmi:
142 $(OCAMLC_CMD) -c $<
143
144 .ml.cmx:
145 $(OCAMLOPT_CMD) -c $<
146
147
148 # clean rule for others files
149 clean::
150 rm -f *.cm[iox] *.o *.annot
151 rm -f *~ .*~ #*#
152
153 .PHONEY: depend
154 .depend depend:
155 $(OCAMLDEP_CMD) *.mli *.ml > .depend
156
157 ifneq ($(MAKECMDGOALS),clean)
158 ifneq ($(MAKECMDGOALS),distclean)
159 ifneq ($(FEATURE_OCAMLBUILD),yes)
160 -include .depend
161 endif
162 endif
163 endif
164
165 include ../Makefile.common