From 940db16d2e6ce69f769f790bf1def56978f0ac6c Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 4 Feb 2014 17:24:10 +0900 Subject: tools: convert makefiles to kbuild style 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 --- tools/env/Makefile | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) (limited to 'tools/env/Makefile') diff --git a/tools/env/Makefile b/tools/env/Makefile index 27892f74d0..c30381565d 100644 --- a/tools/env/Makefile +++ b/tools/env/Makefile @@ -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 -- cgit From fea1ca8e3418bac4b55f4cc8b66a6ae0d41e91e4 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 4 Feb 2014 17:24:20 +0900 Subject: Makefile: refactor include path settings This commit merges commonly-used header include paths to UBOOTINCLUDE and NOSTDINC_FLAGS variables, which are placed at the top Makefile. Signed-off-by: Masahiro Yamada --- tools/env/Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'tools/env/Makefile') diff --git a/tools/env/Makefile b/tools/env/Makefile index c30381565d..d47fe16c07 100644 --- a/tools/env/Makefile +++ b/tools/env/Makefile @@ -6,9 +6,7 @@ # # Compile for a hosted environment on the target -HOST_EXTRACFLAGS = -idirafter $(SRCTREE)/include \ - -idirafter $(SRCTREE)/arch/$(ARCH)/include \ - -idirafter $(OBJTREE)/include \ +HOST_EXTRACFLAGS = $(patsubst -I%,-idirafter%, $(UBOOTINCLUDE)) \ -idirafter $(SRCTREE)/tools/env \ -DUSE_HOSTCC \ -DTEXT_BASE=$(TEXT_BASE) -- cgit From 79fc0c5f498c3982aa4740c273ab1a9255063d9c Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 4 Feb 2014 17:24:45 +0900 Subject: tools/env: cross-compile fw_printenv without setting HOSTCC fw_printenv is a program which mostly runs on the target Linux. Before switching to Kbuild, we needed to set HOSTCC at the command line like this: make HOSTCC= env Going forward we can cross compile it by specifying CROSS_COMPILE: make CROSS_COMPILE= env This looks more natural. Signed-off-by: Masahiro Yamada Tested-by: Gerhard Sittig --- tools/env/Makefile | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'tools/env/Makefile') diff --git a/tools/env/Makefile b/tools/env/Makefile index d47fe16c07..6ad81fdb33 100644 --- a/tools/env/Makefile +++ b/tools/env/Makefile @@ -5,6 +5,11 @@ # SPDX-License-Identifier: GPL-2.0+ # +# fw_printenv is supposed to run on the target system, which means it should be +# built with cross tools. Although it may look weird, we only replace "HOSTCC" +# with "CC" here for the maximum code reuse of scripts/Makefile.host. +HOSTCC = $(CC) + # Compile for a hosted environment on the target HOST_EXTRACFLAGS = $(patsubst -I%,-idirafter%, $(UBOOTINCLUDE)) \ -idirafter $(SRCTREE)/tools/env \ @@ -15,9 +20,15 @@ ifeq ($(MTD_VERSION),old) HOST_EXTRACFLAGS += -DMTD_OLD endif -hostprogs-y := fw_printenv -always := $(hostprogs-y) +always := fw_printenv +hostprogs-y := fw_printenv_unstripped -fw_printenv-objs := fw_env.o fw_env_main.o \ +fw_printenv_unstripped-objs := fw_env.o fw_env_main.o \ crc32.o ctype.o linux_string.o \ env_attr.o env_flags.o + +quiet_cmd_strip = STRIP $@ + cmd_strip = $(STRIP) -o $@ $< + +$(obj)/fw_printenv: $(obj)/fw_printenv_unstripped FORCE + $(call if_changed,strip) -- cgit