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