Skip to contentSkip to conversation

libusb: add an option to compile examples

PATCH New Gaël PORTAY 2 participants 5 messages Jun 10, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libusb: add an option to compile examples

---
 package/libusb/Config.in |  7 +++++++
 package/libusb/libusb.mk | 11 +++++++++++
 2 files changed, 18 insertions(+)
package/libusb/Config.in +7 -0
index 5238588aa8..d31a717fdf 100644
@@ -6,5 +6,12 @@ config BR2_PACKAGE_LIBUSB
 
 	  http://libusb.info/
 
+if BR2_PACKAGE_LIBUSB
+
+config BR2_PACKAGE_LIBUSB_EXAMPLES
+	bool "build libusb examples"
+
+endif
+
 comment "libusb needs a toolchain w/ threads"
 	depends on !BR2_TOOLCHAIN_HAS_THREADS
package/libusb/libusb.mk +11 -0
index aee3622f8d..89ec91bb42 100644
@@ -25,5 +25,16 @@ else
 LIBUSB_CONF_OPTS += --disable-udev
 endif
 
+ifeq ($(BR2_PACKAGE_LIBUSB_EXAMPLES),y)
+LIBUSB_CONF_OPTS += --enable-examples-build
+define LIBUSB_INSTALL_TARGET_EXAMPLES
+	for example in listdevs xusb fxload hotplugtest testlibusb dpfp dpfp_threaded sam3u_benchmark ; do \
+		[ -x $(@D)/examples/$${example} ] || continue; \
+		cp -dpfr $(@D)/examples/$${example} $(TARGET_DIR)/usr/bin; \
+	done
+endef
+LIBUSB_POST_INSTALL_TARGET_HOOKS += LIBUSB_INSTALL_TARGET_EXAMPLES
+endif
+
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 libusb: add an option to compile examples

Hi Ga?l,

Quoted 28 lines · Ga?l PORTAY
---
 package/libusb/Config.in |  7 +++++++
 package/libusb/libusb.mk | 11 +++++++++++
 2 files changed, 18 insertions(+)
package/libusb/Config.in +7 -0
index 5238588aa8..d31a717fdf 100644
@@ -6,5 +6,12 @@ config BR2_PACKAGE_LIBUSB
 
 	  http://libusb.info/
 
+if BR2_PACKAGE_LIBUSB
+
+config BR2_PACKAGE_LIBUSB_EXAMPLES
+	bool "build libusb examples"
+
+endif
+
 comment "libusb needs a toolchain w/ threads"
 	depends on !BR2_TOOLCHAIN_HAS_THREADS
package/libusb/libusb.mk +0 -0
index aee3622f8d..89ec91bb42 100644

package/libusb/libusb.mk else · line 32

Quoted 8 lines
package/libusb/libusb.mk +5 -0
@@ -25,5 +25,16 @@ else
 LIBUSB_CONF_OPTS += --disable-udev
 endif
 
+ifeq ($(BR2_PACKAGE_LIBUSB_EXAMPLES),y)
+LIBUSB_CONF_OPTS += --enable-examples-build
+define LIBUSB_INSTALL_TARGET_EXAMPLES
+	for example in listdevs xusb fxload hotplugtest testlibusb dpfp dpfp_threaded sam3u_benchmark ; do \
+		[ -x $(@D)/examples/$${example} ] || continue; \

Why is this file presence check needed?

package/libusb/libusb.mk else · line 40

Quoted 8 lines
package/libusb/libusb.mk +6 -0
+		cp -dpfr $(@D)/examples/$${example} $(TARGET_DIR)/usr/bin; \
+	done
+endef
+LIBUSB_POST_INSTALL_TARGET_HOOKS += LIBUSB_INSTALL_TARGET_EXAMPLES
+endif
+
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))

baruch

Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
#2 lore raw

PATCH 1/1 libusb: add an option to compile examples

Hi Baruch,

Quoted 8 lines · Baruch Siach
Quoted 8 lines
package/libusb/libusb.mk +0 -0
index aee3622f8d..89ec91bb42 100644
@@ -25,5 +25,16 @@ else
 LIBUSB_CONF_OPTS += --disable-udev
 endif
 
Quoted 8 lines

package/libusb/libusb.mk else · line 32

Quoted 5 lines
package/libusb/libusb.mk +5 -0
+ifeq ($(BR2_PACKAGE_LIBUSB_EXAMPLES),y)
+LIBUSB_CONF_OPTS += --enable-examples-build
+define LIBUSB_INSTALL_TARGET_EXAMPLES
+	for example in listdevs xusb fxload hotplugtest testlibusb dpfp dpfp_threaded sam3u_benchmark ; do \
+		[ -x $(@D)/examples/$${example} ] || continue; \

Why is this file presence check needed?

Because, some of the examples are compiled under HAVE_xxx condition.

See the extract of examples/Makefile.am below.

	noinst_PROGRAMS = listdevs xusb fxload hotplugtest testlibusb
	
	if HAVE_SIGACTION
	noinst_PROGRAMS += dpfp
	
	if THREADS_POSIX
	dpfp_threaded_CFLAGS = $(AM_CFLAGS)
	noinst_PROGRAMS += dpfp_threaded
	endif
	
	sam3u_benchmark_SOURCES = sam3u_benchmark.c
	noinst_PROGRAMS += sam3u_benchmark
	endif
Quoted 15 lines

package/libusb/libusb.mk else · line 40

Quoted 8 lines
package/libusb/libusb.mk +6 -0
+		cp -dpfr $(@D)/examples/$${example} $(TARGET_DIR)/usr/bin; \
+	done
+endef
+LIBUSB_POST_INSTALL_TARGET_HOOKS += LIBUSB_INSTALL_TARGET_EXAMPLES
+endif
+
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))

baruch

Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -

Regards,
Gael

#3 lore raw

PATCH 1/1 libusb: add an option to compile examples

Hi Ga?l,

Quoted 21 lines · Ga?l PORTAY
Quoted 8 lines · Baruch Siach
Quoted 8 lines
package/libusb/libusb.mk +0 -0
index aee3622f8d..89ec91bb42 100644
@@ -25,5 +25,16 @@ else
 LIBUSB_CONF_OPTS += --disable-udev
 endif
 
Quoted 7 lines

package/libusb/libusb.mk else · line 32

Quoted 5 lines
package/libusb/libusb.mk +5 -0
+ifeq ($(BR2_PACKAGE_LIBUSB_EXAMPLES),y)
+LIBUSB_CONF_OPTS += --enable-examples-build
+define LIBUSB_INSTALL_TARGET_EXAMPLES
+	for example in listdevs xusb fxload hotplugtest testlibusb dpfp dpfp_threaded sam3u_benchmark ; do \
+		[ -x $(@D)/examples/$${example} ] || continue; \

Why is this file presence check needed?

Because, some of the examples are compiled under HAVE_xxx condition.

See the extract of examples/Makefile.am below.

Quoted 13 lines
	noinst_PROGRAMS = listdevs xusb fxload hotplugtest testlibusb
	
	if HAVE_SIGACTION
	noinst_PROGRAMS += dpfp
	
	if THREADS_POSIX
	dpfp_threaded_CFLAGS = $(AM_CFLAGS)
	noinst_PROGRAMS += dpfp_threaded
	endif
	
	sam3u_benchmark_SOURCES = sam3u_benchmark.c
	noinst_PROGRAMS += sam3u_benchmark
	endif

All Buildroot libcs support sigaction. Also, libusb depends on threads support, so THREADS_POSIX is always true in Buildroot.

So I think this check is not needed.

baruch

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
package/libusb/libusb.mk +6 -0
+		cp -dpfr $(@D)/examples/$${example} $(TARGET_DIR)/usr/bin; \
+	done
+endef
+LIBUSB_POST_INSTALL_TARGET_HOOKS += LIBUSB_INSTALL_TARGET_EXAMPLES
+endif
+
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))
Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
#4 lore raw

PATCH 1/1 libusb: add an option to compile examples

Baruch,

Quoted 1 line · Baruch Siach

(...)

Hi Ga?l,

Quoted 33 lines · Ga?l PORTAY
Quoted 31 lines · Baruch Siach
Quoted 8 lines
Quoted 8 lines
package/libusb/libusb.mk +0 -0
index aee3622f8d..89ec91bb42 100644
@@ -25,5 +25,16 @@ else
 LIBUSB_CONF_OPTS += --disable-udev
 endif
 
Quoted 7 lines

package/libusb/libusb.mk else · line 32

Quoted 5 lines
package/libusb/libusb.mk +5 -0
+ifeq ($(BR2_PACKAGE_LIBUSB_EXAMPLES),y)
+LIBUSB_CONF_OPTS += --enable-examples-build
+define LIBUSB_INSTALL_TARGET_EXAMPLES
+	for example in listdevs xusb fxload hotplugtest testlibusb dpfp dpfp_threaded sam3u_benchmark ; do \
+		[ -x $(@D)/examples/$${example} ] || continue; \

Why is this file presence check needed?

Because, some of the examples are compiled under HAVE_xxx condition.

See the extract of examples/Makefile.am below.

	noinst_PROGRAMS = listdevs xusb fxload hotplugtest testlibusb
	
	if HAVE_SIGACTION
	noinst_PROGRAMS += dpfp
	
	if THREADS_POSIX
	dpfp_threaded_CFLAGS = $(AM_CFLAGS)
	noinst_PROGRAMS += dpfp_threaded
	endif
Quoted 9 lines
Quoted 3 lines
	sam3u_benchmark_SOURCES = sam3u_benchmark.c
	noinst_PROGRAMS += sam3u_benchmark
	endif

All Buildroot libcs support sigaction. Also, libusb depends on threads support, so THREADS_POSIX is always true in Buildroot.

So I think this check is not needed.

Okay, I will send a v2 without this check.