[CRIU] [PATCH v2 3/4] make: cleanup pie build
Kinsbursky Stanislav
skinsbursky at openvz.org
Wed Nov 7 05:43:27 EST 2012
From: Stanislav Kinsbursky <skinsbursky at openvz.org>
This patch simplifies pie build. Main change is replaces explicit rules by
implicit which reduces Makefile size and makes it more readable.
Notes:
1) intermediate build files are preserved.
2) Both blobs are linked with util-net.o. Restorer blob doesn't require it,
but this allows to avoid explicit rule for it.
Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
---
pie/Makefile | 86 ++++++++++++++++------------------------------------------
1 files changed, 24 insertions(+), 62 deletions(-)
-------------- next part --------------
diff --git a/pie/Makefile b/pie/Makefile
index 119e837..dcef8d5 100644
--- a/pie/Makefile
+++ b/pie/Makefile
@@ -1,92 +1,54 @@
-SYSCALL-LIB := ../syscall/syscall-x86-64.o
-CFLAGS += -I../include/ -I../protobuf/ -I../syscall/
-
include ../Makefile.inc
GEN-OFFSETS := gen-offsets.sh
PASM-OBJS += parasite-head-x86-64.o
-PASM-SRC += $(patsubst %.o,%.S,$(PASM-OBJS))
-
-POBJS += parasite.o
-PSRCS += $(patsubst %.o,%.c,$(POBJS))
-
-PBLOB-NAME := parasite
-PBLOB-HDR := parasite-blob.h
-PBLOB-BIN := parasite.bin
-PBLOB-BIN-O := $(PBLOB-BIN).o
-
-ROBJS += restorer.o
-ROBJS += log-simple.o
-RSRCS += $(patsubst %.o,%.c,$(ROBJS))
-
-RBLOB-NAME := restorer
-RBLOB-HDR := restorer-blob.h
-RBLOB-BIN := restorer.bin
-RBLOB-BIN-O := $(RBLOB-BIN).o
-
-DEPS += $(patsubst %.o,%.d,$(POBJS))
-DEPS += $(patsubst %.o,%.d,$(ROBJS))
+PARASITE += parasite.o
+RESTORER := restorer.o
+BLOBS := parasite-blob.h restorer-blob.h
PIELDS := pie.lds.S
-PIEFLAGS := -fpie -Wa,--noexecstack -fno-strict-aliasing
ASMFLAGS := -D__ASSEMBLY__
-.DEFAULT_GOAL := pie
+CFLAGS += -fpie -Wa,--noexecstack -fno-strict-aliasing
+CFLAGS += -I../include/ -I../protobuf/ -I../syscall/
-$(PASM-OBJS): $(PASM-SRC) $(SYSCALL-LIB)
- $(E) " CC " $@
- $(Q) $(CC) -c $(ASMFLAGS) $(CFLAGS) $(PIEFLAGS) $(patsubst %.o,%.S,$@) -o $@
+.DEFAULT_GOAL := pie
-$(POBJS): $(PSRCS) $(PASM-OBJS) $(SYSCALL-LIB)
- $(E) " CC " $@
- $(Q) $(CC) -c $(CFLAGS) $(PIEFLAGS) $(patsubst %.o,%.c,$@) -o $@
+SYSCALL-LIB := ../syscall/syscall-x86-64.o
+LIB-OBJS := util-net.o log-simple.o $(SYSCALL-LIB)
-parasite-util-net.o: util-net.c $(SYSCALL-LIB)
- $(E) " CC " $@
- $(Q) $(CC) -c $(CFLAGS) $(PIEFLAGS) $< -o $@
+$(PARASITE): $(LIB-OBJS) $(PASM-OBJS)
+$(RESTORER): $(LIB-OBJS)
-parasite-log.o: log-simple.c $(SYSCALL-LIB)
+%.o: %.S
$(E) " CC " $@
- $(Q) $(CC) -c $(CFLAGS) $(PIEFLAGS) $< -o $@
-
-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) $(SYSCALL-LIB)
+ $(Q) $(CC) -c $(ASMFLAGS) $(CFLAGS) $< -o $@
-$(PBLOB-BIN): $(PBLOB-BIN-O) $(PIELDS) $(POBJS) $(PASM-OBJS)
- $(E) " GEN " $@
- $(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) $(SYSCALL-LIB)
+%.o: %.c
$(E) " CC " $@
- $(Q) $(CC) -c $(CFLAGS) $(PIEFLAGS) $(patsubst %.o,%.c,$@) -o $@
+ $(Q) $(CC) -c $(CFLAGS) $< -o $@
-$(RBLOB-BIN-O): $(PIELDS) $(ROBJS)
+%.bin.o: %.o $(PIELDS)
$(E) " GEN " $@
- $(Q) $(LD) --oformat=elf64-x86-64 -T $(PIELDS) -o $(RBLOB-BIN).o $(ROBJS) $(SYSCALL-LIB)
+ $(Q) $(LD) --oformat=elf64-x86-64 -T $(PIELDS) -o $@ $< $(LIB-OBJS)
-$(RBLOB-BIN): $(RBLOB-BIN-O) $(PIELDS) $(ROBJS)
+%.bin: %.bin.o
$(E) " GEN " $@
- $(Q) $(LD) --oformat=binary -T $(PIELDS) -o $(RBLOB-BIN) $(ROBJS) $(SYSCALL-LIB)
+ $(Q) $(LD) --oformat=binary -T $(PIELDS) -o $@ $(SYSCALL-LIB)
-$(RBLOB-HDR): $(RBLOB-BIN) $(GEN-OFFSETS)
+%-blob.h: %.bin $(GEN-OFFSETS)
$(E) " GEN " $@
- $(Q) $(SH) $(GEN-OFFSETS) $(RBLOB-NAME) > $@ || rm -f $@
+ $(Q) $(SH) $(GEN-OFFSETS) $(@:-blob.h=) > $@ || rm -f $@
-pie: $(PBLOB-HDR) $(RBLOB-HDR)
+pie: $(BLOBS)
clean:
$(E) " CLEAN PIE"
- $(Q) $(RM) -f ./$(PBLOB-HDR)
- $(Q) $(RM) -f ./$(RBLOB-HDR)
+ $(Q) $(RM) -f ./*-blob.h
$(Q) $(RM) -f ./*.o
$(Q) $(RM) -f ./*.bin
$(Q) $(RM) -f ./*.bin.o
+
.PHONY: clean pie
+.SECONDARY:
More information about the CRIU
mailing list