diff options
author | Masahiro Yamada <yamada.m@jp.panasonic.com> | 2014-02-04 17:24:37 +0900 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2014-02-19 11:10:04 -0500 |
commit | 656de6b819c7a5b830de5a5e374133b631820dbc (patch) | |
tree | 8087e0c3aaa49b43e8a7f2ec2e99c15031447900 | |
parent | cbce795e5ef2175b1fd3ec580281ef8ce397afd7 (diff) | |
download | u-boot-imx-656de6b819c7a5b830de5a5e374133b631820dbc.zip u-boot-imx-656de6b819c7a5b830de5a5e374133b631820dbc.tar.gz u-boot-imx-656de6b819c7a5b830de5a5e374133b631820dbc.tar.bz2 |
kbuild: refactor Makefile and spl/Makefile more
This commit refactors rules of directory descending
and defines u-boot-dirs and u-boot-all-dirs.
(We will need u-boot-all-dirs when using
scripts/Makefile.clean)
Additionally, rename LIBS-y to libs-y.
Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
-rw-r--r-- | Makefile | 165 | ||||
-rw-r--r-- | spl/Makefile | 113 |
2 files changed, 141 insertions, 137 deletions
@@ -561,17 +561,7 @@ CHECKFLAGS += $(NOSTDINC_FLAGS) cpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS) c_flags := $(KBUILD_CFLAGS) $(cpp_flags) -# The "tools" are needed early, so put this first -# Don't include stuff already done in $(LIBS) -# The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC -# is "yes"), so compile examples after U-Boot is compiled. -SUBDIR_TOOLS = tools -SUBDIRS = $(SUBDIR_TOOLS) - -.PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE) - -SUBDIR_EXAMPLES-y := examples -SUBDIRS += $(SUBDIR_EXAMPLES-y) +.PHONY : $(VERSION_FILE) $(TIMESTAMP_FILE) ######################################################################### # U-Boot objects....order is important (i.e. start must be first) @@ -580,70 +570,76 @@ head-y := $(CPUDIR)/start.o head-$(CONFIG_4xx) += arch/powerpc/cpu/ppc4xx/resetvec.o head-$(CONFIG_MPC85xx) += arch/powerpc/cpu/mpc85xx/resetvec.o -OBJS := $(head-y) - HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n) -LIBS-y += lib/ -LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/ -LIBS-y += $(CPUDIR)/ +libs-y += lib/ +libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/ +libs-y += $(CPUDIR)/ ifdef SOC -LIBS-y += $(CPUDIR)/$(SOC)/ +libs-y += $(CPUDIR)/$(SOC)/ endif -LIBS-$(CONFIG_IXP4XX_NPE) += drivers/net/npe/ -LIBS-$(CONFIG_OF_EMBED) += dts/ -LIBS-y += arch/$(ARCH)/lib/ -LIBS-y += fs/ -LIBS-y += net/ -LIBS-y += disk/ -LIBS-y += drivers/ -LIBS-y += drivers/dma/ -LIBS-y += drivers/gpio/ -LIBS-y += drivers/i2c/ -LIBS-y += drivers/input/ -LIBS-y += drivers/mmc/ -LIBS-y += drivers/mtd/ -LIBS-$(CONFIG_CMD_NAND) += drivers/mtd/nand/ -LIBS-y += drivers/mtd/onenand/ -LIBS-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/ -LIBS-y += drivers/mtd/spi/ -LIBS-y += drivers/net/ -LIBS-y += drivers/net/phy/ -LIBS-y += drivers/pci/ -LIBS-y += drivers/power/ \ +libs-$(CONFIG_IXP4XX_NPE) += drivers/net/npe/ +libs-$(CONFIG_OF_EMBED) += dts/ +libs-y += arch/$(ARCH)/lib/ +libs-y += fs/ +libs-y += net/ +libs-y += disk/ +libs-y += drivers/ +libs-y += drivers/dma/ +libs-y += drivers/gpio/ +libs-y += drivers/i2c/ +libs-y += drivers/input/ +libs-y += drivers/mmc/ +libs-y += drivers/mtd/ +libs-$(CONFIG_CMD_NAND) += drivers/mtd/nand/ +libs-y += drivers/mtd/onenand/ +libs-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/ +libs-y += drivers/mtd/spi/ +libs-y += drivers/net/ +libs-y += drivers/net/phy/ +libs-y += drivers/pci/ +libs-y += drivers/power/ \ drivers/power/fuel_gauge/ \ drivers/power/mfd/ \ drivers/power/pmic/ \ drivers/power/battery/ -LIBS-y += drivers/spi/ -LIBS-$(CONFIG_FMAN_ENET) += drivers/net/fm/ -LIBS-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/ -LIBS-y += drivers/serial/ -LIBS-y += drivers/usb/eth/ -LIBS-y += drivers/usb/gadget/ -LIBS-y += drivers/usb/host/ -LIBS-y += drivers/usb/musb/ -LIBS-y += drivers/usb/musb-new/ -LIBS-y += drivers/usb/phy/ -LIBS-y += drivers/usb/ulpi/ -LIBS-y += common/ -LIBS-y += lib/libfdt/ -LIBS-$(CONFIG_API) += api/ -LIBS-$(CONFIG_HAS_POST) += post/ -LIBS-y += test/ +libs-y += drivers/spi/ +libs-$(CONFIG_FMAN_ENET) += drivers/net/fm/ +libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/ +libs-y += drivers/serial/ +libs-y += drivers/usb/eth/ +libs-y += drivers/usb/gadget/ +libs-y += drivers/usb/host/ +libs-y += drivers/usb/musb/ +libs-y += drivers/usb/musb-new/ +libs-y += drivers/usb/phy/ +libs-y += drivers/usb/ulpi/ +libs-y += common/ +libs-y += lib/libfdt/ +libs-$(CONFIG_API) += api/ +libs-$(CONFIG_HAS_POST) += post/ +libs-y += test/ ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610)) -LIBS-y += arch/$(ARCH)/imx-common/ +libs-y += arch/$(ARCH)/imx-common/ endif -LIBS-$(CONFIG_ARM) += arch/arm/cpu/ -LIBS-$(CONFIG_PPC) += arch/powerpc/cpu/ +libs-$(CONFIG_ARM) += arch/arm/cpu/ +libs-$(CONFIG_PPC) += arch/powerpc/cpu/ + +libs-y += board/$(BOARDDIR)/ + +libs-y := $(sort $(libs-y)) -LIBS-y += board/$(BOARDDIR)/ +u-boot-dirs := $(patsubst %/,%,$(filter %/, $(libs-y))) tools examples + +u-boot-alldirs := $(sort $(u-boot-dirs) $(patsubst %/,%,$(filter %/, $(libs-)))) + +libs-y := $(patsubst %/, %/built-in.o, $(libs-y)) + +u-boot-init := $(head-y) +u-boot-main := $(libs-y) -LIBS-y := $(patsubst %/, %/built-in.o, $(LIBS-y)) -LIBS := $(sort $(LIBS-y)) -.PHONY : $(LIBS) # Add GCC lib ifdef USE_PRIVATE_LIBGCC @@ -727,7 +723,7 @@ ifneq ($(CONFIG_SYS_TEXT_BASE),) LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE) endif -all: $(ALL-y) $(SUBDIR_EXAMPLES-y) +all: $(ALL-y) u-boot.dtb: checkdtc u-boot $(MAKE) $(build)=dts binary @@ -774,7 +770,7 @@ u-boot.img: u-boot.bin sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \ -d $< $@ -u-boot.imx: u-boot.bin depend +u-boot.imx: u-boot.bin $(MAKE) $(build)=arch/arm/imx-common $(objtree)/u-boot.imx u-boot.kwb: u-boot.bin @@ -893,17 +889,17 @@ u-boot.elf: u-boot.bin ifeq ($(CONFIG_SANDBOX),y) GEN_UBOOT = \ $(CC) $(SYMS) -T u-boot.lds \ - -Wl,--start-group $(LIBS) -Wl,--end-group \ + -Wl,--start-group $(u-boot-main) -Wl,--end-group \ $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot else GEN_UBOOT = \ $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \ - $(OBJS) \ - --start-group $(LIBS) --end-group $(PLATFORM_LIBS) \ + $(u-boot-init) \ + --start-group $(u-boot-main) --end-group $(PLATFORM_LIBS) \ -Map u-boot.map -o u-boot endif -u-boot: depend $(SUBDIR_TOOLS) $(OBJS) $(LIBS) u-boot.lds +u-boot: $(u-boot-init) $(u-boot-main) u-boot.lds $(GEN_UBOOT) ifeq ($(CONFIG_KALLSYMS),y) smap=`$(call SYSTEM_MAP,u-boot) | \ @@ -913,16 +909,27 @@ ifeq ($(CONFIG_KALLSYMS),y) $(GEN_UBOOT) common/system_map.o endif -$(OBJS): - @: +# The actual objects are generated when descending, +# make sure no implicit rule kicks in +$(sort $(u-boot-init) $(u-boot-main)): $(u-boot-dirs) ; -$(LIBS): depend $(SUBDIR_TOOLS) scripts_basic - $(Q)$(MAKE) $(build)=$(patsubst %/,%,$(dir $@)) +# Handle descending into subdirectories listed in $(vmlinux-dirs) +# Preset locale variables to speed up the build process. Limit locale +# tweaks to this spot to avoid wrong language settings when running +# make menuconfig etc. +# Error messages still appears in the original language -$(SUBDIRS): scripts_basic $(TIMESTAMP_FILE) $(VERSION_FILE) - $(Q)$(MAKE) $(build)=$@ +PHONY += $(u-boot-dirs) +$(u-boot-dirs): depend scripts_basic + $(Q)$(MAKE) $(build)=$@ + +tools: $(TIMESTAMP_FILE) $(VERSION_FILE) +# The "tools" are needed early +$(filter-out tools, $(u-boot-dirs)): tools +# The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC +# is "yes"), so compile examples after U-Boot is compiled. +examples: $(filter-out examples, $(u-boot-dirs)) -$(SUBDIR_EXAMPLES-y): u-boot # # Auto-generate the autoconf.mk file (which is included by all makefiles) @@ -956,10 +963,10 @@ nand_spl: $(TIMESTAMP_FILE) $(VERSION_FILE) depend scripts_basic u-boot-nand.bin: nand_spl u-boot.bin cat nand_spl/u-boot-spl-16k.bin u-boot.bin > u-boot-nand.bin -spl/u-boot-spl.bin: $(SUBDIR_TOOLS) depend scripts_basic +spl/u-boot-spl.bin: tools depend scripts_basic $(MAKE) obj=spl -f $(srctree)/spl/Makefile all -tpl/u-boot-tpl.bin: $(SUBDIR_TOOLS) depend scripts_basic +tpl/u-boot-tpl.bin: tools depend scripts_basic $(MAKE) obj=tpl -f $(srctree)/spl/Makefile all CONFIG_TPL_BUILD=y # Explicitly make _depend in subdirs containing multiple targets to prevent @@ -968,9 +975,7 @@ depend dep: $(TIMESTAMP_FILE) $(VERSION_FILE) \ include/generated/generic-asm-offsets.h \ include/generated/asm-offsets.h -TAG_SUBDIRS = $(SUBDIRS) -TAG_SUBDIRS += $(dir $(LIBS)) -TAG_SUBDIRS += include +TAG_SUBDIRS := $(u-boot-dirs) include FIND := find FINDFLAGS := -L @@ -1155,7 +1160,7 @@ clobber: clean @find $(OBJTREE) -type f \( -name '*.srec' \ -o -name '*.bin' -o -name u-boot.img \) \ -print0 | xargs -0 rm -f - @rm -f $(OBJS) *.bak ctags etags TAGS \ + @rm -f *.bak ctags etags TAGS \ cscope.* *.*~ @rm -f u-boot u-boot.map u-boot.hex $(ALL-y) @rm -f u-boot.kwb diff --git a/spl/Makefile b/spl/Makefile index 25f9921..bf98024 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -79,67 +79,65 @@ head-$(CONFIG_X86) += $(START_PATH)/start16.o $(START_PATH)/resetvec.o head-$(CONFIG_4xx) += $(START_PATH)/resetvec.o head-$(CONFIG_MPC85xx) += $(START_PATH)/resetvec.o -LIBS-y += arch/$(ARCH)/lib/ +libs-y += arch/$(ARCH)/lib/ -LIBS-y += $(CPUDIR)/ +libs-y += $(CPUDIR)/ ifdef SOC -LIBS-y += $(CPUDIR)/$(SOC)/ -endif -LIBS-y += board/$(BOARDDIR)/ -LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/ - -LIBS-$(CONFIG_SPL_FRAMEWORK) += common/spl/ -LIBS-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/ -LIBS-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/ -LIBS-$(CONFIG_SPL_I2C_SUPPORT) += drivers/i2c/ -LIBS-$(CONFIG_SPL_GPIO_SUPPORT) += drivers/gpio/ -LIBS-$(CONFIG_SPL_MMC_SUPPORT) += drivers/mmc/ -LIBS-$(CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT) += drivers/ddr/fsl/ -LIBS-$(CONFIG_SPL_SERIAL_SUPPORT) += drivers/serial/ -LIBS-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += drivers/mtd/spi/ -LIBS-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/ -LIBS-y += fs/ -LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/ -LIBS-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/ \ - drivers/power/pmic/ -LIBS-$(if $(CONFIG_CMD_NAND),$(CONFIG_SPL_NAND_SUPPORT)) += drivers/mtd/nand/ -LIBS-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += drivers/misc/ -LIBS-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/ -LIBS-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/ -LIBS-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/ -LIBS-$(CONFIG_SPL_NET_SUPPORT) += net/ -LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/ -LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/ -LIBS-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/net/phy/ -LIBS-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += drivers/usb/musb-new/ -LIBS-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/usb/gadget/ -LIBS-$(CONFIG_SPL_WATCHDOG_SUPPORT) += drivers/watchdog/ -LIBS-$(CONFIG_SPL_USB_HOST_SUPPORT) += drivers/usb/host/ -LIBS-$(CONFIG_OMAP_USB_PHY) += drivers/usb/phy/ -LIBS-$(CONFIG_SPL_SATA_SUPPORT) += drivers/block/ +libs-y += $(CPUDIR)/$(SOC)/ +endif +libs-y += board/$(BOARDDIR)/ +libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/ + +libs-$(CONFIG_SPL_FRAMEWORK) += common/spl/ +libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/ +libs-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/ +libs-$(CONFIG_SPL_I2C_SUPPORT) += drivers/i2c/ +libs-$(CONFIG_SPL_GPIO_SUPPORT) += drivers/gpio/ +libs-$(CONFIG_SPL_MMC_SUPPORT) += drivers/mmc/ +libs-$(CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT) += drivers/ddr/fsl/ +libs-$(CONFIG_SPL_SERIAL_SUPPORT) += drivers/serial/ +libs-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += drivers/mtd/spi/ +libs-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/ +libs-y += fs/ +libs-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/ +libs-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/ drivers/power/pmic/ +libs-$(if $(CONFIG_CMD_NAND),$(CONFIG_SPL_NAND_SUPPORT)) += drivers/mtd/nand/ +libs-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += drivers/misc/ +libs-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/ +libs-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/ +libs-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/ +libs-$(CONFIG_SPL_NET_SUPPORT) += net/ +libs-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/ +libs-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/ +libs-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/net/phy/ +libs-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += drivers/usb/musb-new/ +libs-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/usb/gadget/ +libs-$(CONFIG_SPL_WATCHDOG_SUPPORT) += drivers/watchdog/ +libs-$(CONFIG_SPL_USB_HOST_SUPPORT) += drivers/usb/host/ +libs-$(CONFIG_OMAP_USB_PHY) += drivers/usb/phy/ +libs-$(CONFIG_SPL_SATA_SUPPORT) += drivers/block/ ifneq (,$(CONFIG_MX23)$(CONFIG_MX35)$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35)) -LIBS-y += arch/$(ARCH)/imx-common/ +libs-y += arch/$(ARCH)/imx-common/ endif -LIBS-$(CONFIG_ARM) += arch/arm/cpu/ -LIBS-$(CONFIG_PPC) += arch/powerpc/cpu/ +libs-$(CONFIG_ARM) += arch/arm/cpu/ +libs-$(CONFIG_PPC) += arch/powerpc/cpu/ -LIBS-y := $(patsubst %/, %/built-in.o, $(LIBS-y)) +head-y := $(addprefix $(obj)/,$(head-y)) +libs-y := $(addprefix $(obj)/,$(libs-y)) +u-boot-spl-dirs := $(patsubst %/,%,$(filter %/, $(libs-y))) + +libs-y := $(patsubst %/, %/built-in.o, $(libs-y)) # Add GCC lib ifeq ("$(USE_PRIVATE_LIBGCC)", "yes") PLATFORM_LIBS := $(SPLTREE)/arch/$(ARCH)/lib/lib.a endif -LIBS-y := $(sort $(LIBS-y)) - -__START := $(head-y) -__LIBS := $(LIBS-y) - -START := $(addprefix $(obj)/,$(head-y)) -LIBS := $(addprefix $(obj)/,$(LIBS-y)) +u-boot-spl-init := $(head-y) +u-boot-spl-main := $(libs-y) # Linker Script ifdef CONFIG_SPL_LDSCRIPT @@ -209,19 +207,20 @@ ifneq ($(CONFIG_SPL_TEXT_BASE),) LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE) endif -GEN_UBOOT = \ - cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $(__START) \ - --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \ - -Map $(SPL_BIN).map -o $(SPL_BIN) +quiet_cmd_u-boot-spl = LD $@ + cmd_u-boot-spl = cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \ + $(patsubst $(obj)/%,%,$(u-boot-spl-init)) --start-group \ + $(patsubst $(obj)/%,%,$(u-boot-spl-main)) --end-group \ + $(PLATFORM_LIBS) -Map $(SPL_BIN).map -o $(SPL_BIN) -$(obj)/$(SPL_BIN): $(START) $(LIBS) $(obj)/u-boot-spl.lds - $(GEN_UBOOT) +$(obj)/$(SPL_BIN): $(u-boot-spl-init) $(u-boot-spl-main) $(obj)/u-boot-spl.lds + $(call cmd,u-boot-spl) -$(START): - @: +$(sort $(u-boot-spl-init) $(u-boot-spl-main)): $(u-boot-spl-dirs) ; -$(LIBS): - $(Q)$(MAKE) $(build)=$(patsubst %/,%,$(dir $@)) +PHONY += $(u-boot-spl-dirs) +$(u-boot-spl-dirs): + $(Q)$(MAKE) $(build)=$@ # FIX ME cpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS) |