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