2012-05-29 18:33:00 +04:00
|
|
|
include Makefile.inc
|
2011-09-23 12:00:45 +04:00
|
|
|
|
|
|
|
CFLAGS += -I./include
|
2012-02-01 19:00:02 +04:00
|
|
|
CFLAGS += -O0 -ggdb3
|
2011-09-23 12:00:45 +04:00
|
|
|
|
2012-07-12 13:06:00 +04:00
|
|
|
LIBS += -lrt -lpthread -lprotobuf-c
|
2011-09-23 12:00:45 +04:00
|
|
|
|
|
|
|
DEFINES += -D_FILE_OFFSET_BITS=64
|
|
|
|
DEFINES += -D_GNU_SOURCE
|
|
|
|
|
|
|
|
ifneq ($(WERROR),0)
|
|
|
|
WARNINGS += -Werror
|
|
|
|
endif
|
|
|
|
|
2011-12-27 02:27:20 +04:00
|
|
|
ifeq ($(DEBUG),1)
|
|
|
|
DEFINES += -DCR_DEBUG
|
|
|
|
endif
|
|
|
|
|
2012-05-18 15:35:00 +04:00
|
|
|
WARNINGS += -Wall
|
2011-09-23 12:00:45 +04:00
|
|
|
CFLAGS += $(WARNINGS) $(DEFINES)
|
|
|
|
|
|
|
|
PROGRAM := crtools
|
|
|
|
|
2011-09-29 16:03:36 +04:00
|
|
|
export CC ECHO MAKE CFLAGS LIBS ARCH DEFINES
|
|
|
|
|
2012-04-18 15:44:00 +04:00
|
|
|
OBJS += parasite-syscall.o
|
|
|
|
OBJS += cr-restore.o
|
2011-09-23 12:00:45 +04:00
|
|
|
OBJS += crtools.o
|
2012-06-28 03:12:08 +04:00
|
|
|
OBJS += image.o
|
2012-01-13 20:52:35 +04:00
|
|
|
OBJS += proc_parse.o
|
2011-09-23 12:00:45 +04:00
|
|
|
OBJS += cr-dump.o
|
|
|
|
OBJS += cr-show.o
|
2012-03-02 14:01:08 +04:00
|
|
|
OBJS += cr-check.o
|
2011-09-23 12:00:45 +04:00
|
|
|
OBJS += util.o
|
2012-02-01 13:00:49 +03:00
|
|
|
OBJS += util-net.o
|
2012-02-02 19:55:48 +04:00
|
|
|
OBJS += sysctl.o
|
2011-12-19 21:57:59 +04:00
|
|
|
OBJS += ptrace.o
|
2012-04-09 18:01:18 +04:00
|
|
|
OBJS += kcmp-ids.o
|
2012-02-24 23:11:08 +04:00
|
|
|
OBJS += rbtree.o
|
2011-12-19 18:52:50 +04:00
|
|
|
OBJS += log.o
|
2011-12-26 22:12:03 +04:00
|
|
|
OBJS += libnetlink.o
|
|
|
|
OBJS += sockets.o
|
2012-04-26 14:30:42 +04:00
|
|
|
OBJS += sk-inet.o
|
2012-04-28 17:29:14 +04:00
|
|
|
OBJS += sk-tcp.o
|
2012-04-26 15:04:40 +04:00
|
|
|
OBJS += sk-unix.o
|
2012-04-23 14:12:00 +04:00
|
|
|
OBJS += sk-queue.o
|
2012-01-10 18:03:00 +04:00
|
|
|
OBJS += files.o
|
2012-06-20 20:00:30 +04:00
|
|
|
OBJS += files-reg.o
|
2012-04-05 20:02:00 +04:00
|
|
|
OBJS += pipes.o
|
2012-06-26 02:36:13 +04:00
|
|
|
OBJS += fifo.o
|
2012-02-28 18:27:28 +04:00
|
|
|
OBJS += file-ids.o
|
2012-01-26 15:27:00 +04:00
|
|
|
OBJS += namespaces.o
|
2012-01-31 11:29:23 +03:00
|
|
|
OBJS += uts_ns.o
|
2012-01-31 22:28:55 +04:00
|
|
|
OBJS += ipc_ns.o
|
2012-04-28 17:21:32 +04:00
|
|
|
OBJS += netfilter.o
|
2012-05-03 18:01:05 +04:00
|
|
|
OBJS += shmem.o
|
2012-05-04 13:38:00 +04:00
|
|
|
OBJS += eventfd.o
|
2012-05-04 13:38:00 +04:00
|
|
|
OBJS += eventpoll.o
|
2012-05-04 13:38:00 +04:00
|
|
|
OBJS += mount.o
|
2012-05-04 13:38:00 +04:00
|
|
|
OBJS += inotify.o
|
2012-06-26 14:51:00 +04:00
|
|
|
OBJS += pstree.o
|
2012-07-17 07:00:18 +04:00
|
|
|
OBJS += protobuf.o
|
2011-09-23 12:00:45 +04:00
|
|
|
|
2012-07-12 13:06:00 +04:00
|
|
|
PROTOBUF-LIB := protobuf/protobuf-lib.o
|
|
|
|
|
2012-04-18 15:44:00 +04:00
|
|
|
DEPS := $(patsubst %.o,%.d,$(OBJS))
|
2012-01-23 11:26:00 +04:00
|
|
|
|
2012-05-31 15:39:00 +04:00
|
|
|
MAKEFLAGS += --no-print-directory
|
|
|
|
|
syscalls: Complete redesign v9
At early days we've been using only a few syscalls
which together with debug compiler options always
produce relative addresses for memory variables used
in parasite and restorer blobs. Thus it came in unnoticed
that there is something worng with syscalls declarations
we use.
Basically all our syscalls are just a wrappers over inline
assembly code in form of
static long syscall2(int nr, long arg0, long arg1)
{
long ret;
asm volatile(
"movl %1, %%eax \t\n"
"movq %2, %%rdi \t\n"
"movq %3, %%rsi \t\n"
"syscall \t\n"
"movq %%rax, %0 \t\n"
: "=r"(ret)
: "g" ((int)nr), "g" (arg0), "g" (arg1)
: "rax", "rdi", "rsi", "memory");
return ret;
}
so every argument treated to be plain long (even if the call
sematics implies it's a memory address passed but not some
integer direct value) and transferred via general purpose
register.
As being mentioned it caused no problems when debug options
specified at compile time, the compiler do not tries to optimize
addressing but generates code which always compute them.
The situation is changed if one is building crtools with
optimization enabled -- the compiler finds that arguments
are rather plain long numbers and might pass direct addresses
of variables, instead of generating relative addresses
(because function declarations have no pointers and 'g' in cope
with 'mov' is used, which is of course wrong).
To fix all this -- now syscalls declarations are generated from
syscall.def file and function arguments are passed in conform
with x86-64 ABI.
This shrinks amount of source code needed to declare syscalls
and opens a way to use optimization.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-18 18:10:12 +04:00
|
|
|
include Makefile.syscall
|
2012-04-18 15:44:00 +04:00
|
|
|
include Makefile.pie
|
2012-02-22 02:09:14 +04:00
|
|
|
|
2012-05-29 18:33:00 +04:00
|
|
|
.PHONY: all test-legacy zdtm test rebuild clean distclean tags cscope \
|
2012-07-12 13:06:00 +04:00
|
|
|
docs help pie protobuf
|
2012-05-29 18:33:00 +04:00
|
|
|
|
2012-07-12 13:06:00 +04:00
|
|
|
all: protobuf pie
|
2012-05-31 15:39:00 +04:00
|
|
|
$(Q) $(MAKE) $(PROGRAM)
|
2012-05-29 18:33:00 +04:00
|
|
|
|
2012-05-31 15:39:00 +04:00
|
|
|
pie: $(PIE-GEN)
|
2012-01-17 16:08:08 +03:00
|
|
|
|
2012-07-12 13:06:00 +04:00
|
|
|
protobuf:
|
2012-07-19 14:55:08 +04:00
|
|
|
$(Q) $(MAKE) -C protobuf/
|
2012-07-12 13:06:00 +04:00
|
|
|
|
2011-09-23 12:00:45 +04:00
|
|
|
%.o: %.c
|
|
|
|
$(E) " CC " $@
|
|
|
|
$(Q) $(CC) -c $(CFLAGS) $< -o $@
|
|
|
|
|
2012-01-26 14:00:40 +04:00
|
|
|
%.i: %.c
|
|
|
|
$(E) " CC " $@
|
|
|
|
$(Q) $(CC) -E $(CFLAGS) $< -o $@
|
|
|
|
|
2012-02-12 19:45:45 +04:00
|
|
|
%.s: %.c
|
|
|
|
$(E) " CC " $@
|
|
|
|
$(Q) $(CC) -S $(CFLAGS) -fverbose-asm $< -o $@
|
|
|
|
|
2012-05-29 18:33:00 +04:00
|
|
|
%.d: %.c
|
|
|
|
$(E) " DEP " $@
|
|
|
|
$(Q) $(CC) -M -MT $@ -MT $(patsubst %.d,%.o,$@) $(CFLAGS) $< -o $@
|
|
|
|
|
2012-07-12 13:06:00 +04:00
|
|
|
$(PROGRAM): $(OBJS) $(SYS-OBJ) $(PROTOBUF-LIB)
|
2011-09-23 12:00:45 +04:00
|
|
|
$(E) " LINK " $@
|
2012-06-05 18:36:00 +04:00
|
|
|
$(Q) $(CC) $(CFLAGS) $^ $(LIBS) -o $@
|
2011-09-23 12:00:45 +04:00
|
|
|
|
2012-05-29 18:33:00 +04:00
|
|
|
test-legacy: all
|
2012-01-24 19:37:44 +04:00
|
|
|
$(Q) $(MAKE) -C test/legacy all
|
|
|
|
|
2012-05-29 18:33:00 +04:00
|
|
|
zdtm: all
|
2012-01-24 19:37:44 +04:00
|
|
|
$(Q) $(MAKE) -C test/zdtm all
|
|
|
|
|
|
|
|
test: zdtm
|
2012-01-25 16:56:57 +04:00
|
|
|
$(Q) $(SH) test/zdtm.sh
|
2011-09-29 16:03:36 +04:00
|
|
|
|
2011-11-03 11:58:45 +04:00
|
|
|
rebuild:
|
|
|
|
$(E) " FORCE-REBUILD"
|
|
|
|
$(Q) $(RM) -f ./*.o
|
|
|
|
$(Q) $(RM) -f ./*.d
|
|
|
|
$(Q) $(MAKE)
|
|
|
|
|
syscalls: Complete redesign v9
At early days we've been using only a few syscalls
which together with debug compiler options always
produce relative addresses for memory variables used
in parasite and restorer blobs. Thus it came in unnoticed
that there is something worng with syscalls declarations
we use.
Basically all our syscalls are just a wrappers over inline
assembly code in form of
static long syscall2(int nr, long arg0, long arg1)
{
long ret;
asm volatile(
"movl %1, %%eax \t\n"
"movq %2, %%rdi \t\n"
"movq %3, %%rsi \t\n"
"syscall \t\n"
"movq %%rax, %0 \t\n"
: "=r"(ret)
: "g" ((int)nr), "g" (arg0), "g" (arg1)
: "rax", "rdi", "rsi", "memory");
return ret;
}
so every argument treated to be plain long (even if the call
sematics implies it's a memory address passed but not some
integer direct value) and transferred via general purpose
register.
As being mentioned it caused no problems when debug options
specified at compile time, the compiler do not tries to optimize
addressing but generates code which always compute them.
The situation is changed if one is building crtools with
optimization enabled -- the compiler finds that arguments
are rather plain long numbers and might pass direct addresses
of variables, instead of generating relative addresses
(because function declarations have no pointers and 'g' in cope
with 'mov' is used, which is of course wrong).
To fix all this -- now syscalls declarations are generated from
syscall.def file and function arguments are passed in conform
with x86-64 ABI.
This shrinks amount of source code needed to declare syscalls
and opens a way to use optimization.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-18 18:10:12 +04:00
|
|
|
clean: cleanpie cleansyscall
|
2011-09-23 12:00:45 +04:00
|
|
|
$(E) " CLEAN"
|
2011-09-29 16:03:36 +04:00
|
|
|
$(Q) $(RM) -f ./*.o
|
|
|
|
$(Q) $(RM) -f ./*.d
|
2012-01-26 14:00:40 +04:00
|
|
|
$(Q) $(RM) -f ./*.i
|
2011-09-29 16:03:36 +04:00
|
|
|
$(Q) $(RM) -f ./*.img
|
|
|
|
$(Q) $(RM) -f ./*.out
|
|
|
|
$(Q) $(RM) -f ./*.bin
|
|
|
|
$(Q) $(RM) -f ./$(PROGRAM)
|
2012-02-02 13:35:33 +03:00
|
|
|
$(Q) $(RM) -rf ./test/dump/
|
2012-07-12 13:06:00 +04:00
|
|
|
$(Q) $(MAKE) -C protobuf/ clean
|
2012-01-24 19:37:44 +04:00
|
|
|
$(Q) $(MAKE) -C test/legacy clean
|
2012-01-25 17:40:09 +04:00
|
|
|
$(Q) $(MAKE) -C test/zdtm cleandep
|
2012-01-24 19:37:44 +04:00
|
|
|
$(Q) $(MAKE) -C test/zdtm clean
|
2012-01-25 17:45:49 +04:00
|
|
|
$(Q) $(MAKE) -C test/zdtm cleanout
|
2012-02-01 15:10:55 +04:00
|
|
|
$(Q) $(MAKE) -C Documentation clean
|
2011-09-23 12:00:45 +04:00
|
|
|
|
2012-02-14 03:10:29 +04:00
|
|
|
distclean: clean
|
|
|
|
$(E) " DISTCLEAN"
|
|
|
|
$(Q) $(RM) -f ./tags
|
|
|
|
$(Q) $(RM) -f ./cscope*
|
|
|
|
|
2011-09-23 12:00:45 +04:00
|
|
|
tags:
|
|
|
|
$(E) " GEN" $@
|
|
|
|
$(Q) $(RM) -f tags
|
2012-02-23 23:21:27 +04:00
|
|
|
$(Q) $(FIND) . -name '*.[hcS]' ! -path './.*' -print | xargs ctags -a
|
2011-09-23 12:00:45 +04:00
|
|
|
|
|
|
|
cscope:
|
|
|
|
$(E) " GEN" $@
|
2012-02-23 23:21:27 +04:00
|
|
|
$(Q) $(FIND) . -name '*.[hcS]' ! -path './.*' -print > cscope.files
|
2011-09-23 12:00:45 +04:00
|
|
|
$(Q) $(CSCOPE) -bkqu
|
2012-01-17 16:08:22 +03:00
|
|
|
|
2012-01-28 18:45:28 +04:00
|
|
|
docs:
|
|
|
|
$(Q) $(MAKE) -s -C Documentation all
|
|
|
|
|
2012-01-27 18:41:09 +04:00
|
|
|
help:
|
|
|
|
$(E) ' Targets:'
|
|
|
|
$(E) ' all - Build all [*] targets'
|
|
|
|
$(E) ' * crtools - Build crtools'
|
|
|
|
$(E) ' zdtm - Build zdtm test-suite'
|
2012-01-28 18:45:28 +04:00
|
|
|
$(E) ' docs - Build documentation'
|
2012-01-27 18:41:09 +04:00
|
|
|
$(E) ' clean - Clean everything'
|
|
|
|
$(E) ' tags - Generate tags file (ctags)'
|
|
|
|
$(E) ' cscope - Generate cscope database'
|
|
|
|
$(E) ' rebuild - Force-rebuild of [*] targets'
|
|
|
|
$(E) ' test - Run zdtm test-suite'
|
|
|
|
|
2012-05-31 15:39:00 +04:00
|
|
|
deps-targets := $(OBJS) $(patsubst %.o,%.s,$(OBJS)) $(patsubst %.o,%.i,$(OBJS)) $(PROGRAM)
|
2012-03-31 13:35:00 +04:00
|
|
|
|
2012-05-29 18:33:00 +04:00
|
|
|
.DEFAULT_GOAL := all
|
2012-04-18 15:44:00 +04:00
|
|
|
|
2012-04-05 16:49:12 +04:00
|
|
|
ifneq ($(filter $(deps-targets), $(MAKECMDGOALS)),)
|
|
|
|
INCDEPS := 1
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(INCDEPS),1)
|
2012-01-17 16:08:22 +03:00
|
|
|
-include $(DEPS)
|
2012-01-20 17:53:19 +03:00
|
|
|
endif
|