Patchwork [U-Boot] Only build fw_printenv if we have mtd/mtd-user.h

login
register
mail settings
Submitter Loïc Minier
Date Feb. 7, 2011, 11:23 p.m.
Message ID <1297120981-29885-1-git-send-email-loic.minier@linaro.org>
Download mbox | patch
Permalink /patch/82228/
State Changes Requested
Headers show

Comments

Loïc Minier - Feb. 7, 2011, 11:23 p.m.
mtd/mtd-user.h is missing on FreeBSD hosts; add a macro to test whether
a specific host header is present and use it to decide to build
fw_printenv if mtd/mtd-user.h is present.
---

 How about this approach?

 If it's ok, then I could extend it to handle the MTD_VERSION=old case as well,
 perhaps replacing this MTD_VERSION with a test for linux/mtd/mtd.h.

 I would have preferred putting this in /Makefile to disable the
 make -C tools/env altogether, but config.mk isn't included by default so
 HOSTCC isn't available for the test.

 tools/env/Makefile |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
Wolfgang Denk - April 12, 2011, 7:27 p.m.
Dear =?UTF-8?q?Lo=C3=AFc=20Minier?=,

In message <1297120981-29885-1-git-send-email-loic.minier@linaro.org> you wrote:
> mtd/mtd-user.h is missing on FreeBSD hosts; add a macro to test whether
> a specific host header is present and use it to decide to build
> fw_printenv if mtd/mtd-user.h is present.
> ---

Sorry for the delay.

I understand thi is just a RFC, not a patch (yet) intended for
inclusion? [In that case it would miss your SoB line...]

>  How about this approach?
> 
>  If it's ok, then I could extend it to handle the MTD_VERSION=old case as well,
>  perhaps replacing this MTD_VERSION with a test for linux/mtd/mtd.h.

I'm fine with that.  Thanks!

Best regards,

Wolfgang Denk
Loïc Minier - April 12, 2011, 7:46 p.m.
On Tue, Apr 12, 2011, Wolfgang Denk wrote:
> I understand thi is just a RFC, not a patch (yet) intended for
> inclusion? [In that case it would miss your SoB line...]

 Correct!  was just a RFC (albeit I did include it in the Debian
 packaging for now, until we have an upstreamable way of doing it)

> >  How about this approach?  If it's ok, then I could extend it to
> >  handle the MTD_VERSION=old case as well, perhaps replacing this
> >  MTD_VERSION with a test for linux/mtd/mtd.h.
> I'm fine with that.  Thanks!

 Ok, will resubmit; thanks for the comment :-)

 I'll likely replace MTD_OLD with similar logic and hence avoid passing
 it down; it will just be autodetected.

Patch

diff --git a/tools/env/Makefile b/tools/env/Makefile
index 2f7a59c..294bb95 100644
--- a/tools/env/Makefile
+++ b/tools/env/Makefile
@@ -36,7 +36,18 @@  ifeq ($(MTD_VERSION),old)
 HOSTCPPFLAGS += -DMTD_OLD
 endif
 
+# macro to check whether a host header is present; outputs 1 if present, 0 if
+# not
+check_include = $(shell echo | $(HOSTCC) $(HOSTCFLAGS_NOPED) -E -include $(1) -o /dev/null - 2>/dev/null && echo 1 || echo 0)
+
+# whether to build tools/env or not
+has_mtd_user := $(call check_include, mtd/mtd-user.h)
+
+ifeq ($(has_mtd_user),1)
 all:	$(obj)fw_printenv
+else
+all:
+endif
 
 # Some files complain if compiled with -pedantic, use HOSTCFLAGS_NOPED
 $(obj)fw_printenv:	$(HOSTSRCS) $(HEADERS)