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