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