Skip to contentSkip to conversation

Second step towards Kbuild: Descend down like Kbuild

PATCH Superseded Masahiro Yamada 2 participants 10 messages Sep 30, 2013 – Oct 4, 2013

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Second step towards Kbuild: Descend down like Kbuild

Note:
Update for v3 is the only patch subjects.
The patch body is the same as v2.

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 and warning messages
for all boards and they are the same.
This means these patches do not introduce any additional errors, warnings.

Cc Simon Glass <[email protected]>
Cc Tom Rini <[email protected]>

Changes for v3:
1/6 - 3/6: No change
4/6 - 6/6: Fix mesleading patch subject (No change in body)

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
#1 lore raw

PATCH v3 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 v3:
- No change

Changes for v2:
- No change

 scripts/Makefile.build | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
scripts/Makefile.build +15 -0
index f969ec5..2ef7341 100644
@@ -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
#2 lore raw

PATCH v3 2/6 drivers: move some drivers to drivers/Makefile

In reply to Masahiro Yamada

This commit moves some drivers subdirectory entry from the toplevel Makefile to drivers/Makefile using Kbuild descending feature.

---

Changes for v3:
- No change

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
index 1a9445d..90cd554 100644
@@ -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
index f9c2beb..b30b667 100644
@@ -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
index 1d905e9..cbfc94f 100644
@@ -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
new file mode 100644
index 0000000..9cec2ba
@@ -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
#3 lore raw

PATCH v3 3/6 fs: move some file system to fs/Makefile

In reply to Masahiro Yamada

This commit moves some subdirectories of fs
from the toplevel Makefile to fs/Makefile
using Kbuild descending feature.

---

Changes for v3:
- No change

Changes for v2:
- No change

 Makefile    | 12 +-----------
 fs/Makefile | 11 +++++++++++
 2 files changed, 12 insertions(+), 11 deletions(-)
Makefile +1 -11
index 90cd554..42616e3 100644
@@ -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
index ea2eb09..bdcd746 100644
@@ -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
#4 lore raw

PATCH v3 4/6 ARM: tegra: move Tegra specific code under arch/arm/

In reply to Masahiro Yamada

This patch moves Tegra specific directory entries from the toplevel Makefile and spl/Makefile
to arch/arm/cpu/*/Makefile using Kbuild descending feature.

---

Changes for v3:
- Fix misleading commit subject (No change in body)

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
index 42616e3..92dc088 100644
@@ -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
new file mode 100644
index 0000000..fd0da53
@@ -0,0 +1,2 @@
+obj-$(CONFIG_TEGRA) += $(SOC)-common/
+obj-$(CONFIG_TEGRA) += tegra-common/
arch/arm/cpu/arm720t/Makefile +2 -0
index 243a123..6badb3b 100644
@@ -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
index 75fac4b..7b260ac 100644
@@ -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
index 3197d61..3f1a1da 100644
@@ -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
#5 lore raw

PATCH v3 5/6 ARM: omap: move OMAP specific code under arch/arm/

In reply to 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.

---

Changes for v3:
- Fix misleading commit subject (No change in body)

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
index 92dc088..24e0161 100644
@@ -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
index 7b260ac..7443b39 100644
@@ -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
index 3f1a1da..d2b999e 100644
@@ -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
#6 lore raw

PATCH v3 6/6 ARM: s5pc, exynos: move Samsung ARM SoC specific code under arch/arm/

In reply to Masahiro Yamada

This patch moves S5PC, EXYNOS specific directory entries from the toplevel Makefile to arch/arm/cpu/armv7/Makefile using Kbuild descending feature.

---

Changes for v3:
- Fix misleading commit subject (No change in body)

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
index 24e0161..5a10361 100644
@@ -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
index 7443b39..8d5bde9 100644
@@ -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
index d2b999e..ab43b5c 100644
@@ -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
#7 lore raw

v3 cover Second step towards Kbuild: Descend down like Kbuild

In reply to Masahiro Yamada

Hi Masahiro,

Quoted 100 lines · Masahiro Yamada

Note:
Update for v3 is the only patch subjects.
The patch body is the same as v2.

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 and warning messages
for all boards and they are the same.
This means these patches do not introduce any additional errors, warnings.

Cc Simon Glass <[email protected]>
Cc Tom Rini <[email protected]>

Changes for v3:
1/6 - 3/6: No change
4/6 - 6/6: Fix mesleading patch subject (No change in body)

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

Quoted 15 lines
 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

Can you please explain why you need to change the .lds files - sorry it is not obvious to me.

Regards,
Simon

Quoted 5 lines

--
1.8.1.2

#8 lore raw

v3 cover Second step towards Kbuild: Descend down like Kbuild

Hello Simon

Quoted 2 lines

Can you please explain why you need to change the .lds files - sorry it is not obvious to me.

This series changes how objects are linked.

Before this series,
drivers/bios_emulator/libatibiosemu.o drivers/block/libblock.o drivers/pcmcia/libpcmcia.o
...
are directly linked into ./u-boot at the final link stage.

After this series,
drivers/bios_emulator/built-in.o drivers/block/built-in.o drivers/pcmcia/built-in.o
...
are combined into drivers/libdrivers.o
and then drivers/libdrivers.o is linked into ./u-boot.

This means that all symbols in
drivers/bios_emulator/built-in.o
drivers/block/built-in.o
drivers/pcmcia/built-in.o
...
are also included in drivers/libdrivers.o

board/tqc/tqm8xx/u-boot.lds SECTIONS · line 30

Quoted 13 lines
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*)

This is to avoid multiple definition error at the link stage.

.test.pcmcia_on and .text.pcmcia_hardware_enable
are included in both drivers/pcmcia/built-in.o and drivers/libdrivers.o so I replaced the former with the latter.

board/LEOX/elpt860/u-boot.lds SECTIONS · line 39

Quoted 12 lines
board/LEOX/elpt860/u-boot.lds +0 -1
index f9c2beb..b30b667 100644
@@ -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

Becuase only a comment line is deleted,
this change has no impact and I might not have needed to touch it actually. I deleted it just because we don't have drivers/rtc/librtc.c any more.

Best Regards
Masahiro Yamada

#9 lore raw

v3 cover Second step towards Kbuild: Descend down like Kbuild

Hi Mashahiro,

Quoted 65 lines · Masahiro Yamada

Hello Simon

Quoted 2 lines

Can you please explain why you need to change the .lds files - sorry it is not obvious to me.

This series changes how objects are linked.

Before this series,
drivers/bios_emulator/libatibiosemu.o drivers/block/libblock.o drivers/pcmcia/libpcmcia.o
...
are directly linked into ./u-boot at the final link stage.

After this series,
drivers/bios_emulator/built-in.o drivers/block/built-in.o drivers/pcmcia/built-in.o
...
are combined into drivers/libdrivers.o
and then drivers/libdrivers.o is linked into ./u-boot.

This means that all symbols in
drivers/bios_emulator/built-in.o
drivers/block/built-in.o
drivers/pcmcia/built-in.o
...
are also included in drivers/libdrivers.o

board/tqc/tqm8xx/u-boot.lds SECTIONS · line 30

Quoted 13 lines
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*)

This is to avoid multiple definition error at the link stage.

.test.pcmcia_on and .text.pcmcia_hardware_enable
are included in both drivers/pcmcia/built-in.o and drivers/libdrivers.o so I replaced the former with the latter.

Quoted 10 lines
board/LEOX/elpt860/u-boot.lds +0 -1
index f9c2beb..b30b667 100644
@@ -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*)        */
 
Quoted 6 lines

board/LEOX/elpt860/u-boot.lds SECTIONS · line 39

Quoted 2 lines
board/LEOX/elpt860/u-boot.lds +0 -0
     . = env_offset;
     common/env_embedded.o

Becuase only a comment line is deleted,
this change has no impact and I might not have needed to touch it actually. I deleted it just because we don't have drivers/rtc/librtc.c any more.

OK this sounds reasonable, thank for you the explanation.

Regards,
Simon