Coccinelle release-1.0.0-rc11
[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 # Configuration section
27 #############################################################################
28 -include ../Makefile.config
29
30 ##############################################################################
31 # Variables
32 ##############################################################################
33 TARGET=coccipython
34
35 SOURCES= pycocci_aux.ml $(PYCOCCI_FILE) pycocci.ml
36
37 INCLUDEDIRS_LOCAL = ../commons ../commons/ocamlextra ../globals \
38 ../parsing_c ../parsing_cocci
39
40 ifeq ("$(PYCAMLDIR)", "pycaml")
41 INCLUDEDIRS_LOCAL += ../$(PYCAMLDIR)
42 INCLUDEDIRS = $(INCLUDEDIRS_LOCAL)
43 else
44 INCLUDEDIRS = $(INCLUDEDIRS_LOCAL) $(PYCAMLDIR)
45 endif
46
47 SYSLIBS = str.cma unix.cma pycaml.cma
48 LIBS=../commons/commons.cma ../globals/globals.cma
49
50 ##############################################################################
51 # Generic variables
52 ##############################################################################
53
54 INCLUDES=$(INCLUDEDIRS:%=-I %) $(INCLUDESEXTRA)
55 INCLUDES_DEPEND=$(INCLUDEDIRS_LOCAL:%=-I %) $(INCLUDESEXTRA)
56
57 ##############################################################################
58 # Generic ocaml variables
59 ##############################################################################
60
61 # The Caml compilers.
62 OCAMLCFLAGS ?= -g -dtypes
63 OCAMLC =ocamlc$(OPTBIN) $(OCAMLCFLAGS) $(INCLUDES)
64 OCAMLOPT = ocamlopt$(OPTBIN) $(OPTFLAGS) $(INCLUDES)
65 OCAMLDEP = ocamldep$(OPTBIN) $(INCLUDES_DEPEND)
66
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
85 #all: $(EXEC) $(LIB)
86 all: $(LIB)
87
88 all.opt: $(OPTLIB)
89
90 ctl: $(CTLEXEC)
91
92
93 $(LIB): $(OBJS)
94 $(OCAMLC) -a -o $(LIB) $(OBJS)
95
96 clean::
97 rm -f $(LIB)
98
99
100 $(OPTLIB): $(OPTOBJS)
101 $(OCAMLOPT) -a -o $(OPTLIB) $(OPTOBJS)
102
103
104 $(EXEC): $(OBJS) main.cmo $(LIBS)
105 $(OCAMLC) -o $(EXEC) $(SYSLIBS) $(LIBS) $(OBJS) main.cmo
106
107 $(CTLEXEC): $(CTLOBJS) $(LIBS)
108 $(OCAMLC) -o $(CTLEXEC) $(SYSLIBS) $(LIBS) $(CTLOBJS)
109
110
111 clean::
112 rm -f $(OPTLIB) $(LIB:.cma=.a)
113 rm -f $(TARGET)
114 rm -f $(TARGET).byte
115 rm -f $(CTLTARGET)
116
117 distclean::
118 $(MAKE) -C coccilib $@
119 rm -f .depend
120 rm -f pycocci.ml
121
122 ##############################################################################
123 # Generic ocaml rules
124 ##############################################################################
125
126 .SUFFIXES:
127 .SUFFIXES: .ml .mli .cmo .cmi .cmx
128
129 .ml.cmo:
130 $(OCAMLC) -c $<
131
132 .mli.cmi:
133 $(OCAMLC) -c $<
134
135 .ml.cmx:
136 $(OCAMLOPT) -c $<
137
138
139 # clean rule for others files
140 clean::
141 rm -f *.cm[iox] *.o *.annot
142 rm -f *~ .*~ #*#
143
144 beforedepend:
145
146 depend: beforedepend
147 $(OCAMLDEP) *.mli *.ml > .depend
148
149 .depend:
150 $(OCAMLDEP) *.mli *.ml > .depend
151
152 -include .depend