Makefile.am 23.5 KB
Newer Older
D
Daniel Veillard 已提交
1 2
## Process this file with automake to produce Makefile.in

3
## Copyright (C) 2005-2018 Red Hat, Inc.
E
Eric Blake 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16 17
##
## This library is free software; you can redistribute it and/or
## modify it under the terms of the GNU Lesser General Public
## License as published by the Free Software Foundation; either
## version 2.1 of the License, or (at your option) any later version.
##
## This library is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## Lesser General Public License for more details.
##
## You should have received a copy of the GNU Lesser General Public
## License along with this library.  If not, see
## <http://www.gnu.org/licenses/>.
18

19 20
# No libraries with the exception of LIBXML should be listed
# here. List them against the individual XXX_la_CFLAGS targets
21
# that actually use them.
22
AM_CPPFLAGS =	-I../gnulib/lib \
23 24 25 26 27 28 29
		-I$(top_srcdir)/gnulib/lib \
		-I$(top_srcdir) \
		-I../include \
		-I$(top_srcdir)/include \
		-I$(srcdir)/util \
		-I./util \
		-DIN_LIBVIRT \
30 31
		-Dabs_top_builddir="\"$(abs_top_builddir)\"" \
		-Dabs_top_srcdir="\"$(abs_top_srcdir)\"" \
32
		$(NULL)
E
Eric Blake 已提交
33

34 35
WARN_CFLAGS += $(STRICT_FRAME_LIMIT_CFLAGS)

36 37 38 39
AM_CFLAGS =	$(LIBXML_CFLAGS) \
		$(WARN_CFLAGS) \
		$(LOCK_CHECKING_CFLAGS) \
		$(WIN32_EXTRA_CFLAGS) \
40
		$(COVERAGE_CFLAGS) \
41
		$(NULL)
42
AM_LDFLAGS =	$(DRIVER_MODULES_LDFLAGS) \
43
		$(COVERAGE_LDFLAGS) \
44 45 46 47
		$(RELRO_LDFLAGS) \
		$(NO_INDIRECT_LDFLAGS) \
		$(CYGWIN_EXTRA_LDFLAGS) \
		$(MINGW_EXTRA_LDFLAGS) \
G
Guido Günther 已提交
48
		$(NULL)
49 50 51 52 53
AM_LDFLAGS_MOD = \
	-module \
	-avoid-version \
	$(LIBVIRT_NODELETE) \
	$(AM_LDFLAGS)
54
AM_LDFLAGS_MOD_NOUNDEF = $(AM_LDFLAGS_MOD) $(NO_UNDEFINED_LDFLAGS)
55

56 57
POD2MAN = pod2man -c "Virtualization Support" -r "$(PACKAGE)-$(VERSION)"

58
EXTRA_DIST = $(conf_DATA)
59

60
BUILT_SOURCES =
61 62 63
CLEANFILES =
DISTCLEANFILES =
MAINTAINERCLEANFILES =
64
nodist_conf_DATA =
65 66 67 68 69
DRIVER_SOURCE_FILES =
STATEFUL_DRIVER_SOURCE_FILES =
noinst_LTLIBRARIES =
mod_LTLIBRARIES =
INSTALL_DATA_DIRS =
70 71
INSTALL_DATA_LOCAL =
UNINSTALL_LOCAL =
72
libvirt_la_BUILT_LIBADD =
73 74 75
SYM_FILES =
USED_SYM_FILES =
GENERATED_SYM_FILES =
76 77 78 79 80 81
augeas_DATA =
augeastest_DATA =
conf_DATA =
if WITH_DTRACE_PROBES
tapset_DATA =
endif WITH_DTRACE_PROBES
82 83
libexec_PROGRAMS =
RPC_PROBE_FILES =
84 85 86
LOGROTATE_FILES_IN =
PODFILES =
MANINFILES =
87
SYSTEMD_UNIT_FILES =
88 89 90 91
SYSTEMD_UNIT_FILES_IN =
SYSCONF_FILES =
sbin_PROGRAMS =
man8_MANS =
92
DRIVER_SOURCES =
93
man7_MANS =
94

95
COMMON_UNIT_VARS = \
96
	-e 's|[@]runstatedir[@]|$(runstatedir)|g' \
97 98 99 100
	-e 's|[@]sbindir[@]|$(sbindir)|g' \
	-e 's|[@]sysconfdir[@]|$(sysconfdir)|g' \
	$(NULL)

101
include util/Makefile.inc.am
102
include conf/Makefile.inc.am
103
include cpu/Makefile.inc.am
104
include cpu_map/Makefile.inc.am
105
include security/Makefile.inc.am
106
include access/Makefile.inc.am
107
include logging/Makefile.inc.am
108
include locking/Makefile.inc.am
109
include admin/Makefile.inc.am
110
include rpc/Makefile.inc.am
111
include phyp/Makefile.inc.am
112
include test/Makefile.inc.am
113
include esx/Makefile.inc.am
114
include hyperv/Makefile.inc.am
115
include vmx/Makefile.inc.am
116
include vmware/Makefile.inc.am
117
include vbox/Makefile.inc.am
118
include openvz/Makefile.inc.am
119
include qemu/Makefile.inc.am
120
include bhyve/Makefile.inc.am
121
include libxl/Makefile.inc.am
122
include vz/Makefile.inc.am
123
include lxc/Makefile.inc.am
124
include interface/Makefile.inc.am
125
include network/Makefile.inc.am
126
include nwfilter/Makefile.inc.am
127
include node_device/Makefile.inc.am
128
include secret/Makefile.inc.am
129
include storage/Makefile.inc.am
130
include remote/Makefile.inc.am
131

132

E
Eric Blake 已提交
133 134
THREAD_LIBS = $(LIB_PTHREAD) $(LTLIBMULTITHREAD)

J
Jim Fehlig 已提交
135
SECDRIVER_CFLAGS =
136 137
SECDRIVER_LIBS =
if WITH_SECDRIVER_SELINUX
J
Jim Fehlig 已提交
138
SECDRIVER_CFLAGS += $(SELINUX_CFLAGS)
139
SECDRIVER_LIBS += $(SELINUX_LIBS)
140
endif WITH_SECDRIVER_SELINUX
141
if WITH_SECDRIVER_APPARMOR
J
Jim Fehlig 已提交
142
SECDRIVER_CFLAGS += $(APPARMOR_CFLAGS)
143
SECDRIVER_LIBS += $(APPARMOR_LIBS)
144
endif WITH_SECDRIVER_APPARMOR
145

146

147
lib_LTLIBRARIES = libvirt.la libvirt-qemu.la libvirt-lxc.la
148

149
moddir = $(libdir)/libvirt/connection-driver
150

A
Amy Griffis 已提交
151
confdir = $(sysconfdir)/libvirt
152
conf_DATA += libvirt.conf libvirt-admin.conf
153

154 155 156
CLEANFILES += $(nodist_conf_DATA)
BUILT_SOURCES += $(nodist_conf_DATA)

157 158 159 160
augeasdir = $(datadir)/augeas/lenses

augeastestdir = $(datadir)/augeas/lenses/tests

161
CLEANFILES += $(augeastest_DATA)
L
Lai Jiangshan 已提交
162

163
# Internal generic driver infrastructure
O
Osier Yang 已提交
164
DATATYPES_SOURCES = datatypes.h datatypes.c
165
DRIVER_SOURCES += \
166 167 168 169 170 171 172 173 174 175 176 177 178 179
		driver.c driver.h \
		driver-hypervisor.h \
		driver-interface.h \
		driver-network.h \
		driver-nodedev.h \
		driver-nwfilter.h \
		driver-secret.h \
		driver-state.h \
		driver-storage.h \
		driver-stream.h \
		internal.h \
		$(DATATYPES_SOURCES) \
		libvirt.c libvirt_internal.h \
		libvirt-domain.c \
180
		libvirt-domain-checkpoint.c \
181 182 183 184 185 186 187 188 189
		libvirt-domain-snapshot.c \
		libvirt-host.c \
		libvirt-interface.c \
		libvirt-network.c \
		libvirt-nodedev.c \
		libvirt-nwfilter.c \
		libvirt-secret.c \
		libvirt-storage.c \
		libvirt-stream.c \
190
		$(NULL)
191

192

193

M
Martin Kletzander 已提交
194

195 196 197 198 199 200 201 202 203 204
# Ensure that we don't change the struct or member names or member ordering
# in remote_protocol.x  The embedded perl below needs a few comments, and
# presumes you know what pdwtags output looks like:
# * use -0777 -n to slurp the entire file into $_.
# * the "split" splits on the /* DD */ comments, so that $p iterates
#     through the struct definitions.
# * process only "struct remote_..." entries
# * remove comments and preceding TAB throughout
# * remove empty lines throughout
# * remove white space at end of buffer
205 206 207 208

# With pdwtags 1.8, --verbose output includes separators like these:
# /* 93 */
# /* <0> (null):0 */
209 210
# with the second line omitted for intrinsic types.
# Whereas with pdwtags 1.3, they look like this:
211
# /* <2d2> /usr/include/libio.h:180 */
212 213
# The alternation of the following regexps matches both cases.
r1 = /\* \d+ \*/
214
r2 = /\* <[[:xdigit:]]+> \S+:\d+ \*/
M
Martin Kletzander 已提交
215 216 217
libs_prefix = remote_|qemu_|lxc_|admin_
other_prefix = keepalive|vir(Net|LockSpace|LXCMonitor)
struct_prefix = ($(libs_prefix)|$(other_prefix))
218

219
# Depending on configure options, libtool creates one or both of
E
Eric Blake 已提交
220 221
# remote/{,.libs/}libvirt_driver_remote_la-remote_protocol.o.  We want
# the newest of the two, in case configure options changed and a stale
222
# file is left around from an earlier build.
223 224 225
# The pdwtags output is completely different when building with clang
# which causes the comparison against expected output to fail, so skip
# if using clang as CC.
226
PDWTAGS = \
A
Andrea Bolognani 已提交
227
	$(AM_V_GEN)if $(CC) -v 2>&1 | grep -q clang; then \
228 229 230 231
	   echo 'WARNING: skipping pdwtags test with Clang' >&2; \
	   exit 0; \
	fi; \
	if (pdwtags --help) > /dev/null 2>&1; then \
232 233 234 235 236 237 238
	  o=`ls -t $(<:.lo=.$(OBJEXT)) \
	     $(subst /,/.libs/,$(<:.lo=.$(OBJEXT))) \
	    2>/dev/null | sed -n 1p`; \
	  test -f "$$o" || { echo ".o for $< not found" >&2; exit 1; }; \
	  pdwtags --verbose $$o > $(@F)-t1 2> $(@F)-t2; \
	  if test ! -s $(@F)-t1 && test -s $(@F)-t2; then \
	    rm -rf $(@F)-t?; \
239
	    echo 'WARNING: pdwtags appears broken; skipping the $@ test' >&2;\
240 241 242
	  else \
	    $(PERL) -0777 -n \
		-e 'foreach my $$p (split m!\n*(?:$(r1)|$(r2))\n!) {' \
243
		-e '  if ($$p =~ /^(struct|enum) $(struct_prefix)/) {' \
244 245 246 247 248 249 250 251 252 253 254 255 256
		-e '    $$p =~ s!\t*/\*.*?\*/!!sg;' \
		-e '    $$p =~ s!\s+\n!\n!sg;' \
		-e '    $$p =~ s!\s+$$!!;' \
		-e '    $$p =~ s!\t!        !g;' \
		-e '    print "$$p\n";' \
		-e '    $$n++;' \
		-e '  }' \
		-e '}' \
		-e 'BEGIN {' \
		-e '  print "/* -*- c -*- */\n";' \
		-e '}' \
		-e 'END {' \
		-e '  if ($$n < 1) {' \
257
		-e '    warn "WARNING: your pdwtags program is too old\n";' \
258
		-e '    warn "WARNING: skipping the $@ test\n";' \
259
		-e '    warn "WARNING: install dwarves-1.3 or newer\n";' \
260 261 262 263
		-e '    exit 8;' \
		-e '  }' \
		-e '}' \
		< $(@F)-t1 > $(@F)-t3; \
264
	    case $$? in 8) rm -f $(@F)-t?; exit 0;; 0) ;; *) exit 1;; esac;\
265 266 267 268
	    diff -u $(@)s $(@F)-t3; st=$$?; rm -f $(@F)-t?; exit $$st; \
	  fi; \
	else \
	  echo 'WARNING: you lack pdwtags; skipping the $@ test' >&2; \
269
	  echo 'WARNING: install the dwarves package to get pdwtags' >&2; \
270
	fi
271

272
# .libs/libvirt.so is built by libtool as a side-effect of the Makefile
273 274
# rule for libvirt.la.  However, checking symbols relies on Linux ELF layout
if WITH_LINUX
275 276 277
check-symfile: libvirt.syms libvirt.la
	$(AM_V_GEN)$(PERL) $(srcdir)/check-symfile.pl libvirt.syms \
	  .libs/libvirt.so
278 279 280
check-admin-symfile: libvirt_admin.syms libvirt-admin.la
	$(AM_V_GEN)$(PERL) $(srcdir)/check-symfile.pl libvirt_admin.syms \
	  .libs/libvirt-admin.so
281
else ! WITH_LINUX
282
check-symfile:
283
check-admin-symfile:
284
endif ! WITH_LINUX
285
check-symsorting:
286
	$(AM_V_GEN)$(PERL) $(srcdir)/check-symsorting.pl \
287
		$(srcdir) $(SYM_FILES)
288 289 290
check-admin-symsorting:
	$(AM_V_GEN)$(PERL) $(srcdir)/check-symsorting.pl \
		$(srcdir) $(ADMIN_SYM_FILES)
J
Jiri Denemark 已提交
291
EXTRA_DIST += check-symfile.pl check-symsorting.pl
292

E
Eric Blake 已提交
293
# Keep this list synced with RPC_PROBE_FILES
294 295
PROTOCOL_STRUCTS = \
	$(srcdir)/remote_protocol-structs \
296
	$(srcdir)/lxc_protocol-structs \
297
	$(srcdir)/qemu_protocol-structs \
J
Jiri Denemark 已提交
298
	$(srcdir)/virnetprotocol-structs \
E
Eric Blake 已提交
299 300 301
	$(srcdir)/virkeepaliveprotocol-structs \
	$(srcdir)/lxc_monitor_protocol-structs \
	$(srcdir)/lock_protocol-structs \
M
Martin Kletzander 已提交
302
	$(srcdir)/admin_protocol-structs \
E
Eric Blake 已提交
303 304
	$(NULL)

305
if WITH_REMOTE
306 307
check-protocol: $(PROTOCOL_STRUCTS) $(PROTOCOL_STRUCTS:structs=struct)

308 309
# The .o file that pdwtags parses is created as a side effect of running
# libtool; but from make's perspective we depend on the .lo file.
310 311 312
$(srcdir)/remote_protocol-struct \
	$(srcdir)/qemu_protocol-struct \
	$(srcdir)/lxc_protocol-struct: \
E
Eric Blake 已提交
313
		$(srcdir)/%-struct: remote/libvirt_driver_remote_la-%.lo
314
	$(PDWTAGS)
315
$(srcdir)/virnetprotocol-struct $(srcdir)/virkeepaliveprotocol-struct: \
E
Eric Blake 已提交
316
		$(srcdir)/%-struct: rpc/libvirt_net_rpc_la-%.lo
317
	$(PDWTAGS)
318
if WITH_LXC
E
Eric Blake 已提交
319
$(srcdir)/lxc_monitor_protocol-struct: \
E
Eric Blake 已提交
320
		$(srcdir)/%-struct: lxc/libvirt_driver_lxc_impl_la-%.lo
E
Eric Blake 已提交
321
	$(PDWTAGS)
322
endif WITH_LXC
E
Eric Blake 已提交
323
$(srcdir)/lock_protocol-struct: \
E
Eric Blake 已提交
324
		$(srcdir)/%-struct: locking/lockd_la-%.lo
E
Eric Blake 已提交
325
	$(PDWTAGS)
M
Martin Kletzander 已提交
326 327 328
$(srcdir)/admin_protocol-struct: \
		$(srcdir)/%-struct: admin/libvirt_admin_la-%.lo
	$(PDWTAGS)
E
Eric Blake 已提交
329

330
else !WITH_REMOTE
331 332 333
# The $(PROTOCOL_STRUCTS) files must live in git, because they cannot be
# re-generated when configured --without-remote.
check-protocol:
334
endif !WITH_REMOTE
J
Jiri Denemark 已提交
335
EXTRA_DIST += $(PROTOCOL_STRUCTS)
336 337 338 339 340

check-drivername:
	$(AM_V_GEN)$(PERL) $(srcdir)/check-drivername.pl \
		$(srcdir)/driver.h \
		$(srcdir)/libvirt_public.syms \
341
		$(srcdir)/libvirt_admin_public.syms \
342 343 344 345 346
		$(srcdir)/libvirt_qemu.syms \
		$(srcdir)/libvirt_lxc.syms

EXTRA_DIST += check-drivername.pl

347 348
check-driverimpls:
	$(AM_V_GEN)$(PERL) $(srcdir)/check-driverimpls.pl \
349
		$(filter /%,$(DRIVER_SOURCE_FILES)) \
E
Eric Blake 已提交
350 351 352
		$(filter $(srcdir)/%,$(DRIVER_SOURCE_FILES)) \
		$(addprefix $(srcdir)/,$(filter-out $(srcdir)/%, \
			$(filter-out /%,$(DRIVER_SOURCE_FILES))))
353

354 355
check-aclrules:
	$(AM_V_GEN)$(PERL) $(srcdir)/check-aclrules.pl \
E
Eric Blake 已提交
356
		$(REMOTE_PROTOCOL) \
357
		$(addprefix $(srcdir)/,$(filter-out /%,$(STATEFUL_DRIVER_SOURCE_FILES)))
358

359 360 361 362 363
check-aclperms:
	$(AM_V_GEN)$(PERL) $(srcdir)/check-aclperms.pl \
		$(srcdir)/access/viraccessperm.h \
		$(srcdir)/access/viraccessperm.c

G
Guido Günther 已提交
364
EXTRA_DIST += check-driverimpls.pl check-aclrules.pl check-aclperms.pl
365

366
check-local: check-protocol check-symfile check-symsorting \
367
	check-drivername check-driverimpls check-aclrules \
368
	check-aclperms check-admin-symfile check-admin-symsorting
369
.PHONY: check-protocol $(PROTOCOL_STRUCTS:structs=struct)
370

371 372 373 374 375 376 377

#########################
#
# Build up list of libvirt.la source files based on configure conditions
#
# First deal with sources usable in non-daemon context

378

379
noinst_LTLIBRARIES += libvirt_driver.la
380
libvirt_la_BUILT_LIBADD += libvirt_driver.la
381
libvirt_driver_la_SOURCES = $(DRIVER_SOURCES)
382

383
libvirt_driver_la_CFLAGS = \
384
		$(GNUTLS_CFLAGS) $(CURL_CFLAGS) $(XDR_CFLAGS) \
385
		-I$(srcdir)/conf $(AM_CFLAGS)
386
libvirt_driver_la_LIBADD = \
387
		$(GNUTLS_LIBS) $(CURL_LIBS) $(DLOPEN_LIBS)
388

389 390
# All .syms files should be placed in exactly one of these three lists,
# depending on whether they are stored in git and/or used in the build.
391 392 393
SYM_FILES += $(USED_SYM_FILES)
USED_SYM_FILES += $(srcdir)/libvirt_private.syms
GENERATED_SYM_FILES += \
394
	libvirt.syms libvirt.def libvirt_qemu.def libvirt_lxc.def \
395
	libvirt_admin.syms libvirt_admin.def \
396
	$(NULL)
397

C
Chris Lalancette 已提交
398

399

400
%protocol.c: %protocol.x %protocol.h $(srcdir)/rpc/genprotocol.pl
401
	$(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/genprotocol.pl $(RPCGEN) -c \
402
	       $< $(srcdir)/$(subst $(srcdir)/,,$@)
403

404
%protocol.h: %protocol.x $(srcdir)/rpc/genprotocol.pl
405
	$(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/genprotocol.pl $(RPCGEN) -h \
406
	       $< $(srcdir)/$(subst $(srcdir)/,,$@)
407

408 409
check-local: check-augeas

410 411 412 413 414 415 416 417 418 419 420 421
check-augeas: $(augeas_DATA) $(augeastest_DATA)
	$(AM_V_GEN) \
	if test -x "$(AUGPARSE)"; then \
	    for f in $(augeastest_DATA); do \
		DIR=$$(dirname "$$f"); \
		FILE=$$(basename "$$f"); \
		"$(AUGPARSE)" \
		    -I "$(srcdir)/$$DIR" -I "$(builddir)/$$DIR" \
		    "$$DIR/$$FILE"; \
	    done; \
	fi
.PHONY: check-augeas
422

423
AUG_GENTEST = $(PERL) $(top_srcdir)/build-aux/augeas-gentest.pl
424

425

426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444
#
# Build our version script.  This is composed of three parts:
#
# 1. libvirt_public.syms - public API.  These functions are always
# present in the library and should never change incompatibly.
#
# 2. libvirt_private.syms - private API.  These symbols are private and
# semantics may change on every release, hence the version number is
# spliced in at build time. This ensures that if libvirtd, virsh, or a
# driver module was built against one libvirt release, it will refuse to
# load with another where symbols may have same names but different
# semantics. Such symbols should never be visible in an (installed)
# public header file.
#
# 3. libvirt_*.syms - dynamic private API.  Like libvirt_private.syms,
# except that build options (such as --enable-debug) can mean these
# symbols aren't present at all.
#

445
USED_SYM_FILES += $(srcdir)/libvirt_driver_modules.syms
446

447
if WITH_LINUX
448
USED_SYM_FILES += $(srcdir)/libvirt_linux.syms
449
else ! WITH_LINUX
450
SYM_FILES += $(srcdir)/libvirt_linux.syms
451
endif ! WITH_LINUX
452

453
if WITH_SASL
454
USED_SYM_FILES += $(srcdir)/libvirt_sasl.syms
455
else ! WITH_SASL
456
SYM_FILES += $(srcdir)/libvirt_sasl.syms
457
endif ! WITH_SASL
E
Eric Blake 已提交
458

459
if WITH_SSH2
460
USED_SYM_FILES += $(srcdir)/libvirt_libssh2.syms
461
else ! WITH_SSH2
462
SYM_FILES += $(srcdir)/libvirt_libssh2.syms
463
endif ! WITH_SSH2
464

465
if WITH_ATOMIC_OPS_PTHREAD
466
USED_SYM_FILES += $(srcdir)/libvirt_atomic.syms
467
else ! WITH_ATOMIC_OPS_PTHREAD
468
SYM_FILES += $(srcdir)/libvirt_atomic.syms
469
endif ! WITH_ATOMIC_OPS_PTHREAD
470

471 472 473 474 475 476
if WITH_LIBSSH
USED_SYM_FILES += $(srcdir)/libvirt_libssh.syms
else ! WITH_LIBSSH
SYM_FILES += $(srcdir)/libvirt_libssh.syms
endif ! WITH_LIBSSH

477
EXTRA_DIST += \
478 479 480 481 482 483
	libvirt_public.syms \
	libvirt_lxc.syms \
	libvirt_qemu.syms \
	libvirt_admin_public.syms \
	$(SYM_FILES) \
	$(ADMIN_SYM_FILES) \
484
	$(NULL)
485

486
BUILT_SOURCES += $(GENERATED_SYM_FILES)
487

488 489
libvirt.syms: libvirt_public.syms $(USED_SYM_FILES) \
		$(ACCESS_DRIVER_SYM_FILES) \
490
		$(top_builddir)/config.status
491 492 493 494 495 496
	$(AM_V_GEN)rm -f $@-tmp $@ ; \
	printf '# WARNING: generated from the following:\n# $^\n\n' >$@-tmp && \
	cat $(srcdir)/libvirt_public.syms >>$@-tmp && \
	printf '\n\n# Private symbols\n\n' >>$@-tmp && \
	printf 'LIBVIRT_PRIVATE_$(VERSION) {\n\n'  >>$@-tmp && \
	printf 'global:\n\n' >>$@-tmp && \
497
	cat $(USED_SYM_FILES) $(ACCESS_DRIVER_SYM_FILES) >>$@-tmp && \
498 499
	printf '\n\nlocal:\n*;\n\n};' >>$@-tmp && \
	chmod a-w $@-tmp && \
500
	mv $@-tmp libvirt.syms
501

502
%.def: %.syms
503 504
	$(AM_V_GEN)rm -f -- $@-tmp $@ ; \
	printf 'EXPORTS\n' > $@-tmp && \
505
	sed -e '/^$$/d; /#/d; /:/d; /}/d; /\*/d; /LIBVIRT_/d' \
506
	    -e 's/[	 ]*\(.*\)\;/    \1/g' $^ >> $@-tmp && \
507
	chmod a-w $@-tmp && \
508
	mv $@-tmp $@
509

510 511 512 513 514 515 516 517 518 519 520 521 522
libvirt_admin.syms: libvirt_admin_public.syms $(ADMIN_SYM_FILES) \
		$(top_builddir)/config.status
	$(AM_V_GEN)rm -f $@-tmp $@ ; \
	printf '# WARNING: generated from the following:\n# $^\n\n' >$@-tmp && \
	cat $(srcdir)/libvirt_admin_public.syms >>$@-tmp && \
	printf '\n\n# Private symbols\n\n' >>$@-tmp && \
	printf 'LIBVIRT_ADMIN_PRIVATE_$(VERSION) {\n\n'  >>$@-tmp && \
	printf 'global:\n\n' >>$@-tmp && \
	cat $(ADMIN_SYM_FILES) >>$@-tmp && \
	printf '\n\nlocal:\n*;\n\n};' >>$@-tmp && \
	chmod a-w $@-tmp && \
	mv $@-tmp libvirt_admin.syms

523

M
Martin Kletzander 已提交
524 525
lib_LTLIBRARIES += libvirt-admin.la
libvirt_admin_la_SOURCES = \
526 527
		libvirt-admin.c \
		$(ADMIN_PROTOCOL_GENERATED) \
M
Martin Kletzander 已提交
528 529 530
		$(DATATYPES_SOURCES)

libvirt_admin_la_LDFLAGS = \
531 532
		$(VERSION_SCRIPT_FLAGS)$(LIBVIRT_ADMIN_SYMBOL_FILE) \
		-version-info $(LIBVIRT_VERSION_INFO) \
533 534 535
		$(LIBVIRT_NODELETE) \
		$(AM_LDFLAGS) \
		$(NULL)
M
Martin Kletzander 已提交
536 537

libvirt_admin_la_LIBADD = \
538
		libvirt.la \
M
Martin Kletzander 已提交
539 540 541
		$(CYGWIN_EXTRA_LIBADD)

libvirt_admin_la_CFLAGS = \
542 543 544
		$(AM_CFLAGS) \
		-I$(srcdir)/remote \
		-I$(srcdir)/rpc \
M
Martin Kletzander 已提交
545 546 547
		-I$(srcdir)/admin

libvirt_admin_la_CFLAGS += \
548 549
		$(XDR_CFLAGS) \
		$(CAPNG_CFLAGS) \
550
		$(YAJL_CFLAGS) \
551 552 553
		$(SSH2_CFLAGS) \
		$(SASL_CFLAGS) \
		$(GNUTLS_CFLAGS) \
554
		$(LIBSSH_CFLAGS)
M
Martin Kletzander 已提交
555 556

libvirt_admin_la_LIBADD += \
557
		$(CAPNG_LIBS) \
558
		$(YAJL_LIBS) \
559 560 561 562 563
		$(DEVMAPPER_LIBS) \
		$(LIBXML_LIBS) \
		$(SSH2_LIBS) \
		$(SASL_LIBS) \
		$(GNUTLS_LIBS) \
564
		$(LIBSSH_LIBS)
M
Martin Kletzander 已提交
565

566 567
ADMIN_SYM_FILES = $(srcdir)/libvirt_admin_private.syms

M
Martin Kletzander 已提交
568 569 570 571
if WITH_DTRACE_PROBES
libvirt_admin_la_LIBADD += libvirt_probes.lo
endif WITH_DTRACE_PROBES

572 573
# Empty source list - it merely links a bunch of convenience libs together
libvirt_la_SOURCES =
D
Daniel P. Berrange 已提交
574 575 576 577
libvirt_la_LDFLAGS = \
		$(VERSION_SCRIPT_FLAGS)$(LIBVIRT_SYMBOL_FILE) \
		-version-info $(LIBVIRT_VERSION_INFO) \
		$(LIBVIRT_NODELETE) \
578
		$(NO_UNDEFINED_LDFLAGS) \
579 580 581 582 583 584 585
		$(AM_LDFLAGS)
if WITH_MACOS
# macOS has two-level namespaces by default.
# Override it to allow symbol replacement with DYLD_INSERT_LIBRARIES
libvirt_la_LDFLAGS += -Wl,-flat_namespace
endif WITH_MACOS
libvirt_la_LDFLAGS += $(NULL)
586
libvirt_la_BUILT_LIBADD += ../gnulib/lib/libgnu.la
587
libvirt_la_LIBADD += \
588
		    $(DRIVER_MODULES_LIBS) \
589
		    $(CYGWIN_EXTRA_LIBADD)
590
libvirt_la_CFLAGS = -DIN_LIBVIRT $(AM_CFLAGS)
591 592 593 594 595 596
# Because we specify libvirt_la_DEPENDENCIES for $(LIBVIRT_SYMBOL_FILE), we
# lose automake's automatic dependencies on an appropriate subset of
# $(libvirt_la_LIBADD).  But we were careful to create
# $(libvirt_la_BUILT_LIBADD) as the subset that automake would have
# picked out for us.
libvirt_la_DEPENDENCIES = $(libvirt_la_BUILT_LIBADD) $(LIBVIRT_SYMBOL_FILE)
597

598
if WITH_DTRACE_PROBES
599
libvirt_la_BUILT_LIBADD += libvirt_probes.lo
600
libvirt_la_DEPENDENCIES += libvirt_probes.lo libvirt_probes.o
601
nodist_libvirt_la_SOURCES = libvirt_probes.h
E
Eric Blake 已提交
602
if WITH_REMOTE
E
Eric Blake 已提交
603
nodist_libvirt_driver_remote_la_SOURCES = libvirt_probes.h
E
Eric Blake 已提交
604
endif WITH_REMOTE
605
DTRACE2SYSTEMTAP_FLAGS = --with-modules
606

607 608
BUILT_SOURCES += libvirt_probes.h libvirt_probes.stp libvirt_functions.stp

609 610

tapsetdir = $(datadir)/systemtap/tapset
611
tapset_DATA += libvirt_probes.stp libvirt_functions.stp
612

613
%_probes.h: %_probes.d
614 615
	$(AM_V_GEN)$(DTRACE) -o $@ -h -s $<

E
Eric Blake 已提交
616
.PRECIOUS: %_probes.o
617
%_probes.o: %_probes.d
618 619
	$(AM_V_GEN)$(DTRACE) -o $@ -G -s $<

620 621 622 623 624 625 626 627 628
%_probes.lo: %_probes.o
	$(AM_V_GEN)printf %s\\n \
	  '# $@ - a libtool object file' \
	  '# Generated by libtool (GNU libtool) 2.4' \
	  '# Actually generated by Makefile.am, in order to shut up libtool' \
	  "pic_object='$<'" \
	  "non_pic_object='$<'" \
	> $@

E
Eric Blake 已提交
629
# Keep this list synced with PROTOCOL_STRUCTS
630
RPC_PROBE_FILES += $(srcdir)/rpc/virnetprotocol.x \
J
Jiri Denemark 已提交
631 632
		  $(srcdir)/rpc/virkeepaliveprotocol.x \
		  $(srcdir)/remote/remote_protocol.x \
633
		  $(srcdir)/remote/lxc_protocol.x \
634
		  $(srcdir)/remote/qemu_protocol.x \
M
Martin Kletzander 已提交
635
		  $(srcdir)/admin/admin_protocol.x
636 637

libvirt_functions.stp: $(RPC_PROBE_FILES) $(srcdir)/rpc/gensystemtap.pl
638
	$(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gensystemtap.pl $(RPC_PROBE_FILES) > $@
639

640 641
%_probes.stp: %_probes.d $(srcdir)/dtrace2systemtap.pl \
		$(top_builddir)/config.status
642
	$(AM_V_GEN)$(PERL) -w $(srcdir)/dtrace2systemtap.pl \
643
	  $(DTRACE2SYSTEMTAP_FLAGS) $(bindir) $(sbindir) $(libdir) $< > $@
644

645
CLEANFILES += libvirt_probes.h libvirt_probes.o libvirt_probes.lo \
646
              libvirt_functions.stp libvirt_probes.stp
647
endif WITH_DTRACE_PROBES
648

649
EXTRA_DIST += libvirt_probes.d
650

C
Chris Lalancette 已提交
651
libvirt_qemu_la_SOURCES = libvirt-qemu.c
D
Daniel P. Berrange 已提交
652 653 654
libvirt_qemu_la_LDFLAGS = \
		$(VERSION_SCRIPT_FLAGS)$(LIBVIRT_QEMU_SYMBOL_FILE) \
		-version-info $(LIBVIRT_VERSION_INFO) \
655
		$(LIBVIRT_NODELETE) \
D
Daniel P. Berrange 已提交
656 657
		$(AM_LDFLAGS) \
		$(NULL)
658
libvirt_qemu_la_CFLAGS = $(AM_CFLAGS)
C
Chris Lalancette 已提交
659
libvirt_qemu_la_LIBADD = libvirt.la $(CYGWIN_EXTRA_LIBADD)
660

661
libvirt_lxc_la_SOURCES = libvirt-lxc.c
D
Daniel P. Berrange 已提交
662 663 664
libvirt_lxc_la_LDFLAGS = \
		$(VERSION_SCRIPT_FLAGS)$(LIBVIRT_LXC_SYMBOL_FILE) \
		-version-info $(LIBVIRT_VERSION_INFO) \
665
		$(LIBVIRT_NODELETE) \
D
Daniel P. Berrange 已提交
666 667
		$(AM_LDFLAGS) \
		$(NULL)
668 669 670
libvirt_lxc_la_CFLAGS = $(AM_CFLAGS)
libvirt_lxc_la_LIBADD = libvirt.la $(CYGWIN_EXTRA_LIBADD)

671
EXTRA_DIST += $(SYSCONF_FILES)
672 673

install-sysconfig:
E
Eric Blake 已提交
674
	$(MKDIR_P) $(DESTDIR)$(sysconfdir)/sysconfig
675 676 677
	for f in $(SYSCONF_FILES:%.sysconf=%) ; \
	do \
	  tgt=`basename $$f`; \
678
	  $(INSTALL_DATA) $(srcdir)/$$f.sysconf \
679
	      $(DESTDIR)$(sysconfdir)/sysconfig/$$tgt; \
680
	done
681 682

uninstall-sysconfig:
683 684 685 686 687
	for f in $(SYSCONF_FILES:%.sysconf=%) ; \
	do \
	  tgt=`basename $$f`; \
	  rm -f $(DESTDIR)$(sysconfdir)/sysconfig/$$tgt; \
	done
E
Eric Blake 已提交
688
	rmdir $(DESTDIR)$(sysconfdir)/sysconfig || :
689

690
LOGROTATE_FILES := $(LOGROTATE_FILES_IN:remote/%.in=%)
691 692 693 694

EXTRA_DIST += $(LOGROTATE_FILES_IN)

BUILT_SOURCES += $(LOGROTATE_FILES)
695
CLEANFILES += $(LOGROTATE_FILES)
696 697 698 699 700 701 702

%.logrotate: remote/%.logrotate.in
	$(AM_V_GEN)sed \
	    -e 's|[@]localstatedir[@]|$(localstatedir)|g' \
	    < $< > $@-t && \
	mv $@-t $@

703
if WITH_LIBVIRTD
704 705 706 707 708 709 710 711 712 713 714 715
install-logrotate: $(LOGROTATE_FILES)
	$(MKDIR_P) $(DESTDIR)$(sysconfdir)/logrotate.d/
	for f in $(LOGROTATE_FILES) ; \
	do \
	  tgt=`echo $$f | sed -e 's/.logrotate//'`; \
	  $(INSTALL_DATA) $$f \
		$(DESTDIR)$(sysconfdir)/logrotate.d/$$tgt; \
	done

uninstall-logrotate:
	rm -f $(LOGROTATE_FILES:%.logrotate=$(DESTDIR)$(sysconfdir)/logrotate.d/%)
	rmdir $(DESTDIR)$(sysconfdir)/logrotate.d || :
716 717 718 719

INSTALL_DATA_LOCAL += install-logrotate
UNINSTALL_LOCAL += uninstall-logrotate
endif WITH_LIBVIRTD
720

721

722
%.8: %.8.in $(top_srcdir)/configure.ac
723
	$(AM_V_GEN)sed \
724 725 726
		-e 's|[@]sysconfdir[@]|$(sysconfdir)|g' \
		-e 's|[@]localstatedir[@]|$(localstatedir)|g' \
		< $< > $@-t && \
727 728
	mv $@-t $@

729
CLEANFILES += $(man8_MANS)
A
Andrea Bolognani 已提交
730
MAINTAINERCLEANFILES += $(MANINFILES)
731 732

EXTRA_DIST += \
733
        $(SYSTEMD_UNIT_FILES_IN) \
A
Andrea Bolognani 已提交
734 735
        $(PODFILES) \
        $(MANINFILES) \
736
        $(NULL)
737

738 739 740 741

if WITH_LIBVIRTD
if LIBVIRT_INIT_SCRIPT_SYSTEMD

742
SYSTEMD_UNIT_DIR = $(prefix)/lib/systemd/system
743

744 745
BUILT_SOURCES += $(SYSTEMD_UNIT_FILES)
DISTCLEANFILES += $(SYSTEMD_UNIT_FILES)
746

747
install-systemd: $(SYSTEMD_UNIT_FILES) install-sysconfig
E
Eric Blake 已提交
748
	$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
749 750 751 752
	for f in $(SYSTEMD_UNIT_FILES); \
	do \
	  $(INSTALL_DATA) $$f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/ ; \
	done
753 754

uninstall-systemd: uninstall-sysconfig
755
	rm -f $(SYSTEMD_UNIT_FILES:%=$(DESTDIR)$(SYSTEMD_UNIT_DIR)/%)
E
Eric Blake 已提交
756
	rmdir $(DESTDIR)$(SYSTEMD_UNIT_DIR) || :
757 758 759 760 761

INSTALL_DATA_LOCAL += install-systemd
UNINSTALL_LOCAL += uninstall-systemd
endif LIBVIRT_INIT_SCRIPT_SYSTEMD
endif WITH_LIBVIRTD
762 763


764
EXTRA_DIST += dtrace2systemtap.pl
765

766

767
if WITH_LIBVIRTD
768 769
libexec_PROGRAMS += libvirt_iohelper
libvirt_iohelper_SOURCES = $(UTIL_IO_HELPER_SOURCES)
D
Daniel P. Berrange 已提交
770 771 772 773
libvirt_iohelper_LDFLAGS = \
		$(AM_LDFLAGS) \
		$(PIE_LDFLAGS) \
		$(NULL)
774
libvirt_iohelper_LDADD = \
775
		libvirt.la \
776
		../gnulib/lib/libgnu.la
777 778
if WITH_DTRACE_PROBES
libvirt_iohelper_LDADD += libvirt_probes.lo
779
endif WITH_DTRACE_PROBES
780

D
Daniel P. Berrange 已提交
781 782 783 784
libvirt_iohelper_CFLAGS = \
		$(AM_CFLAGS) \
		$(PIE_CFLAGS) \
		$(NULL)
785 786


787
endif WITH_LIBVIRTD
788

789

790 791
install-data-local: $(INSTALL_DATA_LOCAL) \
		$(INSTALL_DATA_DIRS:%=install-data-%)
792 793
	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/cache/libvirt"
	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/images"
794
	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/filesystems"
795
	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/boot"
796

797
uninstall-local: $(UNINSTALL_LOCAL) \
798
		$(INSTALL_DATA_DIRS:%=uninstall-data-%)
799 800
	rmdir "$(DESTDIR)$(localstatedir)/cache/libvirt" ||:
	rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/images" ||:
801
	rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/filesystems" ||:
802 803
	rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/boot" ||:
	rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt" ||:
R
Richard W.M. Jones 已提交
804

805 806
CLEANFILES += *.gcov .libs/*.gcda .libs/*.gcno *.gcno *.gcda *.i *.s
DISTCLEANFILES += $(GENERATED_SYM_FILES)