[CRIU] [PATCH v3 1/4] make: move syscalls files and build to separated directory
Kinsbursky Stanislav
skinsbursky at openvz.org
Fri Nov 9 03:02:46 EST 2012
From: Stanislav Kinsbursky <skinsbursky at openvz.org>
Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
---
Makefile | 13 ++++++++-----
Makefile.inc | 2 ++
Makefile.pie | 18 +++++++++---------
syscall/Makefile | 21 +++++++++++++++------
syscall/syscall-common-x86-64.S | 2 +-
syscall/syscalls-x86-64.sh | 14 ++++++++------
6 files changed, 43 insertions(+), 27 deletions(-)
rename Makefile.syscall => syscall/Makefile (68%)
rename syscall-common-x86-64.S => syscall/syscall-common-x86-64.S (86%)
rename syscalls-x86-64.sh => syscall/syscalls-x86-64.sh (74%)
-------------- next part --------------
diff --git a/Makefile b/Makefile
index 5574b8c..0f457c8 100644
--- a/Makefile
+++ b/Makefile
@@ -50,21 +50,23 @@ 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 syscall
all: pie
$(Q) $(MAKE) $(PROGRAM)
-pie: protobuf
+pie: protobuf syscall
$(Q) $(MAKE) $(PIE-GEN)
protobuf:
$(Q) $(MAKE) -C protobuf/
+syscall:
+ $(Q) $(MAKE) -C syscall/
+
%.o: %.c
$(E) " CC " $@
$(Q) $(CC) -c $(CFLAGS) $< -o $@
@@ -81,7 +83,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 +101,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 +112,7 @@ clean: cleanpie cleansyscall
$(Q) $(RM) -f ./$(PROGRAM)
$(Q) $(RM) -rf ./test/dump/
$(Q) $(MAKE) -C protobuf/ clean
+ $(Q) $(MAKE) -C syscall/ 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..717e1ca 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -69,3 +69,5 @@ WARNINGS += -Wall
CFLAGS += $(WARNINGS) $(DEFINES)
export CC ECHO MAKE CFLAGS LIBS ARCH DEFINES
+
+SYSCALL-LIB := syscall/syscall-x86-64.o
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/syscall/Makefile
similarity index 68%
rename from Makefile.syscall
rename to syscall/Makefile
index 29e61a7..90eea77 100644
--- a/Makefile.syscall
+++ b/syscall/Makefile
@@ -1,9 +1,11 @@
-SYS-DEF := include/syscall-x86-64.def
+include ../Makefile.inc
+
+SYS-DEF := ../include/syscall-x86-64.def
SYS-ASM-COMMON := syscall-common-x86-64.S
-SYS-TYPES := include/syscall-types.h
+SYS-TYPES := ../include/syscall-types.h
-SYS-CODES := include/syscall-codes.h
-SYS-PROTO := include/syscall.h
+SYS-CODES := ../include/syscall-codes.h
+SYS-PROTO := ../include/syscall.h
SYS-ASM := syscall-x86-64.S
SYS-GEN := syscalls-x86-64.sh
@@ -12,6 +14,8 @@ SYS-OBJ := $(patsubst %.S,%.o,$(SYS-ASM))
SYS-FLAGS := -fpie -Wstrict-prototypes -Wa,--noexecstack -D__ASSEMBLY__ -nostdlib -fomit-frame-pointer
+.DEFAULT_GOAL := syscalls
+
$(SYS-ASM): $(SYS-GEN) $(SYS-DEF) $(SYS-ASM-COMMON) $(SYS-TYPES)
$(E) " GEN " $@
$(Q) $(SH) \
@@ -23,12 +27,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:
+syscalls: $(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 syscalls
diff --git a/syscall-common-x86-64.S b/syscall/syscall-common-x86-64.S
similarity index 86%
rename from syscall-common-x86-64.S
rename to syscall/syscall-common-x86-64.S
index 84bcd8b..7802d50 100644
--- a/syscall-common-x86-64.S
+++ b/syscall/syscall-common-x86-64.S
@@ -1,4 +1,4 @@
-#include "linkage.h"
+#include "../include/linkage.h"
#define SYSCALL(name, opcode) \
ENTRY(name); \
diff --git a/syscalls-x86-64.sh b/syscall/syscalls-x86-64.sh
similarity index 74%
rename from syscalls-x86-64.sh
rename to syscall/syscalls-x86-64.sh
index b0a5c4f..7a54bcd 100644
--- a/syscalls-x86-64.sh
+++ b/syscall/syscalls-x86-64.sh
@@ -2,15 +2,17 @@
in=$1
codesout=$2
-codes=`echo $2 | sed -e 's/include\///g'`
+codes=`echo $2`
protosout=$3
-protos=`echo $3 | sed -e 's/include\///g'`
+protos=`echo $3`
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:]].-" _`
+codeslocal=`echo $codes | sed -e 's/\.\.\/include\///g'`
+
+codesdef=`echo $codes_local | tr "[[:space:]].-" _`
+protosdef=`echo $protos | sed -e 's/\/include\///g' | tr "[[:space:]].-" _`
echo "/* Autogenerated, don't edit */" > $codesout
echo "#ifndef $codesdef" >> $codesout
@@ -20,7 +22,7 @@ echo "/* Autogenerated, don't edit */" > $protosout
echo "#ifndef $protosdef" >> $protosout
echo "#define $protosdef" >> $protosout
echo "#include \"$prototypes\"" >> $protosout
-echo "#include \"$codes\"" >> $protosout
+echo "#include \"$codeslocal\"" >> $protosout
echo "/* Autogenerated, don't edit */" > $asmout
echo "#include \"$codes\"" >> $asmout
More information about the CRIU
mailing list