diff mbox

[02/47] package/libfdt: new package

Message ID 1351113973-17237-3-git-send-email-yann.morin.1998@free.fr
State Changes Requested
Headers show

Commit Message

Yann E. MORIN Oct. 24, 2012, 9:25 p.m. UTC
libfdt allows one to manipulate a Flat Device Tree.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
 package/Config.in                          |    1 +
 package/dtc/Config.in                      |    9 +++++++
 package/dtc/dtc-extra_cflags.patch         |   12 +++++++++
 package/dtc/dtc-separate-lib-install.patch |   28 +++++++++++++++++++++
 package/dtc/dtc.mk                         |   36 ++++++++++++++++++++++++++++
 5 files changed, 86 insertions(+), 0 deletions(-)
 create mode 100644 package/dtc/Config.in
 create mode 100644 package/dtc/dtc-extra_cflags.patch
 create mode 100644 package/dtc/dtc-separate-lib-install.patch
 create mode 100644 package/dtc/dtc.mk

Comments

Arnout Vandecappelle Oct. 25, 2012, 9:55 p.m. UTC | #1
The package is called dtc, not libfdt.

On 24/10/12 23:25, Yann E. MORIN wrote:
> libfdt allows one to manipulate a Flat Device Tree.

  Flattened Device Tree

>
> Signed-off-by: "Yann E. MORIN"<yann.morin.1998@free.fr>
> ---
>   package/Config.in                          |    1 +
>   package/dtc/Config.in                      |    9 +++++++
>   package/dtc/dtc-extra_cflags.patch         |   12 +++++++++
>   package/dtc/dtc-separate-lib-install.patch |   28 +++++++++++++++++++++
>   package/dtc/dtc.mk                         |   36 ++++++++++++++++++++++++++++
>   5 files changed, 86 insertions(+), 0 deletions(-)
>   create mode 100644 package/dtc/Config.in
>   create mode 100644 package/dtc/dtc-extra_cflags.patch
>   create mode 100644 package/dtc/dtc-separate-lib-install.patch
>   create mode 100644 package/dtc/dtc.mk
>
> diff --git a/package/Config.in b/package/Config.in
> index 1650c71..c9cb3ed 100644
> --- a/package/Config.in
> +++ b/package/Config.in
> @@ -396,6 +396,7 @@ source "package/libaio/Config.in"
>   source "package/libraw1394/Config.in"
>   source "package/tslib/Config.in"
>   source "package/libfreefare/Config.in"
> +source "package/dtc/Config.in"

  Alphabetical order.

  Also, even if for now it only installs libftd, I guess it shouldn't be
a problem to install dtc as well.  In that case it fits more in
Development tools or Hardware handling.

>   source "package/libftdi/Config.in"
>   source "package/libhid/Config.in"
>   source "package/libiqrf/Config.in"
> diff --git a/package/dtc/Config.in b/package/dtc/Config.in
> new file mode 100644
> index 0000000..7b86c60
> --- /dev/null
> +++ b/package/dtc/Config.in
> @@ -0,0 +1,9 @@
> +config BR2_PACKAGE_DTC
> +	bool "dtc"
> +	help
> +	  dtc is the Device Tree Compiler, to generate Device Trees.

  dtc generates Flattened Device Trees (i.e. it flattens the device
tree).

> +	  libfdt if a library to manipulate Flat Device Trees.

  Flattened

> +	
> +	  Note that only the library is installed for now.

  Why?  Build failures in the binaries?

> +	
> +	  http://git.jdl.com/gitweb/?p=dtc.git  (no home page)
> diff --git a/package/dtc/dtc-extra_cflags.patch b/package/dtc/dtc-extra_cflags.patch
> new file mode 100644
> index 0000000..03225e7
> --- /dev/null
> +++ b/package/dtc/dtc-extra_cflags.patch
> @@ -0,0 +1,12 @@
> +diff -durN dtc-e4b497f367a3b2ae99cc52089a14a221b13a76ef.orig/Makefile dtc-e4b497f367a3b2ae99cc52089a14a221b13a76ef/Makefile
> +--- dtc-e4b497f367a3b2ae99cc52089a14a221b13a76ef.orig/Makefile	2012-10-22 22:02:47.541240846 +0200
> ++++ dtc-e4b497f367a3b2ae99cc52089a14a221b13a76ef/Makefile	2012-10-22 22:03:21.151047833 +0200
> +@@ -18,7 +18,7 @@
> + CPPFLAGS = -I libfdt -I .
> + WARNINGS = -Werror -Wall -Wpointer-arith -Wcast-qual -Wnested-externs \
> + 	-Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls
> +-CFLAGS = -g -Os -fPIC -Werror $(WARNINGS)
> ++CFLAGS = -g -Os -fPIC -Werror $(WARNINGS) $(EXTRA_CFLAGS)

  Why not CFLAGS += ...?

  And maybe CPPFLAGS should also be fixed.

> +
> + BISON = bison
> + LEX = flex
> diff --git a/package/dtc/dtc-separate-lib-install.patch b/package/dtc/dtc-separate-lib-install.patch
> new file mode 100644
> index 0000000..c86d587
> --- /dev/null
> +++ b/package/dtc/dtc-separate-lib-install.patch
> @@ -0,0 +1,28 @@
> +Makefile: add a rule to only install libfdt
> +
> +Signed-off-by: "Yann E. MORIN"<yann.morin.1998@free.fr>
> +
> +---
> +Patch not sent upstream.
> +
> +It's really specific to buildroot, and is probably not
> +good (aka generic) enough to be pushed upstream.
> +
> +diff --git a/Makefile b/Makefile
> +index 1169e6c..39e7190 100644
> +--- a/Makefile
> ++++ b/Makefile
> +@@ -160,10 +160,12 @@ endif
> + # intermediate target and building them again "for real"
> + .SECONDARY: $(DTC_GEN_SRCS) $(CONVERT_GEN_SRCS)
> +
> +-install: all $(SCRIPTS)
> ++install: all $(SCRIPTS) libfdt_install
> + 	@$(VECHO) INSTALL
> + 	$(INSTALL) -d $(DESTDIR)$(BINDIR)
> + 	$(INSTALL) $(BIN) $(SCRIPTS) $(DESTDIR)$(BINDIR)
> ++
> ++libfdt_install: libfdt
> + 	$(INSTALL) -d $(DESTDIR)$(LIBDIR)
> + 	$(INSTALL) $(LIBFDT_lib) $(DESTDIR)$(LIBDIR)
> + 	ln -sf $(notdir $(LIBFDT_lib)) $(DESTDIR)$(LIBDIR)/$(LIBFDT_soname)
> diff --git a/package/dtc/dtc.mk b/package/dtc/dtc.mk
> new file mode 100644
> index 0000000..d53e78a
> --- /dev/null
> +++ b/package/dtc/dtc.mk
> @@ -0,0 +1,36 @@
> +#############################################################
> +#
> +# libcurl
> +#
> +#############################################################
> +
> +DTC_VERSION         = e4b497f367a3b2ae99cc52089a14a221b13a76ef
> +DTC_SITE            = git://git.jdl.com/software/dtc.git
> +DTC_LICENSE         = GPLv2+/BSD-2c
> +DTC_LICENSE_FILES   = README.license GPL
> +# Note: the dual-license only applies to the library.
> +#       The DT compiler (dtc) is GPLv2+, but we do not install it.
> +DTC_INSTALL_STAGING = YES
> +
> +# Need -fPIC for x86-64

  ???

> +define DTC_BUILD_CMDS
> +	$(TARGET_CONFIGURE_OPTS) $(MAKE1) -C $(@D)                          \

  Looking at the Makefile, I don't see why parallel builds would fail...

> +	                                  EXTRA_CFLAGS="$(TARGET_CFLAGS)"   \
> +	                                  PREFIX=/usr                       \

  It's nicer to put these two options in DTC_MAKE_OPTS.

  Regards,
  Arnout

> +	                                  libfdt
> +endef
> +
> +# libfdt_install is our own install rule added by our patch
> +define DTC_INSTALL_STAGING_CMDS
> +	$(MAKE1) -C $(@D) DESTDIR=$(STAGING_DIR) PREFIX=/usr libfdt_install
> +endef
> +
> +define DTC_INSTALL_TARGET_CMDS
> +	$(MAKE1) -C $(@D) DESTDIR=$(TARGET_DIR) PREFIX=/usr libfdt_install
> +endef
> +
> +define DTC_CLEAN_CMDS
> +	$(MAKE) -C $(@D) libfdt_clean
> +endef
> +
> +$(eval $(generic-package))
Yann E. MORIN Oct. 26, 2012, 5:36 p.m. UTC | #2
Arnout, All,

On Thursday 25 October 2012 Arnout Vandecappelle wrote:
>   The package is called dtc, not libfdt.

Gah... Yes.

> On 24/10/12 23:25, Yann E. MORIN wrote:
> > libfdt allows one to manipulate a Flat Device Tree.
> 
>   Flattened Device Tree

Yep.

[--SNIP--]
> > diff --git a/package/Config.in b/package/Config.in
> > index 1650c71..c9cb3ed 100644
> > --- a/package/Config.in
> > +++ b/package/Config.in
> > @@ -396,6 +396,7 @@ source "package/libaio/Config.in"
> >   source "package/libraw1394/Config.in"
> >   source "package/tslib/Config.in"
> >   source "package/libfreefare/Config.in"
> > +source "package/dtc/Config.in"
> 
>   Alphabetical order.

Yep.

>   Also, even if for now it only installs libftd, I guess it shouldn't be
> a problem to install dtc as well.  In that case it fits more in
> Development tools or Hardware handling.

"Hardware handling" sounds like the proper place, IMHO.

> >   source "package/libftdi/Config.in"
> >   source "package/libhid/Config.in"
> >   source "package/libiqrf/Config.in"
> > diff --git a/package/dtc/Config.in b/package/dtc/Config.in
> > new file mode 100644
> > index 0000000..7b86c60
> > --- /dev/null
> > +++ b/package/dtc/Config.in
> > @@ -0,0 +1,9 @@
> > +config BR2_PACKAGE_DTC
> > +	bool "dtc"
> > +	help
> > +	  dtc is the Device Tree Compiler, to generate Device Trees.
> 
>   dtc generates Flattened Device Trees (i.e. it flattens the device
> tree).

From Documentation/manual.txt:

---8<---
The currently supported Input Formats are:
    - "dtb": "blob" format.  A flattened device-tree block with
        header in one binary blob.
    - "dts": "source" format.  A text file containing a "source"
        for a device-tree.
    - "fs" format.  A representation equivalent to the output of
        /proc/device-tree  where nodes are directories and
        properties are files.

The currently supported Output Formats are:
     - "dtb": "blob" format
     - "dts": "source" format
     - "asm": assembly language file.  A file that can be sourced
        by gas to generate a device-tree "blob".  That file can
        then simply be added to your Makefile.  Additionally, the
        assembly file exports some symbols that can be used.
---8<---

So, dtc does not /generate/ flattened, it uses them as _input_.
What about this formulation (also from the same manual.txt) :

    The Device Tree Compiler, dtc, takes as input a device-tree in
    a given format and outputs a device-tree in another format.


> > +	  Note that only the library is installed for now.
>   Why?  Build failures in the binaries?

Because I do not need it in my use-case, so I did not test it, so
I did not install it.

Also, this package could probably also be a host package. This patch
only adds dtc as a target package.

[--SNIP--]
> > ++++ dtc-e4b497f367a3b2ae99cc52089a14a221b13a76ef/Makefile	2012-10-22 22:03:21.151047833 +0200
> > +@@ -18,7 +18,7 @@
> > + CPPFLAGS = -I libfdt -I .
> > + WARNINGS = -Werror -Wall -Wpointer-arith -Wcast-qual -Wnested-externs \
> > + 	-Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls
> > +-CFLAGS = -g -Os -fPIC -Werror $(WARNINGS)
> > ++CFLAGS = -g -Os -fPIC -Werror $(WARNINGS) $(EXTRA_CFLAGS)
> 
>   Why not CFLAGS += ...?
> 
>   And maybe CPPFLAGS should also be fixed.

I'll look again at this.

[--SNIP--]
> > diff --git a/package/dtc/dtc.mk b/package/dtc/dtc.mk
> > new file mode 100644
> > index 0000000..d53e78a
> > --- /dev/null
> > +++ b/package/dtc/dtc.mk
> > @@ -0,0 +1,36 @@
> > +#############################################################
> > +#
> > +# libcurl

dtc, not libcurl. Sigh...

> > +#
> > +#############################################################
> > +
> > +DTC_VERSION         = e4b497f367a3b2ae99cc52089a14a221b13a76ef
> > +DTC_SITE            = git://git.jdl.com/software/dtc.git
> > +DTC_LICENSE         = GPLv2+/BSD-2c
> > +DTC_LICENSE_FILES   = README.license GPL
> > +# Note: the dual-license only applies to the library.
> > +#       The DT compiler (dtc) is GPLv2+, but we do not install it.
> > +DTC_INSTALL_STAGING = YES
> > +
> > +# Need -fPIC for x86-64
>   ???

Probably left-over from debugging?...

> > +define DTC_BUILD_CMDS
> > +	$(TARGET_CONFIGURE_OPTS) $(MAKE1) -C $(@D)                          \
>   Looking at the Makefile, I don't see why parallel builds would fail...

I will investigate again.

> > +	                                  EXTRA_CFLAGS="$(TARGET_CFLAGS)"   \
> > +	                                  PREFIX=/usr                       \
>   It's nicer to put these two options in DTC_MAKE_OPTS.

OK, I'll see to it.

Thanks!

Regards,
Yann E. MORIN.
Arnout Vandecappelle Oct. 26, 2012, 10:58 p.m. UTC | #3
On 26/10/12 19:36, Yann E. MORIN wrote:
> Arnout, All,
>
> On Thursday 25 October 2012 Arnout Vandecappelle wrote:
[snip]
>>    dtc generates Flattened Device Trees (i.e. it flattens the device
>> tree).
>
>  From Documentation/manual.txt:
>
> ---8<---
> The currently supported Input Formats are:
>      - "dtb": "blob" format.  A flattened device-tree block with
>          header in one binary blob.
>      - "dts": "source" format.  A text file containing a "source"
>          for a device-tree.
>      - "fs" format.  A representation equivalent to the output of
>          /proc/device-tree  where nodes are directories and
>          properties are files.
>
> The currently supported Output Formats are:
>       - "dtb": "blob" format
>       - "dts": "source" format
>       - "asm": assembly language file.  A file that can be sourced
>          by gas to generate a device-tree "blob".  That file can
>          then simply be added to your Makefile.  Additionally, the
>          assembly file exports some symbols that can be used.
> ---8<---
>
> So, dtc does not /generate/ flattened, it uses them as _input_.

  Only the dtb is flattened, the source and fs are still a tree.
But anyway, what I wrote wasn't correct either.

> What about this formulation (also from the same manual.txt) :
>
>      The Device Tree Compiler, dtc, takes as input a device-tree in
>      a given format and outputs a device-tree in another format.

  Much better :-)


>>> +	  Note that only the library is installed for now.
>>    Why?  Build failures in the binaries?
>
> Because I do not need it in my use-case, so I did not test it, so
> I did not install it.

  Well, it just seems silly to do extra effort to remove something from the
build, unless there's a good reason for it. So unless there's a build
failure, I would include the dtc as well even if you haven't tested it
on the target.


> Also, this package could probably also be a host package. This patch
> only adds dtc as a target package.

  For the host package, it's probably dtc that you need anyway...

>
> [--SNIP--]
>>> ++++ dtc-e4b497f367a3b2ae99cc52089a14a221b13a76ef/Makefile	2012-10-22 22:03:21.151047833 +0200
>>> +@@ -18,7 +18,7 @@
>>> + CPPFLAGS = -I libfdt -I .
>>> + WARNINGS = -Werror -Wall -Wpointer-arith -Wcast-qual -Wnested-externs \
>>> + 	-Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls
>>> +-CFLAGS = -g -Os -fPIC -Werror $(WARNINGS)
>>> ++CFLAGS = -g -Os -fPIC -Werror $(WARNINGS) $(EXTRA_CFLAGS)
>>
>>    Why not CFLAGS += ...?
>>
>>    And maybe CPPFLAGS should also be fixed.
>
> I'll look again at this.
>
> [--SNIP--]
>>> diff --git a/package/dtc/dtc.mk b/package/dtc/dtc.mk
>>> new file mode 100644
>>> index 0000000..d53e78a
>>> --- /dev/null
>>> +++ b/package/dtc/dtc.mk
>>> @@ -0,0 +1,36 @@
>>> +#############################################################
>>> +#
>>> +# libcurl
>
> dtc, not libcurl. Sigh...
>
>>> +#
>>> +#############################################################
>>> +
>>> +DTC_VERSION         = e4b497f367a3b2ae99cc52089a14a221b13a76ef
>>> +DTC_SITE            = git://git.jdl.com/software/dtc.git
>>> +DTC_LICENSE         = GPLv2+/BSD-2c
>>> +DTC_LICENSE_FILES   = README.license GPL
>>> +# Note: the dual-license only applies to the library.
>>> +#       The DT compiler (dtc) is GPLv2+, but we do not install it.
>>> +DTC_INSTALL_STAGING = YES
>>> +
>>> +# Need -fPIC for x86-64
>>    ???
>
> Probably left-over from debugging?...

  Now I see it: the -fPIC is in the upstream Makefile and is required
(unlike the -g -Os -Werror), so the CFLAGS shouldn't just be overridden.



  Regards,
  Arnout
[snip]
diff mbox

Patch

diff --git a/package/Config.in b/package/Config.in
index 1650c71..c9cb3ed 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -396,6 +396,7 @@  source "package/libaio/Config.in"
 source "package/libraw1394/Config.in"
 source "package/tslib/Config.in"
 source "package/libfreefare/Config.in"
+source "package/dtc/Config.in"
 source "package/libftdi/Config.in"
 source "package/libhid/Config.in"
 source "package/libiqrf/Config.in"
diff --git a/package/dtc/Config.in b/package/dtc/Config.in
new file mode 100644
index 0000000..7b86c60
--- /dev/null
+++ b/package/dtc/Config.in
@@ -0,0 +1,9 @@ 
+config BR2_PACKAGE_DTC
+	bool "dtc"
+	help
+	  dtc is the Device Tree Compiler, to generate Device Trees.
+	  libfdt if a library to manipulate Flat Device Trees.
+	  
+	  Note that only the library is installed for now.
+	  
+	  http://git.jdl.com/gitweb/?p=dtc.git  (no home page)
diff --git a/package/dtc/dtc-extra_cflags.patch b/package/dtc/dtc-extra_cflags.patch
new file mode 100644
index 0000000..03225e7
--- /dev/null
+++ b/package/dtc/dtc-extra_cflags.patch
@@ -0,0 +1,12 @@ 
+diff -durN dtc-e4b497f367a3b2ae99cc52089a14a221b13a76ef.orig/Makefile dtc-e4b497f367a3b2ae99cc52089a14a221b13a76ef/Makefile
+--- dtc-e4b497f367a3b2ae99cc52089a14a221b13a76ef.orig/Makefile	2012-10-22 22:02:47.541240846 +0200
++++ dtc-e4b497f367a3b2ae99cc52089a14a221b13a76ef/Makefile	2012-10-22 22:03:21.151047833 +0200
+@@ -18,7 +18,7 @@
+ CPPFLAGS = -I libfdt -I .
+ WARNINGS = -Werror -Wall -Wpointer-arith -Wcast-qual -Wnested-externs \
+ 	-Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls
+-CFLAGS = -g -Os -fPIC -Werror $(WARNINGS)
++CFLAGS = -g -Os -fPIC -Werror $(WARNINGS) $(EXTRA_CFLAGS)
+ 
+ BISON = bison
+ LEX = flex
diff --git a/package/dtc/dtc-separate-lib-install.patch b/package/dtc/dtc-separate-lib-install.patch
new file mode 100644
index 0000000..c86d587
--- /dev/null
+++ b/package/dtc/dtc-separate-lib-install.patch
@@ -0,0 +1,28 @@ 
+Makefile: add a rule to only install libfdt
+
+Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
+
+---
+Patch not sent upstream.
+
+It's really specific to buildroot, and is probably not
+good (aka generic) enough to be pushed upstream.
+
+diff --git a/Makefile b/Makefile
+index 1169e6c..39e7190 100644
+--- a/Makefile
++++ b/Makefile
+@@ -160,10 +160,12 @@ endif
+ # intermediate target and building them again "for real"
+ .SECONDARY: $(DTC_GEN_SRCS) $(CONVERT_GEN_SRCS)
+ 
+-install: all $(SCRIPTS)
++install: all $(SCRIPTS) libfdt_install
+ 	@$(VECHO) INSTALL
+ 	$(INSTALL) -d $(DESTDIR)$(BINDIR)
+ 	$(INSTALL) $(BIN) $(SCRIPTS) $(DESTDIR)$(BINDIR)
++
++libfdt_install: libfdt
+ 	$(INSTALL) -d $(DESTDIR)$(LIBDIR)
+ 	$(INSTALL) $(LIBFDT_lib) $(DESTDIR)$(LIBDIR)
+ 	ln -sf $(notdir $(LIBFDT_lib)) $(DESTDIR)$(LIBDIR)/$(LIBFDT_soname)
diff --git a/package/dtc/dtc.mk b/package/dtc/dtc.mk
new file mode 100644
index 0000000..d53e78a
--- /dev/null
+++ b/package/dtc/dtc.mk
@@ -0,0 +1,36 @@ 
+#############################################################
+#
+# libcurl
+#
+#############################################################
+
+DTC_VERSION         = e4b497f367a3b2ae99cc52089a14a221b13a76ef
+DTC_SITE            = git://git.jdl.com/software/dtc.git
+DTC_LICENSE         = GPLv2+/BSD-2c
+DTC_LICENSE_FILES   = README.license GPL
+# Note: the dual-license only applies to the library.
+#       The DT compiler (dtc) is GPLv2+, but we do not install it.
+DTC_INSTALL_STAGING = YES
+
+# Need -fPIC for x86-64
+define DTC_BUILD_CMDS
+	$(TARGET_CONFIGURE_OPTS) $(MAKE1) -C $(@D)                          \
+	                                  EXTRA_CFLAGS="$(TARGET_CFLAGS)"   \
+	                                  PREFIX=/usr                       \
+	                                  libfdt
+endef
+
+# libfdt_install is our own install rule added by our patch
+define DTC_INSTALL_STAGING_CMDS
+	$(MAKE1) -C $(@D) DESTDIR=$(STAGING_DIR) PREFIX=/usr libfdt_install
+endef
+
+define DTC_INSTALL_TARGET_CMDS
+	$(MAKE1) -C $(@D) DESTDIR=$(TARGET_DIR) PREFIX=/usr libfdt_install
+endef
+
+define DTC_CLEAN_CMDS
+	$(MAKE) -C $(@D) libfdt_clean
+endef
+
+$(eval $(generic-package))