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