diff mbox

[v4] openzwave: new package

Message ID 25411_1464600165_574C0665_25411_219_1_5b748601-166d-4115-9569-971779a5f3f2@OPEXCLILM5F.corporate.adroot.infra.ftgroup
State Accepted
Commit 0f8fcca593d7c0b4d2b9c39b96887819682d7dc8
Headers show

Commit Message

fabrice.fontaine@orange.com May 30, 2016, 9:22 a.m. UTC
Free software library that interfaces with selected Z-Wave PC
controllers, allowing anyone to create applications that manipulate and
respond to devices on a Z-Wave network, without requiring in-depth
knowledge of the Z-Wave protocol

Signed-off-by: Fabrice Fontaine <fabrice.fontaine@orange.com>
---
Changes v3 -> v4 (after review of Peter Korsgaard):
 - Add a patch to fix git revision

Changes v2 -> v3 (after reviews of Thomas Petazzoni and
Julien Boibessot):
 - Remove empty line in Config.in
 - Add hash file with locally computed sha256 of openzwave-v1.4.tar.gz
 - Format correctly the wcsdup patch (git patch with signed-off-by
   description)
 - Remove unneeded comments before OPENZWAVE_LICENSE
 - Add TARGET_MAKE_ENV in openzwave.mk
 - Use instlibdir variable to install library in /usr/lib instead of
   /usr/lib64
 - Use sysconfdir variable to install configuration files in
   /etc/openzwave instead of /usr/etc/openzwave
 - Remove unneeded ozw_config binary from target directory

Changes v1 -> v2:
 - Fix indentation in Config.in
 - Add dependency on BR2_USE_WCHAR (from patch of Joris Lijssens)
 - Remove TARGET_CONFIGURE_ENV from openzwave.mk
 - Use CROSS_COMPILE variable to build (from patch of Joris Lijssens)
 - Add a patch to fix wcsdup implicit declaration (from review of Julien
   Boibessot)

 package/Config.in                                  |  1 +
 ...ix-warning-on-wcsdup-implicit-declaration.patch | 29 ++++++++++++
 .../0002-Ensure-correct-git-repository-path.patch  | 29 ++++++++++++
 package/openzwave/Config.in                        | 17 +++++++
 package/openzwave/openzwave.hash                   |  2 +
 package/openzwave/openzwave.mk                     | 52 ++++++++++++++++++++++
 6 files changed, 130 insertions(+)
 create mode 100644 package/openzwave/0001-Fix-warning-on-wcsdup-implicit-declaration.patch
 create mode 100644 package/openzwave/0002-Ensure-correct-git-repository-path.patch
 create mode 100644 package/openzwave/Config.in
 create mode 100644 package/openzwave/openzwave.hash
 create mode 100644 package/openzwave/openzwave.mk

Comments

Peter Korsgaard May 30, 2016, 3:22 p.m. UTC | #1
>>>>>   <fabrice.fontaine@orange.com> writes:

 > Free software library that interfaces with selected Z-Wave PC
 > controllers, allowing anyone to create applications that manipulate and
 > respond to devices on a Z-Wave network, without requiring in-depth
 > knowledge of the Z-Wave protocol

 > Signed-off-by: Fabrice Fontaine <fabrice.fontaine@orange.com>
 > ---
 > Changes v3 -> v4 (after review of Peter Korsgaard):
 >  - Add a patch to fix git revision

 > +++ b/package/openzwave/openzwave.mk
 > @@ -0,0 +1,52 @@
 > +################################################################################
 > +#
 > +# openzwave
 > +#
 > +################################################################################
 > +
 > +OPENZWAVE_VERSION = v1.4
 > +OPENZWAVE_SITE = $(call github,OpenZWave,open-zwave,$(OPENZWAVE_VERSION))
 > +OPENZWAVE_LICENSE = LGPLv3+, GPLv3 (examples), Apache-2.0 (sh2ju.sh)
 > +OPENZWAVE_LICENSE_FILES = license/license.txt license/lgpl.txt \
 > +	license/gpl.txt license/Apache-License-2.0.txt
 > +
 > +OPENZWAVE_DEPENDENCIES = host-pkgconf udev
 > +OPENZWAVE_INSTALL_STAGING = YES
 > +
 > +define OPENZWAVE_BUILD_CMDS
 > +	$(TARGET_MAKE_ENV) $(MAKE) CROSS_COMPILE="$(TARGET_CROSS)" -C $(@D)
 > +endef
 > +
 > +# Set instlibdir to install libopenzwave.so* in the correct directory
 > +# otherwise openzwave will check that /lib64 exists (on the host) to
 > +# know if the library should be installed in $(PREFIX)/lib or $(PREFIX)/lib64.
 > +# Set pkgconfigdir to /lib/pkgconfig to install libopenzwave.pc in the
 > +# correct directory otherwise openzwave will call
 > +# "pkg-config --variable pc_path pkg-config" which returns an incorrect value.
 > +# Set sysconfdir to /etc/openzwave to install openzwave configuration files in
 > +# the correct directory otherwise openzwave will install configuration files in
 > +# $(PREFIX)/etc/openzwave.
 > +define OPENZWAVE_INSTALL_STAGING_CMDS
 > +	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
 > +		PREFIX=/usr DESTDIR=$(STAGING_DIR) \
 > +		instlibdir=/usr/lib \
 > +		pkgconfigdir=/usr/lib/pkgconfig \
 > +		sysconfdir=/etc/openzwave \
 > +		install

This is a bit of a mess. At least sysconfdir is also used at build time
for the default configuration directory, but it is hardcoded as
$PREFIX/etc/openzwave, and other places in the source code hardcodes
/etc/openzwave:

strings libopenzwave.so.1.4 | grep /etc
/etc/openzwave/
Cannot find a path to the configuration files at %s, Using /etc/openzwave/ instead...
/usr/local/etc/openzwave/

We also need to pass DOXYGEN= to get it to not spend time on building
documentation during the installation step. As there's several variables
and we need to pass (a subset of) them to build / staging-install /
target-install I've added them to an OPENZWAVE_MAKE_OPTS variable and
used that everywhere.

Committed to next with that fixed, thanks.
diff mbox

Patch

diff --git a/package/Config.in b/package/Config.in
index 9d668bf..10d9a6e 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1177,6 +1177,7 @@  menu "Networking"
 	source "package/omniorb/Config.in"
 	source "package/openldap/Config.in"
 	source "package/openpgm/Config.in"
+	source "package/openzwave/Config.in"
 	source "package/ortp/Config.in"
 	source "package/qdecoder/Config.in"
 	source "package/qpid-proton/Config.in"
diff --git a/package/openzwave/0001-Fix-warning-on-wcsdup-implicit-declaration.patch b/package/openzwave/0001-Fix-warning-on-wcsdup-implicit-declaration.patch
new file mode 100644
index 0000000..1fe30e4
--- /dev/null
+++ b/package/openzwave/0001-Fix-warning-on-wcsdup-implicit-declaration.patch
@@ -0,0 +1,29 @@ 
+From 0878d933223158343af3fe13e03bcd128e8b4cbc Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <fabrice.fontaine@orange.com>
+Date: Fri, 22 Apr 2016 17:06:27 +0200
+Subject: [PATCH 1/1] Fix warning on wcsdup implicit declaration
+
+Define __GNU_SOURCE in cpp/hidapi/linux/hid.c (like already done in
+cpp/hidapi/libusb/hid.c) to fix implicit declaration of wcsdup function
+
+Signed-off-by: Fabrice Fontaine <fabrice.fontaine@orange.com>
+---
+ cpp/hidapi/linux/hid.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/cpp/hidapi/linux/hid.c b/cpp/hidapi/linux/hid.c
+index dbf9b9b..c3eb22b 100644
+--- a/cpp/hidapi/linux/hid.c
++++ b/cpp/hidapi/linux/hid.c
+@@ -21,6 +21,8 @@
+         http://github.com/signal11/hidapi .
+ ********************************************************/
+ 
++#define _GNU_SOURCE /* needed for wcsdup() before glibc 2.10 */
++
+ /* C */
+ #include <stdio.h>
+ #include <string.h>
+-- 
+1.9.1
+
diff --git a/package/openzwave/0002-Ensure-correct-git-repository-path.patch b/package/openzwave/0002-Ensure-correct-git-repository-path.patch
new file mode 100644
index 0000000..6c40ec9
--- /dev/null
+++ b/package/openzwave/0002-Ensure-correct-git-repository-path.patch
@@ -0,0 +1,29 @@ 
+From 89cdc83307f61422db21cc7965ea294862c128bf Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <fabrice.fontaine@orange.com>
+Date: Mon, 30 May 2016 10:37:42 +0200
+Subject: [PATCH 2/2] Ensure correct git repository path
+
+Add "--git-dir ./.git" to ensure the correct git repository path is used (this
+fix a bug when trying to add openzwave to buildroot build system)
+
+Signed-off-by: Fabrice Fontaine <fabrice.fontaine@orange.com>
+---
+ cpp/build/support.mk | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/cpp/build/support.mk b/cpp/build/support.mk
+index 3f74c7e..f529b25 100644
+--- a/cpp/build/support.mk
++++ b/cpp/build/support.mk
+@@ -29,7 +29,7 @@ GIT		:= $(shell which git)
+ ifeq ($(GIT),)
+ VERSION_REV ?= 0
+ else
+-GITVERSION	:= $(shell $(GIT) describe --long --tags --dirty 2>/dev/null | sed s/^v//)
++GITVERSION	:= $(shell $(GIT) --git-dir ./.git describe --long --tags --dirty 2>/dev/null | sed s/^v//)
+ ifeq ($(GITVERSION),)
+ GITVERSION	:= $(VERSION_MAJ).$(VERSION_MIN).-1
+ VERSION_REV	:= 0
+-- 
+2.7.4
+
diff --git a/package/openzwave/Config.in b/package/openzwave/Config.in
new file mode 100644
index 0000000..190b88b
--- /dev/null
+++ b/package/openzwave/Config.in
@@ -0,0 +1,17 @@ 
+config BR2_PACKAGE_OPENZWAVE
+	bool "openzwave"
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on BR2_INSTALL_LIBSTDCPP
+	depends on BR2_PACKAGE_HAS_UDEV
+	depends on BR2_USE_WCHAR
+	help
+	  Free software library that interfaces with selected Z-Wave PC
+	  controllers, allowing anyone to create applications that manipulate
+	  and respond to devices on a Z-Wave network, without requiring
+	  in-depth knowledge of the Z-Wave protocol
+
+	  http://www.openzwave.net
+
+comment "openzwave needs udev and a toolchain w/ C++, threads, wchar"
+	depends on !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_HAS_THREADS || \
+		!BR2_PACKAGE_HAS_UDEV || !BR2_USE_WCHAR
diff --git a/package/openzwave/openzwave.hash b/package/openzwave/openzwave.hash
new file mode 100644
index 0000000..bab940e
--- /dev/null
+++ b/package/openzwave/openzwave.hash
@@ -0,0 +1,2 @@ 
+# Locally computed:
+sha256	ca122365f6237dc245be0129eb460e78126976b9c7bd06487795d3acfc9f2a5f	openzwave-v1.4.tar.gz
diff --git a/package/openzwave/openzwave.mk b/package/openzwave/openzwave.mk
new file mode 100644
index 0000000..eab9943
--- /dev/null
+++ b/package/openzwave/openzwave.mk
@@ -0,0 +1,52 @@ 
+################################################################################
+#
+# openzwave
+#
+################################################################################
+
+OPENZWAVE_VERSION = v1.4
+OPENZWAVE_SITE = $(call github,OpenZWave,open-zwave,$(OPENZWAVE_VERSION))
+OPENZWAVE_LICENSE = LGPLv3+, GPLv3 (examples), Apache-2.0 (sh2ju.sh)
+OPENZWAVE_LICENSE_FILES = license/license.txt license/lgpl.txt \
+	license/gpl.txt license/Apache-License-2.0.txt
+
+OPENZWAVE_DEPENDENCIES = host-pkgconf udev
+OPENZWAVE_INSTALL_STAGING = YES
+
+define OPENZWAVE_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) CROSS_COMPILE="$(TARGET_CROSS)" -C $(@D)
+endef
+
+# Set instlibdir to install libopenzwave.so* in the correct directory
+# otherwise openzwave will check that /lib64 exists (on the host) to
+# know if the library should be installed in $(PREFIX)/lib or $(PREFIX)/lib64.
+# Set pkgconfigdir to /lib/pkgconfig to install libopenzwave.pc in the
+# correct directory otherwise openzwave will call
+# "pkg-config --variable pc_path pkg-config" which returns an incorrect value.
+# Set sysconfdir to /etc/openzwave to install openzwave configuration files in
+# the correct directory otherwise openzwave will install configuration files in
+# $(PREFIX)/etc/openzwave.
+define OPENZWAVE_INSTALL_STAGING_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
+		PREFIX=/usr DESTDIR=$(STAGING_DIR) \
+		instlibdir=/usr/lib \
+		pkgconfigdir=/usr/lib/pkgconfig \
+		sysconfdir=/etc/openzwave \
+		install
+endef
+
+# Apply the same tricks (even if the trick on pkgconfigdir is not needed as
+# libopenzwave.pc is not useful in target directory).
+# Delete unneeded ozw_config binary from target directory as this is an utility
+# application used to get the openzwave build configuration.
+define OPENZWAVE_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
+		PREFIX=/usr DESTDIR=$(TARGET_DIR) \
+		instlibdir=/usr/lib \
+		pkgconfigdir=/usr/lib/pkgconfig \
+		sysconfdir=/etc/openzwave \
+		install
+	rm -f $(TARGET_DIR)/usr/bin/ozw_config
+endef
+
+$(eval $(generic-package))