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