diff mbox series

[OpenWrt-Devel] treewide: simplify inclusion of subtarget image files

Message ID 20200607111115.1958-1-freifunk@adrianschmutzler.de
State Accepted
Delegated to: Adrian Schmutzler
Headers show
Series [OpenWrt-Devel] treewide: simplify inclusion of subtarget image files | expand

Commit Message

Adrian Schmutzler June 7, 2020, 11:11 a.m. UTC
Many target use a repetitive if-include scheme for their subtarget
image files, though their names are consistent with the subtarget
names.

This patch removes these redundant conditions and just uses the
variable for the include where the target setup allows it.

For sunxi, this includes a trivial rename of the subtarget image
Makefiles.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
---
 target/linux/at91/image/Makefile              |  7 +------
 target/linux/ath79/image/Makefile             | 20 ++++++++-----------
 target/linux/layerscape/image/Makefile        |  8 +-------
 target/linux/mvebu/image/Makefile             | 12 +----------
 target/linux/oxnas/image/Makefile             |  8 +-------
 target/linux/rockchip/image/Makefile          |  4 +---
 target/linux/sunxi/image/Makefile             | 12 +----------
 .../image/{cortex-a53.mk => cortexa53.mk}     |  0
 .../sunxi/image/{cortex-a7.mk => cortexa7.mk} |  0
 .../sunxi/image/{cortex-a8.mk => cortexa8.mk} |  0
 target/linux/x86/image/Makefile               | 16 +--------------
 11 files changed, 15 insertions(+), 72 deletions(-)
 rename target/linux/sunxi/image/{cortex-a53.mk => cortexa53.mk} (100%)
 rename target/linux/sunxi/image/{cortex-a7.mk => cortexa7.mk} (100%)
 rename target/linux/sunxi/image/{cortex-a8.mk => cortexa8.mk} (100%)

Comments

Matthias Schiffer June 7, 2020, 11:33 a.m. UTC | #1
On 6/7/20 1:11 PM, Adrian Schmutzler wrote:
> Many target use a repetitive if-include scheme for their subtarget
> image files, though their names are consistent with the subtarget
> names.
> 
> This patch removes these redundant conditions and just uses the
> variable for the include where the target setup allows it.
> 
> For sunxi, this includes a trivial rename of the subtarget image
> Makefiles.
> 
> Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> ---
[...]
> diff --git a/target/linux/ath79/image/Makefile b/target/linux/ath79/image/Makefile
> index 529baf8f57..a555cfc6d5 100644
> --- a/target/linux/ath79/image/Makefile
> +++ b/target/linux/ath79/image/Makefile
> @@ -68,20 +68,16 @@ define Device/Default
>  	append-rootfs | pad-rootfs | append-metadata | check-size
>  endef
>  
> +include $(SUBTARGET).mk
> +
>  ifeq ($(SUBTARGET),generic)
> -include ./generic.mk
> -include ./generic-tp-link.mk
> -include ./generic-ubnt.mk
> -endif
> -ifeq ($(SUBTARGET),mikrotik)
> -include ./mikrotik.mk
> -endif
> -ifeq ($(SUBTARGET),nand)
> -include ./nand.mk
> +include generic-tp-link.mk
> +include generic-ubnt.mk

How about moving these lines into generic.mk, etc.? That way we could get
rid of the ifeq ($(SUBTARGET),...) completely.

>  endif
> +
>  ifeq ($(SUBTARGET),tiny)
> -include ./tiny.mk
> -include ./tiny-netgear.mk
> -include ./tiny-tp-link.mk
> +include tiny-netgear.mk
> +include tiny-tp-link.mk
>  endif
> +
>  $(eval $(call BuildImage))
[...]
Adrian Schmutzler June 7, 2020, 11:56 a.m. UTC | #2
Hi Matthias,

> -----Original Message-----
> From: openwrt-devel [mailto:openwrt-devel-bounces@lists.openwrt.org]
> On Behalf Of Matthias Schiffer
> Sent: Sonntag, 7. Juni 2020 13:33
> To: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> Cc: openwrt-devel@lists.openwrt.org
> Subject: Re: [OpenWrt-Devel] [PATCH] treewide: simplify inclusion of
> subtarget image files
> 
> On 6/7/20 1:11 PM, Adrian Schmutzler wrote:
> > Many target use a repetitive if-include scheme for their subtarget
> > image files, though their names are consistent with the subtarget
> > names.
> >
> > This patch removes these redundant conditions and just uses the
> > variable for the include where the target setup allows it.
> >
> > For sunxi, this includes a trivial rename of the subtarget image
> > Makefiles.
> >
> > Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> > ---
> [...]
> > diff --git a/target/linux/ath79/image/Makefile
> > b/target/linux/ath79/image/Makefile
> > index 529baf8f57..a555cfc6d5 100644
> > --- a/target/linux/ath79/image/Makefile
> > +++ b/target/linux/ath79/image/Makefile
> > @@ -68,20 +68,16 @@ define Device/Default
> >  	append-rootfs | pad-rootfs | append-metadata | check-size  endef
> >
> > +include $(SUBTARGET).mk
> > +
> >  ifeq ($(SUBTARGET),generic)
> > -include ./generic.mk
> > -include ./generic-tp-link.mk
> > -include ./generic-ubnt.mk
> > -endif
> > -ifeq ($(SUBTARGET),mikrotik)
> > -include ./mikrotik.mk
> > -endif
> > -ifeq ($(SUBTARGET),nand)
> > -include ./nand.mk
> > +include generic-tp-link.mk
> > +include generic-ubnt.mk
> 
> How about moving these lines into generic.mk, etc.? That way we could get
> rid of the ifeq ($(SUBTARGET),...) completely.

I considered that as well, but personally I like it better "my" way, as the image/Makefile provides "an overview"  of the relevant files rather than having a cascading arrangement. (Of course, that's purely matter of taste and your proposed method wouldn't be worse by any means.)

Best

Adrian

> 
> >  endif
> > +
> >  ifeq ($(SUBTARGET),tiny)
> > -include ./tiny.mk
> > -include ./tiny-netgear.mk
> > -include ./tiny-tp-link.mk
> > +include tiny-netgear.mk
> > +include tiny-tp-link.mk
> >  endif
> > +
> >  $(eval $(call BuildImage))
> [...]
diff mbox series

Patch

diff --git a/target/linux/at91/image/Makefile b/target/linux/at91/image/Makefile
index adb7c6d0ba..ff801dae86 100644
--- a/target/linux/at91/image/Makefile
+++ b/target/linux/at91/image/Makefile
@@ -13,12 +13,7 @@  define Build/at91-install-zImage
     $(CP) $(KDIR)/zImage $@
 endef
 
-ifeq ($(SUBTARGET),sam9x)
-include ./sam9x.mk
-endif
-ifeq ($(SUBTARGET),sama5)
-include ./sama5.mk
-endif
+include $(SUBTARGET).mk
 
 AT91_SD_BOOT_PARTSIZE:=64
 FAT32_BLOCK_SIZE:=1024
diff --git a/target/linux/ath79/image/Makefile b/target/linux/ath79/image/Makefile
index 529baf8f57..a555cfc6d5 100644
--- a/target/linux/ath79/image/Makefile
+++ b/target/linux/ath79/image/Makefile
@@ -68,20 +68,16 @@  define Device/Default
 	append-rootfs | pad-rootfs | append-metadata | check-size
 endef
 
+include $(SUBTARGET).mk
+
 ifeq ($(SUBTARGET),generic)
-include ./generic.mk
-include ./generic-tp-link.mk
-include ./generic-ubnt.mk
-endif
-ifeq ($(SUBTARGET),mikrotik)
-include ./mikrotik.mk
-endif
-ifeq ($(SUBTARGET),nand)
-include ./nand.mk
+include generic-tp-link.mk
+include generic-ubnt.mk
 endif
+
 ifeq ($(SUBTARGET),tiny)
-include ./tiny.mk
-include ./tiny-netgear.mk
-include ./tiny-tp-link.mk
+include tiny-netgear.mk
+include tiny-tp-link.mk
 endif
+
 $(eval $(call BuildImage))
diff --git a/target/linux/layerscape/image/Makefile b/target/linux/layerscape/image/Makefile
index bc65748853..f5a5ad9980 100644
--- a/target/linux/layerscape/image/Makefile
+++ b/target/linux/layerscape/image/Makefile
@@ -43,12 +43,6 @@  define Build/traverse-fit
 	@mv -f $@.new $@
 endef
 
-ifeq ($(SUBTARGET),armv8_64b)
-include armv8_64b.mk
-endif
-
-ifeq ($(SUBTARGET),armv7)
-include armv7.mk
-endif
+include $(SUBTARGET).mk
 
 $(eval $(call BuildImage))
diff --git a/target/linux/mvebu/image/Makefile b/target/linux/mvebu/image/Makefile
index 3a47878069..cbf34c1bc8 100644
--- a/target/linux/mvebu/image/Makefile
+++ b/target/linux/mvebu/image/Makefile
@@ -138,16 +138,6 @@  define Device/NAND-512K
   PAGESIZE := 4096
 endef
 
-ifeq ($(SUBTARGET),cortexa9)
-include cortexa9.mk
-endif
-
-ifeq ($(SUBTARGET),cortexa53)
-include cortexa53.mk
-endif
-
-ifeq ($(SUBTARGET),cortexa72)
-include cortexa72.mk
-endif
+include $(SUBTARGET).mk
 
 $(eval $(call BuildImage))
diff --git a/target/linux/oxnas/image/Makefile b/target/linux/oxnas/image/Makefile
index 644c2b8795..abf83caa1a 100644
--- a/target/linux/oxnas/image/Makefile
+++ b/target/linux/oxnas/image/Makefile
@@ -4,12 +4,6 @@  include $(INCLUDE_DIR)/image.mk
 VMLINUX:=$(BIN_DIR)/$(IMG_PREFIX)-vmlinux
 UIMAGE:=$(BIN_DIR)/$(IMG_PREFIX)-uImage
 
-ifeq ($(SUBTARGET),ox810se)
-include ox810se.mk
-endif
-
-ifeq ($(SUBTARGET),ox820)
-include ox820.mk
-endif
+include $(SUBTARGET).mk
 
 $(eval $(call BuildImage))
diff --git a/target/linux/rockchip/image/Makefile b/target/linux/rockchip/image/Makefile
index 5f605ebfe5..22854d9d02 100644
--- a/target/linux/rockchip/image/Makefile
+++ b/target/linux/rockchip/image/Makefile
@@ -56,8 +56,6 @@  define Device/Default
   DEVICE_DTS = rockchip/$$(SOC)-$(lastword $(subst _, ,$(1)))
 endef
 
-ifeq ($(SUBTARGET),armv8)
-  include armv8.mk
-endif
+include $(SUBTARGET).mk
 
 $(eval $(call BuildImage))
diff --git a/target/linux/sunxi/image/Makefile b/target/linux/sunxi/image/Makefile
index 1b98849a50..01e9742b46 100644
--- a/target/linux/sunxi/image/Makefile
+++ b/target/linux/sunxi/image/Makefile
@@ -42,16 +42,6 @@  define Device/Default
   SUNXI_DTS = $$(SUNXI_DTS_DIR)$$(SOC)-$(lastword $(subst _, ,$(1)))
 endef
 
-ifeq ($(SUBTARGET),cortexa7)
-include cortex-a7.mk
-endif
-
-ifeq ($(SUBTARGET),cortexa8)
-include cortex-a8.mk
-endif
-
-ifeq ($(SUBTARGET),cortexa53)
-include cortex-a53.mk
-endif
+include $(SUBTARGET).mk
 
 $(eval $(call BuildImage))
diff --git a/target/linux/sunxi/image/cortex-a53.mk b/target/linux/sunxi/image/cortexa53.mk
similarity index 100%
rename from target/linux/sunxi/image/cortex-a53.mk
rename to target/linux/sunxi/image/cortexa53.mk
diff --git a/target/linux/sunxi/image/cortex-a7.mk b/target/linux/sunxi/image/cortexa7.mk
similarity index 100%
rename from target/linux/sunxi/image/cortex-a7.mk
rename to target/linux/sunxi/image/cortexa7.mk
diff --git a/target/linux/sunxi/image/cortex-a8.mk b/target/linux/sunxi/image/cortexa8.mk
similarity index 100%
rename from target/linux/sunxi/image/cortex-a8.mk
rename to target/linux/sunxi/image/cortexa8.mk
diff --git a/target/linux/x86/image/Makefile b/target/linux/x86/image/Makefile
index 174c272a51..85c850c128 100644
--- a/target/linux/x86/image/Makefile
+++ b/target/linux/x86/image/Makefile
@@ -146,21 +146,7 @@  define Device/Default
   ARTIFACTS := $$(ARTIFACTS-y)
 endef
 
-ifeq ($(SUBTARGET),64)
-  include 64.mk
-endif
-
-ifeq ($(SUBTARGET),generic)
-  include generic.mk
-endif
-
-ifeq ($(SUBTARGET),geode)
-  include geode.mk
-endif
-
-ifeq ($(SUBTARGET),legacy)
-  include legacy.mk
-endif
+include $(SUBTARGET).mk
 
 $(eval $(call BuildImage))