From 25e8cb5c58e5fe0e8817ab6180721abf334f12ab Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Fri, 15 Feb 2013 23:40:33 +0400 Subject: [PATCH] make: Switch main Makefile to simplified form This is a bit tricky since the build infrastructure we're switching to is targeted to per-directory targets if simplified Makefiles are used. So I did the following - move rules to compile general sources to Makefile.crtools - main Makefiles now simply calls for scritps/Makefile.build help to generate built-in.o target Also note that we clean up suffixes for implicit rules with .SUFFIXES: this is done on purpose to eliminate any possible side effect in future -- all rules _must_ be described explicitly. Because of implicit rules used in zdtm building procedure I can't use of stict makefile mode and add MAKEFLAGS := -r to the top of the general Makefile. This should be done one day latter (if ever). Signed-off-by: Cyrill Gorcunov Signed-off-by: Pavel Emelyanov --- Makefile | 98 +++++++++++------------------------------------- Makefile.crtools | 47 +++++++++++++++++++++++ 2 files changed, 68 insertions(+), 77 deletions(-) create mode 100644 Makefile.crtools diff --git a/Makefile b/Makefile index 92eadb09a..a71912663 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,16 @@ +# +# FIXME zdtm building procedure requires implicit rules +# so I can't use strict make file mode and drop completely +# all of implicit rules, so I tuned only .SUFFIXES: +# +# In future zdtm makefiles need to be fixed and the line below +# may be uncommented. +# +#MAKEFLAGS := -r -R --no-print-directory + # # Common definitions # - ifeq ($(strip $(V)),) E = @echo Q = @ @@ -89,58 +98,16 @@ export SRC_DIR SYSCALL-LIB SH RM ARCH_DIR OBJCOPY LDARCH LD include scripts/Makefile.version include scripts/Makefile.rules + +.SUFFIXES: + # # shorthand -build := -s -r -R --no-print-directory -f scripts/Makefile.build makefile=Makefile obj +build := -r -R --no-print-directory -f scripts/Makefile.build makefile=Makefile obj +build-crtools := -r -R --no-print-directory -f scripts/Makefile.build makefile=Makefile.crtools obj PROGRAM := crtools -OBJS += parasite-syscall.o -OBJS += cr-restore.o -OBJS += crtools.o -OBJS += image.o -OBJS += net.o -OBJS += proc_parse.o -OBJS += cr-dump.o -OBJS += cr-show.o -OBJS += cr-check.o -OBJS += util.o -OBJS += sysctl.o -OBJS += ptrace.o -OBJS += kcmp-ids.o -OBJS += rbtree.o -OBJS += log.o -OBJS += libnetlink.o -OBJS += sockets.o -OBJS += sk-inet.o -OBJS += sk-tcp.o -OBJS += sk-unix.o -OBJS += sk-packet.o -OBJS += sk-queue.o -OBJS += files.o -OBJS += files-reg.o -OBJS += pipes.o -OBJS += fifo.o -OBJS += file-ids.o -OBJS += namespaces.o -OBJS += uts_ns.o -OBJS += ipc_ns.o -OBJS += netfilter.o -OBJS += shmem.o -OBJS += eventfd.o -OBJS += eventpoll.o -OBJS += mount.o -OBJS += fsnotify.o -OBJS += signalfd.o -OBJS += pstree.o -OBJS += protobuf.o -OBJS += tty.o -OBJS += cr-exec.o -OBJS += cpu.o -OBJS += file-lock.o - -DEPS := $(patsubst %.o,%.d,$(OBJS)) - .PHONY: all zdtm test rebuild clean distclean tags cscope \ docs help pie protobuf arch/$(ARCH) @@ -166,23 +133,12 @@ pie/%:: arch/$(ARCH) pie: arch/$(ARCH) $(Q) $(MAKE) $(build)=pie all -%.o: %.c - $(E) " CC " $@ - $(Q) $(CC) -c $(CFLAGS) $< -o $@ +%.o %.i %.s %.d: $(VERSION_HEADER) pie + $(Q) $(MAKE) $(build-crtools)=. $@ +built-in.o: $(VERSION_HEADER) pie + $(Q) $(MAKE) $(build-crtools)=. $@ -%.i: %.c - $(E) " CC " $@ - $(Q) $(CC) -E $(CFLAGS) $< -o $@ - -%.s: %.c - $(E) " CC " $@ - $(Q) $(CC) -S $(CFLAGS) -fverbose-asm $< -o $@ - -%.d: %.c - $(E) " DEP " $@ - $(Q) $(CC) -M -MT $@ -MT $(patsubst %.d,%.o,$@) $(CFLAGS) $< -o $@ - -$(PROGRAM): $(SYSCALL-LIB) $(ARCH-LIB) pie/util-net.o protobuf/built-in.o $(OBJS) +$(PROGRAM): $(SYSCALL-LIB) $(ARCH-LIB) pie/util-net.o protobuf/built-in.o built-in.o $(E) " LINK " $@ $(Q) $(CC) $(CFLAGS) $^ $(LIBS) -o $@ @@ -206,9 +162,7 @@ clean: $(Q) $(MAKE) $(build)=arch/$(ARCH) clean $(Q) $(MAKE) $(build)=protobuf clean $(Q) $(MAKE) $(build)=pie clean - $(Q) $(RM) ./*.o - $(Q) $(RM) ./*.d - $(Q) $(RM) ./*.i + $(Q) $(MAKE) $(build-crtools)=. clean $(Q) $(RM) ./*.img $(Q) $(RM) ./*.out $(Q) $(RM) ./*.bin @@ -264,14 +218,4 @@ gcov: lcov -a crtools.l.info -a crtools.ns.info -o crtools.info && \ genhtml -o html crtools.info -deps-targets := $(OBJS) $(patsubst %.o,%.s,$(OBJS)) $(patsubst %.o,%.i,$(OBJS)) $(PROGRAM) - .DEFAULT_GOAL := all - -ifneq ($(filter $(deps-targets), $(MAKECMDGOALS)),) - INCDEPS := 1 -endif - -ifeq ($(INCDEPS),1) --include $(DEPS) -endif diff --git a/Makefile.crtools b/Makefile.crtools new file mode 100644 index 000000000..314828f84 --- /dev/null +++ b/Makefile.crtools @@ -0,0 +1,47 @@ +obj-y += parasite-syscall.o +obj-y += cr-restore.o +obj-y += crtools.o +obj-y += image.o +obj-y += net.o +obj-y += proc_parse.o +obj-y += cr-dump.o +obj-y += cr-show.o +obj-y += cr-check.o +obj-y += util.o +obj-y += sysctl.o +obj-y += ptrace.o +obj-y += kcmp-ids.o +obj-y += rbtree.o +obj-y += log.o +obj-y += libnetlink.o +obj-y += sockets.o +obj-y += sk-inet.o +obj-y += sk-tcp.o +obj-y += sk-unix.o +obj-y += sk-packet.o +obj-y += sk-queue.o +obj-y += files.o +obj-y += files-reg.o +obj-y += pipes.o +obj-y += fifo.o +obj-y += file-ids.o +obj-y += namespaces.o +obj-y += uts_ns.o +obj-y += ipc_ns.o +obj-y += netfilter.o +obj-y += shmem.o +obj-y += eventfd.o +obj-y += eventpoll.o +obj-y += mount.o +obj-y += fsnotify.o +obj-y += signalfd.o +obj-y += pstree.o +obj-y += protobuf.o +obj-y += tty.o +obj-y += cr-exec.o +obj-y += cpu.o +obj-y += file-lock.o + +ifneq ($(MAKECMDGOALS),clean) +incdeps := y +endif