New API: inspect-get-hostname to return the hostname of the guest.
[libguestfs.git] / src / Makefile.am
1 # libguestfs
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 generator_built = \
21         guestfs_protocol.x \
22         guestfs.h \
23         guestfs-internal-actions.h \
24         actions.c \
25         bindtests.c \
26         errnostring_gperf.gperf \
27         errnostring.c \
28         errnostring.h \
29         guestfs-actions.pod \
30         guestfs-availability.pod \
31         guestfs-structs.pod \
32         libguestfs.syms
33
34 BUILT_SOURCES = \
35         $(generator_built) \
36         guestfs_protocol.c \
37         guestfs_protocol.h \
38         errnostring_gperf.c
39
40 EXTRA_DIST = \
41         $(BUILT_SOURCES) \
42         MAX_PROC_NR \
43         libguestfs.3 \
44         guestfs.pod \
45         api-support/added \
46         api-support/README \
47         api-support/update-from-tarballs.sh
48
49 include_HEADERS = guestfs.h
50
51 lib_LTLIBRARIES = libguestfs.la
52
53 # This convenience library is solely to avoid compiler warnings
54 # in its generated sources.
55 libprotocol_la_SOURCES = \
56   guestfs_protocol.c \
57   guestfs_protocol.h
58
59 libprotocol_la_CFLAGS =
60
61 # Build the errnostring perfect hash code.  The generated code has lots
62 # of warnings so we must compile it in a separate mini-library.
63 liberrnostring_la_SOURCES = \
64         errnostring_gperf.c \
65         errnostring.h \
66         errnostring.c
67 liberrnostring_la_CFLAGS =
68
69 errnostring_gperf.c: errnostring_gperf.gperf
70         rm -f $@
71         $(GPERF) -t $< > $@-t
72         mv $@-t $@
73
74 # From the libtool info file, with comments:
75 #
76 # |  1. Start with version information of `0:0:0' for each libtool library.
77 # |
78 # |  2. Update the version information only immediately before a public
79 # |     release of your software.  More frequent updates are unnecessary,
80 # |     and only guarantee that the current interface number gets larger
81 # |     faster.
82 # |
83 # |  3. If the library source code has changed at all since the last
84 # |     update, then increment REVISION (`C:R:A' becomes `C:r+1:A').
85 #
86 # [So it seems like we should always update the middle 'R' field
87 # for any release.]
88 #
89 # |  4. If any interfaces have been added, removed, or changed since the
90 # |     last update, increment CURRENT, and set REVISION to 0.
91 # |
92 # |  5. If any interfaces have been added since the last public release,
93 # |     then increment AGE.
94 #
95 # [These two rules seem to mean that if any change is made to the
96 # generator, we should increment C and A, and set R to 0, so:
97 # C+1:0:A+1.]
98 #
99 # |  6. If any interfaces have been removed since the last public release,
100 # |     then set AGE to 0.
101 #
102 # [Our ABI guarantee means we won't remove interfaces except in
103 # very exceptional circumstances.]
104 #
105 # The maximum proc number (see guestfs_protocol.x:guestfs_procedure) is
106 # a mostly accurate stand-in for C & A in rules 5 & 6, so we use that.  It
107 # is always incremented when we add a new appliance interface, and easy to
108 # calculate.
109 #
110 # The middle number is hard to increment-and-reset as described in rules
111 # 4 & 5, so for the moment it is always set to 0.
112 #
113 # Note that this scheme means the real library version will always be
114 # 'libguestfs.so.0.$(MAX_PROC_NR).0'.
115 libguestfs_la_LDFLAGS = -version-info $(MAX_PROC_NR):0:$(MAX_PROC_NR)
116
117 libguestfs_la_LDFLAGS += $(VERSION_SCRIPT_FLAGS)libguestfs.syms
118
119 libguestfs_la_SOURCES = \
120         guestfs.c \
121         guestfs.h \
122         guestfs-internal.h \
123         guestfs_protocol.h \
124         gettext.h \
125         actions.c \
126         appliance.c \
127         bindtests.c \
128         filearch.c \
129         inspect.c \
130         launch.c \
131         listfs.c \
132         proto.c \
133         virt.c \
134         libguestfs.syms
135
136 libguestfs_la_LIBADD = \
137         $(HIVEX_LIBS) $(AUGEAS_LIBS) $(PCRE_LIBS) $(MAGIC_LIBS) \
138         $(LIBVIRT_LIBS) $(LIBXML2_LIBS) \
139         $(LTLIBTHREAD) ../gnulib/lib/libgnu.la
140
141 # Make libguestfs include the convenience libraries.
142 noinst_LTLIBRARIES = liberrnostring.la libprotocol.la
143 libguestfs_la_LIBADD += liberrnostring.la libprotocol.la
144
145 libguestfs_la_CFLAGS = \
146   -DGUESTFS_DEFAULT_PATH='"$(libdir)/guestfs"' \
147   $(HIVEX_CFLAGS) $(AUGEAS_CFLAGS) $(PCRE_CFLAGS) \
148   $(LIBVIRT_CFLAGS) $(LIBXML2_CFLAGS) \
149   $(WARN_CFLAGS) $(WERROR_CFLAGS)
150
151 libguestfs_la_CPPFLAGS = -I$(top_srcdir)/gnulib/lib
152
153 if HAVE_RPCGEN
154 guestfs_protocol.c: guestfs_protocol.x
155         rm -f $@-t $@-t2
156         $(RPCGEN) -c -o $@-t $<
157         sed 's,\.\./\.\./src/,,' < $@-t > $@-t2
158         rm $@-t
159         mv $@-t2 $@
160
161 guestfs_protocol.h: guestfs_protocol.x
162         rm -f $@-t
163         $(RPCGEN) -h -o $@-t $<
164         mv $@-t $@
165 endif
166
167 # Manual page.
168 # guestfs-actions.pod, guestfs-availability.pod and guestfs-structs.pod
169 # are autogenerated.  There is no include mechanism for POD, so we
170 # have to do it by hand.
171
172 man_MANS = guestfs.3 libguestfs.3
173
174 guestfs.3: guestfs.pod \
175                 guestfs-actions.pod \
176                 guestfs-availability.pod \
177                 guestfs-structs.pod
178         sed \
179           -e '/@ACTIONS@/rguestfs-actions.pod' \
180           -e 's/@ACTIONS@//' \
181           -e '/@AVAILABILITY@/rguestfs-availability.pod' \
182           -e 's/@AVAILABILITY@//' \
183           -e '/@STRUCTS@/rguestfs-structs.pod' \
184           -e 's/@STRUCTS@//' \
185           < $< | \
186         $(POD2MAN) \
187           --section 3 \
188           -c "Virtualization Support" \
189           --name "guestfs" \
190           --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
191           > $@
192
193 # Check user doesn't try to do 'make all' or 'make check' as root.
194 # https://www.redhat.com/archives/libguestfs/2010-April/msg00098.html
195
196 all-local: checkroot
197 check-local: checkroot
198 checkroot:
199         @if [ "`id -u`" = 0 ]; then \
200             echo "*** Error: Don't run 'make' or 'make check' as root."; \
201             exit 1; \
202         fi