avoid compiler warnings about unused vars in generated code
[libguestfs.git] / src / Makefile.am
1 # libguestfs
2 # Copyright (C) 2009 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 EXTRA_DIST = \
19         guestfs_protocol.x \
20         MAX_PROC_NR \
21         stamp-generator \
22         generator.ml
23
24 # Rerun the generator if it has changed.
25 # Git removes empty directories, so in cases where the
26 # generator is creating the sole file in a directory, we
27 # have to create the directory first.
28 noinst_DATA = stamp-generator
29
30 stamp-generator: generator.ml
31         mkdir -p $(top_srcdir)/perl/lib/Sys
32         mkdir -p $(top_srcdir)/ruby/ext/guestfs
33         mkdir -p $(top_srcdir)/java/com/redhat/et/libguestfs
34         cd $(top_srcdir) && ocaml -warn-error A src/generator.ml
35
36 guestfs_protocol.x: stamp-generator
37
38 include_HEADERS = guestfs.h guestfs-actions.h guestfs-structs.h
39
40 lib_LTLIBRARIES = libguestfs.la
41
42 BUILT_SOURCES = \
43   guestfs_protocol.x \
44   guestfs_protocol.c \
45   guestfs_protocol.h \
46   guestfs-structs.h \
47   guestfs-actions.h \
48   guestfs-actions.c \
49   guestfs-bindtests.c
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 = -Wall -Wno-unused
58
59 $(BUILT_SOURCES): stamp-generator
60
61 CLEANFILES = guestfs_protocol.c guestfs_protocol.h
62
63 # From the libtool info file, with comments:
64 #
65 # |  1. Start with version information of `0:0:0' for each libtool library.
66 # |
67 # |  2. Update the version information only immediately before a public
68 # |     release of your software.  More frequent updates are unnecessary,
69 # |     and only guarantee that the current interface number gets larger
70 # |     faster.
71 # |
72 # |  3. If the library source code has changed at all since the last
73 # |     update, then increment REVISION (`C:R:A' becomes `C:r+1:A').
74 #
75 # [So it seems like we should always update the middle 'R' field
76 # for any release.]
77 #
78 # |  4. If any interfaces have been added, removed, or changed since the
79 # |     last update, increment CURRENT, and set REVISION to 0.
80 # |
81 # |  5. If any interfaces have been added since the last public release,
82 # |     then increment AGE.
83 #
84 # [These two rules seem to mean that if any change is made to the
85 # generator, we should increment C and A, and set R to 0, so:
86 # C+1:0:A+1.]
87 #
88 # |  6. If any interfaces have been removed since the last public release,
89 # |     then set AGE to 0.
90 #
91 # [Our ABI guarantee means we won't remove interfaces except in
92 # very exceptional circumstances.]
93 #
94 # The maximum proc number (see guestfs_protocol.x:guestfs_procedure) is
95 # a mostly accurate stand-in for C & A in rules 5 & 6, so we use that.  It
96 # is always incremented when we add a new appliance interface, and easy to
97 # calculate.
98 #
99 # The middle number is hard to increment-and-reset as described in rules
100 # 4 & 5, so for the moment it is always set to 0.
101 #
102 # Note that this scheme means the real library version will always be
103 # 'libguestfs.so.0.$(MAX_PROC_NR).0'.
104
105 libguestfs_la_LDFLAGS = -version-info $(MAX_PROC_NR):0:$(MAX_PROC_NR)
106 libguestfs_la_SOURCES = \
107         guestfs.c \
108         guestfs.h \
109         guestfs-actions.h \
110         guestfs-actions.c \
111         guestfs-bindtests.c \
112         gettext.h
113
114 # Make libguestfs include the convenience library.
115 noinst_LTLIBRARIES = libprotocol.la
116 libguestfs_la_LIBADD = libprotocol.la
117
118 libguestfs_la_CFLAGS = -Wall -DGUESTFS_DEFAULT_PATH='"$(libdir)/guestfs"'
119
120 if HAVE_RPCGEN
121 guestfs_protocol.c: guestfs_protocol.x
122         rm -f $@-t $@-t2
123         $(RPCGEN) -c -o $@-t $<
124         sed 's,\.\./\.\./src/,,' < $@-t > $@-t2
125         rm $@-t
126         mv $@-t2 $@
127
128 guestfs_protocol.h: guestfs_protocol.x
129         rm -f $@-t
130         $(RPCGEN) -h -o $@-t $<
131         mv $@-t $@
132 endif