Combine generator subdirectories into one.
[wrappi.git] / generator / Makefile.am
1 # wrappi
2 # Copyright (C) 2011-2012 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         $(OCAMLPACKAGES)
23 OCAMLOPTFLAGS = $(OCAMLCFLAGS)
24
25 # In alphabetical order.
26 SOURCES = \
27         config.ml \
28         wrappi_accumulator.mli \
29         wrappi_accumulator.ml \
30         wrappi_boilerplate.mli \
31         wrappi_boilerplate.ml \
32         wrappi_c_impl.mli \
33         wrappi_c_impl.ml \
34         wrappi_c_xdr.mli \
35         wrappi_c_xdr.ml \
36         wrappi_c.mli \
37         wrappi_c.ml \
38         wrappi_enums.mli \
39         wrappi_enums.ml \
40         wrappi_main.ml \
41         wrappi_pr.mli \
42         wrappi_pr.ml \
43         wrappi_structs.mli \
44         wrappi_structs.ml \
45         wrappi_types.mli \
46         wrappi_types.ml \
47         wrappi_utils.mli \
48         wrappi_utils.ml
49
50 # The difference between LIB_OBJECTS and OBJECTS is just that
51 # functions and types in LIB_OBJECTS can be used in pa_wrap and in the
52 # code generated from the API objects (../APIs/*.api).  LIB_OBJECTS
53 # are built into generator_lib.cma which is linked to pa_wrap, and to
54 # the APIs, and into the generator.
55 #
56 # In dependency order.
57 LIB_OBJECTS = \
58         config.cmo \
59         wrappi_utils.cmo \
60         wrappi_types.cmo \
61         wrappi_accumulator.cmo
62
63 OBJECTS = \
64         wrappi_pr.cmo \
65         wrappi_boilerplate.cmo \
66         wrappi_enums.cmo \
67         wrappi_structs.cmo \
68         wrappi_c_impl.cmo \
69         wrappi_c_xdr.cmo \
70         wrappi_c.cmo \
71         wrappi_main.cmo
72
73 noinst_SCRIPTS = generator_lib.cma pa_wrap.cmo generator
74
75 generator_lib.cma: $(LIB_OBJECTS)
76         $(OCAMLFIND) ocamlc -a $^ -o $@
77
78 pa_wrap.cmo: pa_wrap.ml generator_lib.cma
79         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \
80           -linkpkg generator_lib.cma \
81           -pp $(CAMLP4OF) \
82           -c $< -o $@
83
84 generator: generator_lib.cma $(OBJECTS) ../APIs/apis.cma
85         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \
86           -linkpkg generator_lib.cma ../APIs/apis.cma $(OBJECTS) \
87           -o $@
88
89 ../APIs/apis.cma: generator_lib.cma pa_wrap.cmo
90         $(MAKE) -C ../APIs apis.cma
91
92 %.cmi: %.mli
93         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
94 %.cmo: %.ml
95         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
96 %.cmx: %.ml
97         $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -c $< -o $@
98
99 # Run the generator.
100 noinst_DATA = stamp-generator
101
102 stamp-generator: generator
103         cd $(top_srcdir) && generator/generator
104
105 depend: .depend
106
107 .depend: $(SOURCES)
108         rm -f $@ $@-t
109         $(OCAMLFIND) ocamldep $^ | \
110           $(SED) -e 's/ *$$//' | \
111           $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
112           LANG=C sort > $@-t
113         mv $@-t $@
114
115 include .depend
116
117 CLEANFILES = *.cmi *.cmo *.cmx *.cma *.cmxa *~ generator
118
119 SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly