[CRIU] [PATCH v5 1/5] make: cleanup the whole infrastructure a bit

Kinsbursky Stanislav skinsbursky at openvz.org
Wed Nov 21 07:50:46 EST 2012


From: Stanislav Kinsbursky <skinsbursky at openvz.org>

Main things:
1) Variables are defined properly (":=" or ":=" instead of "+"). Otherwise,
because we call nested makefiles, and such variables like CFLAGS are
inheriting it's previous state.
2) SYS-OBJ renamed to SYSCALL-LIB.
3) Inlcude of Makefile.inc removed from protobuf/Makefile

Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
---
 Makefile          |    6 +-----
 Makefile.inc      |   20 ++++++++++++--------
 Makefile.pie      |   18 +++++++++---------
 Makefile.syscall  |    5 ++---
 protobuf/Makefile |    4 +---
 5 files changed, 25 insertions(+), 28 deletions(-)
-------------- next part --------------
diff --git a/Makefile b/Makefile
index 5574b8c..772bef2 100644
--- a/Makefile
+++ b/Makefile
@@ -44,12 +44,8 @@ OBJS		+= pstree.o
 OBJS		+= protobuf.o
 OBJS		+= tty.o
 
-PROTOBUF-LIB	:= protobuf/protobuf-lib.o
-
 DEPS		:= $(patsubst %.o,%.d,$(OBJS))
 
-MAKEFLAGS	+= --no-print-directory
-
 include Makefile.syscall
 include Makefile.pie
 
@@ -81,7 +77,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 $@
 
diff --git a/Makefile.inc b/Makefile.inc
index 722cbfc..f41e21c 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -9,7 +9,6 @@ else
 	E = @\#
 	Q =
 endif
-export E Q
 
 FIND		:= find
 CSCOPE		:= cscope
@@ -34,22 +33,24 @@ ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
 uname_M      := $(shell uname -m | sed -e s/i.86/i386/)
 ifeq ($(uname_M),i386)
 	ARCH         := x86
-	DEFINES      += -DCONFIG_X86_32
+	DEFINES      := -DCONFIG_X86_32
 endif
 ifeq ($(uname_M),x86_64)
 	ARCH         := x86
-	DEFINES      += -DCONFIG_X86_64
+	DEFINES      := -DCONFIG_X86_64
 endif
 
-no-deps-targets := tags cscope clean cleanout cleandep realclean
+SRC_DIR		?= $(shell pwd)
 
-CFLAGS		+= -I./include -fno-strict-aliasing
+CFLAGS		= -I$(SRC_DIR)/include -fno-strict-aliasing
 
-LIBS		+= -lrt -lpthread -lprotobuf-c
+LIBS		:= -lrt -lpthread -lprotobuf-c
 
 DEFINES		+= -D_FILE_OFFSET_BITS=64
 DEFINES		+= -D_GNU_SOURCE
 
+WARNINGS	:= -Wall
+
 ifneq ($(WERROR),0)
 	WARNINGS += -Werror
 endif
@@ -65,7 +66,10 @@ else
 	CFLAGS	+= -O2
 endif
 
-WARNINGS	+= -Wall
 CFLAGS		+= $(WARNINGS) $(DEFINES)
+MAKEFLAGS	:= --no-print-directory
+SYSCALL-LIB	= $(SRC_DIR)/syscall-x86-64.o
+PROTOBUF-LIB	= $(SRC_DIR)/protobuf/protobuf-lib.o
+
+export E Q CC ECHO MAKE CFLAGS LIBS ARCH DEFINES MAKEFLAGS SRC_DIR SYSCALL-LIB SH
 
-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/Makefile.syscall
index 29e61a7..f5e4efc 100644
--- a/Makefile.syscall
+++ b/Makefile.syscall
@@ -8,8 +8,6 @@ SYS-PROTO	:= include/syscall.h
 SYS-ASM		:= syscall-x86-64.S
 SYS-GEN		:= syscalls-x86-64.sh
 
-SYS-OBJ		:= $(patsubst %.S,%.o,$(SYS-ASM))
-
 SYS-FLAGS	:= -fpie -Wstrict-prototypes -Wa,--noexecstack -D__ASSEMBLY__ -nostdlib -fomit-frame-pointer
 
 $(SYS-ASM): $(SYS-GEN) $(SYS-DEF) $(SYS-ASM-COMMON) $(SYS-TYPES)
@@ -23,7 +21,7 @@ $(SYS-ASM): $(SYS-GEN) $(SYS-DEF) $(SYS-ASM-COMMON) $(SYS-TYPES)
 		$(SYS-ASM-COMMON)	\
 		$(SYS-TYPES)
 
-$(SYS-OBJ): $(SYS-ASM)
+$(SYSCALL-LIB): $(SYS-ASM)
 	$(E) "  CC      " $@
 	$(Q) $(CC) -c $(CFLAGS) $(SYS-FLAGS)  $< -o $@
 
@@ -32,3 +30,4 @@ cleansyscall:
 	$(Q) $(RM) -f ./$(SYS-ASM)
 	$(Q) $(RM) -f ./$(SYS-CODES)
 	$(Q) $(RM) -f ./$(SYS-PROTO)
+	$(Q) $(RM) -f ./$(SYSCALL-LIB)
diff --git a/protobuf/Makefile b/protobuf/Makefile
index 6a7f297..c5e9314 100644
--- a/protobuf/Makefile
+++ b/protobuf/Makefile
@@ -1,5 +1,3 @@
-include ../Makefile.inc
-
 PROTO_LIBRARY	:= protobuf-lib.o
 
 PROTO_FILES	+= inventory.proto
@@ -58,7 +56,7 @@ PROTO_OBJS	:= $(patsubst %.c,%.o,$(PROTO_SRCS))
 
 $(PROTO_LIBRARY): $(PROTO_OBJS)
 	$(E) "  LINK     "$@
-	$(Q) ld -r -o $@ $(PROTO_OBJS)
+	$(Q) $(LD) -r -o $@ $(PROTO_OBJS)
 
 .PHONY: protobuf
 


More information about the CRIU mailing list