Second step towards Kbuild: Descend down like Kbuild
Subsystems (3)
v2 cover 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
endifAnd 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.
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
Signature · 1 line
1.8.1.2
PATCH v2 1/6 Makefile: support descending down to subdirectories
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/
---
Changes for v2:
- No change
scripts/Makefile.build | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
scripts/Makefile.build +15 -0
@@ -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
Signature · 1 line
1.8.1.2
PATCH v2 2/6 drivers: move some drivers to drivers/Makefile
In reply to Masahiro YamadaThis commit moves some drivers subdirectory entry from the toplevel Makefile to drivers/Makefile using Kbuild descending feature.
---
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
Makefile +1 -15
@@ -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
board/LEOX/elpt860/u-boot.lds +0 -1
@@ -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*)
board/tqc/tqm8xx/u-boot.lds +2 -2
@@ -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*)
drivers/Makefile new file +15 -0
@@ -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/
Signature · 1 line
1.8.1.2
PATCH v2 3/6 fs: move some file system to fs/Makefile
In reply to Masahiro YamadaThis commit moves some subdirectories of fs
from the toplevel Makefile to fs/Makefile
using Kbuild descending feature.
---
Changes for v2:
- No change
Makefile | 12 +----------- fs/Makefile | 11 +++++++++++ 2 files changed, 12 insertions(+), 11 deletions(-)
Makefile +1 -11
@@ -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
fs/Makefile +11 -0
@@ -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/
Signature · 1 line
1.8.1.2
PATCH v2 4/6 ARM: tegra: delete Tegra specific code from toplevel Makefile
In reply to Masahiro YamadaThis patch moves Tegra specific directory entries from the toplevel Makefile and spl/Makefile
to arch/arm/cpu/*/Makefile using Kbuild descending feature.
---
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
Makefile +1 -5
@@ -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)
arch/arm/cpu/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_TEGRA) += $(SOC)-common/ +obj-$(CONFIG_TEGRA) += tegra-common/
arch/arm/cpu/arm720t/Makefile +2 -0
@@ -7,3 +7,5 @@ extra-y = start.o obj-y = interrupts.o cpu.o + +obj-$(CONFIG_TEGRA) += tegra-common/
arch/arm/cpu/armv7/Makefile +2 -0
@@ -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/
spl/Makefile +1 -5
@@ -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
Signature · 1 line
1.8.1.2
PATCH v2 4/6 ARM: tegra: delete Tegra specific code from toplevel Makefile
Quoted 3 lines · Masahiro Yamada
This patch moves Tegra specific directory entries from the toplevel
Makefileand spl/Makefile
toarch/arm/cpu/*/MakefileusingKbuilddescending feature.
That sounds more like a "move" than a "delete", so the patch subject sounds misleading...
PATCH v2 4/6 ARM: tegra: delete Tegra specific code from toplevel Makefile
Hello Stephen
Quoted 6 lines
Quoted 3 lines
This patch moves Tegra specific directory entries from the toplevel
Makefileand spl/Makefile
toarch/arm/cpu/*/MakefileusingKbuilddescending 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
PATCH v2 5/6 ARM: omap: delete OMAP specific code from toplevel Makefile
In reply to Masahiro YamadaThis patch moves OMAP specific directory entries
from the toplevel Makefile and spl/Makefile
to arch/arm/cpu/armv7/Makefile using Kbuild descending feature.
---
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(-)
Makefile +0 -4
@@ -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
arch/arm/cpu/armv7/Makefile +3 -0
@@ -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/
spl/Makefile +0 -4
@@ -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
Signature · 1 line
1.8.1.2
PATCH v2 6/6 ARM: s5pc, exynos: delete Samsung ARM SoC specific code from toplevel Makefile
In reply to Masahiro YamadaThis patch moves S5PC, EXYNOS specific directory entries from the toplevel Makefile to arch/arm/cpu/armv7/Makefile using Kbuild descending feature.
---
Changes for v2:
- No change
Makefile | 6 ------ arch/arm/cpu/armv7/Makefile | 4 ++++ spl/Makefile | 4 ---- 3 files changed, 4 insertions(+), 10 deletions(-)
Makefile +0 -6
@@ -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)))
arch/arm/cpu/armv7/Makefile +4 -0
@@ -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
spl/Makefile +0 -4
@@ -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
Signature · 1 line
1.8.1.2