31d1b102ea3d55c32695c5862779515f011ecde9
[wrappi.git] / generator / Makefile.am
1 # wrappi
2 # Copyright (C) 2011 Red Hat Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18 OCAMLPACKAGES = -package unix,camlp4.lib
19
20 OCAMLCFLAGS = \
21         -g -warn-error CDEFLMPSUVYZX \
22         -I ../generator-lib $(OCAMLPACKAGES)
23 OCAMLOPTFLAGS = $(OCAMLCFLAGS)
24
25 # In alphabetical order.
26 SOURCES = \
27         wrappi_boilerplate.mli \
28         wrappi_boilerplate.ml \
29         wrappi_c.mli \
30         wrappi_c.ml \
31         wrappi_main.ml \
32         wrappi_pr.mli \
33         wrappi_pr.ml
34
35 # In dependency order.
36 OBJECTS = \
37         wrappi_pr.cmo \
38         wrappi_boilerplate.cmo \
39         wrappi_c.cmo \
40         wrappi_main.cmo
41
42 noinst_SCRIPTS = generator
43
44 generator: $(OBJECTS) ../generator-lib/generator_lib.cma ../APIs/apis.cma
45         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -linkpkg \
46           ../generator-lib/generator_lib.cma ../APIs/apis.cma \
47           $(OBJECTS) \
48           -o $@
49
50 %.cmi: %.mli
51         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
52 %.cmo: %.ml
53         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
54 %.cmx: %.ml
55         $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -c $< -o $@
56
57 # Run the generator.
58 noinst_DATA = stamp-generator
59
60 stamp-generator: generator
61         cd $(top_srcdir) && generator/generator
62
63 depend: .depend
64
65 .depend: $(SOURCES)
66         rm -f $@ $@-t
67         $(OCAMLFIND) ocamldep $^ | \
68           $(SED) -e 's/ *$$//' | \
69           $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
70           LANG=C sort > $@-t
71         mv $@-t $@
72
73 include .depend
74
75 CLEANFILES = *.cmi *.cmo *.cmx *~ generator
76
77 SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly