]> git.sur5r.net Git - u-boot/commitdiff
tools: convert makefiles to kbuild style
authorMasahiro Yamada <yamada.m@jp.panasonic.com>
Tue, 4 Feb 2014 08:24:10 +0000 (17:24 +0900)
committerTom Rini <trini@ti.com>
Wed, 19 Feb 2014 16:07:49 +0000 (11:07 -0500)
Before this commit, makefiles under tools/ directory
were implemented with their own way.

This commit refactors them by using "hostprogs-y" variable.

Several C sources have been added to wrap other C sources
to simplify Makefile.
For example, tools/crc32.c includes lib/crc32.c

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
28 files changed:
Makefile
config.mk
rules.mk
spl/Makefile
tools/.gitignore
tools/Makefile
tools/crc32.c [new file with mode: 0644]
tools/easylogo/Makefile
tools/env/Makefile
tools/env/crc32.c [new file with mode: 0644]
tools/env/ctype.c [new file with mode: 0644]
tools/env/env_attr.c [new file with mode: 0644]
tools/env/env_flags.c [new file with mode: 0644]
tools/env/linux_string.c [new file with mode: 0644]
tools/env_embedded.c [new file with mode: 0644]
tools/fdt.c [new file with mode: 0644]
tools/fdt_ro.c [new file with mode: 0644]
tools/fdt_rw.c [new file with mode: 0644]
tools/fdt_strerror.c [new file with mode: 0644]
tools/fdt_wip.c [new file with mode: 0644]
tools/gdb/Makefile
tools/image-fit.c [new file with mode: 0644]
tools/image-sig.c [new file with mode: 0644]
tools/image.c [new file with mode: 0644]
tools/kernel-doc/Makefile
tools/md5.c [new file with mode: 0644]
tools/rsa-sign.c [new file with mode: 0644]
tools/sha1.c [new file with mode: 0644]

index 1687e2e90abe4353e47a76f496ee7949df58e487..a1e2810b33dd6320b9fabffc7405de6f346e19c2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -126,6 +126,8 @@ unexport CDPATH
 
 #########################################################################
 
+build := -f $(TOPDIR)/scripts/Makefile.build -C
+
 # The "tools" are needed early, so put this first
 # Don't include stuff already done in $(LIBS)
 # The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
@@ -362,8 +364,6 @@ endif
 endif
 endif
 
-build := -f $(TOPDIR)/scripts/Makefile.build -C
-
 all:           $(ALL-y) $(SUBDIR_EXAMPLES-y)
 
 $(obj)u-boot.dtb:      checkdtc $(obj)u-boot
@@ -558,7 +558,10 @@ $(OBJS):
 $(LIBS):       depend $(SUBDIR_TOOLS)
                $(MAKE) $(build) $(dir $(subst $(obj),,$@))
 
-$(SUBDIRS):    depend
+tools: depend
+               $(MAKE) $(build) $@ all
+
+$(filter-out tools,$(SUBDIRS)):        depend
                $(MAKE) -C $@ all
 
 $(SUBDIR_EXAMPLES-y): $(obj)u-boot
@@ -711,7 +714,7 @@ depend dep tags ctags etags cscope $(obj)System.map:
        @ exit 1
 
 tools: $(VERSION_FILE) $(TIMESTAMP_FILE)
-       $(MAKE) -C $@ all
+       $(MAKE) $(build) $@ all
 endif  # config.mk
 
 # ARM relocations should all be R_ARM_RELATIVE (32-bit) or
@@ -746,14 +749,15 @@ $(TIMESTAMP_FILE):
                @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
 
 easylogo env gdb:
-       $(MAKE) -C tools/$@ all MTD_VERSION=${MTD_VERSION}
+       $(MAKE) $(build) tools/$@ MTD_VERSION=${MTD_VERSION}
+
 gdbtools: gdb
 
 xmldocs pdfdocs psdocs htmldocs mandocs: tools/kernel-doc/docproc
        $(MAKE) U_BOOT_VERSION=$(U_BOOT_VERSION) -C doc/DocBook/ $@
 
 tools-all: easylogo env gdb $(VERSION_FILE) $(TIMESTAMP_FILE)
-       $(MAKE) -C tools HOST_TOOLS_ALL=y
+       $(MAKE) $(build) tools HOST_TOOLS_ALL=y
 
 .PHONY : CHANGELOG
 CHANGELOG:
@@ -798,7 +802,7 @@ clean:
               $(obj)tools/gen_eth_addr    $(obj)tools/img2srec           \
               $(obj)tools/dump{env,}image                \
               $(obj)tools/mk{env,}image   $(obj)tools/mpc86x_clk         \
-              $(obj)tools/mk{$(BOARD),}spl                               \
+              $(obj)tools/mk{$(BOARD),exynos}spl                         \
               $(obj)tools/mxsboot                                        \
               $(obj)tools/ncb             $(obj)tools/ubsha1             \
               $(obj)tools/kernel-doc/docproc                             \
index 60e297ae9c75c7559c3b1c905810e755467a5ceb..07afb350c2ba596dd20a49b36d8fe165e22e986d 100644 (file)
--- a/config.mk
+++ b/config.mk
@@ -58,7 +58,6 @@ PLATFORM_LDFLAGS =
 
 HOSTCFLAGS     = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \
                  $(HOSTCPPFLAGS)
-HOSTSTRIP      = strip
 
 #
 # Mac OS X / Darwin's C preprocessor is Apple specific.  It
@@ -93,13 +92,6 @@ ifeq ($(HOSTOS),cygwin)
 HOSTCFLAGS     += -ansi
 endif
 
-# We build some files with extra pedantic flags to try to minimize things
-# that won't build on some weird host compiler -- though there are lots of
-# exceptions for files that aren't complaint.
-
-HOSTCFLAGS_NOPED = $(filter-out -pedantic,$(HOSTCFLAGS))
-HOSTCFLAGS     += -pedantic
-
 #########################################################################
 #
 # Option checker, gcc version (courtesy linux kernel) to ensure
@@ -213,24 +205,6 @@ CPPFLAGS += -ffunction-sections -fdata-sections
 LDFLAGS_FINAL += --gc-sections
 endif
 
-# TODO(sjg@chromium.org): Is this correct on Mac OS?
-
-# MXSImage needs LibSSL
-ifneq ($(CONFIG_MX23)$(CONFIG_MX28),)
-HOSTLIBS       += -lssl -lcrypto
-# Add CONFIG_MXS into host CFLAGS, so we can check whether or not register
-# the mxsimage support within tools/mxsimage.c .
-HOSTCFLAGS     += -DCONFIG_MXS
-endif
-
-ifdef CONFIG_FIT_SIGNATURE
-HOSTLIBS       += -lssl -lcrypto
-
-# This affects include/image.h, but including the board config file
-# is tricky, so manually define this options here.
-HOSTCFLAGS     += -DCONFIG_FIT_SIGNATURE
-endif
-
 ifneq ($(CONFIG_SYS_TEXT_BASE),)
 CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
 endif
@@ -341,7 +315,7 @@ endif
 
 #########################################################################
 
-export HOSTCC HOSTCFLAGS HOSTLDFLAGS PEDCFLAGS HOSTSTRIP CROSS_COMPILE \
+export HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE \
        AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP MAKE
 export CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
 
index f4510b7cb6aa13caad7e2d6422266c2f7844b657..b36de4daa2b4db45d4a43dcf987fe4128581c56e 100644 (file)
--- a/rules.mk
+++ b/rules.mk
@@ -43,9 +43,4 @@ $(obj).depend.%:      %.c
 $(obj).depend.%:       %.S
        $(MAKE_DEPEND)
 
-$(HOSTOBJS): $(obj)%.o: %.c
-       $(HOSTCC) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $< -c
-$(NOPEDOBJS): $(obj)%.o: %.c
-       $(HOSTCC) $(HOSTCFLAGS_NOPED) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $< -c
-
 #########################################################################
index 28fcfdd48626101d1619a6bc6ef7d215472d3d3f..3c40a7e523c1807a63a3a4f3d2563aef9e2e6128 100644 (file)
@@ -165,7 +165,9 @@ else
 VAR_SIZE_PARAM =
 endif
 $(obj)$(BOARD)-spl.bin: $(obj)u-boot-spl.bin
-       $(OBJTREE)/tools/mk$(BOARD)spl $(VAR_SIZE_PARAM) $< $@
+       $(if $(wildcard $(OBJTREE)/tools/mk$(BOARD)spl),\
+       $(OBJTREE)/tools/mk$(BOARD)spl,\
+       $(OBJTREE)/tools/mkexynosspl) $(VAR_SIZE_PARAM) $< $@
 endif
 
 $(obj)$(SPL_BIN).bin:  $(obj)$(SPL_BIN)
index cd2f041cc2cf9519afd805376419fc0576455d87..13283b7d8cd3458b5fe3a893f512b199fb0b763c 100644 (file)
@@ -6,6 +6,7 @@
 /dumpimage
 /mkenvimage
 /mkimage
+/mkexynosspl
 /mpc86x_clk
 /mxsboot
 /ncb
@@ -15,7 +16,6 @@
 /xway-swap-bytes
 /*.exe
 /easylogo/easylogo
-/env/crc32.c
 /env/fw_printenv
 /gdb/gdbcont
 /gdb/gdbsend
index 052e4d4f1fa2b4770dbec906dc960385ba472a28..c3cdaf0bdcb7c5534c5311ab730f88cd8c22ebf6 100644 (file)
@@ -5,14 +5,6 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-TOOLSUBDIRS = kernel-doc
-
-#
-# Include this after HOSTOS HOSTARCH check
-# so that we can act intelligently.
-#
-include $(TOPDIR)/config.mk
-
 #
 # toolchains targeting win32 generate .exe files
 #
@@ -43,82 +35,111 @@ ENVCRC-$(CONFIG_ENV_IS_IN_NVRAM) = y
 ENVCRC-$(CONFIG_ENV_IS_IN_SPI_FLASH) = y
 CONFIG_BUILD_ENVCRC ?= $(ENVCRC-y)
 
-# Generated executable files
-BIN_FILES-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX)
-BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX)
-BIN_FILES-$(CONFIG_BUILD_ENVCRC) += envcrc$(SFX)
-BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
-BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
-BIN_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes$(SFX)
-BIN_FILES-y += dumpimage$(SFX)
-BIN_FILES-y += mkenvimage$(SFX)
-BIN_FILES-y += mkimage$(SFX)
-BIN_FILES-$(CONFIG_EXYNOS5250) += mk$(BOARD)spl$(SFX)
-BIN_FILES-$(CONFIG_EXYNOS5420) += mk$(BOARD)spl$(SFX)
-BIN_FILES-$(CONFIG_MX23) += mxsboot$(SFX)
-BIN_FILES-$(CONFIG_MX28) += mxsboot$(SFX)
-BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
-BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
-BIN_FILES-$(CONFIG_KIRKWOOD) += kwboot$(SFX)
-BIN_FILES-y += proftool$(SFX)
-BIN_FILES-$(CONFIG_STATIC_RELA) += relocate-rela$(SFX)
-
-# Source files which exist outside the tools directory
-EXT_OBJ_FILES-$(CONFIG_BUILD_ENVCRC) += common/env_embedded.o
-EXT_OBJ_FILES-y += common/image.o
-EXT_OBJ_FILES-$(CONFIG_FIT) += common/image-fit.o
-EXT_OBJ_FILES-y += common/image-sig.o
-EXT_OBJ_FILES-y += lib/crc32.o
-EXT_OBJ_FILES-y += lib/md5.o
-EXT_OBJ_FILES-y += lib/sha1.o
-
-# Source files located in the tools directory
-NOPED_OBJ_FILES-y += aisimage.o
-NOPED_OBJ_FILES-y += default_image.o
-NOPED_OBJ_FILES-y += dumpimage.o
-NOPED_OBJ_FILES-y += fit_image.o
-NOPED_OBJ_FILES-y += image-host.o
-NOPED_OBJ_FILES-y += imximage.o
-NOPED_OBJ_FILES-y += kwbimage.o
-NOPED_OBJ_FILES-y += imagetool.o
-NOPED_OBJ_FILES-y += mkenvimage.o
-NOPED_OBJ_FILES-y += mkimage.o
-NOPED_OBJ_FILES-y += mxsimage.o
-NOPED_OBJ_FILES-y += omapimage.o
-NOPED_OBJ_FILES-y += os_support.o
-NOPED_OBJ_FILES-y += pblimage.o
-NOPED_OBJ_FILES-y += proftool.o
-NOPED_OBJ_FILES-y += ublimage.o
-NOPED_OBJ_FILES-y += relocate-rela.o
-OBJ_FILES-$(CONFIG_BUILD_ENVCRC) += envcrc.o
-OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
-OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
-OBJ_FILES-$(CONFIG_EXYNOS_SPL) += mkexynosspl.o
-OBJ_FILES-$(CONFIG_KIRKWOOD) += kwboot.o
-OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
-OBJ_FILES-$(CONFIG_MX23) += mxsboot.o
-OBJ_FILES-$(CONFIG_MX28) += mxsboot.o
-OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
-OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
-OBJ_FILES-$(CONFIG_SMDK5250) += mkexynosspl.o
-OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
-OBJ_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes.o
+# TODO: CONFIG_CMD_LICENSE does not work
+hostprogs-$(CONFIG_CMD_LICENSE) += bin2header$(SFX)
 
-# Don't build by default
-#ifeq ($(ARCH),ppc)
-#BIN_FILES-y += mpc86x_clk$(SFX)
-#OBJ_FILES-y += mpc86x_clk.o
-#endif
+hostprogs-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX)
+hostprogs-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX)
+HOSTCFLAGS_bmp_logo$(SFX) := -pedantic
+
+hostprogs-$(CONFIG_BUILD_ENVCRC) += envcrc$(SFX)
+envcrc$(SFX)-objs := crc32.o env_embedded.o envcrc.o sha1.o
+
+hostprogs-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
+HOSTCFLAGS_gen_eth_addr$(SFX) := -pedantic
 
+hostprogs-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
+HOSTCFLAGS_img2srec$(SFX) := -pedantic
+
+hostprogs-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes$(SFX)
+HOSTCFLAGS_xway-swap-bytes$(SFX) := -pedantic
+
+hostprogs-y += mkenvimage$(SFX)
+mkenvimage$(SFX)-objs := crc32.o mkenvimage.o os_support.o
+
+hostprogs-y += dumpimage$(SFX) mkimage$(SFX)
+
+FIT_SIG_OBJS-$(CONFIG_FIT_SIGNATURE) := image-sig.o
 # Flattened device tree objects
-LIBFDT_OBJ_FILES-y += fdt.o
-LIBFDT_OBJ_FILES-y += fdt_ro.o
-LIBFDT_OBJ_FILES-y += fdt_rw.o
-LIBFDT_OBJ_FILES-y += fdt_strerror.o
-LIBFDT_OBJ_FILES-y += fdt_wip.o
+LIBFDT_OBJS := fdt.o fdt_ro.o fdt_rw.o fdt_strerror.o fdt_wip.o
+RSA_OBJS-$(CONFIG_FIT_SIGNATURE) := rsa-sign.o
+
+# common objs for dumpimage and mkimage
+dumpimage-mkimage-objs := aisimage.o \
+                       $(FIT_SIG_OBJS-y) \
+                       crc32.o \
+                       default_image.o \
+                       fit_image.o \
+                       image-fit.o \
+                       image-host.o \
+                       image.o \
+                       imagetool.o \
+                       imximage.o \
+                       kwbimage.o \
+                       md5.o \
+                       mxsimage.o \
+                       omapimage.o \
+                       os_support.o \
+                       pblimage.o \
+                       sha1.o \
+                       ublimage.o \
+                       $(LIBFDT_OBJS) \
+                       $(RSA_OBJS-y)
+
+dumpimage$(SFX)-objs := $(dumpimage-mkimage-objs) dumpimage.o
+mkimage$(SFX)-objs   := $(dumpimage-mkimage-objs) mkimage.o
+
+# TODO(sjg@chromium.org): Is this correct on Mac OS?
+
+# MXSImage needs LibSSL
+ifneq ($(CONFIG_MX23)$(CONFIG_MX28),)
+HOSTLOADLIBES_dumpimage$(SFX) := -lssl -lcrypto
+HOSTLOADLIBES_mkimage$(SFX) := -lssl -lcrypto
+# Add CONFIG_MXS into host CFLAGS, so we can check whether or not register
+# the mxsimage support within tools/mxsimage.c .
+HOSTCFLAGS     += -DCONFIG_MXS
+endif
+
+ifdef CONFIG_FIT_SIGNATURE
+HOSTLOADLIBES_dumpimage$(SFX) := -lssl -lcrypto
+HOSTLOADLIBES_mkimage$(SFX) := -lssl -lcrypto
+
+# This affects include/image.h, but including the board config file
+# is tricky, so manually define this options here.
+HOST_EXTRACFLAGS       += -DCONFIG_FIT_SIGNATURE
+endif
+
+hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl$(SFX)
+hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl$(SFX)
+HOSTCFLAGS_mkexynosspl$(SFX) := -pedantic
+
+hostprogs-$(CONFIG_MX23) += mxsboot$(SFX)
+hostprogs-$(CONFIG_MX28) += mxsboot$(SFX)
+HOSTCFLAGS_mxsboot$(SFX) := -pedantic
+
+hostprogs-$(CONFIG_NETCONSOLE) += ncb$(SFX)
+hostprogs-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
+
+ubsha1$(SFX)-objs := os_support.o sha1.o ubsha1.o
+
+HOSTCFLAGS_ubsha1.o := -pedantic
+
+hostprogs-$(CONFIG_KIRKWOOD) += kwboot$(SFX)
+hostprogs-y += proftool$(SFX)
+hostprogs-$(CONFIG_STATIC_RELA) += relocate-rela$(SFX)
 
-# RSA objects
-RSA_OBJ_FILES-$(CONFIG_FIT_SIGNATURE) += rsa-sign.o
+# We build some files with extra pedantic flags to try to minimize things
+# that won't build on some weird host compiler -- though there are lots of
+# exceptions for files that aren't complaint.
+HOSTCFLAGS_crc32.o := -pedantic
+HOSTCFLAGS_md5.o := -pedantic
+HOSTCFLAGS_sha1.o := -pedantic
+
+# Don't build by default
+#hostprogs-$(CONFIG_PPC) += mpc86x_clk$(SFX)
+#HOSTCFLAGS_mpc86x_clk$(SFX) := -pedantic
+
+always := $(hostprogs-y)
 
 # Generated LCD/video logo
 LOGO_H = $(OBJTREE)/include/bmp_logo.h
@@ -147,24 +168,13 @@ endif # !LOGO_BMP
 HOSTSRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
 HOSTSRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
 HOSTSRCS += $(addprefix $(SRCTREE)/lib/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
-HOSTSRCS += $(addprefix $(SRCTREE)/lib/rsa/,$(RSA_OBJ_FILES-y:.o=.c))
-BINS   := $(addprefix $(obj),$(sort $(BIN_FILES-y)))
-LIBFDT_OBJS    := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
-RSA_OBJS       := $(addprefix $(obj),$(RSA_OBJ_FILES-y))
-
-# We cannot check CONFIG_FIT_SIGNATURE here since it is not set on the host
-FIT_SIG_OBJ_FILES      := image-sig.o
-FIT_SIG_OBJS           := $(addprefix $(obj),$(FIT_SIG_OBJ_FILES))
-
-HOSTOBJS := $(addprefix $(obj),$(OBJ_FILES-y))
-NOPEDOBJS := $(addprefix $(obj),$(NOPED_OBJ_FILES-y))
 
 #
 # Use native tools and options
 # Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
 # Define _GNU_SOURCE to obtain the getline prototype from stdio.h
 #
-HOSTCPPFLAGS = -include $(SRCTREE)/include/libfdt_env.h \
+HOST_EXTRACFLAGS += -include $(SRCTREE)/include/libfdt_env.h \
                -idirafter $(SRCTREE)/include \
                -idirafter $(SRCTREE)/arch/$(ARCH)/include \
                -idirafter $(OBJTREE)/include \
@@ -175,152 +185,12 @@ HOSTCPPFLAGS =   -include $(SRCTREE)/include/libfdt_env.h \
                -D__KERNEL_STRICT_NAMES \
                -D_GNU_SOURCE
 
+all:   $(LOGO-y)
 
-all:   $(obj).depend $(BINS) $(LOGO-y) subdirs
-
-$(obj)bin2header$(SFX): $(obj)bin2header.o
-       $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-       $(HOSTSTRIP) $@
-
-$(obj)bmp_logo$(SFX):  $(obj)bmp_logo.o
-       $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-       $(HOSTSTRIP) $@
-
-$(obj)proftool$(SFX):  $(obj)proftool.o
-       $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-       $(HOSTSTRIP) $@
-
-$(obj)envcrc$(SFX):    $(obj)crc32.o $(obj)env_embedded.o $(obj)envcrc.o $(obj)sha1.o
-       $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-
-$(obj)gen_eth_addr$(SFX):      $(obj)gen_eth_addr.o
-       $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-       $(HOSTSTRIP) $@
-
-$(obj)img2srec$(SFX):  $(obj)img2srec.o
-       $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-       $(HOSTSTRIP) $@
-
-$(obj)xway-swap-bytes$(SFX):   $(obj)xway-swap-bytes.o
-       $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-       $(HOSTSTRIP) $@
-
-$(obj)dumpimage$(SFX): $(obj)aisimage.o \
-                       $(FIT_SIG_OBJS) \
-                       $(obj)crc32.o \
-                       $(obj)default_image.o \
-                       $(obj)fit_image.o \
-                       $(obj)image-fit.o \
-                       $(obj)image.o \
-                       $(obj)image-host.o \
-                       $(obj)imagetool.o \
-                       $(obj)imximage.o \
-                       $(obj)kwbimage.o \
-                       $(obj)dumpimage.o \
-                       $(obj)md5.o \
-                       $(obj)mxsimage.o \
-                       $(obj)omapimage.o \
-                       $(obj)os_support.o \
-                       $(obj)pblimage.o \
-                       $(obj)sha1.o \
-                       $(obj)ublimage.o \
-                       $(LIBFDT_OBJS) \
-                       $(RSA_OBJS)
-       $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTLIBS)
-       $(HOSTSTRIP) $@
-
-$(obj)mkenvimage$(SFX):        $(obj)crc32.o $(obj)mkenvimage.o \
-       $(obj)os_support.o
-       $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-       $(HOSTSTRIP) $@
-
-$(obj)mkimage$(SFX):   $(obj)aisimage.o \
-                       $(FIT_SIG_OBJS) \
-                       $(obj)crc32.o \
-                       $(obj)default_image.o \
-                       $(obj)fit_image.o \
-                       $(obj)image-fit.o \
-                       $(obj)image-host.o \
-                       $(obj)image.o \
-                       $(obj)imagetool.o \
-                       $(obj)imximage.o \
-                       $(obj)kwbimage.o \
-                       $(obj)md5.o \
-                       $(obj)mkimage.o \
-                       $(obj)mxsimage.o \
-                       $(obj)omapimage.o \
-                       $(obj)os_support.o \
-                       $(obj)pblimage.o \
-                       $(obj)sha1.o \
-                       $(obj)ublimage.o \
-                       $(LIBFDT_OBJS) \
-                       $(RSA_OBJS)
-       $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTLIBS)
-       $(HOSTSTRIP) $@
-
-$(obj)mk$(BOARD)spl$(SFX):     $(obj)mkexynosspl.o
-       $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-       $(HOSTSTRIP) $@
-
-$(obj)mpc86x_clk$(SFX):        $(obj)mpc86x_clk.o
-       $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-       $(HOSTSTRIP) $@
-
-$(obj)mxsboot$(SFX):   $(obj)mxsboot.o
-       $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-       $(HOSTSTRIP) $@
-
-$(obj)ncb$(SFX):       $(obj)ncb.o
-       $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-       $(HOSTSTRIP) $@
-
-$(obj)ubsha1$(SFX):    $(obj)os_support.o $(obj)sha1.o $(obj)ubsha1.o
-       $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-
-$(obj)kwboot$(SFX): $(obj)kwboot.o
-       $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-       $(HOSTSTRIP) $@
-
-$(obj)relocate-rela$(SFX): $(obj)relocate-rela.o
-       $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-       $(HOSTSTRIP) $@
-
-# Some of the tool objects need to be accessed from outside the tools directory
-$(obj)%.o: $(SRCTREE)/common/%.c
-       $(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
-
-$(obj)%.o: $(SRCTREE)/lib/%.c
-       $(HOSTCC) -g $(HOSTCFLAGS) -c -o $@ $<
-
-$(obj)%.o: $(SRCTREE)/lib/libfdt/%.c
-       $(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
-
-$(obj)%.o: $(SRCTREE)/lib/rsa/%.c
-       $(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
-
-subdirs:
-ifeq ($(TOOLSUBDIRS),)
-       @:
-else
-       @for dir in $(TOOLSUBDIRS) ; do \
-           $(MAKE) \
-               HOSTOS=$(HOSTOS) \
-               HOSTARCH=$(HOSTARCH) \
-               -C $$dir || exit 1 ; \
-       done
-endif
+subdir-y := kernel-doc
 
 $(LOGO_H):     $(obj)bmp_logo $(LOGO_BMP)
        $(obj)./bmp_logo --gen-info $(LOGO_BMP) > $@
 
 $(LOGO_DATA_H):        $(obj)bmp_logo $(LOGO_BMP)
        $(obj)./bmp_logo --gen-data $(LOGO_BMP) > $@
-
-#########################################################################
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
diff --git a/tools/crc32.c b/tools/crc32.c
new file mode 100644 (file)
index 0000000..aed7112
--- /dev/null
@@ -0,0 +1 @@
+#include "../lib/crc32.c"
index d8e28b0e12adae3978dd8d5959d3b98b8da5350d..10aba2ba66ded871e1b08f72402bf5682a7998da 100644 (file)
@@ -1,11 +1,3 @@
-include $(TOPDIR)/config.mk
+hostprogs-y := easylogo
 
-all: $(obj)easylogo
-
-$(obj)easylogo: $(SRCTREE)/tools/easylogo/easylogo.c
-       $(HOSTCC) $(HOSTCFLAGS_NOPED) $(HOSTLDFLAGS) -o $@ $^
-
-clean:
-       rm -f $(obj)easylogo
-
-.PHONY: all clean
+always := $(hostprogs-y)
index 27892f74d096b56c8440c898e0af73e876b8cf4e..c30381565d515496931e743a474381c639eb0afd 100644 (file)
@@ -5,15 +5,8 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-include $(TOPDIR)/config.mk
-
-HOSTSRCS := $(SRCTREE)/lib/crc32.c  fw_env.c  fw_env_main.c
-HOSTSRCS += $(SRCTREE)/lib/ctype.c $(SRCTREE)/lib/linux_string.c
-HOSTSRCS += $(SRCTREE)/common/env_attr.c $(SRCTREE)/common/env_flags.c
-HEADERS        := fw_env.h $(OBJTREE)/include/config.h
-
 # Compile for a hosted environment on the target
-HOSTCPPFLAGS  = -idirafter $(SRCTREE)/include \
+HOST_EXTRACFLAGS  = -idirafter $(SRCTREE)/include \
                -idirafter $(SRCTREE)/arch/$(ARCH)/include \
                -idirafter $(OBJTREE)/include \
                -idirafter $(SRCTREE)/tools/env \
@@ -21,23 +14,12 @@ HOSTCPPFLAGS  = -idirafter $(SRCTREE)/include \
                -DTEXT_BASE=$(TEXT_BASE)
 
 ifeq ($(MTD_VERSION),old)
-HOSTCPPFLAGS += -DMTD_OLD
+HOST_EXTRACFLAGS += -DMTD_OLD
 endif
 
-all:   $(obj)fw_printenv
-
-# Some files complain if compiled with -pedantic, use HOSTCFLAGS_NOPED
-$(obj)fw_printenv:     $(HOSTSRCS) $(HEADERS)
-       $(HOSTCC) $(HOSTCFLAGS_NOPED) $(HOSTLDFLAGS) -o $@ $(HOSTSRCS)
-       $(HOSTSTRIP) $@
-
-clean:
-       rm -f $(obj)fw_printenv
-
-#########################################################################
-
-include $(TOPDIR)/rules.mk
-
-sinclude $(obj).depend
+hostprogs-y := fw_printenv
+always := $(hostprogs-y)
 
-#########################################################################
+fw_printenv-objs := fw_env.o fw_env_main.o \
+       crc32.o ctype.o linux_string.o \
+       env_attr.o env_flags.o
diff --git a/tools/env/crc32.c b/tools/env/crc32.c
new file mode 100644 (file)
index 0000000..34f8178
--- /dev/null
@@ -0,0 +1 @@
+#include "../../lib/crc32.c"
diff --git a/tools/env/ctype.c b/tools/env/ctype.c
new file mode 100644 (file)
index 0000000..21050e9
--- /dev/null
@@ -0,0 +1 @@
+#include "../../lib/ctype.c"
diff --git a/tools/env/env_attr.c b/tools/env/env_attr.c
new file mode 100644 (file)
index 0000000..502d4c9
--- /dev/null
@@ -0,0 +1 @@
+#include "../../common/env_attr.c"
diff --git a/tools/env/env_flags.c b/tools/env/env_flags.c
new file mode 100644 (file)
index 0000000..b261cb8
--- /dev/null
@@ -0,0 +1 @@
+#include "../../common/env_flags.c"
diff --git a/tools/env/linux_string.c b/tools/env/linux_string.c
new file mode 100644 (file)
index 0000000..6c01add
--- /dev/null
@@ -0,0 +1 @@
+#include "../../lib/linux_string.c"
diff --git a/tools/env_embedded.c b/tools/env_embedded.c
new file mode 100644 (file)
index 0000000..59a6357
--- /dev/null
@@ -0,0 +1 @@
+#include "../common/env_embedded.c"
diff --git a/tools/fdt.c b/tools/fdt.c
new file mode 100644 (file)
index 0000000..1eafc56
--- /dev/null
@@ -0,0 +1 @@
+#include "../lib/libfdt/fdt.c"
diff --git a/tools/fdt_ro.c b/tools/fdt_ro.c
new file mode 100644 (file)
index 0000000..9005fe3
--- /dev/null
@@ -0,0 +1 @@
+#include "../lib/libfdt/fdt_ro.c"
diff --git a/tools/fdt_rw.c b/tools/fdt_rw.c
new file mode 100644 (file)
index 0000000..adc3fdf
--- /dev/null
@@ -0,0 +1 @@
+#include "../lib/libfdt/fdt_rw.c"
diff --git a/tools/fdt_strerror.c b/tools/fdt_strerror.c
new file mode 100644 (file)
index 0000000..d0b5822
--- /dev/null
@@ -0,0 +1 @@
+#include "../lib/libfdt/fdt_strerror.c"
diff --git a/tools/fdt_wip.c b/tools/fdt_wip.c
new file mode 100644 (file)
index 0000000..7810f07
--- /dev/null
@@ -0,0 +1 @@
+#include "../lib/libfdt/fdt_wip.c"
index dd98fb65c0dccef2701d1bb877f055d0cda58c83..850bb9b20e56befd0a1e042cef0ddc1c685219ce 100644 (file)
@@ -8,49 +8,18 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-include $(TOPDIR)/config.mk
-
-BINS   = gdbsend gdbcont
-
-COBJS  = gdbsend.o gdbcont.o error.o remote.o serial.o
-
-HOSTOBJS := $(addprefix $(obj),$(COBJS))
-HOSTSRCS := $(COBJS:.o=.c)
-BINS   := $(addprefix $(obj),$(BINS))
+ifneq ($(HOSTOS),cygwin)
 
 #
 # Use native tools and options
 #
-HOSTCPPFLAGS = -I$(BFD_ROOT_DIR)/include
-
-ifeq ($(HOSTOS),cygwin)
-
-all:
-$(obj).depend:
-
-else   # ! CYGWIN
-
-all:   $(obj).depend $(BINS)
-
-$(obj)gdbsend: $(obj)gdbsend.o $(obj)error.o $(obj)remote.o $(obj)serial.o
-               $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-
-$(obj)gdbcont: $(obj)gdbcont.o $(obj)error.o $(obj)remote.o $(obj)serial.o
-               $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-
-clean:
-       rm -f $(HOSTOBJS)
-
-distclean:     clean
-       rm -f $(BINS) $(obj)core $(obj)*.bak $(obj).depend
-
-#########################################################################
+HOST_EXTRACFLAGS := -I$(BFD_ROOT_DIR)/include -pedantic
 
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
+hostprogs-y := gdbsend gdbcont
 
-sinclude $(obj).depend
+gdbsend-objs := gdbsend.o error.o remote.o serial.o
+gdbcont-objs := gdbcont.o error.o remote.o serial.o
 
-#########################################################################
+always := $(hostprogs-y)
 
 endif  # cygwin
diff --git a/tools/image-fit.c b/tools/image-fit.c
new file mode 100644 (file)
index 0000000..037e5cc
--- /dev/null
@@ -0,0 +1 @@
+#include "../common/image-fit.c"
diff --git a/tools/image-sig.c b/tools/image-sig.c
new file mode 100644 (file)
index 0000000..e45419f
--- /dev/null
@@ -0,0 +1 @@
+#include "../common/image-sig.c"
diff --git a/tools/image.c b/tools/image.c
new file mode 100644 (file)
index 0000000..0f9bacc
--- /dev/null
@@ -0,0 +1 @@
+#include "../common/image.c"
index eb56e2e753b35b7e9a0391e228eb89ade918f479..f15a4b7bfa9efff7ce49ce80ed21f92d51680d54 100644 (file)
@@ -4,22 +4,7 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-include $(TOPDIR)/config.mk
+hostprogs-y := docproc
+always := $(hostprogs-y)
 
-all:   $(obj)docproc
-
-$(obj)docproc: docproc.c
-       $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-       $(HOSTSTRIP) $@
-
-clean:
-       rm -rf docproc
-
-#########################################################################
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
+HOST_EXTRACFLAGS := -pedantic
diff --git a/tools/md5.c b/tools/md5.c
new file mode 100644 (file)
index 0000000..befaa32
--- /dev/null
@@ -0,0 +1 @@
+#include "../lib/md5.c"
diff --git a/tools/rsa-sign.c b/tools/rsa-sign.c
new file mode 100644 (file)
index 0000000..150bbe1
--- /dev/null
@@ -0,0 +1 @@
+#include "../lib/rsa/rsa-sign.c"
diff --git a/tools/sha1.c b/tools/sha1.c
new file mode 100644 (file)
index 0000000..0d717df
--- /dev/null
@@ -0,0 +1 @@
+#include "../lib/sha1.c"