1XEN_ROOT = $(CURDIR)/.. 2 3export PKG_CONFIG_DIR = $(CURDIR)/pkg-config 4 5include $(XEN_ROOT)/tools/Rules.mk 6 7SUBDIRS-y := 8SUBDIRS-y += libs 9SUBDIRS-y += libxc 10SUBDIRS-y += flask 11SUBDIRS-y += fuzz 12SUBDIRS-y += xenstore 13SUBDIRS-y += misc 14SUBDIRS-y += examples 15SUBDIRS-y += hotplug 16SUBDIRS-y += xentrace 17SUBDIRS-$(CONFIG_XCUTILS) += xcutils 18SUBDIRS-$(CONFIG_X86) += firmware 19SUBDIRS-y += console 20SUBDIRS-y += xenmon 21SUBDIRS-y += xenstat 22SUBDIRS-$(CONFIG_Linux) += memshr 23SUBDIRS-$(CONFIG_BLKTAP2) += blktap2 24SUBDIRS-$(CONFIG_NetBSD) += xenbackendd 25SUBDIRS-y += libfsimage 26SUBDIRS-$(CONFIG_Linux) += libvchan 27 28# do not recurse in to a dir we are about to delete 29ifneq "$(MAKECMDGOALS)" "distclean" 30SUBDIRS-$(CONFIG_QEMU_TRAD) += qemu-xen-traditional-dir 31SUBDIRS-$(CONFIG_QEMU_XEN) += qemu-xen-dir 32endif 33 34SUBDIRS-y += xenpmd 35SUBDIRS-y += libxl 36SUBDIRS-$(CONFIG_GOLANG) += golang 37SUBDIRS-y += xl 38SUBDIRS-y += helpers 39SUBDIRS-$(CONFIG_X86) += xenpaging 40SUBDIRS-$(CONFIG_X86) += debugger/gdbsx 41SUBDIRS-$(CONFIG_X86) += debugger/kdd 42SUBDIRS-$(CONFIG_TESTS) += tests 43 44# These don't cross-compile 45ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH)) 46SUBDIRS-y += python 47SUBDIRS-y += pygrub 48SUBDIRS-$(OCAML_TOOLS) += ocaml 49endif 50 51ifeq ($(CONFIG_RUMP),y) 52SUBDIRS-y := libs libxc xenstore 53endif 54 55# For the sake of linking, set the sys-root 56ifneq ($(CROSS_COMPILE),) 57CROSS_BIN_PATH ?= /usr/$(CROSS_COMPILE:-=)/bin 58CROSS_SYS_ROOT ?= /usr/$(CROSS_COMPILE:-=)/sys-root 59export CROSS_SYS_ROOT # exported for check/funcs.sh 60export CROSS_BIN_PATH # exported for cross-install.sh 61endif 62 63.PHONY: build all 64build all: subdirs-all 65 66.PHONY: install 67install: 68 $(INSTALL_DIR) -m 700 $(DESTDIR)$(XEN_DUMP_DIR) 69 $(INSTALL_DIR) $(DESTDIR)$(XEN_LOG_DIR) 70 $(INSTALL_DIR) $(DESTDIR)$(XEN_RUN_DIR) 71 $(INSTALL_DIR) $(DESTDIR)$(XEN_LIB_DIR) 72 $(INSTALL_DIR) $(DESTDIR)$(XEN_RUN_STORED) 73 $(INSTALL_DIR) $(DESTDIR)$(PKG_INSTALLDIR) 74 $(MAKE) subdirs-install 75 76.PHONY: uninstall 77uninstall: D=$(DESTDIR) 78uninstall: 79 [ -d $(D)$(XEN_CONFIG_DIR) ] && mv -f $(D)$(XEN_CONFIG_DIR) $(D)$(XEN_CONFIG_DIR).old-`date +%s` || true 80 rm -rf $(D)$(libdir)/xen 81 rm -rf $(D)$(SHAREDIR)/xen 82 rm -rf $(D)$(SHAREDIR)/qemu-xen 83 $(MAKE) subdirs-uninstall 84 85.PHONY: clean 86clean: subdirs-clean 87 rm -rf pkg-config 88 89.PHONY: distclean 90distclean: subdirs-distclean clean 91 rm -rf qemu-xen-traditional-dir qemu-xen-traditional-dir-remote 92 rm -rf qemu-xen-dir qemu-xen-dir-remote qemu-xen-build 93 rm -rf ../config/Tools.mk config.h config.log config.status \ 94 config.cache autom4te.cache 95 96ifneq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH)) 97IOEMU_CONFIGURE_CROSS ?= --cross-prefix=$(CROSS_COMPILE) \ 98 --interp-prefix=$(CROSS_SYS_ROOT) 99endif 100 101ifeq ($(XEN_TOOLS_RPATH),y) 102QEMU_UPSTREAM_RPATH := -Wl,-rpath,$(LIBEXEC_LIB):$(libdir) 103IOEMU_EXTRA_LDFLAGS := --extra-ldflags="-Wl,-rpath,$(libdir)" 104else 105QEMU_UPSTREAM_RPATH := -Wl,-rpath,$(LIBEXEC_LIB) 106IOEMU_EXTRA_LDFLAGS := 107endif 108 109QEMU_ROOT := $(shell if [ -d "$(QEMU_TRADITIONAL_LOC)" ]; then echo "$(QEMU_TRADITIONAL_LOC)"; else echo .; fi) 110ifneq ($(QEMU_ROOT),.) 111export QEMU_ROOT 112endif 113 114# Targets for external trees: 115# ${target}-dir-find 116# See if the directory exists and check it out if not. 117# ${target}-dir-force-update 118# Pull to the most recent update (as if you had checked it out for the 119# first time) 120# subdir-all-${target}-dir 121# Do "make all" for ${target}, including all prerequisites (such as 122# configure) 123# subdir-install-${target}-dir 124# Do "make install" for $TARGET 125# subdir-clean-${target}-dir 126# Do "make clean" for $TARGET 127# 128# Directories for external trees: 129# ${target}-dir 130# Used for local builds. Usually a link to ${target}-dir-remote 131# ${target}-dir-remote 132# Where remote repositories are cloned 133# ${target} 134# Where a copy of the source files are put when building a source 135# tarball for release 136# 137# Expected variables: 138# ${TARGET}_URL 139# A url from which to clone a git repo 140# ${TARGET}_REVISION 141# The target revision to check out when doing "find" or "force-update" 142# ${TARGET}_INTREE 143# The directory where the subtree can be found (usually used when building 144# a source tarball) 145# ${TARGET}_LOC 146# The ultimate location of the source (either a local dir or remote URL) 147 148# External target: qemu-xen-traditional 149qemu-xen-traditional-dir-find: 150 set -ex; \ 151 if test -d $(QEMU_TRADITIONAL_LOC); then \ 152 mkdir -p qemu-xen-traditional-dir; \ 153 else \ 154 export GIT=$(GIT); \ 155 $(XEN_ROOT)/scripts/git-checkout.sh $(QEMU_TRADITIONAL_LOC) $(QEMU_TRADITIONAL_REVISION) qemu-xen-traditional-dir; \ 156 fi 157 158.PHONY: qemu-xen-traditional-dir-force-update 159qemu-xen-traditional-dir-force-update: qemu-xen-traditional-dir-find 160 set -ex; \ 161 if [ "$(QEMU_TRADITIONAL_REVISION)" ]; then \ 162 cd qemu-xen-traditional-dir-remote; \ 163 $(GIT) fetch origin; \ 164 $(GIT) reset --hard $(QEMU_TRADITIONAL_REVISION); \ 165 fi 166 167qemu-traditional-recurse = \ 168 set -e; \ 169 $(buildmakevars2shellvars); \ 170 export CONFIG_BLKTAP1=n; \ 171 cd qemu-xen-traditional-dir; \ 172 $(1) 173 174subdir-all-qemu-xen-traditional-dir: qemu-xen-traditional-dir-find 175 $(call qemu-traditional-recurse,\ 176 $(QEMU_ROOT)/xen-setup \ 177 --extra-cflags="-D__XEN_TOOLS__ $(EXTRA_CFLAGS_QEMU_TRADITIONAL)" \ 178 $(IOEMU_EXTRA_LDFLAGS) \ 179 --cpu=$(IOEMU_CPU_ARCH) \ 180 $(IOEMU_CONFIGURE_CROSS); \ 181 $(MAKE) all \ 182 ) 183 184subdir-install-qemu-xen-traditional-dir: subdir-all-qemu-xen-traditional-dir 185 $(call qemu-traditional-recurse,$(MAKE) install) 186 187subdir-clean-qemu-xen-traditional-dir: 188 set -e; if test -d qemu-xen-traditional-dir/.; then \ 189 $(MAKE) -C qemu-xen-traditional-dir clean; \ 190 fi 191subdir-uninstall-qemu-xen-traditional-dir: 192 rm -f $(D)$(bindir)/qemu-nbd* 193 rm -f $(D)$(bindir)/qemu-img* 194 195# External target: qemu-xen 196qemu-xen-dir-find: 197 if test -d $(QEMU_UPSTREAM_LOC) ; then \ 198 mkdir -p qemu-xen-dir; \ 199 else \ 200 export GIT=$(GIT); \ 201 $(XEN_ROOT)/scripts/git-checkout.sh $(QEMU_UPSTREAM_LOC) $(QEMU_UPSTREAM_REVISION) qemu-xen-dir ; \ 202 fi 203 204.PHONY: qemu-xen-dir-force-update 205qemu-xen-dir-force-update: qemu-xen-dir-find 206 set -ex; \ 207 if [ "$(QEMU_UPSTREAM_REVISION)" ]; then \ 208 cd qemu-xen-dir-remote; \ 209 $(GIT) fetch origin; \ 210 $(GIT) reset --hard $(QEMU_UPSTREAM_REVISION); \ 211 fi 212 213ifeq ($(debug),y) 214QEMU_XEN_ENABLE_DEBUG := --enable-debug 215else 216QEMU_XEN_ENABLE_DEBUG := 217endif 218 219subdir-all-qemu-xen-dir: qemu-xen-dir-find 220 unset MAKELEVEL; \ 221 if test -d $(QEMU_UPSTREAM_LOC) ; then \ 222 source=$(QEMU_UPSTREAM_LOC); \ 223 else \ 224 source=$(XEN_ROOT)/tools/qemu-xen-dir; \ 225 fi; \ 226 mkdir -p qemu-xen-build; \ 227 cd qemu-xen-build; \ 228 if $$source/scripts/tracetool.py --check-backend --backend log ; then \ 229 enable_trace_backend='--enable-trace-backend=log'; \ 230 elif $$source/scripts/tracetool.py --check-backend --backend stderr ; then \ 231 enable_trace_backend='--enable-trace-backend=stderr'; \ 232 else \ 233 enable_trace_backend='' ; \ 234 fi ; \ 235 PKG_CONFIG_PATH=$(XEN_ROOT)/tools/pkg-config \ 236 $$source/configure --enable-xen --target-list=i386-softmmu \ 237 $(QEMU_XEN_ENABLE_DEBUG) \ 238 $$enable_trace_backend \ 239 --prefix=$(LIBEXEC) \ 240 --libdir=$(LIBEXEC_LIB) \ 241 --includedir=$(LIBEXEC_INC) \ 242 --source-path=$$source \ 243 --extra-cflags="-DXC_WANT_COMPAT_EVTCHN_API=1 \ 244 -DXC_WANT_COMPAT_GNTTAB_API=1 \ 245 -DXC_WANT_COMPAT_MAP_FOREIGN_API=1 \ 246 -DXC_WANT_COMPAT_DEVICEMODEL_API=1 \ 247 -I$(XEN_ROOT)/tools/include \ 248 -I$(XEN_ROOT)/tools/libs/toolcore/include \ 249 -I$(XEN_ROOT)/tools/libs/toollog/include \ 250 -I$(XEN_ROOT)/tools/libs/evtchn/include \ 251 -I$(XEN_ROOT)/tools/libs/gnttab/include \ 252 -I$(XEN_ROOT)/tools/libs/foreignmemory/include \ 253 -I$(XEN_ROOT)/tools/libs/devicemodel/include \ 254 -I$(XEN_ROOT)/tools/libxc/include \ 255 -I$(XEN_ROOT)/tools/xenstore/include \ 256 -I$(XEN_ROOT)/tools/xenstore/compat/include \ 257 $(EXTRA_CFLAGS_QEMU_XEN)" \ 258 --extra-ldflags="-L$(XEN_ROOT)/tools/libxc \ 259 -L$(XEN_ROOT)/tools/xenstore \ 260 -L$(XEN_ROOT)/tools/libs/toolcore \ 261 -L$(XEN_ROOT)/tools/libs/evtchn \ 262 -L$(XEN_ROOT)/tools/libs/gnttab \ 263 -L$(XEN_ROOT)/tools/libs/foreignmemory \ 264 -L$(XEN_ROOT)/tools/libs/devicemodel \ 265 -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/toolcore \ 266 -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/toollog \ 267 -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/evtchn \ 268 -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/gnttab \ 269 -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/call \ 270 -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/foreignmemory \ 271 -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/devicemodel \ 272 $(QEMU_UPSTREAM_RPATH)" \ 273 --bindir=$(LIBEXEC_BIN) \ 274 --datadir=$(SHAREDIR)/qemu-xen \ 275 --localstatedir=$(localstatedir) \ 276 --disable-kvm \ 277 --disable-docs \ 278 --disable-guest-agent \ 279 --python=$(PYTHON) \ 280 $(CONFIG_QEMUU_EXTRA_ARGS) \ 281 --cpu=$(IOEMU_CPU_ARCH) \ 282 $(IOEMU_CONFIGURE_CROSS); \ 283 $(MAKE) all 284 285subdir-install-qemu-xen-dir: subdir-all-qemu-xen-dir 286 cd qemu-xen-build; \ 287 $(MAKE) install 288 289subdir-clean-qemu-xen-dir: 290 set -e; if test -d qemu-xen-build/.; then \ 291 $(MAKE) -C qemu-xen-build clean; \ 292 fi 293 294subdir-uninstall-qemu-xen-dir: ; 295 296subdir-clean-debugger/gdbsx subdir-distclean-debugger/gdbsx: .phony 297 $(MAKE) -C debugger/gdbsx clean 298 299subdir-install-debugger/gdbsx: .phony 300 $(MAKE) -C debugger/gdbsx install 301 302subdir-all-debugger/gdbsx: .phony 303 $(MAKE) -C debugger/gdbsx all 304 305subdir-uninstall-debugger/gdbsx: .phony 306 $(MAKE) -C debugger/gdbsx uninstall 307 308subdir-clean-debugger/kdd subdir-distclean-debugger/kdd: .phony 309 $(MAKE) -C debugger/kdd clean 310 311subdir-install-debugger/kdd: .phony 312 $(MAKE) -C debugger/kdd install 313 314subdir-uninstall-debugger/kdd: .phony 315 $(MAKE) -C debugger/kdd uninstall 316 317subdir-all-debugger/kdd: .phony 318 $(MAKE) -C debugger/kdd all 319 320subdir-distclean-firmware: .phony 321 $(MAKE) -C firmware distclean 322 323subtree-force-update: 324ifeq ($(CONFIG_QEMU_XEN),y) 325 $(MAKE) qemu-xen-dir-force-update 326endif 327ifeq ($(CONFIG_QEMU_TRAD),y) 328 $(MAKE) qemu-xen-traditional-dir-force-update 329endif 330ifeq ($(CONFIG_X86),y) 331 $(MAKE) -C firmware subtree-force-update 332endif 333 334subtree-force-update-all: 335 $(MAKE) qemu-xen-dir-force-update 336 $(MAKE) qemu-xen-traditional-dir-force-update 337 $(MAKE) -C firmware subtree-force-update-all 338