diff options
author | Tony Theodore <tonyt@logyst.com> | 2017-11-18 07:29:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-18 07:29:46 (GMT) |
commit | f515c687c82c2b00cb2732ceb30e9ae7a14249b3 (patch) | |
tree | b2feed2a45af67475edd4e9d8c38d9e14d90b21e | |
parent | ee36fd05505e3eb96b8119d7d59a118beb3f282f (diff) | |
parent | 621bd95acc69de1f1b6f997bd3931d11c9d7f94e (diff) | |
download | mxe-f515c687c82c2b00cb2732ceb30e9ae7a14249b3.zip mxe-f515c687c82c2b00cb2732ceb30e9ae7a14249b3.tar.gz mxe-f515c687c82c2b00cb2732ceb30e9ae7a14249b3.tar.bz2 |
Merge pull request #1983 from tonytheodore/libsigrok
add libsigrok and libserialport
-rw-r--r-- | src/libserialport-test.c | 23 | ||||
-rw-r--r-- | src/libserialport.mk | 30 | ||||
-rw-r--r-- | src/libsigrok-test.c | 26 | ||||
-rw-r--r-- | src/libsigrok.mk | 45 |
4 files changed, 124 insertions, 0 deletions
diff --git a/src/libserialport-test.c b/src/libserialport-test.c new file mode 100644 index 0000000..a4bbd7e --- /dev/null +++ b/src/libserialport-test.c @@ -0,0 +1,23 @@ +/* + * This file is part of MXE. See LICENSE.md for licensing information. + */ + +#include <stdio.h> +#include <libserialport.h> + +int main(int argc, char *argv[]) +{ + int i; + struct sp_port **ports; + (void)argc; + (void)argv; + + sp_list_ports(&ports); + + for (i = 0; ports[i]; i++) + printf("Found port: '%s'.\n", sp_get_port_name(ports[i])); + + sp_free_port_list(ports); + + return 0; +} diff --git a/src/libserialport.mk b/src/libserialport.mk new file mode 100644 index 0000000..c36af4e --- /dev/null +++ b/src/libserialport.mk @@ -0,0 +1,30 @@ +# This file is part of MXE. See LICENSE.md for licensing information. + +PKG := libserialport +$(PKG)_WEBSITE := https://sigrok.org/wiki/Libserialport +$(PKG)_DESCR := libserialport +$(PKG)_IGNORE := +$(PKG)_VERSION := 0.1.1 +$(PKG)_CHECKSUM := 4a2af9d9c3ff488e92fb75b4ba38b35bcf9b8a66df04773eba2a7bbf1fa7529d +$(PKG)_SUBDIR := libserialport-$($(PKG)_VERSION) +$(PKG)_FILE := libserialport-$($(PKG)_VERSION).tar.gz +$(PKG)_URL := https://sigrok.org/download/source/libserialport/libserialport-$($(PKG)_VERSION).tar.gz +$(PKG)_DEPS := gcc + +define $(PKG)_UPDATE + $(call GET_LATEST_VERSION, https://sigrok.org/download/source/libserialport) +endef + +define $(PKG)_BUILD + # build and install the library + cd '$(BUILD_DIR)' && $(SOURCE_DIR)/configure \ + $(MXE_CONFIGURE_OPTS) + $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' + $(MAKE) -C '$(BUILD_DIR)' -j 1 install + + # compile test + '$(TARGET)-gcc' \ + -W -Wall -Werror -ansi -pedantic \ + '$(TEST_FILE)' -o '$(PREFIX)/$(TARGET)/bin/test-$(PKG).exe' \ + `'$(TARGET)-pkg-config' $(PKG) --cflags --libs` +endef diff --git a/src/libsigrok-test.c b/src/libsigrok-test.c new file mode 100644 index 0000000..cfb23c6 --- /dev/null +++ b/src/libsigrok-test.c @@ -0,0 +1,26 @@ +/* + * This file is part of MXE. See LICENSE.md for licensing information. + */ + +#include <stdio.h> +#include <libsigrok/libsigrok.h> + +int main(int argc, char **argv) +{ + int ret; + struct sr_context *sr_ctx; + (void)argc; + (void)argv; + + if ((ret = sr_init(&sr_ctx)) != SR_OK) { + printf("Error initializing libsigrok (%s): %s.\n", + sr_strerror_name(ret), sr_strerror(ret)); + return 1; + } + if ((ret = sr_exit(sr_ctx)) != SR_OK) { + printf("Error shutting down libsigrok (%s): %s.\n", + sr_strerror_name(ret), sr_strerror(ret)); + return 1; + } + return 0; +} diff --git a/src/libsigrok.mk b/src/libsigrok.mk new file mode 100644 index 0000000..5fb8a52 --- /dev/null +++ b/src/libsigrok.mk @@ -0,0 +1,45 @@ +# This file is part of MXE. See LICENSE.md for licensing information. + +PKG := libsigrok +$(PKG)_WEBSITE := https://www.sigrok.org/wiki/Libsigrok +$(PKG)_DESCR := libsigrok +$(PKG)_IGNORE := +$(PKG)_VERSION := 0.5.0 +$(PKG)_CHECKSUM := 4c8c86779b880a5c419f6c77a08b1147021e5a19fa83b0f3b19da27463c9f3a4 +$(PKG)_SUBDIR := libsigrok-$($(PKG)_VERSION) +$(PKG)_FILE := libsigrok-$($(PKG)_VERSION).tar.gz +$(PKG)_URL := https://sigrok.org/download/source/libsigrok/libsigrok-$($(PKG)_VERSION).tar.gz +$(PKG)_DEPS := gcc glibmm libftdi1 libieee1284 libserialport libzip + +define $(PKG)_UPDATE + $(call GET_LATEST_VERSION, https://sigrok.org/download/source/libsigrok) +endef + +# Windows builds require the event-abstraction branch of libusb +# github.com/dickens/libusb + +define $(PKG)_BUILD + # build and install the library + # doxygen is required to build c++ bindings + cd '$(BUILD_DIR)' && $(SOURCE_DIR)/configure \ + $(MXE_CONFIGURE_OPTS) \ + ac_cv_prog_HAVE_DOXYGEN=$(shell which doxygen >/dev/null 2>&1 && echo yes) \ + --enable-cxx \ + --disable-python \ + --disable-ruby \ + --disable-java \ + --with-libserialport \ + --with-libftdi \ + --without-libusb \ + --without-librevisa \ + --without-libgpib \ + --with-libieee1284 + $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' + $(MAKE) -C '$(BUILD_DIR)' -j 1 install + + # compile test + '$(TARGET)-gcc' \ + -W -Wall -Werror -ansi -pedantic \ + '$(TEST_FILE)' -o '$(PREFIX)/$(TARGET)/bin/test-$(PKG).exe' \ + `'$(TARGET)-pkg-config' $(PKG) --cflags --libs` +endef |