e822ac30b97c22bfb2f2e07440c8a083ea3678f4
[libguestfs.git] / cat / Makefile.am
1 # libguestfs virt-cat and virt-ls.
2 # Copyright (C) 2010 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         run-cat-locally \
22         test-virt-cat.sh \
23         virt-cat.pod \
24         run-ls-locally \
25         test-virt-ls.sh \
26         virt-ls.pod
27
28 bin_PROGRAMS = virt-cat virt-ls
29
30 SHARED_SOURCE_FILES = \
31         ../fish/inspect.c \
32         ../fish/keys.c \
33         ../fish/options.h \
34         ../fish/options.c \
35         ../fish/virt.c
36
37 virt_cat_SOURCES = \
38         $(SHARED_SOURCE_FILES) \
39         virt-cat.c
40
41 virt_cat_CFLAGS = \
42         -I$(top_srcdir)/src -I$(top_builddir)/src \
43         -I$(top_srcdir)/fish \
44         -I$(srcdir)/../gnulib/lib -I../gnulib/lib \
45         -DLOCALEBASEDIR=\""$(datadir)/locale"\" \
46         $(WARN_CFLAGS) $(WERROR_CFLAGS)
47
48 virt_cat_LDADD = \
49         $(top_builddir)/src/libguestfs.la \
50         ../gnulib/lib/libgnu.la
51
52 virt_ls_SOURCES = \
53         $(SHARED_SOURCE_FILES) \
54         virt-ls.c
55
56 virt_ls_CFLAGS = \
57         -I$(top_srcdir)/src -I$(top_builddir)/src \
58         -I$(top_srcdir)/fish \
59         -I$(srcdir)/../gnulib/lib -I../gnulib/lib \
60         -DLOCALEBASEDIR=\""$(datadir)/locale"\" \
61         $(WARN_CFLAGS) $(WERROR_CFLAGS)
62
63 virt_ls_LDADD = \
64         $(top_builddir)/src/libguestfs.la \
65         ../gnulib/lib/libgnu.la
66
67 # Manual pages and HTML files for the website.
68 man_MANS = virt-cat.1 virt-ls.1
69
70 noinst_DATA = \
71         $(top_builddir)/html/virt-cat.1.html \
72         $(top_builddir)/html/virt-ls.1.html
73
74 virt-cat.1: virt-cat.pod
75         $(POD2MAN) \
76           --section 1 \
77           -c "Virtualization Support" \
78           --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
79           $< > $@-t && mv $@-t $@
80
81 $(top_builddir)/html/virt-cat.1.html: virt-cat.pod
82         mkdir -p $(top_builddir)/html
83         cd $(top_builddir) && pod2html \
84           --css 'pod.css' \
85           --htmldir html \
86           --outfile html/$@ \
87           $(abs_srcdir)/$<
88
89 virt-ls.1: virt-ls.pod
90         $(POD2MAN) \
91           --section 1 \
92           -c "Virtualization Support" \
93           --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
94           $< > $@-t && mv $@-t $@
95
96 $(top_builddir)/html/virt-ls.1.html: virt-ls.pod
97         mkdir -p $(top_builddir)/html
98         cd $(top_builddir) && pod2html \
99           --css 'pod.css' \
100           --htmldir html \
101           --outfile html/$@ \
102           $(abs_srcdir)/$<
103
104 # Tests.
105
106 random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)
107
108 TESTS_ENVIRONMENT = \
109         MALLOC_PERTURB_=$(random_val) \
110         LD_LIBRARY_PATH=$(top_builddir)/src/.libs \
111         LIBGUESTFS_PATH=$(top_builddir)/appliance
112
113 TESTS = test-virt-cat.sh test-virt-ls.sh
114
115 # Build a partly-static binary (for the binary distribution).
116
117 virt-cat.static$(EXEEXT): $(virt_cat_OBJECTS) $(virt_cat_DEPENDENCIES)
118         $(top_srcdir)/relink-static.sh \
119         $(virt_cat_LINK) $(virt_cat_OBJECTS) -static $(virt_cat_LDADD) $(virt_cat_LIBS) $(LIBVIRT_LIBS) $(LIBXML2_LIBS) -lpcre -lhivex -lmagic -lz -lm
120
121 virt-ls.static$(EXEEXT): $(virt_ls_OBJECTS) $(virt_ls_DEPENDENCIES)
122         $(top_srcdir)/relink-static.sh \
123         $(virt_ls_LINK) $(virt_ls_OBJECTS) -static $(virt_ls_LDADD) $(virt_ls_LIBS) $(LIBVIRT_LIBS) $(LIBXML2_LIBS) -lpcre -lhivex -lmagic -lz -lm