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