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