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