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