resize: Add tests for some Utils functions.
[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_c.c \
33         progress.mli \
34         progress.ml \
35         resize.ml \
36         utils.ml \
37         utils_tests.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         resize.cmx
46
47 bin_SCRIPTS = virt-resize
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 pcre -I $(top_builddir)/src/.libs -I ../ocaml
53
54 OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX $(OCAMLPACKAGES)
55 OCAMLOPTFLAGS = $(OCAMLCFLAGS)
56
57 virt-resize: $(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-resize.1
79
80 noinst_DATA = $(top_builddir)/html/virt-resize.1.html
81
82 virt-resize.1 $(top_builddir)/html/virt-resize.1.html: stamp-virt-resize.pod
83
84 stamp-virt-resize.pod: virt-resize.pod
85         $(top_builddir)/podwrapper.sh \
86           --man virt-resize.1 \
87           --html $(top_builddir)/html/virt-resize.1.html \
88           $<
89         touch $@
90
91 CLEANFILES += stamp-virt-resize.pod
92
93 # Tests.
94
95 check_SCRIPTS = utils_tests
96
97 utils_tests: utils.cmx utils_tests.cmx
98         $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \
99           mlguestfs.cmxa -linkpkg $^ -cclib -lncurses -o $@
100
101 random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)
102
103 TESTS_ENVIRONMENT = \
104         MALLOC_PERTURB_=$(random_val) \
105         LD_LIBRARY_PATH=$(top_builddir)/src/.libs \
106         LIBGUESTFS_PATH=$(top_builddir)/appliance \
107         TMPDIR=$(top_builddir)
108
109 TESTS = test-virt-resize.sh utils_tests
110
111 # Dependencies.
112 depend: .depend
113
114 .depend: $(wildcard *.mli) $(wildcard *.ml)
115         rm -f $@ $@-t
116         $(OCAMLFIND) ocamldep -I ../ocaml $^ | \
117           $(SED) 's/ *$$//' | \
118           $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
119           sort > $@-t
120         mv $@-t $@
121
122 include .depend
123
124 .PHONY: depend docs
125
126 endif
127 endif
128
129 # Parallel builds don't obey dependencies for some reason we
130 # don't understand.
131 .NOTPARALLEL: