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