devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC/PATCH] libfdt: Use quotes to include header files
@ 2015-01-02 21:10 Chris Packham
       [not found] ` <1420233023-12710-1-git-send-email-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Packham @ 2015-01-02 21:10 UTC (permalink / raw)
  To: David Gibson, Jon Loeliger
  Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Chris Packham

The linux kernel which carries the source of the device-tree-compiler
and libfdt verbatim makes use of the include guards in libfdt_env.h and
fdt.h to substitute kernel specific versions of the files. Unfortunately
because these hare included in libfdt.h using angle brackets they are
looked for in the "system" header location instead of the same directory
as libfdt.h. This means that any file that includes libfdt.h needs to
have special CFLAGS to add the path containing libfdt_env.h and fdt.h
just so that their contents can be discarded by the include guards.

By using quotes in libfdt/libfdt.h it picks up fdt.h and libfdt_env.h
from the source directory without needing to add CFLAGS for the sources
that happen to include linux/libfdt.h.

Signed-off-by: Chris Packham <chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
---
Hi,

This patch has bounced around a couple of other mailing lists[1] and I've
been directed here. This is a fairly linux-kernel centric problem so I'm
open to other suggestions. The desire has been expressed to avoid having
to have custom CFLAGS[2] just because a file needs to operate on the
flattened device tree.

Jon had previously mentioned a recollection that the angle brackets were
intentional[3] can anyone confirm or deny this?

Regards,
Chris
--
[1] - http://www.spinics.net/lists/devicetree/msg62553.html
[2] - http://lists.infradead.org/pipermail/linux-arm-kernel/2014-December/310297.html
[3] - http://www.spinics.net/lists/devicetree/msg62604.html

 libfdt/libfdt.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libfdt/libfdt.h b/libfdt/libfdt.h
index 32d5227..020e760 100644
--- a/libfdt/libfdt.h
+++ b/libfdt/libfdt.h
@@ -51,8 +51,8 @@
  *     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <libfdt_env.h>
-#include <fdt.h>
+#include "libfdt_env.h"
+#include "fdt.h"
 
 #define FDT_FIRST_SUPPORTED_VERSION	0x10
 #define FDT_LAST_SUPPORTED_VERSION	0x11
-- 
2.2.0.rc0

--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RFC/PATCH] libfdt: Use quotes to include header files
       [not found] ` <1420233023-12710-1-git-send-email-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
@ 2015-01-27  6:01   ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2015-01-27  6:01 UTC (permalink / raw)
  To: Chris Packham; +Cc: Jon Loeliger, devicetree-compiler-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 2820 bytes --]

On Sat, Jan 03, 2015 at 10:10:23AM +1300, Chris Packham wrote:
> The linux kernel which carries the source of the device-tree-compiler
> and libfdt verbatim makes use of the include guards in libfdt_env.h and
> fdt.h to substitute kernel specific versions of the files. Unfortunately
> because these hare included in libfdt.h using angle brackets they are
> looked for in the "system" header location instead of the same directory
> as libfdt.h. This means that any file that includes libfdt.h needs to
> have special CFLAGS to add the path containing libfdt_env.h and fdt.h
> just so that their contents can be discarded by the include guards.
> 
> By using quotes in libfdt/libfdt.h it picks up fdt.h and libfdt_env.h
> from the source directory without needing to add CFLAGS for the sources
> that happen to include linux/libfdt.h.
> 
> Signed-off-by: Chris Packham <chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
> ---
> Hi,
> 
> This patch has bounced around a couple of other mailing lists[1] and I've
> been directed here. This is a fairly linux-kernel centric problem so I'm
> open to other suggestions. The desire has been expressed to avoid having
> to have custom CFLAGS[2] just because a file needs to operate on the
> flattened device tree.
> 
> Jon had previously mentioned a recollection that the angle brackets were
> intentional[3] can anyone confirm or deny this?

Sorry it's been so long before I replied.

There are a couple of cases I'm concerned about in considering this
change:

Case 1: libfdt installed as a userspace library

Here, libfdt.h, fdt.h and (the userspace version of) libfdt_env.h will
be in /usr/include.

I can never remember the exact details of how "" include works
compared to <> include.  If a program the user is writing includes
<libfdt.h>, will the "" includes within it correctly find the system
installed versions of the other headers?

Case 2: Building against a custom libfdt_env.h

As you know, libfdt is designed so it can be built with a custom
libfdt_env.h to embed it in bootloaders or other unusual environments.
The idea is that libfdt_env.h should be the *only* file that needs
adjustment in order to embed libfdt, the remaining files should be
exactly as included in the libfdt tree.

Wouldn't using "" mean that the local environment's libfdt_env.h must
be in the same directory as the libfdt.h you're building with, which
might be inconvenient if the embedding project wants to include the
whole libfdt directory without modification, but store the
libfdt_env.h file elsewhere in its tree.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-27  6:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-02 21:10 [RFC/PATCH] libfdt: Use quotes to include header files Chris Packham
     [not found] ` <1420233023-12710-1-git-send-email-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
2015-01-27  6:01   ` David Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).