Files
mckernel/kernel/Makefile.build.in
Dominique Martinet b894619d1b Speed up parallel builds
- make should be $(MAKE)
 - add + in front of rules spawning long-lasted make process in a
subshell. (This would not be needed with $(MAKE) -C .. target, but our
makefiles do not handle that because they use $(PWD))
 - split the main 'all' rule as all 4 targets are independant
 - fix dependencies where appropriate for parallelism

Extra, not speed-related changes:
 - remove some double-colon for targets as they do not need it

This cuts build time from 5s to 1.5s on a laptop with -j4, and more
importantly from 85s to 35s on a KNL node.
As a bonus, the fixed dependencies removes the need to clean before
rebuilding all the time. Probably.
2017-10-13 10:02:11 +09:00

77 lines
2.2 KiB
Makefile

# Makefile.build.in COPYRIGHT FUJITSU LIMITED 2015-2016
VPATH=@abs_srcdir@
SRC=$(VPATH)
IHKDIR=$(IHKBASE)/$(TARGETDIR)
OBJS = init.o mem.o debug.o mikc.o listeners.o ap.o syscall.o cls.o host.o
OBJS += process.o copy.o waitq.o futex.o timer.o plist.o fileobj.o shmobj.o
OBJS += zeroobj.o procfs.o devobj.o sysfs.o xpmem.o profile.o freeze.o
OBJS += rbtree.o
OBJS += pager.o
# POSTK_DEBUG_ARCH_DEP_18 coredump arch separation.
# OBJS added gencore.o
ifeq ($(ARCH), arm64)
OBJS += gencore.o
endif
DEPSRCS=$(wildcard $(SRC)/*.c)
CFLAGS += -I$(SRC)/include -I@abs_builddir@/../ -I@abs_builddir@/include -D__KERNEL__ -g -fno-omit-frame-pointer -fno-inline -fno-inline-small-functions
LDFLAGS += -e arch_start
IHKOBJ = ihk/ihk.o
# POSTK_DEBUG_ARCH_DEP_24
ifeq ($(ARCH), arm64)
default: all
endif
ifeq ($(ARCH), arm64)
include @abs_builddir@/config/config.$(TARGET)
else
include $(SRC)/config/config.$(TARGET)
endif
include @abs_builddir@/../../ihk/cokernel/Makefile.common
# CFLAGS += -I$(SRC)/../arch/$(IHKARCH)/kernel/include -I$(SRC)/../lib/include
OBJDUMP ?= objdump
OBJCOPY ?= objcopy
# POSTK_DEBUG_ARCH_DEP_26
ifeq ($(ARCH), arm64)
SUBCMD_OPTS = TARGET=$(TARGET) O=$(CURDIR)/ihk CC=$(CC) LD=$(LD) OBJCOPY=$(OBJCOPY) SRC=$(SRC)
else
SUBCMD_OPTS = TARGET=$(TARGET) O=$(CURDIR)/ihk CC=$(CC) LD=$(LD) SRC=$(SRC)
endif
ld_kern_cmd_base = $(LD) $(LDFLAGS) -o $@.elf $^
mkimage_cmd_base = [ -f $(SRC)/script/mkimage.$(TARGET) ] && CC=$(CC) LD=$(LD) LDFLAGS="$(LDFLAGS_MKIMAGE)" OBJDUMP=$(OBJDUMP) OBJCOPY=$(OBJCOPY) sh $(SRC)/script/mkimage.$(TARGET) '$@.elf' '$@' '$(SRC)' || cp $@.elf $@
ld_kern_cmd = $(call echo_cmd,LDKERN,$@)$(ld_kern_cmd_base)
mkimage_cmd = $(call echo_cmd,MKIMAGE,$@)$(mkimage_cmd_base)
all: depend kernel.img
kernel.img: $(OBJS) $(IHKOBJ)
$(ld_kern_cmd)
$(mkimage_cmd)
clean:
$(rm_cmd) $(OBJS) kernel.img kernel.img.elf Makefile.dep
@$(submake) -C $(IHKBASE) $(SUBCMD_OPTS) clean
depend: Makefile.dep
Makefile.dep:
$(call dep_cmd,$(DEPSRCS))
$(IHKOBJ): FORCE
@mkdir -p $(dir $(IHKOBJ))
+$(call echo_cmd,BUILD IHK,$(TARGET))$(submake) -C $(IHKBASE) $(SUBCMD_OPTS) prepare
+$(call echo_cmd,BUILD IHK,$(TARGET))$(submake) -C $(IHKBASE) $(SUBCMD_OPTS)
%.o: $(SRC)/%.c
$(cc_cmd)
FORCE:
-include Makefile.dep