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