Update FSF address.
[libguestfs.git] / sparsify / Makefile.am
1 # libguestfs virt-sparsify tool
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 include $(top_srcdir)/subdir-rules.mk
19
20 EXTRA_DIST = \
21         $(SOURCES) \
22         virt-sparsify.pod \
23         test-virt-sparsify.sh
24
25 CLEANFILES = *~ *.cmi *.cmo *.cmx *.cmxa *.o virt-sparsify test.img
26
27 if HAVE_OCAML
28
29 # Alphabetical order.
30 SOURCES = \
31         progress_c.c \
32         progress.mli \
33         progress.ml \
34         sparsify.ml \
35         utils.ml
36
37 # Note this list must be in dependency order.
38 OBJECTS = \
39         ../fish/guestfish-progress.o \
40         progress_c.o \
41         utils.cmx \
42         progress.cmx \
43         sparsify.cmx
44
45 bin_SCRIPTS = virt-sparsify
46
47 # -I $(top_builddir)/src/.libs is a hack which forces corresponding -L
48 # option to be passed to gcc, so we don't try linking against an
49 # installed copy of libguestfs.
50 OCAMLPACKAGES = -package unix -I $(top_builddir)/src/.libs -I ../ocaml
51
52 OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX $(OCAMLPACKAGES)
53 OCAMLOPTFLAGS = $(OCAMLCFLAGS)
54
55 virt-sparsify: $(OBJECTS)
56         $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \
57           mlguestfs.cmxa -linkpkg $^ -cclib -lncurses -o $@
58
59 .mli.cmi:
60         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
61 .ml.cmo:
62         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
63 .ml.cmx:
64         $(OCAMLFIND) ocamlopt $(OCAMLCFLAGS) -c $< -o $@
65
66 # automake will decide we don't need C support in this file.  Really
67 # we do, so we have to provide it ourselves.
68
69 DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(shell $(OCAMLC) -where) -I../fish
70
71 .c.o:
72         $(CC) $(CFLAGS) $(PROF_CFLAGS) $(DEFAULT_INCLUDES) -c $< -o $@
73
74 # Manual pages and HTML files for the website.
75
76 man_MANS = virt-sparsify.1
77
78 noinst_DATA = $(top_builddir)/html/virt-sparsify.1.html
79
80 virt-sparsify.1 $(top_builddir)/html/virt-sparsify.1.html: stamp-virt-sparsify.pod
81
82 stamp-virt-sparsify.pod: virt-sparsify.pod
83         $(top_builddir)/podwrapper.sh \
84           --man virt-sparsify.1 \
85           --html $(top_builddir)/html/virt-sparsify.1.html \
86           $<
87         touch $@
88
89 CLEANFILES += stamp-virt-sparsify.pod
90
91 # Tests.
92
93 random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)
94
95 TESTS_ENVIRONMENT = \
96         MALLOC_PERTURB_=$(random_val) \
97         LD_LIBRARY_PATH=$(top_builddir)/src/.libs \
98         LIBGUESTFS_PATH=$(top_builddir)/appliance \
99         TMPDIR=$(top_builddir)
100
101 TESTS = test-virt-sparsify.sh
102
103 # Dependencies.
104 depend: .depend
105
106 .depend: $(wildcard *.mli) $(wildcard *.ml)
107         rm -f $@ $@-t
108         $(OCAMLFIND) ocamldep -I ../ocaml $^ | \
109           $(SED) 's/ *$$//' | \
110           $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
111           sort > $@-t
112         mv $@-t $@
113
114 include .depend
115
116 .PHONY: depend docs
117
118 endif
119
120 # Parallel builds don't obey dependencies for some reason we
121 # don't understand.
122 .NOTPARALLEL: