Coccinelle release 1.0.0-rc13
[bpt/coccinelle.git] / python / Makefile
CommitLineData
17ba0788
C
1# Copyright 2012, INRIA
2# Julia Lawall, Gilles Muller
3# Copyright 2010-2011, INRIA, University of Copenhagen
f537ebc4
C
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
34e49164
C
25#############################################################################
26# Configuration section
27#############################################################################
feec80c3
C
28ifneq ($(MAKECMDGOALS),distclean)
29include ../Makefile.config
30endif
34e49164
C
31
32##############################################################################
33# Variables
34##############################################################################
35TARGET=coccipython
36
d6ce1786
C
37OCAMLCFLAGS ?= -g -dtypes
38OPTFLAGS ?= -g -dtypes
39
17ba0788 40SOURCES= pycocci_aux.ml $(PYCOCCI_FILE) pycocci.ml
34e49164 41
413ffc02
C
42INCLUDEDIRS_LOCAL = ../commons ../commons/ocamlextra ../globals \
43 ../parsing_c ../parsing_cocci
44
413ffc02 45INCLUDEDIRS = $(INCLUDEDIRS_LOCAL) $(PYCAMLDIR)
34e49164 46
90aeb998 47SYSLIBS = str.cma unix.cma pycaml.cma
b1b2de81 48LIBS=../commons/commons.cma ../globals/globals.cma
34e49164 49
34e49164
C
50##############################################################################
51# Generic variables
52##############################################################################
53
54INCLUDES=$(INCLUDEDIRS:%=-I %) $(INCLUDESEXTRA)
413ffc02 55INCLUDES_DEPEND=$(INCLUDEDIRS_LOCAL:%=-I %) $(INCLUDESEXTRA)
34e49164
C
56
57##############################################################################
58# Generic ocaml variables
59##############################################################################
60
61# The Caml compilers.
d6ce1786
C
62OCAMLC_CMD=$(OCAMLC) -thread $(OCAMLCFLAGS) $(INCLUDES)
63OCAMLOPT_CMD=$(OCAMLOPT) -thread $(OPTFLAGS) $(INCLUDES)
feec80c3
C
64OCAMLDEP_CMD=$(OCAMLDEP) $(INCLUDES_DEPEND)
65OCAMLMKTOP_CMD=$(OCAMLMKTOP) -g -custom $(INCLUDES)
34e49164
C
66
67##############################################################################
68# Top rules
69##############################################################################
70
71EXEC=$(TARGET).byte
72LIB=$(TARGET).cma
73OPTLIB=$(LIB:.cma=.cmxa)
74
75CTLEXEC=$(CTLTARGET)
76
77OBJS = $(SOURCES:.ml=.cmo)
78OPTOBJS = $(OBJS:.cmo=.cmx)
79
80CTLOBJS = $(CTLSOURCES:.ml=.cmo)
81CTLOPTOBJS = $(CTLOBJS:.cmo=.cmx)
82
34e49164
C
83all: $(LIB)
84
d6ce1786
C
85all.opt:
86 @$(MAKE) $(OPTLIB) BUILD_OPT=yes
34e49164
C
87
88ctl: $(CTLEXEC)
89
90
91$(LIB): $(OBJS)
feec80c3 92 $(OCAMLC_CMD) -a -o $(LIB) $(OBJS)
34e49164
C
93
94clean::
95 rm -f $(LIB)
96
97
b1b2de81 98$(OPTLIB): $(OPTOBJS)
feec80c3 99 $(OCAMLOPT_CMD) -a -o $(OPTLIB) $(OPTOBJS)
34e49164
C
100
101
102$(EXEC): $(OBJS) main.cmo $(LIBS)
feec80c3 103 $(OCAMLC_CMD) -o $(EXEC) $(SYSLIBS) $(LIBS) $(OBJS) main.cmo
34e49164
C
104
105$(CTLEXEC): $(CTLOBJS) $(LIBS)
feec80c3 106 $(OCAMLC_CMD) -o $(CTLEXEC) $(SYSLIBS) $(LIBS) $(CTLOBJS)
34e49164
C
107
108
109clean::
b1b2de81 110 rm -f $(OPTLIB) $(LIB:.cma=.a)
c491d8ee
C
111 rm -f $(TARGET)
112 rm -f $(TARGET).byte
34e49164 113 rm -f $(CTLTARGET)
feec80c3 114 rm -f .depend
34e49164 115
c491d8ee
C
116distclean::
117 $(MAKE) -C coccilib $@
c491d8ee 118 rm -f pycocci.ml
34e49164
C
119
120##############################################################################
121# Generic ocaml rules
122##############################################################################
123
124.SUFFIXES:
125.SUFFIXES: .ml .mli .cmo .cmi .cmx
126
127.ml.cmo:
feec80c3 128 $(OCAMLC_CMD) -c $<
34e49164
C
129
130.mli.cmi:
feec80c3 131 $(OCAMLC_CMD) -c $<
34e49164
C
132
133.ml.cmx:
feec80c3 134 $(OCAMLOPT_CMD) -c $<
34e49164
C
135
136
137# clean rule for others files
138clean::
139 rm -f *.cm[iox] *.o *.annot
b1b2de81
C
140 rm -f *~ .*~ #*#
141
feec80c3
C
142.PHONEY: depend
143.depend depend:
144 $(OCAMLDEP_CMD) *.mli *.ml > .depend
34e49164 145
feec80c3
C
146ifneq ($(MAKECMDGOALS),clean)
147ifneq ($(MAKECMDGOALS),distclean)
34e49164 148-include .depend
feec80c3
C
149endif
150endif
d6ce1786
C
151
152include ../Makefile.common