2016-02-15 15:26:55 +03:00
|
|
|
#
|
2016-02-15 15:26:49 +03:00
|
|
|
# Import the build engine first
|
|
|
|
__nmk_dir=$(CURDIR)/scripts/nmk/scripts/
|
|
|
|
export __nmk_dir
|
|
|
|
|
|
|
|
include $(__nmk_dir)/include.mk
|
2016-02-15 15:26:55 +03:00
|
|
|
include $(__nmk_dir)/macro.mk
|
2012-11-22 18:54:21 +04:00
|
|
|
|
2016-02-18 12:43:27 +03:00
|
|
|
#
|
|
|
|
# Import tools versions early
|
|
|
|
# so subsequents may refer them.
|
|
|
|
include Makefile.versions
|
|
|
|
|
2013-02-15 23:40:33 +04:00
|
|
|
#
|
2016-02-15 15:26:55 +03:00
|
|
|
# To build host helpers.
|
2015-09-29 22:26:21 +03:00
|
|
|
HOSTCC ?= gcc
|
|
|
|
HOSTLD ?= ld
|
2016-02-15 15:26:55 +03:00
|
|
|
export HOSTCC HOSTLD
|
2012-11-22 18:54:21 +04:00
|
|
|
|
2014-02-07 12:04:42 -05:00
|
|
|
CFLAGS += $(USERCFLAGS)
|
2016-02-15 15:26:55 +03:00
|
|
|
export CFLAGS
|
2015-09-29 22:26:21 +03:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
HOSTCFLAGS ?= $(CFLAGS)
|
2015-09-29 22:26:21 +03:00
|
|
|
export HOSTCFLAGS
|
2014-02-07 12:04:42 -05:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
#
|
|
|
|
# Where we live.
|
|
|
|
SRC_DIR := $(CURDIR)
|
|
|
|
export SRC_DIR
|
2016-02-15 15:26:52 +03:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
#
|
|
|
|
# General architecture specific options.
|
|
|
|
UNAME-M := $(shell uname -m)
|
|
|
|
export UNAME-M
|
2012-11-22 18:54:21 +04:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
ifeq ($(ARCH),arm)
|
|
|
|
ARMV := $(shell echo $(UNAME-M) | sed -nr 's/armv([[:digit:]]).*/\1/p; t; i7')
|
|
|
|
DEFINES := -DCONFIG_ARMV$(ARMV)
|
2015-12-29 13:56:00 +03:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
USERCFLAGS += -Wa,-mimplicit-it=always
|
2013-07-10 10:15:54 +04:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
ifeq ($(ARMV),6)
|
|
|
|
USERCFLAGS += -march=armv6
|
|
|
|
endif
|
2014-12-24 11:42:00 +03:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
ifeq ($(ARMV),7)
|
|
|
|
USERCFLAGS += -march=armv7-a
|
|
|
|
endif
|
2013-07-10 10:15:54 +04:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
PROTOUFIX := y
|
|
|
|
endif
|
2013-01-22 22:53:24 +04:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
ifeq ($(ARCH),x86)
|
|
|
|
DEFINES := -DCONFIG_X86_64
|
2015-04-22 20:19:59 +03:00
|
|
|
endif
|
|
|
|
|
2016-02-11 19:48:15 +03:00
|
|
|
ifeq ($(ARCH),aarch64)
|
|
|
|
VDSO := y
|
|
|
|
endif
|
|
|
|
|
2015-04-30 09:57:49 +03:00
|
|
|
#
|
|
|
|
# The PowerPC 64 bits architecture could be big or little endian.
|
|
|
|
# They are handled in the same way.
|
|
|
|
#
|
2016-02-15 15:26:55 +03:00
|
|
|
ifeq ($(ARCH),powerpc)
|
|
|
|
ifeq ($(UNAME-M),ppc64)
|
|
|
|
error := $(error ppc64 big endian not yet supported)
|
|
|
|
endif
|
2013-10-11 10:48:00 +04:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
DEFINES := -DCONFIG_PPC64
|
2015-06-16 12:31:00 +03:00
|
|
|
endif
|
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
export PROTOUFIX DEFINES USERCFLAGS
|
2012-11-22 18:54:21 +04:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
#
|
|
|
|
# Independent options for all tools.
|
|
|
|
DEFINES += -D_FILE_OFFSET_BITS=64
|
|
|
|
DEFINES += -D_GNU_SOURCE
|
2012-11-22 18:54:21 +04:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
CFLAGS += $(USERCFLAGS)
|
2012-11-22 18:54:21 +04:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
WARNINGS := -Wall
|
2012-11-22 18:54:21 +04:00
|
|
|
|
|
|
|
ifneq ($(WERROR),0)
|
2016-02-15 15:26:55 +03:00
|
|
|
WARNINGS += -Werror
|
2012-11-22 18:54:21 +04:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(DEBUG),1)
|
2016-02-15 15:26:55 +03:00
|
|
|
DEFINES += -DCR_DEBUG
|
|
|
|
CFLAGS += -O0 -ggdb3
|
2012-11-22 18:54:21 +04:00
|
|
|
else
|
2016-02-15 15:26:55 +03:00
|
|
|
CFLAGS += -O2 -g
|
2015-06-05 00:04:02 +03:00
|
|
|
endif
|
2012-11-22 18:54:21 +04:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
CFLAGS += $(WARNINGS) $(DEFINES)
|
2013-02-15 23:40:33 +04:00
|
|
|
|
2013-02-15 23:40:28 +04:00
|
|
|
#
|
2016-02-15 15:26:55 +03:00
|
|
|
# Protobuf images first, they are not depending
|
|
|
|
# on anything else.
|
|
|
|
$(eval $(call gen-built-in,images))
|
|
|
|
PHONY += images
|
2015-06-05 00:04:02 +03:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
#
|
|
|
|
# CRIU building done in own directory
|
|
|
|
# with slightly different rules so we
|
|
|
|
# can't use nmk engine directly (we
|
|
|
|
# build syscalls library and such).
|
|
|
|
#
|
|
|
|
# But note that we're already included
|
|
|
|
# the nmk so we can reuse it there.
|
|
|
|
criu/%: images/built-in.o
|
|
|
|
$(Q) $(MAKE) -C criu $@
|
|
|
|
criu: images/built-in.o
|
|
|
|
$(Q) $(MAKE) -C criu all
|
|
|
|
criu/criu: criu
|
|
|
|
PHONY += criu
|
2012-01-26 14:00:40 +04:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
#
|
|
|
|
# Libraries next once criu it ready
|
|
|
|
# (we might generate headers and such
|
|
|
|
# when building criu itself).
|
|
|
|
lib/%: criu
|
2016-02-15 15:26:53 +03:00
|
|
|
$(Q) $(MAKE) -C lib $@
|
2016-02-15 15:26:55 +03:00
|
|
|
lib: criu
|
2016-02-15 15:26:53 +03:00
|
|
|
$(Q) $(MAKE) -C lib all
|
2016-02-15 15:26:55 +03:00
|
|
|
PHONY += lib
|
2016-02-15 15:26:53 +03:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
all: criu lib
|
|
|
|
PHONY += all
|
2016-02-15 15:26:53 +03:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
clean-built:
|
|
|
|
$(Q) $(MAKE) $(build)=images clean
|
|
|
|
$(Q) $(MAKE) -C criu clean
|
|
|
|
$(Q) $(MAKE) -C lib clean
|
2016-02-15 22:32:00 +03:00
|
|
|
$(Q) $(MAKE) -C Documentation clean
|
2016-02-15 15:26:55 +03:00
|
|
|
PHONY += clean-built
|
2013-08-28 23:57:47 +04:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
clean: clean-built
|
|
|
|
$(call msg-clean, criu)
|
|
|
|
PHONY += clean
|
2013-05-24 01:42:11 +04:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
#
|
|
|
|
# Non-CRIU stuff.
|
|
|
|
#
|
2013-05-24 01:42:12 +04:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
docs:
|
|
|
|
$(Q) $(MAKE) -s -C Documentation all
|
|
|
|
PHONY += docs
|
2011-09-23 12:00:45 +04:00
|
|
|
|
2012-05-29 18:33:00 +04:00
|
|
|
zdtm: all
|
2012-01-24 19:37:44 +04:00
|
|
|
$(Q) $(MAKE) -C test/zdtm all
|
2016-02-15 15:26:55 +03:00
|
|
|
PHONY += zdtm
|
2012-01-24 19:37:44 +04:00
|
|
|
|
|
|
|
test: zdtm
|
2014-05-14 17:35:20 +04:00
|
|
|
$(Q) $(MAKE) -C test
|
2016-02-15 15:26:55 +03:00
|
|
|
PHONY += test
|
2011-09-29 16:03:36 +04:00
|
|
|
|
2016-02-18 12:43:29 +03:00
|
|
|
tar-name := $(shell git tag -l v$(CRIU_VERSION))
|
|
|
|
ifeq ($(tar-name),)
|
|
|
|
tar-name := $(shell git describe)
|
|
|
|
endif
|
|
|
|
criu-$(tar-name).tar.bz2:
|
|
|
|
git archive --format tar --prefix 'criu-$(tar-name)/' $(tar-name) | bzip2 > $@
|
|
|
|
dist tar: criu-$(tar-name).tar.bz2
|
|
|
|
@true
|
2016-02-15 15:26:55 +03:00
|
|
|
.PHONY: dist tar
|
2012-02-14 03:10:29 +04:00
|
|
|
|
2011-09-23 12:00:45 +04:00
|
|
|
tags:
|
2016-02-15 15:26:55 +03:00
|
|
|
$(call msg-gen, $@)
|
2013-02-15 17:37:20 +04:00
|
|
|
$(Q) $(RM) tags
|
2015-05-05 12:44:00 +03:00
|
|
|
$(Q) $(FIND) . -name '*.[hcS]' ! -path './.*' ! -path './test/*' -print | xargs ctags -a
|
2016-02-15 15:26:55 +03:00
|
|
|
PHONY += tags
|
2011-09-23 12:00:45 +04:00
|
|
|
|
|
|
|
cscope:
|
2016-02-15 15:26:55 +03:00
|
|
|
$(call msg-gen, $@)
|
2015-05-05 12:44:00 +03:00
|
|
|
$(Q) $(FIND) . -name '*.[hcS]' ! -path './.*' ! -path './test/*' ! -type l -print > cscope.files
|
2011-09-23 12:00:45 +04:00
|
|
|
$(Q) $(CSCOPE) -bkqu
|
2016-02-15 15:26:55 +03:00
|
|
|
PHONY += cscope
|
2012-01-17 16:08:22 +03:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
gcov:
|
|
|
|
$(E) " GCOV"
|
|
|
|
$(Q) test -d gcov || mkdir gcov && \
|
|
|
|
cp *.{gcno,c} test/`pwd`/ && \
|
|
|
|
geninfo --output-filename gcov/crtools.h.info --no-recursion . && \
|
|
|
|
geninfo --output-filename gcov/crtools.ns.info --no-recursion test/`pwd`/ && \
|
|
|
|
sed -i 's#/test/`pwd`##' gcov/crtools.ns.info && \
|
|
|
|
cd gcov && \
|
|
|
|
lcov --rc lcov_branch_coverage=1 --add-tracefile crtools.h.info \
|
|
|
|
--add-tracefile crtools.ns.info --output-file criu.info && \
|
|
|
|
genhtml --rc lcov_branch_coverage=1 --output-directory html criu.info
|
|
|
|
@echo "Code coverage report is in `pwd`/gcov/html/ directory."
|
|
|
|
PHONY += gcov
|
2012-01-28 18:45:28 +04:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
docker-build:
|
2016-02-18 20:41:08 +03:00
|
|
|
$(MAKE) -C scripts/build/ x86_64
|
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
PHONY += docker-build
|
2013-04-30 13:25:06 -07:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
docker-test:
|
2016-02-18 20:41:08 +03:00
|
|
|
docker run --rm -it --privileged criu-x86_64 ./test/zdtm.sh -C -x tcp6 -x tcpbuf6 -x static/rtc -x cgroup -x mountpoint
|
2016-02-15 15:26:55 +03:00
|
|
|
PHONY += docker-test
|
2013-05-03 01:56:30 +04:00
|
|
|
|
2012-01-27 18:41:09 +04:00
|
|
|
help:
|
2013-05-01 20:17:05 -07:00
|
|
|
@echo ' Targets:'
|
|
|
|
@echo ' all - Build all [*] targets'
|
2013-05-01 20:17:06 -07:00
|
|
|
@echo ' * criu - Build criu'
|
2013-05-01 20:17:05 -07:00
|
|
|
@echo ' zdtm - Build zdtm test-suite'
|
|
|
|
@echo ' docs - Build documentation'
|
2013-05-03 01:56:30 +04:00
|
|
|
@echo ' install - Install binary and man page'
|
2013-05-03 01:56:31 +04:00
|
|
|
@echo ' dist - Create a source tarball'
|
2013-05-01 20:17:05 -07:00
|
|
|
@echo ' clean - Clean everything'
|
|
|
|
@echo ' tags - Generate tags file (ctags)'
|
|
|
|
@echo ' cscope - Generate cscope database'
|
|
|
|
@echo ' rebuild - Force-rebuild of [*] targets'
|
|
|
|
@echo ' test - Run zdtm test-suite'
|
2016-02-15 15:26:55 +03:00
|
|
|
@echo ' gcov - Make code coverage report'
|
|
|
|
PHONY += help
|
2012-12-25 22:43:14 +04:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
include Makefile.install
|
2015-03-20 11:33:09 +03:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
.PHONY: $(PHONY)
|
2015-03-20 11:33:09 +03:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
.DEFAULT_GOAL := all
|
2015-05-01 02:25:00 +03:00
|
|
|
|
2016-02-15 15:26:55 +03:00
|
|
|
#
|
|
|
|
# Optional local include.
|
2015-05-01 02:25:00 +03:00
|
|
|
-include Makefile.local
|