Skip to contentSkip to conversation

More trivial refactoring of makefiles

PATCH New Masahiro Yamada 2 participants 6 messages Nov 28, 2013 – Dec 16, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover More trivial refactoring of makefiles

Masahiro Yamada (2):
post: descend only when CONFIG_HAS_POST is defined
Makefile: Select objects by CONFIG_ rather than $(ARCH) or $(CPU)

 Makefile                          | 14 +++++---------
 arch/powerpc/cpu/Makefile         |  6 +++---
 arch/powerpc/cpu/mpc8xxx/Makefile |  6 ++----
 examples/standalone/Makefile      | 26 +++++++++++++-------------
 post/Makefile                     | 16 +++++++---------
 post/board/lwmon/Makefile         |  2 +-
 post/board/lwmon5/Makefile        |  2 +-
 post/board/netta/Makefile         |  2 +-
 post/board/pdm360ng/Makefile      |  2 +-
 post/cpu/mpc83xx/Makefile         |  2 +-
 post/cpu/ppc4xx/Makefile          | 18 +++++++++---------
 post/drivers/Makefile             |  2 +-
 post/lib_powerpc/Makefile         | 10 +++++-----
 post/lib_powerpc/fpu/Makefile     | 18 +++++++++---------
 spl/Makefile                      | 17 +++++------------
 15 files changed, 64 insertions(+), 79 deletions(-)
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH 1/2 post: descend only when CONFIG_HAS_POST is defined

All objects under post/ directory are enabled by CONFIG_HAS_POST. (post/tests.o is enabled by CONFIG_POST_STD_LIST.
But CONFIG_POST_STD_LIST depends on CONFIG_HAS_POST.)

We can move CONFIG_HAS_POST switch to the top Makefile.

---

FYI:

CONFIG_HAS_POST and CONFIG_POST_STD_LIST are
defined around line 944 of include/common.h

  #ifdef CONFIG_POST
  #define CONFIG_HAS_POST
  #ifndef CONFIG_POST_ALT_LIST
  #define CONFIG_POST_STD_LIST
  #endif
  #endif
 Makefile                      |  2 +-
 post/Makefile                 | 12 +++++-------
 post/board/lwmon/Makefile     |  2 +-
 post/board/lwmon5/Makefile    |  2 +-
 post/board/netta/Makefile     |  2 +-
 post/board/pdm360ng/Makefile  |  2 +-
 post/cpu/mpc83xx/Makefile     |  2 +-
 post/cpu/ppc4xx/Makefile      | 18 +++++++++---------
 post/drivers/Makefile         |  2 +-
 post/lib_powerpc/Makefile     | 10 +++++-----
 post/lib_powerpc/fpu/Makefile | 18 +++++++++---------
 11 files changed, 35 insertions(+), 37 deletions(-)
Makefile +1 -1
index db77484..5d9d32d 100644
@@ -274,7 +274,7 @@ LIBS-y += drivers/usb/ulpi/
 LIBS-y += common/
 LIBS-y += lib/libfdt/
 LIBS-$(CONFIG_API) += api/
-LIBS-y += post/
+LIBS-$(CONFIG_HAS_POST) += post/
 LIBS-y += test/
 
 ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610))
post/Makefile +5 -7
index 1439244..20a463a 100644
@@ -5,16 +5,14 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-$(CONFIG_HAS_POST)	+= post.o
+obj-y	+= post.o
 obj-$(CONFIG_POST_STD_LIST)	+= tests.o
 
-obj-$(CONFIG_HAS_POST) += drivers/
-ifeq ($(ARCH),powerpc)
-obj-$(CONFIG_HAS_POST) += lib_powerpc/
-endif
+obj-y += drivers/
+obj-$(CONFIG_PPC) += lib_powerpc/
 ifneq ($(filter mpc83xx mpc8xx ppc4xx,$(CPU)),)
-obj-$(CONFIG_HAS_POST) += cpu/$(CPU)/
+obj-y += cpu/$(CPU)/
 endif
 ifneq ($(filter lwmon lwmon5 netta pdm360ng,$(BOARD)),)
-obj-$(CONFIG_HAS_POST) += board/$(BOARD)/
+obj-y += board/$(BOARD)/
 endif
post/board/lwmon/Makefile +1 -1
index b23debc..7f6d5a0 100644
@@ -5,4 +5,4 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-$(CONFIG_HAS_POST)	+= sysmon.o
+obj-y += sysmon.o
post/board/lwmon5/Makefile +1 -1
index a50ce67..76262c7 100644
@@ -5,4 +5,4 @@
 #
 # SPDX-License-Identifier:	GPL-2.0+
 
-obj-$(CONFIG_HAS_POST)	+= sysmon.o watchdog.o dspic.o fpga.o dsp.o gdc.o
+obj-y += sysmon.o watchdog.o dspic.o fpga.o dsp.o gdc.o
post/board/netta/Makefile +1 -1
index 5c37f49..8fc1945 100644
@@ -5,4 +5,4 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-$(CONFIG_HAS_POST)	+= codec.o dsp.o
+obj-y += codec.o dsp.o
post/board/pdm360ng/Makefile +1 -1
index b43b77b..9aa96a1 100644
@@ -5,4 +5,4 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-$(CONFIG_HAS_POST)	+= coproc_com.o
+obj-y += coproc_com.o
post/cpu/mpc83xx/Makefile +1 -1
index 4b3c50e..d57b667 100644
@@ -5,4 +5,4 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-$(CONFIG_HAS_POST)	+= ecc.o
+obj-y += ecc.o
post/cpu/ppc4xx/Makefile +9 -9
index ed3e8e8..e9ec286 100644
@@ -5,12 +5,12 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-$(CONFIG_HAS_POST)	+= cache_4xx.o
-obj-$(CONFIG_HAS_POST)	+= cache.o
-obj-$(CONFIG_HAS_POST)	+= denali_ecc.o
-obj-$(CONFIG_HAS_POST)	+= ether.o
-obj-$(CONFIG_HAS_POST)	+= fpu.o
-obj-$(CONFIG_HAS_POST)	+= ocm.o
-obj-$(CONFIG_HAS_POST)	+= spr.o
-obj-$(CONFIG_HAS_POST)	+= uart.o
-obj-$(CONFIG_HAS_POST)	+= watchdog.o
+obj-y += cache_4xx.o
+obj-y += cache.o
+obj-y += denali_ecc.o
+obj-y += ether.o
+obj-y += fpu.o
+obj-y += ocm.o
+obj-y += spr.o
+obj-y += uart.o
+obj-y += watchdog.o
post/drivers/Makefile +1 -1
index 328f880..1abfb1f 100644
@@ -5,4 +5,4 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-$(CONFIG_HAS_POST)	+= flash.o i2c.o memory.o rtc.o
+obj-y += flash.o i2c.o memory.o rtc.o
post/lib_powerpc/Makefile +5 -5
index d2b8a94..0cbb6b6 100644
@@ -5,9 +5,9 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-$(CONFIG_HAS_POST) += asm.o
-obj-$(CONFIG_HAS_POST) += cpu.o cmp.o cmpi.o two.o twox.o three.o threex.o
-obj-$(CONFIG_HAS_POST) += threei.o andi.o srawi.o rlwnm.o rlwinm.o rlwimi.o
-obj-$(CONFIG_HAS_POST) += store.o load.o cr.o b.o multi.o string.o complex.o
+obj-y += asm.o
+obj-y += cpu.o cmp.o cmpi.o two.o twox.o three.o threex.o
+obj-y += threei.o andi.o srawi.o rlwnm.o rlwinm.o rlwimi.o
+obj-y += store.o load.o cr.o b.o multi.o string.o complex.o
 
-obj-$(CONFIG_HAS_POST) += fpu/
+obj-y += fpu/
post/lib_powerpc/fpu/Makefile +9 -9
index ee01a31..ae56a82 100644
@@ -5,15 +5,15 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-$(CONFIG_HAS_POST)	+= 20001122-1.o
-obj-$(CONFIG_HAS_POST)	+= 20010114-2.o
-obj-$(CONFIG_HAS_POST)	+= 20010226-1.o
-obj-$(CONFIG_HAS_POST)	+= 980619-1.o
-obj-$(CONFIG_HAS_POST)	+= acc1.o
-obj-$(CONFIG_HAS_POST)	+= compare-fp-1.o
-obj-$(CONFIG_HAS_POST)	+= fpu.o
-obj-$(CONFIG_HAS_POST)	+= mul-subnormal-single-1.o
-obj-$(CONFIG_HAS_POST)	+= darwin-ldouble.o
+obj-y	+= 20001122-1.o
+obj-y	+= 20010114-2.o
+obj-y	+= 20010226-1.o
+obj-y	+= 980619-1.o
+obj-y	+= acc1.o
+obj-y	+= compare-fp-1.o
+obj-y	+= fpu.o
+obj-y	+= mul-subnormal-single-1.o
+obj-y	+= darwin-ldouble.o
 
 CFLAGS := $(shell echo $(CFLAGS) | sed s/-msoft-float//)
 CFLAGS += -mhard-float -fkeep-inline-functions
Signature · 1 line
1.8.3.2
#2 lore raw

PATCH 1/2 post: descend only when CONFIG_HAS_POST is defined

Quoted 7 lines · Masahiro Yamada

All objects under post/ directory are enabled by CONFIG_HAS_POST. (post/tests.o is enabled by CONFIG_POST_STD_LIST.
But CONFIG_POST_STD_LIST depends on CONFIG_HAS_POST.)

We can move CONFIG_HAS_POST switch to the top Makefile.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131216/fb356b40/attachment.pgp>
#3 lore raw

PATCH 2/2 Makefile: Select objects by CONFIG_ rather than $(ARCH) or $(CPU)

In reply to Masahiro Yamada

Convert like follows:

 CPU mpc83xx  -> CONFIG_MPC83xx
 CPU mpc85xx  -> CONFIG_MPC85xx
 CPU mpc86xx  -> CONFIG_MPC86xx
 CPU mpc5xxx  -> CONFIG_MPC5xxx
 CPU mpc8xx   -> CONFIG_8xx
 CPU mpc8260  -> CONFIG_8260
 CPU ppc4xx   -> CONFIG_4xx
 CPU x86      -> CONFIG_X86
 ARCH x86     -> CONFIG_X86

ARCH powerpc -> CONFIG_PPC

---

I built all target boards and checked md5sum.
I confirmed this change has no impact.

This patch may look trivial
but it has an important meaning.

Before importing build scripts from Linux Kernel, we definitely must fix arch/powerpc/cpu/Makefile:
ifneq ($(filter mpc83xx mpc85xx mpc86xx,$(CPU)),) obj-y += mpc8xxx/
endif

In above code,
obj-y += mpc8xxx/
is not evaluated for CPUs other than mpc83xx, mpc85xx, mpc86xx.

In such a case, Linux build scripts would not generate arch/powerpc/cpu/built-in.o, which results in an error at the final link stage.

Please see around line 137 of scripts/Makefile.build
of Linux Kernel (I want to import this file in my upcoming patch):

ifneq ($(strip $(obj-y) $(obj-m) $(obj-n) $(obj-) $(subdir-m) $(lib-target)),) builtin-target := $(obj)/built-in.o
endif

Note that if $(obj-) and $(obj-y) are both emply,
built-in.o is not generated.

FYI:

CONFIG_MPC83xx is defined in config headers and arch/powerpc/cpu/mpc83xx/config.mk CONFIG_MPC85xx is defined in config headers
CONFIG_MPC86xx is defined in config headers
CONFIG_MPC5xxx is defined in config headers and arch/powerpc/cpu/mpc5xxx/config.mk

CONFIG_8xx     is defined in arch/powerpc/cpu/mpc8xx/config.mk
CONFIG_8260    is defined in arch/powerpc/cpu/mpc8260/config.mk
CONFIG_4xx     is defined in config headers and arch/powerpc/cpu/ppc4xx/config.mk
CONFIG_X86     is defined in arch/x86/config.mk
CONFIG_PPC     is defined in arch/powerpc/config.mk
 Makefile                          | 12 ++++--------
 arch/powerpc/cpu/Makefile         |  6 +++---
 arch/powerpc/cpu/mpc8xxx/Makefile |  6 ++----
 examples/standalone/Makefile      | 26 +++++++++++++-------------
 post/Makefile                     |  6 +++---
 spl/Makefile                      | 17 +++++------------
 6 files changed, 30 insertions(+), 43 deletions(-)
Makefile +4 -8
index 5d9d32d..4db925d 100644
@@ -218,15 +218,11 @@ endif
 #########################################################################
 # U-Boot objects....order is important (i.e. start must be first)
 
-OBJS  = $(CPUDIR)/start.o
-ifeq ($(CPU),ppc4xx)
-OBJS += $(CPUDIR)/resetvec.o
-endif
-ifeq ($(CPU),mpc85xx)
-OBJS += $(CPUDIR)/resetvec.o
-endif
+head-y := $(CPUDIR)/start.o
+head-$(CONFIG_4xx) += arch/powerpc/cpu/ppc4xx/resetvec.o
+head-$(CONFIG_MPC85xx) += arch/powerpc/cpu/mpc85xx/resetvec.o
 
-OBJS := $(addprefix $(obj),$(OBJS))
+OBJS := $(addprefix $(obj),$(head-y))
 
 HAVE_VENDOR_COMMON_LIB = $(if $(wildcard board/$(VENDOR)/common/Makefile),y,n)
 
arch/powerpc/cpu/Makefile +3 -3
index d630abe..88b5298 100644
@@ -1,3 +1,3 @@
-ifneq ($(filter mpc83xx mpc85xx mpc86xx,$(CPU)),)
-obj-y += mpc8xxx/
-endif
+obj-$(CONFIG_MPC83xx) += mpc8xxx/
+obj-$(CONFIG_MPC85xx) += mpc8xxx/
+obj-$(CONFIG_MPC86xx) += mpc8xxx/
arch/powerpc/cpu/mpc8xxx/Makefile +2 -4
index 1d083bf..cf75612 100644
@@ -19,10 +19,8 @@ ifdef MINIMAL
 obj-$(CONFIG_FSL_LAW) += law.o
 
 else
-
-ifneq ($(CPU),mpc83xx)
-obj-y	+= cpu.o
-endif
+obj-$(CONFIG_MPC85xx) += cpu.o
+obj-$(CONFIG_MPC86xx) += cpu.o
 
 obj-$(CONFIG_OF_LIBFDT) += fdt.o
 obj-$(CONFIG_FSL_IFC) += fsl_ifc.o
examples/standalone/Makefile +13 -13
index f4f102b..6e7500d 100644
@@ -7,25 +7,27 @@
 
 include $(TOPDIR)/config.mk
 
-ELF-$(ARCH)  :=
-ELF-$(CPU)   :=
 ELF-y        := hello_world
 
 ELF-$(CONFIG_SMC91111)           += smc91111_eeprom
 ELF-$(CONFIG_SMC911X)            += smc911x_eeprom
 ELF-$(CONFIG_SPI_FLASH_ATMEL)    += atmel_df_pow2
-ELF-i386                         += 82559_eeprom
-ELF-mpc5xxx                      += interrupt
-ELF-mpc8xx                       += test_burst timer
-ELF-mpc8260                      += mem_to_mem_idma2intr
-ELF-ppc                          += sched
+# TODO:
+#   - Fix the warning of 82559_eeprom.c and uncomment the following
+# or
+#   - Delete 82559_eeprom.c and the following line
+#ELF-$(CONFIG_X86)                += 82559_eeprom
+ELF-$(CONFIG_MPC5xxx)            += interrupt
+ELF-$(CONFIG_8xx)                += test_burst timer
+ELF-$(CONFIG_8260)               += mem_to_mem_idma2intr
+ELF-$(CONFIG_PPC)                += sched
 
 #
 # Some versions of make do not handle trailing white spaces properly;
 # leading to build failures. The problem was found with GNU Make 3.80.
 # Using 'strip' as a workaround for the problem.
 #
-ELF := $(strip $(ELF-y) $(ELF-$(ARCH)) $(ELF-$(CPU)))
+ELF := $(strip $(ELF-y))
 
 SREC := $(addsuffix .srec,$(ELF))
 BIN  := $(addsuffix .bin,$(ELF))
@@ -34,11 +36,9 @@ COBJS	:= $(ELF:=.o)
 
 LIB	= $(obj)libstubs.o
 
-LIBAOBJS-$(ARCH)     :=
-LIBAOBJS-$(CPU)      :=
-LIBAOBJS-ppc         += $(ARCH)_longjmp.o $(ARCH)_setjmp.o
-LIBAOBJS-mpc8xx      += test_burst_lib.o
-LIBAOBJS := $(LIBAOBJS-$(ARCH)) $(LIBAOBJS-$(CPU))
+LIBAOBJS-$(CONFIG_PPC) += ppc_longjmp.o ppc_setjmp.o
+LIBAOBJS-$(CONFIG_8xx) += test_burst_lib.o
+LIBAOBJS := $(LIBAOBJS-y)
 
 LIBCOBJS = stubs.o
 
post/Makefile +3 -3
index 20a463a..2fa6f8a 100644
@@ -10,9 +10,9 @@ obj-$(CONFIG_POST_STD_LIST)	+= tests.o
 
 obj-y += drivers/
 obj-$(CONFIG_PPC) += lib_powerpc/
-ifneq ($(filter mpc83xx mpc8xx ppc4xx,$(CPU)),)
-obj-y += cpu/$(CPU)/
-endif
+obj-$(CONFIG_MPC83xx) += cpu/mpc83xx/
+obj-$(CONFIG_8xx) += cpu/mpc8xx/
+obj-$(CONFIG_4xx) += cpu/ppc4xx/
 ifneq ($(filter lwmon lwmon5 netta pdm360ng,$(BOARD)),)
 obj-y += board/$(BOARD)/
 endif
spl/Makefile +5 -12
index 29d7818..7a0400b 100644
@@ -42,17 +42,10 @@ else
 START_PATH := $(CPUDIR)
 endif
 
-START := $(START_PATH)/start.o
-ifeq ($(CPU),x86)
-START += $(START_PATH)/start16.o
-START += $(START_PATH)/resetvec.o
-endif
-ifeq ($(CPU),ppc4xx)
-START += $(START_PATH)/resetvec.o
-endif
-ifeq ($(CPU),mpc85xx)
-START += $(START_PATH)/resetvec.o
-endif
+head-y := $(START_PATH)/start.o
+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/
 
@@ -108,7 +101,7 @@ PLATFORM_LIBGCC = $(SPLTREE)/arch/$(ARCH)/lib/libgcc.o
 PLATFORM_LIBS := $(filter-out %/libgcc.o, $(filter-out -lgcc, $(PLATFORM_LIBS))) $(PLATFORM_LIBGCC)
 endif
 
-START := $(addprefix $(SPLTREE)/,$(START))
+START := $(addprefix $(SPLTREE)/,$(head-y))
 LIBS := $(addprefix $(SPLTREE)/,$(sort $(LIBS-y)))
 
 __START := $(subst $(obj),,$(START))
Signature · 1 line
1.8.3.2
#4 lore raw

PATCH 2/2 Makefile: Select objects by CONFIG_ rather than $(ARCH) or $(CPU)

Hi Tom.

Quoted 5 lines
arch/powerpc/cpu/mpc8xxx/Makefile +0 -0
@@ -19,10 +19,8 @@ ifdef MINIMAL
 obj-$(CONFIG_FSL_LAW) += law.o
 

arch/powerpc/cpu/mpc8xxx/Makefile ifdef MINIMAL · line 26

Quoted 10 lines
arch/powerpc/cpu/mpc8xxx/Makefile +2 -4
 else
-
-ifneq ($(CPU),mpc83xx)
-obj-y	+= cpu.o
-endif
+obj-$(CONFIG_MPC85xx) += cpu.o
+obj-$(CONFIG_MPC86xx) += cpu.o
 
 obj-$(CONFIG_OF_LIBFDT) += fdt.o
 obj-$(CONFIG_FSL_IFC) += fsl_ifc.o

You might see a conflict
when applying this patch to the current u-boot/master.

Please git am with "-C2" option
to avoid a conflict.

Best Regards
Masahiro Yamada

#5 lore raw

PATCH 2/2 Makefile: Select objects by CONFIG_ rather than $(ARCH) or $(CPU)

In reply to Masahiro Yamada
Quoted 11 lines · Masahiro Yamada

Convert like follows:

 CPU mpc83xx  -> CONFIG_MPC83xx
 CPU mpc85xx  -> CONFIG_MPC85xx
 CPU mpc86xx  -> CONFIG_MPC86xx
 CPU mpc5xxx  -> CONFIG_MPC5xxx
 CPU mpc8xx   -> CONFIG_8xx
 CPU mpc8260  -> CONFIG_8260
 CPU ppc4xx   -> CONFIG_4xx
 CPU x86      -> CONFIG_X86
 ARCH x86     -> CONFIG_X86
Quoted 3 lines

ARCH powerpc -> CONFIG_PPC

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131216/5239f163/attachment.pgp>