Release coccinelle-0.2.3rc2
[bpt/coccinelle.git] / python / Makefile
1 # Copyright 2010, INRIA, University of Copenhagen
2 # Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix
3 # Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
4 # Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
5 # This file is part of Coccinelle.
6 #
7 # Coccinelle is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, according to version 2 of the License.
10 #
11 # Coccinelle is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
18 #
19 # The authors reserve the right to distribute this or future versions of
20 # Coccinelle under other licenses.
21
22
23 #############################################################################
24 # Configuration section
25 #############################################################################
26 -include ../Makefile.config
27
28 ##############################################################################
29 # Variables
30 ##############################################################################
31 TARGET=coccipython
32
33 SOURCES= pycocci_aux.ml pycocci.ml
34
35 ifeq ("$(PYCAMLDIR)", "pycaml")
36 INCLUDEDIRS = ../commons ../commons/ocamlextra ../globals ../$(PYCAMLDIR) \
37 ../parsing_c ../parsing_cocci
38 else
39 INCLUDEDIRS = ../commons ../commons/ocamlextra ../globals $(PYCAMLDIR) \
40 ../parsing_c ../parsing_cocci
41 endif
42
43 SYSLIBS = str.cma unix.cma pycaml.cma
44 LIBS=../commons/commons.cma ../globals/globals.cma
45
46 ##############################################################################
47 # Generic variables
48 ##############################################################################
49
50 INCLUDES=$(INCLUDEDIRS:%=-I %) $(INCLUDESEXTRA)
51
52 ##############################################################################
53 # Generic ocaml variables
54 ##############################################################################
55
56 # The Caml compilers.
57 OCAMLCFLAGS ?= -g -dtypes
58 OCAMLC =ocamlc$(OPTBIN) $(OCAMLCFLAGS) $(INCLUDES)
59 OCAMLOPT = ocamlopt$(OPTBIN) $(OPTFLAGS) $(INCLUDES)
60 OCAMLDEP = ocamldep$(OPTBIN) $(INCLUDES)
61
62
63 ##############################################################################
64 # Top rules
65 ##############################################################################
66
67 EXEC=$(TARGET).byte
68 LIB=$(TARGET).cma
69 OPTLIB=$(LIB:.cma=.cmxa)
70
71 CTLEXEC=$(CTLTARGET)
72
73 OBJS = $(SOURCES:.ml=.cmo)
74 OPTOBJS = $(OBJS:.cmo=.cmx)
75
76 CTLOBJS = $(CTLSOURCES:.ml=.cmo)
77 CTLOPTOBJS = $(CTLOBJS:.cmo=.cmx)
78
79
80 #all: $(EXEC) $(LIB)
81 all: $(LIB)
82
83 all.opt: $(OPTLIB)
84
85 ctl: $(CTLEXEC)
86
87
88 $(LIB): $(OBJS)
89 $(OCAMLC) -a -o $(LIB) $(OBJS)
90
91 clean::
92 rm -f $(LIB)
93
94
95 $(OPTLIB): $(OPTOBJS)
96 $(OCAMLOPT) -a -o $(OPTLIB) $(OPTOBJS)
97
98
99 $(EXEC): $(OBJS) main.cmo $(LIBS)
100 $(OCAMLC) -o $(EXEC) $(SYSLIBS) $(LIBS) $(OBJS) main.cmo
101
102 $(CTLEXEC): $(CTLOBJS) $(LIBS)
103 $(OCAMLC) -o $(CTLEXEC) $(SYSLIBS) $(LIBS) $(CTLOBJS)
104
105
106 clean::
107 rm -f $(OPTLIB) $(LIB:.cma=.a)
108 rm -f $(TARGET) rm -f $(TARGET).byte
109 rm -f $(CTLTARGET)
110
111
112 #pycocci.ml: ../pycaml/pycaml.ml ../pycaml/pycaml_ml.c
113 #pycocci_aux.ml: ../pycaml/pycaml.ml ../pycaml/pycaml_ml.c
114 pycocci_aux.ml:
115 @echo "\n\n\t*** pycocci_aux.ml not found ! ***\n\n\tRun 'configure && make depend' first.\n\n"
116
117 rmlinks:
118 rm -f pycocci.ml pycocci_aux.ml
119
120 ##############################################################################
121 # Generic ocaml rules
122 ##############################################################################
123
124 .SUFFIXES:
125 .SUFFIXES: .ml .mli .cmo .cmi .cmx
126
127 .ml.cmo:
128 $(OCAMLC) -c $<
129
130 .mli.cmi:
131 $(OCAMLC) -c $<
132
133 .ml.cmx:
134 $(OCAMLOPT) -c $<
135
136
137 # clean rule for others files
138 clean::
139 rm -f *.cm[iox] *.o *.annot
140 rm -f *~ .*~ #*#
141
142 distclean::
143 rm -f .depend
144
145 beforedepend:
146
147 depend: beforedepend
148 $(OCAMLDEP) *.mli *.ml > .depend
149
150 .depend:
151 $(OCAMLDEP) *.mli *.ml > .depend
152
153 -include .depend