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