[U-Boot] [PATCH v2 0/6] Second step towards Kbuild: Descend down like Kbuild

I have been just wondering why the U-Boot top Makefile is so dirty.
It is sprinkled with SoC-specific code as follows:
ifneq ($(CONFIG_OMAP_COMMON),) LIBS-y += $(CPUDIR)/omap-common/libomap-common.o endif
ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610)) LIBS-y += arch/$(ARCH)/imx-common/libimx-common.o endif
ifeq ($(SOC),s5pc1xx) LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o endif ifeq ($(SOC),exynos) LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o endif ifneq ($(CONFIG_TEGRA),) LIBS-y += arch/$(ARCH)/cpu/$(SOC)-common/lib$(SOC)-common.o LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o LIBS-y += $(CPUDIR)/tegra-common/libtegra-common.o endif
And it describes drivers not right under the top directory, which should be essentially cared by drivers/Makefile.
LIBS-y += drivers/bios_emulator/libatibiosemu.o LIBS-y += drivers/block/libblock.o LIBS-$(CONFIG_BOOTCOUNT_LIMIT) += drivers/bootcount/libbootcount.o LIBS-y += drivers/crypto/libcrypto.o LIBS-y += drivers/dma/libdma.o ...
This series adds the directory descending feature like Kbuild.
1/6 tweaks scripts/Makefile.build to support 'obj-y += foo/' syntax. If the build system finds 'foo/' (trailed by a slash), it visits foo directory.
2/6-6/6 demonstarate how we can refactor makefiles with this syntax.
2/6: Move some drivers LIBS from top Makefile to drivers/Makefile 3/6: Move some fs LIBS from top Makefile to fs/Makefile 4/6: Move Tegra specific lines from top Makefile under arch/arm/ 5/6: Move OMAP specific lines from top Makefile under arch/arm/ 6/6: Move Samsung SoC specific lines from top Makefile under arch/arm/
Note: This series uses [PATCH v2]First step towards Kbuild: Use Kbuild-style makefiles (19 patch files). as a prerequisite. Please apply those patches first.
I believe no boards are broken by this refactoring. In order to confirm my claim, I compiled all boards except nds32 and nios2 architrecutures. (I could not get an appropriate prebuilt cross compilers for those two arch.)
For arm, avr32, sandbox, x86, I could perfectly compile all boards without any warnings.
For the other architectures, I could compile some boards and I could not the others. But the SUMMARY result is still the same after applying this series. In addition I compared all the error messages and the warning messages for all boards and they are the same. This which means these patches do not introduce any additional errors, warnings.
Cc: Simon Glass sjg@chromium.org Cc: Tom Rini trini@ti.com
Changes for v2: 1/6: No change 2/6: additionally refactor drivers/pcmcia drivers/rtc too 3/6, 4/6: No change 5/6: rebase on the master 6/6: No change
Masahiro Yamada (6): Makefile: support descending down to subdirectories drivers: move some drivers to drivers/Makefile fs: move some file system to fs/Makefile ARM: tegra: delete Tegra specific code from toplevel Makefile ARM: omap: delete OMAP specific code from toplevel Makefile ARM: s5pc, exynos: delete Samsung ARM SoC specific code from toplevel Makefile
Makefile | 44 +++---------------------------------------- arch/arm/cpu/Makefile | 2 ++ arch/arm/cpu/arm720t/Makefile | 2 ++ arch/arm/cpu/armv7/Makefile | 9 +++++++++ board/LEOX/elpt860/u-boot.lds | 1 - board/tqc/tqm8xx/u-boot.lds | 4 ++-- drivers/Makefile | 15 +++++++++++++++ fs/Makefile | 11 +++++++++++ scripts/Makefile.build | 15 +++++++++++++++ spl/Makefile | 14 +------------- 10 files changed, 60 insertions(+), 57 deletions(-) create mode 100644 arch/arm/cpu/Makefile create mode 100644 drivers/Makefile

This patch tweaks scripts/Makefile.build to allow the build system to descend into subdirectories like Kbuild.
To use this feature, use "obj-y += foo/" syntax.
Example: obj-$(CONFIG_FOO) += foo/
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com Cc: Simon Glass sjg@chromium.org
---
Changes for v2: - No change
scripts/Makefile.build | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index f969ec5..2ef7341 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -19,6 +19,11 @@ obj-y := $(sort $(obj-y)) extra-y := $(sort $(extra-y)) lib-y := $(sort $(lib-y))
+subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) +obj-y := $(patsubst %/, %/built-in.o, $(obj-y)) +subdir-obj-y := $(filter %/built-in.o, $(obj-y)) +subdir-obj-y := $(addprefix $(obj),$(subdir-obj-y)) + SRCS += $(COBJS:.o=.c) $(SOBJS:.o=.S) \ $(wildcard $(obj-y:.o=.c) $(obj-y:.o=.S) $(lib-y:.o=.c) $(lib-y:.o=.S) $(extra-y:.o=.c) $(extra-y:.o=.S)) OBJS := $(addprefix $(obj),$(COBJS) $(SOBJS) $(obj-y)) @@ -37,6 +42,14 @@ $(LIBGCC): $(obj).depend $(LGOBJS) $(call cmd_link_o_target, $(LGOBJS)) endif
+ifneq ($(subdir-obj-y),) +# Descending +$(subdir-obj-y): $(subdir-y) + +$(subdir-y): FORCE + $(MAKE) -C $@ -f $(TOPDIR)/scripts/Makefile.build +endif + #########################################################################
# defines $(obj).depend target @@ -46,3 +59,5 @@ include $(TOPDIR)/rules.mk sinclude $(obj).depend
######################################################################### + +.PHONY: FORCE

This commit moves some drivers subdirectory entry from the toplevel Makefile to drivers/Makefile using Kbuild descending feature.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes for v2: - refactor also drivers/pcmcia and drivers/rtc
Makefile | 16 +--------------- board/LEOX/elpt860/u-boot.lds | 1 - board/tqc/tqm8xx/u-boot.lds | 4 ++-- drivers/Makefile | 15 +++++++++++++++ 4 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 drivers/Makefile
diff --git a/Makefile b/Makefile index 1a9445d..90cd554 100644 --- a/Makefile +++ b/Makefile @@ -261,17 +261,11 @@ LIBS-y += fs/libfs.o \ fs/zfs/libzfs.o LIBS-y += net/libnet.o LIBS-y += disk/libdisk.o -LIBS-y += drivers/bios_emulator/libatibiosemu.o -LIBS-y += drivers/block/libblock.o -LIBS-$(CONFIG_BOOTCOUNT_LIMIT) += drivers/bootcount/libbootcount.o -LIBS-y += drivers/crypto/libcrypto.o +LIBS-y += drivers/libdrivers.o LIBS-y += drivers/dma/libdma.o -LIBS-y += drivers/fpga/libfpga.o LIBS-y += drivers/gpio/libgpio.o -LIBS-y += drivers/hwmon/libhwmon.o LIBS-y += drivers/i2c/libi2c.o LIBS-y += drivers/input/libinput.o -LIBS-y += drivers/misc/libmisc.o LIBS-y += drivers/mmc/libmmc.o LIBS-y += drivers/mtd/libmtd.o LIBS-y += drivers/mtd/nand/libnand.o @@ -281,13 +275,11 @@ LIBS-y += drivers/mtd/spi/libspi_flash.o LIBS-y += drivers/net/libnet.o LIBS-y += drivers/net/phy/libphy.o LIBS-y += drivers/pci/libpci.o -LIBS-y += drivers/pcmcia/libpcmcia.o LIBS-y += drivers/power/libpower.o \ drivers/power/fuel_gauge/libfuel_gauge.o \ drivers/power/pmic/libpmic.o \ drivers/power/battery/libbattery.o LIBS-y += drivers/spi/libspi.o -LIBS-y += drivers/dfu/libdfu.o ifeq ($(CPU),mpc83xx) LIBS-y += drivers/qe/libqe.o LIBS-y += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o @@ -303,11 +295,7 @@ ifeq ($(CPU),mpc86xx) LIBS-y += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o endif -LIBS-y += drivers/rtc/librtc.o LIBS-y += drivers/serial/libserial.o -LIBS-y += drivers/sound/libsound.o -LIBS-y += drivers/tpm/libtpm.o -LIBS-y += drivers/twserial/libtws.o LIBS-y += drivers/usb/eth/libusb_eth.o LIBS-y += drivers/usb/gadget/libusb_gadget.o LIBS-y += drivers/usb/host/libusb_host.o @@ -315,8 +303,6 @@ LIBS-y += drivers/usb/musb/libusb_musb.o LIBS-y += drivers/usb/musb-new/libusb_musb-new.o LIBS-y += drivers/usb/phy/libusb_phy.o LIBS-y += drivers/usb/ulpi/libusb_ulpi.o -LIBS-y += drivers/video/libvideo.o -LIBS-y += drivers/watchdog/libwatchdog.o LIBS-y += common/libcommon.o LIBS-y += lib/libfdt/libfdt.o LIBS-y += api/libapi.o diff --git a/board/LEOX/elpt860/u-boot.lds b/board/LEOX/elpt860/u-boot.lds index f9c2beb..b30b667 100644 --- a/board/LEOX/elpt860/u-boot.lds +++ b/board/LEOX/elpt860/u-boot.lds @@ -34,7 +34,6 @@ SECTIONS arch/powerpc/cpu/mpc8xx/libmpc8xx.o (.text*) board/LEOX/elpt860/libelpt860.o (.text*) arch/powerpc/lib/libpowerpc.o (.text*) -/* drivers/rtc/librtc.o (.text*) */
. = env_offset; common/env_embedded.o (.text*) diff --git a/board/tqc/tqm8xx/u-boot.lds b/board/tqc/tqm8xx/u-boot.lds index 1d905e9..cbfc94f 100644 --- a/board/tqc/tqm8xx/u-boot.lds +++ b/board/tqc/tqm8xx/u-boot.lds @@ -23,8 +23,8 @@ SECTIONS board/tqc/tqm8xx/libtqm8xx.o (.text*) disk/libdisk.o (.text*) drivers/net/libnet.o (.text*) - drivers/pcmcia/libpcmcia.o (.text.pcmcia_on) - drivers/pcmcia/libpcmcia.o (.text.pcmcia_hardware_enable) + drivers/libdrivers.o (.text.pcmcia_on) + drivers/libdrivers.o (.text.pcmcia_hardware_enable)
. = DEFINED(env_offset) ? env_offset : .; common/env_embedded.o (.ppcenv*) diff --git a/drivers/Makefile b/drivers/Makefile new file mode 100644 index 0000000..9cec2ba --- /dev/null +++ b/drivers/Makefile @@ -0,0 +1,15 @@ +obj-y += bios_emulator/ +obj-y += block/ +obj-$(CONFIG_BOOTCOUNT_LIMIT) += bootcount/ +obj-y += crypto/ +obj-y += fpga/ +obj-y += hwmon/ +obj-y += misc/ +obj-y += pcmcia/ +obj-y += dfu/ +obj-y += rtc/ +obj-y += sound/ +obj-y += tpm/ +obj-y += twserial/ +obj-y += video/ +obj-y += watchdog/

This commit moves some subdirectories of fs from the toplevel Makefile to fs/Makefile using Kbuild descending feature.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes for v2: - No change
Makefile | 12 +----------- fs/Makefile | 11 +++++++++++ 2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/Makefile b/Makefile index 90cd554..42616e3 100644 --- a/Makefile +++ b/Makefile @@ -248,17 +248,7 @@ endif LIBS-$(CONFIG_OF_EMBED) += dts/libdts.o LIBS-y += arch/$(ARCH)/lib/lib$(ARCH).o LIBS-y += fs/libfs.o \ - fs/cbfs/libcbfs.o \ - fs/cramfs/libcramfs.o \ - fs/ext4/libext4fs.o \ - fs/fat/libfat.o \ - fs/fdos/libfdos.o \ - fs/jffs2/libjffs2.o \ - fs/reiserfs/libreiserfs.o \ - fs/sandbox/libsandboxfs.o \ - fs/ubifs/libubifs.o \ - fs/yaffs2/libyaffs2.o \ - fs/zfs/libzfs.o + fs/fat/libfat.o LIBS-y += net/libnet.o LIBS-y += disk/libdisk.o LIBS-y += drivers/libdrivers.o diff --git a/fs/Makefile b/fs/Makefile index ea2eb09..bdcd746 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -7,3 +7,14 @@ #
obj-y += fs.o + +obj-y += cbfs/ +obj-y += cramfs/ +obj-y += ext4/ +obj-y += fdos/ +obj-y += jffs2/ +obj-y += reiserfs/ +obj-y += sandbox/ +obj-y += ubifs/ +obj-y += yaffs2/ +obj-y += zfs/

This patch moves Tegra specific directory entries from the toplevel Makefile and spl/Makefile to arch/arm/cpu/*/Makefile using Kbuild descending feature.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com Cc: Tom Warren TWarren@nvidia.com ---
Changes for v2: - No change
Makefile | 6 +----- arch/arm/cpu/Makefile | 2 ++ arch/arm/cpu/arm720t/Makefile | 2 ++ arch/arm/cpu/armv7/Makefile | 2 ++ spl/Makefile | 6 +----- 5 files changed, 8 insertions(+), 10 deletions(-) create mode 100644 arch/arm/cpu/Makefile
diff --git a/Makefile b/Makefile index 42616e3..92dc088 100644 --- a/Makefile +++ b/Makefile @@ -313,11 +313,7 @@ endif ifeq ($(SOC),exynos) LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o endif -ifneq ($(CONFIG_TEGRA),) -LIBS-y += arch/$(ARCH)/cpu/$(SOC)-common/lib$(SOC)-common.o -LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o -LIBS-y += $(CPUDIR)/tegra-common/libtegra-common.o -endif +LIBS-$(CONFIG_ARM) += arch/arm/cpu/libcpu.o
LIBS := $(addprefix $(obj),$(sort $(LIBS-y))) .PHONY : $(LIBS) diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile new file mode 100644 index 0000000..fd0da53 --- /dev/null +++ b/arch/arm/cpu/Makefile @@ -0,0 +1,2 @@ +obj-$(CONFIG_TEGRA) += $(SOC)-common/ +obj-$(CONFIG_TEGRA) += tegra-common/ diff --git a/arch/arm/cpu/arm720t/Makefile b/arch/arm/cpu/arm720t/Makefile index 243a123..6badb3b 100644 --- a/arch/arm/cpu/arm720t/Makefile +++ b/arch/arm/cpu/arm720t/Makefile @@ -7,3 +7,5 @@
extra-y = start.o obj-y = interrupts.o cpu.o + +obj-$(CONFIG_TEGRA) += tegra-common/ diff --git a/arch/arm/cpu/armv7/Makefile b/arch/arm/cpu/armv7/Makefile index 75fac4b..7b260ac 100644 --- a/arch/arm/cpu/armv7/Makefile +++ b/arch/arm/cpu/armv7/Makefile @@ -15,3 +15,5 @@ obj-y += syslib.o ifneq ($(CONFIG_AM43XX)$(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TEGRA)$(CONFIG_MX6)$(CONFIG_TI81XX),) obj-y += lowlevel_init.o endif + +obj-$(CONFIG_TEGRA) += tegra-common/ diff --git a/spl/Makefile b/spl/Makefile index 3197d61..3f1a1da 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -108,11 +108,7 @@ ifneq (,$(CONFIG_MX23)$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35)) LIBS-y += arch/$(ARCH)/imx-common/libimx-common.o endif
-ifneq ($(CONFIG_TEGRA),) -LIBS-y += arch/$(ARCH)/cpu/$(SOC)-common/lib$(SOC)-common.o -LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o -LIBS-y += $(CPUDIR)/tegra-common/libtegra-common.o -endif +LIBS-$(CONFIG_ARM) += arch/arm/cpu/libcpu.o
ifneq ($(CONFIG_MX23)$(CONFIG_MX35),) LIBS-y += arch/$(ARCH)/imx-common/libimx-common.o

On 09/27/2013 12:09 AM, Masahiro Yamada wrote:
This patch moves Tegra specific directory entries from the toplevel Makefile and spl/Makefile to arch/arm/cpu/*/Makefile using Kbuild descending feature.
That sounds more like a "move" than a "delete", so the patch subject sounds misleading...

Hello Stephen
This patch moves Tegra specific directory entries from the toplevel Makefile and spl/Makefile to arch/arm/cpu/*/Makefile using Kbuild descending feature.
That sounds more like a "move" than a "delete", so the patch subject sounds misleading...
You are right. I posted v3 with updated patch subjects. Thanks!
Best Regards Masahiro Yamada

This patch moves OMAP specific directory entries from the toplevel Makefile and spl/Makefile to arch/arm/cpu/armv7/Makefile using Kbuild descending feature.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com Cc: Tom Rini trini@ti.com ---
Changes for v2: - rebase on the master
Makefile | 4 ---- arch/arm/cpu/armv7/Makefile | 3 +++ spl/Makefile | 4 ---- 3 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile index 92dc088..24e0161 100644 --- a/Makefile +++ b/Makefile @@ -299,10 +299,6 @@ LIBS-y += api/libapi.o LIBS-y += post/libpost.o LIBS-y += test/libtest.o
-ifneq ($(CONFIG_OMAP_COMMON),) -LIBS-y += $(CPUDIR)/omap-common/libomap-common.o -endif - ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610)) LIBS-y += arch/$(ARCH)/imx-common/libimx-common.o endif diff --git a/arch/arm/cpu/armv7/Makefile b/arch/arm/cpu/armv7/Makefile index 7b260ac..7443b39 100644 --- a/arch/arm/cpu/armv7/Makefile +++ b/arch/arm/cpu/armv7/Makefile @@ -13,7 +13,10 @@ obj-y += cpu.o obj-y += syslib.o
ifneq ($(CONFIG_AM43XX)$(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TEGRA)$(CONFIG_MX6)$(CONFIG_TI81XX),) +ifneq ($(CONFIG_SKIP_LOWLEVEL_INIT),y) obj-y += lowlevel_init.o endif +endif
+obj-$(CONFIG_OMAP_COMMON) += omap-common/ obj-$(CONFIG_TEGRA) += tegra-common/ diff --git a/spl/Makefile b/spl/Makefile index 3f1a1da..d2b999e 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -100,10 +100,6 @@ LIBS-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += drivers/usb/musb-new/libusb_musb-new.o LIBS-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/usb/gadget/libusb_gadget.o LIBS-$(CONFIG_SPL_WATCHDOG_SUPPORT) += drivers/watchdog/libwatchdog.o
-ifneq ($(CONFIG_OMAP_COMMON),) -LIBS-y += $(CPUDIR)/omap-common/libomap-common.o -endif - ifneq (,$(CONFIG_MX23)$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35)) LIBS-y += arch/$(ARCH)/imx-common/libimx-common.o endif

This patch moves S5PC, EXYNOS specific directory entries from the toplevel Makefile to arch/arm/cpu/armv7/Makefile using Kbuild descending feature.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com Cc: Minkyu Kang mk7.kang@samsung.com ---
Changes for v2: - No change
Makefile | 6 ------ arch/arm/cpu/armv7/Makefile | 4 ++++ spl/Makefile | 4 ---- 3 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/Makefile b/Makefile index 24e0161..5a10361 100644 --- a/Makefile +++ b/Makefile @@ -303,12 +303,6 @@ ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610)) LIBS-y += arch/$(ARCH)/imx-common/libimx-common.o endif
-ifeq ($(SOC),s5pc1xx) -LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o -endif -ifeq ($(SOC),exynos) -LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o -endif LIBS-$(CONFIG_ARM) += arch/arm/cpu/libcpu.o
LIBS := $(addprefix $(obj),$(sort $(LIBS-y))) diff --git a/arch/arm/cpu/armv7/Makefile b/arch/arm/cpu/armv7/Makefile index 7443b39..8d5bde9 100644 --- a/arch/arm/cpu/armv7/Makefile +++ b/arch/arm/cpu/armv7/Makefile @@ -20,3 +20,7 @@ endif
obj-$(CONFIG_OMAP_COMMON) += omap-common/ obj-$(CONFIG_TEGRA) += tegra-common/ + +ifneq (,$(filter s5pc1xx exynos,$(SOC))) +obj-y += s5p-common/ +endif diff --git a/spl/Makefile b/spl/Makefile index d2b999e..ab43b5c 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -110,10 +110,6 @@ ifneq ($(CONFIG_MX23)$(CONFIG_MX35),) LIBS-y += arch/$(ARCH)/imx-common/libimx-common.o endif
-ifeq ($(SOC),exynos) -LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o -endif - # Add GCC lib ifeq ("$(USE_PRIVATE_LIBGCC)", "yes") PLATFORM_LIBGCC = $(SPLTREE)/arch/$(ARCH)/lib/libgcc.o
participants (2)
-
Masahiro Yamada
-
Stephen Warren