gnulib: Add $(LIB_CLOCK_GETTIME) when linking libguestfs.so.
[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 CLEANFILES = stamp-guestfs.pod
21
22 generator_built = \
23         guestfs_protocol.x \
24         guestfs.h \
25         guestfs-internal-actions.h \
26         actions.c \
27         bindtests.c \
28         errnostring_gperf.gperf \
29         errnostring.c \
30         errnostring.h \
31         guestfs-actions.pod \
32         guestfs-availability.pod \
33         guestfs-structs.pod \
34         libguestfs.syms
35
36 BUILT_SOURCES = \
37         $(generator_built) \
38         guestfs_protocol.c \
39         guestfs_protocol.h \
40         errnostring_gperf.c
41
42 EXTRA_DIST = \
43         $(BUILT_SOURCES) \
44         MAX_PROC_NR \
45         libguestfs.3 \
46         guestfs.pod \
47         api-support/added \
48         api-support/README \
49         api-support/update-from-tarballs.sh
50
51 include_HEADERS = guestfs.h
52
53 lib_LTLIBRARIES = libguestfs.la
54
55 # This convenience library is solely to compile its generated sources with
56 # custom flags.
57 libprotocol_la_SOURCES = guestfs_protocol.c  guestfs_protocol.h
58 libprotocol_la_CFLAGS = -Wall -Wno-unused -fno-strict-aliasing
59
60 # Build the errnostring perfect hash code.  The generated code has lots
61 # of warnings so we must compile it in a separate mini-library.
62 liberrnostring_la_SOURCES = \
63         errnostring_gperf.c \
64         errnostring.h \
65         errnostring.c
66 liberrnostring_la_CFLAGS =
67
68 errnostring_gperf.c: errnostring_gperf.gperf
69         rm -f $@
70         $(GPERF) -t $< > $@-t
71         mv $@-t $@
72
73 # From the libtool info file, with comments:
74 #
75 # |  1. Start with version information of `0:0:0' for each libtool library.
76 # |
77 # |  2. Update the version information only immediately before a public
78 # |     release of your software.  More frequent updates are unnecessary,
79 # |     and only guarantee that the current interface number gets larger
80 # |     faster.
81 # |
82 # |  3. If the library source code has changed at all since the last
83 # |     update, then increment REVISION (`C:R:A' becomes `C:r+1:A').
84 #
85 # [So it seems like we should always update the middle 'R' field
86 # for any release.]
87 #
88 # |  4. If any interfaces have been added, removed, or changed since the
89 # |     last update, increment CURRENT, and set REVISION to 0.
90 # |
91 # |  5. If any interfaces have been added since the last public release,
92 # |     then increment AGE.
93 #
94 # [These two rules seem to mean that if any change is made to the
95 # generator, we should increment C and A, and set R to 0, so:
96 # C+1:0:A+1.]
97 #
98 # |  6. If any interfaces have been removed since the last public release,
99 # |     then set AGE to 0.
100 #
101 # [Our ABI guarantee means we won't remove interfaces except in
102 # very exceptional circumstances.]
103 #
104 # The maximum proc number (see guestfs_protocol.x:guestfs_procedure) is
105 # a mostly accurate stand-in for C & A in rules 5 & 6, so we use that.  It
106 # is always incremented when we add a new appliance interface, and easy to
107 # calculate.
108 #
109 # The middle number is hard to increment-and-reset as described in rules
110 # 4 & 5, so for the moment it is always set to 0.
111 #
112 # Note that this scheme means the real library version will always be
113 # 'libguestfs.so.0.$(MAX_PROC_NR).0'.
114 libguestfs_la_LDFLAGS = -version-info $(MAX_PROC_NR):0:$(MAX_PROC_NR)
115
116 libguestfs_la_LDFLAGS += $(VERSION_SCRIPT_FLAGS)libguestfs.syms
117
118 libguestfs_la_SOURCES = \
119         guestfs.c \
120         guestfs.h \
121         guestfs-internal.h \
122         guestfs_protocol.h \
123         gettext.h \
124         actions.c \
125         appliance.c \
126         bindtests.c \
127         dbdump.c \
128         events.c \
129         filearch.c \
130         inspect.c \
131         inspect_apps.c \
132         inspect_fs.c \
133         inspect_fs_cd.c \
134         inspect_fs_unix.c \
135         inspect_fs_windows.c \
136         inspect_icon.c \
137         launch.c \
138         listfs.c \
139         match.c \
140         proto.c \
141         virt.c \
142         libguestfs.syms
143
144 libguestfs_la_LIBADD = \
145         $(HIVEX_LIBS) $(AUGEAS_LIBS) $(PCRE_LIBS) $(MAGIC_LIBS) \
146         $(LIBVIRT_LIBS) $(LIBXML2_LIBS) \
147         $(LTLIBTHREAD) $(LIB_CLOCK_GETTIME) \
148         ../gnulib/lib/libgnu.la
149
150 # Make libguestfs include the convenience libraries.
151 noinst_LTLIBRARIES = liberrnostring.la libprotocol.la
152 libguestfs_la_LIBADD += liberrnostring.la libprotocol.la
153
154 libguestfs_la_CFLAGS = \
155   -DGUESTFS_DEFAULT_PATH='"$(libdir)/guestfs"' \
156   -DGUESTFS_WARN_DEPRECATED=1 \
157   $(HIVEX_CFLAGS) $(AUGEAS_CFLAGS) $(PCRE_CFLAGS) \
158   $(LIBVIRT_CFLAGS) $(LIBXML2_CFLAGS) \
159   $(WARN_CFLAGS) $(WERROR_CFLAGS)
160
161 libguestfs_la_CPPFLAGS = -I$(top_srcdir)/gnulib/lib
162
163 if HAVE_RPCGEN
164 guestfs_protocol.c: guestfs_protocol.x
165         rm -f $@-t $@-t2
166         $(RPCGEN) -c -o $@-t $<
167         sed 's,\.\./\.\./src/,,' < $@-t > $@-t2
168         rm $@-t
169         mv $@-t2 $@
170
171 guestfs_protocol.h: guestfs_protocol.x
172         rm -f $@-t
173         $(RPCGEN) -h -o $@-t $<
174         mv $@-t $@
175 endif
176
177 # Manual page.
178
179 man_MANS = guestfs.3 libguestfs.3
180 noinst_DATA = $(top_builddir)/html/guestfs.3.html
181
182 guestfs.3 $(top_builddir)/html/guestfs.3.html: stamp-guestfs.pod
183
184 stamp-guestfs.pod: guestfs.pod \
185                 guestfs-actions.pod \
186                 guestfs-availability.pod \
187                 guestfs-structs.pod
188         $(top_srcdir)/podwrapper.sh \
189           --section 3 \
190           --man guestfs.3 \
191           --html $(top_builddir)/html/guestfs.3.html \
192           --insert guestfs-actions.pod:@ACTIONS@ \
193           --insert guestfs-availability.pod:@AVAILABILITY@ \
194           --insert guestfs-structs.pod:@STRUCTS@ \
195           $<
196         touch $@