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