binary: Link guestmount static binary with -lm.
[libguestfs.git] / generator / Makefile.am
1 # libguestfs
2 # Copyright (C) 2010 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., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 SOURCES = \
19         generator_types.ml \
20         generator_utils.mli \
21         generator_utils.ml \
22         generator_actions.mli \
23         generator_actions.ml \
24         generator_structs.mli \
25         generator_structs.ml \
26         generator_optgroups.ml \
27         generator_prepopts.mli \
28         generator_prepopts.ml \
29         generator_pr.mli \
30         generator_pr.ml \
31         generator_docstrings.ml \
32         generator_checks.ml \
33         generator_c.ml \
34         generator_xdr.ml \
35         generator_daemon.ml \
36         generator_capitests.ml \
37         generator_fish.ml \
38         generator_ocaml.ml \
39         generator_perl.ml \
40         generator_python.ml \
41         generator_ruby.ml \
42         generator_java.ml \
43         generator_haskell.ml \
44         generator_csharp.ml \
45         generator_php.ml \
46         generator_bindtests.ml \
47         generator_main.ml
48
49 SOURCES_ML = $(filter %.ml,$(SOURCES))
50 OBJECTS = $(SOURCES_ML:.ml=.cmo)
51
52 EXTRA_DIST = $(SOURCES)
53
54 OCAMLCFLAGS = -I +xml-light -I +../pkg-lib/xml-light
55 OCAMLCLIBS = xml-light.cma unix.cma str.cma
56
57 noinst_PROGRAM = generator
58
59 if HAVE_OCAML
60
61 generator: $(OBJECTS)
62         $(OCAMLC) -o generator $(OCAMLCFLAGS) $(OCAMLCLIBS) $(OBJECTS)
63
64 .ml.cmo:
65         $(OCAMLC) $(OCAMLCFLAGS) -c $< -o $@
66
67 .mli.cmi:
68         $(OCAMLC) $(OCAMLCFLAGS) -c $< -o $@
69
70 depend: .depend
71
72 .depend: $(SOURCES)
73         rm -f $@ $@-t
74         $(OCAMLDEP) $^ | sed 's/  *$$//' > $@-t
75         mv $@-t $@
76
77 include .depend
78
79 else
80
81 # No OCaml compiler.  Just replace the generator with a script that
82 # touches stamp-generator and prints a warning.
83
84 generator: $(SOURCES)
85         rm -f $@ $@-t
86         echo 'echo Warning: Install OCaml compiler in order to rebuild the generated files.' >> $@-t
87         echo 'touch generator/stamp-generator' >> $@-t
88         chmod +x $@-t
89         mv $@-t $@
90
91 endif
92
93 noinst_DATA = stamp-generator
94
95 # Run the generator.
96 # Git removes empty directories, so in cases where the
97 # generator is creating the sole file in a directory, we
98 # have to create the directory first.
99 stamp-generator: generator
100         mkdir -p $(top_srcdir)/perl/lib/Sys
101         mkdir -p $(top_srcdir)/ruby/ext/guestfs
102         mkdir -p $(top_srcdir)/java/com/redhat/et/libguestfs
103         mkdir -p $(top_srcdir)/csharp
104         cd $(top_srcdir) && generator/generator
105
106 CLEANFILES = $(noinst_DATA) $(noinst_PROGRAM) *.cmi *.cmo *~
107
108 SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly