[CRIU] [PATCH v4 1/4] make: move syscalls files and build to separated directory
Kinsbursky Stanislav
skinsbursky at openvz.org
Mon Nov 19 10:35:15 EST 2012
From: Stanislav Kinsbursky <skinsbursky at openvz.org>
This patch set moves all syscalls data to $(ARCH) directory ("x86_64" in this
particular case).
It does also some cleanup to generic Makefile.inc and syscalls-x86-64.sh.
Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
---
Makefile | 15 ++++++++-------
Makefile.inc | 11 ++++++++---
Makefile.pie | 18 +++++++++---------
x86_64/Makefile | 21 ++++++++++++++-------
x86_64/syscall-common-x86-64.S | 0
x86_64/syscalls-x86-64.sh | 12 +++++-------
6 files changed, 44 insertions(+), 33 deletions(-)
rename Makefile.syscall => x86_64/Makefile (64%)
rename syscall-common-x86-64.S => x86_64/syscall-common-x86-64.S (100%)
rename syscalls-x86-64.sh => x86_64/syscalls-x86-64.sh (74%)
mode change 100644 => 100755
-------------- next part --------------
diff --git a/Makefile b/Makefile
index 5574b8c..4bf98db 100644
--- a/Makefile
+++ b/Makefile
@@ -48,23 +48,23 @@ PROTOBUF-LIB := protobuf/protobuf-lib.o
DEPS := $(patsubst %.o,%.d,$(OBJS))
-MAKEFLAGS += --no-print-directory
-
-include Makefile.syscall
include Makefile.pie
.PHONY: all zdtm test rebuild clean distclean tags cscope \
- docs help pie protobuf
+ docs help pie protobuf x86_64
all: pie
$(Q) $(MAKE) $(PROGRAM)
-pie: protobuf
+pie: protobuf $(ARCH)
$(Q) $(MAKE) $(PIE-GEN)
protobuf:
$(Q) $(MAKE) -C protobuf/
+x86_64:
+ $(Q) $(MAKE) -C x86_64/
+
%.o: %.c
$(E) " CC " $@
$(Q) $(CC) -c $(CFLAGS) $< -o $@
@@ -81,7 +81,7 @@ protobuf:
$(E) " DEP " $@
$(Q) $(CC) -M -MT $@ -MT $(patsubst %.d,%.o,$@) $(CFLAGS) $< -o $@
-$(PROGRAM): $(OBJS) $(SYS-OBJ) $(PROTOBUF-LIB)
+$(PROGRAM): $(OBJS) $(SYSCALL-LIB) $(PROTOBUF-LIB)
$(E) " LINK " $@
$(Q) $(CC) $(CFLAGS) $^ $(LIBS) -o $@
@@ -99,7 +99,7 @@ rebuild:
$(Q) $(RM) -f ./protobuf/*.pb-c.h
$(Q) $(MAKE)
-clean: cleanpie cleansyscall
+clean: cleanpie
$(E) " CLEAN"
$(Q) $(RM) -f ./*.o
$(Q) $(RM) -f ./*.d
@@ -110,6 +110,7 @@ clean: cleanpie cleansyscall
$(Q) $(RM) -f ./$(PROGRAM)
$(Q) $(RM) -rf ./test/dump/
$(Q) $(MAKE) -C protobuf/ clean
+ $(Q) $(MAKE) -C x86_64/ clean
$(Q) $(MAKE) -C test/zdtm cleandep
$(Q) $(MAKE) -C test/zdtm clean
$(Q) $(MAKE) -C test/zdtm cleanout
diff --git a/Makefile.inc b/Makefile.inc
index 722cbfc..d59a76b 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -37,13 +37,15 @@ ifeq ($(uname_M),i386)
DEFINES += -DCONFIG_X86_32
endif
ifeq ($(uname_M),x86_64)
- ARCH := x86
+ ARCH := x86_64
DEFINES += -DCONFIG_X86_64
endif
no-deps-targets := tags cscope clean cleanout cleandep realclean
-CFLAGS += -I./include -fno-strict-aliasing
+SRC_DIR ?= $(shell pwd)
+
+CFLAGS += -I$(SRC_DIR)/include -fno-strict-aliasing
LIBS += -lrt -lpthread -lprotobuf-c
@@ -67,5 +69,8 @@ endif
WARNINGS += -Wall
CFLAGS += $(WARNINGS) $(DEFINES)
+MAKEFLAGS += --no-print-directory
+SYSCALL-LIB ?= $(SRC_DIR)/x86_64/syscall-x86-64.o
+
+export CC ECHO MAKE CFLAGS LIBS ARCH DEFINES MAKEFLAGS SRC_DIR SYSCALL-LIB
-export CC ECHO MAKE CFLAGS LIBS ARCH DEFINES
diff --git a/Makefile.pie b/Makefile.pie
index d5caccb..99e3593 100644
--- a/Makefile.pie
+++ b/Makefile.pie
@@ -27,19 +27,19 @@ PIELDS := pie.lds.S
PIEFLAGS := -fpie -Wa,--noexecstack -fno-strict-aliasing
ASMFLAGS := -D__ASSEMBLY__
-$(PASM-OBJS): $(PASM-SRC) $(SYS-OBJ)
+$(PASM-OBJS): $(PASM-SRC) $(SYSCALL-LIB)
$(E) " CC " $@
$(Q) $(CC) -c $(ASMFLAGS) $(CFLAGS) $(PIEFLAGS) $(patsubst %.o,%.S,$@) -o $@
-$(POBJS): $(PSRCS) $(PASM-OBJS) $(SYS-OBJ)
+$(POBJS): $(PSRCS) $(PASM-OBJS) $(SYSCALL-LIB)
$(E) " CC " $@
$(Q) $(CC) -c $(CFLAGS) $(PIEFLAGS) $(patsubst %.o,%.c,$@) -o $@
-parasite-util-net.o: util-net.c $(SYS-OBJ)
+parasite-util-net.o: util-net.c $(SYSCALL-LIB)
$(E) " CC " $@
$(Q) $(CC) -c $(CFLAGS) $(PIEFLAGS) $< -o $@
-parasite-log.o: log-simple.c $(SYS-OBJ)
+parasite-log.o: log-simple.c $(SYSCALL-LIB)
$(E) " CC " $@
$(Q) $(CC) -c $(CFLAGS) $(PIEFLAGS) $< -o $@
@@ -47,27 +47,27 @@ POBJS += parasite-util-net.o parasite-log.o
$(PBLOB-BIN-O): $(PIELDS) $(POBJS) $(PASM-OBJS)
$(E) " GEN " $@
- $(Q) $(LD) --oformat=elf64-x86-64 -T $(PIELDS) -o $(PBLOB-BIN).o $(POBJS) $(PASM-OBJS) $(SYS-OBJ)
+ $(Q) $(LD) --oformat=elf64-x86-64 -T $(PIELDS) -o $(PBLOB-BIN).o $(POBJS) $(PASM-OBJS) $(SYSCALL-LIB)
$(PBLOB-BIN): $(PBLOB-BIN-O) $(PIELDS) $(POBJS) $(PASM-OBJS)
$(E) " GEN " $@
- $(Q) $(LD) --oformat=binary -T $(PIELDS) -o $(PBLOB-BIN) $(POBJS) $(PASM-OBJS) $(SYS-OBJ)
+ $(Q) $(LD) --oformat=binary -T $(PIELDS) -o $(PBLOB-BIN) $(POBJS) $(PASM-OBJS) $(SYSCALL-LIB)
$(PBLOB-HDR): $(PBLOB-BIN) $(GEN-OFFSETS)
$(E) " GEN " $@
$(Q) $(SH) $(GEN-OFFSETS) $(PBLOB-NAME) > $@ || rm -f $@
-$(ROBJS): $(RSRCS) $(SYS-OBJ)
+$(ROBJS): $(RSRCS) $(SYSCALL-LIB)
$(E) " CC " $@
$(Q) $(CC) -c $(CFLAGS) $(PIEFLAGS) $(patsubst %.o,%.c,$@) -o $@
$(RBLOB-BIN-O): $(PIELDS) $(ROBJS)
$(E) " GEN " $@
- $(Q) $(LD) --oformat=elf64-x86-64 -T $(PIELDS) -o $(RBLOB-BIN).o $(ROBJS) $(SYS-OBJ)
+ $(Q) $(LD) --oformat=elf64-x86-64 -T $(PIELDS) -o $(RBLOB-BIN).o $(ROBJS) $(SYSCALL-LIB)
$(RBLOB-BIN): $(RBLOB-BIN-O) $(PIELDS) $(ROBJS)
$(E) " GEN " $@
- $(Q) $(LD) --oformat=binary -T $(PIELDS) -o $(RBLOB-BIN) $(ROBJS) $(SYS-OBJ)
+ $(Q) $(LD) --oformat=binary -T $(PIELDS) -o $(RBLOB-BIN) $(ROBJS) $(SYSCALL-LIB)
$(RBLOB-HDR): $(RBLOB-BIN) $(GEN-OFFSETS)
$(E) " GEN " $@
diff --git a/Makefile.syscall b/x86_64/Makefile
similarity index 64%
rename from Makefile.syscall
rename to x86_64/Makefile
index 29e61a7..de97c86 100644
--- a/Makefile.syscall
+++ b/x86_64/Makefile
@@ -1,17 +1,19 @@
-SYS-DEF := include/syscall-x86-64.def
+SYS-DEF := $(SRC_DIR)/include/syscall-x86-64.def
SYS-ASM-COMMON := syscall-common-x86-64.S
-SYS-TYPES := include/syscall-types.h
+SYS-TYPES := $(SRC_DIR)/include/syscall-types.h
-SYS-CODES := include/syscall-codes.h
-SYS-PROTO := include/syscall.h
+SYS-CODES := $(SRC_DIR)/include/syscall-codes.h
+SYS-PROTO := $(SRC_DIR)/include/syscall.h
SYS-ASM := syscall-x86-64.S
-SYS-GEN := syscalls-x86-64.sh
+SYS-GEN = $(shell pwd)/syscalls-x86-64.sh
SYS-OBJ := $(patsubst %.S,%.o,$(SYS-ASM))
SYS-FLAGS := -fpie -Wstrict-prototypes -Wa,--noexecstack -D__ASSEMBLY__ -nostdlib -fomit-frame-pointer
+.DEFAULT_GOAL := x86_64
+
$(SYS-ASM): $(SYS-GEN) $(SYS-DEF) $(SYS-ASM-COMMON) $(SYS-TYPES)
$(E) " GEN " $@
$(Q) $(SH) \
@@ -23,12 +25,17 @@ $(SYS-ASM): $(SYS-GEN) $(SYS-DEF) $(SYS-ASM-COMMON) $(SYS-TYPES)
$(SYS-ASM-COMMON) \
$(SYS-TYPES)
-$(SYS-OBJ): $(SYS-ASM)
+%.o: %.S
$(E) " CC " $@
$(Q) $(CC) -c $(CFLAGS) $(SYS-FLAGS) $< -o $@
-cleansyscall:
+x86_64: $(SYS-OBJ)
+
+clean:
$(E) " CLEAN SYSCALLS"
$(Q) $(RM) -f ./$(SYS-ASM)
$(Q) $(RM) -f ./$(SYS-CODES)
$(Q) $(RM) -f ./$(SYS-PROTO)
+ $(Q) $(RM) -f ./$(SYS-OBJ)
+
+.PHONY: clean x86_64
diff --git a/syscall-common-x86-64.S b/x86_64/syscall-common-x86-64.S
similarity index 100%
rename from syscall-common-x86-64.S
rename to x86_64/syscall-common-x86-64.S
diff --git a/syscalls-x86-64.sh b/x86_64/syscalls-x86-64.sh
old mode 100644
new mode 100755
similarity index 74%
rename from syscalls-x86-64.sh
rename to x86_64/syscalls-x86-64.sh
index b0a5c4f..f418dfc
--- a/syscalls-x86-64.sh
+++ b/x86_64/syscalls-x86-64.sh
@@ -2,15 +2,13 @@
in=$1
codesout=$2
-codes=`echo $2 | sed -e 's/include\///g'`
protosout=$3
-protos=`echo $3 | sed -e 's/include\///g'`
asmout=$4
asmcommon=$5
-prototypes=`echo $6 | sed -e 's/include\///g'`
+prototypes=`echo $6 | sed -e 's/.*\/include\///g'`
-codesdef=`echo $codes | tr "[[:space:]].-" _`
-protosdef=`echo $protos | tr "[[:space:]].-" _`
+codesdef=`echo $codesout | sed -e 's/.*\/include\///g' | tr "[[:space:]].-" _`
+protosdef=`echo $protosout | sed -e 's/.*\/include\///g' | tr "[[:space:]].-" _`
echo "/* Autogenerated, don't edit */" > $codesout
echo "#ifndef $codesdef" >> $codesout
@@ -20,10 +18,10 @@ echo "/* Autogenerated, don't edit */" > $protosout
echo "#ifndef $protosdef" >> $protosout
echo "#define $protosdef" >> $protosout
echo "#include \"$prototypes\"" >> $protosout
-echo "#include \"$codes\"" >> $protosout
+echo "#include \"$codesout\"" >> $protosout
echo "/* Autogenerated, don't edit */" > $asmout
-echo "#include \"$codes\"" >> $asmout
+echo "#include \"$codesout\"" >> $asmout
echo "#include \"$asmcommon\"" >> $asmout
cat $in | egrep -v '^#' | sed -e 's/\t\{1,\}/|/g' | awk -F '|' '{print "#define", $1, $2}' >> $codesout
More information about the CRIU
mailing list