From f2611e023717f7795e170405d63c4ca0ba925a13 Mon Sep 17 00:00:00 2001 From: CodeforEvolution Date: Wed, 29 Jan 2020 21:16:07 +0200 Subject: [PATCH] Changes to Build System for Haiku Co-authored-by: @CodeforEvolution Co-authored-by: Luca Weiss Co-authored-by: Begasus Co-authored-by: Panagiotis Vasilopoulos --- Makefile.am | 4 ++++ configure.ac | 14 ++++++++++++++ libusb/Makefile-manual | 4 ++++ libusb/Makefile.am | 7 +++++++ libusb/Makefile.haiku | 39 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 68 insertions(+) create mode 100644 libusb/Makefile.haiku diff --git a/Makefile.am b/Makefile.am index a6e47e8..00bcb73 100644 --- a/Makefile.am +++ b/Makefile.am @@ -31,6 +31,10 @@ if OS_KFREEBSD SUBDIRS += libusb endif +if OS_HAIKU +SUBDIRS += libusb +endif + if OS_WINDOWS SUBDIRS += windows endif diff --git a/configure.ac b/configure.ac index 0bf8209..a8f2a84 100644 --- a/configure.ac +++ b/configure.ac @@ -109,6 +109,19 @@ case $host in LIBS_LIBUSB_PRIVATE="${LIBS_LIBUSB_PRIVATE} $libusb_LIBS" CFLAGS_LIBUSB="${CFLAGS_LIBUSB} $libusb_CFLAGS" ;; +*-*-haiku) + AC_MSG_RESULT([ (Haiku back-end)]) + AC_DEFINE(OS_HAIKU, 1, [Haiku implementation]) + AC_SUBST(OS_HAIKU) + backend="libusb" + os="haiku" + threads="pthreads" + + PKG_CHECK_MODULES([libusb], [libusb-1.0 >= 1.0.9], true, [hidapi_lib_error libusb-1.0]) + LIBS_LIBUSB_PRIVATE="${LIBS_LIBUSB_PRIVATE} $libusb_LIBS" + CFLAGS_LIBUSB="${CFLAGS_LIBUSB} $libusb_CFLAGS" + AC_CHECK_LIB([iconv], [libiconv_open], [LIBS_LIBUSB_PRIVATE="${LIBS_LIBUSB_PRIVATE} -liconv"], [hidapi_lib_error libiconv]) + ;; *-mingw*) AC_MSG_RESULT([ (Windows back-end, using MinGW)]) backend="windows" @@ -215,6 +228,7 @@ AM_CONDITIONAL(OS_LINUX, test "x$os" = xlinux) AM_CONDITIONAL(OS_DARWIN, test "x$os" = xdarwin) AM_CONDITIONAL(OS_FREEBSD, test "x$os" = xfreebsd) AM_CONDITIONAL(OS_KFREEBSD, test "x$os" = xkfreebsd) +AM_CONDITIONAL(OS_HAIKU, test "x$os" = xhaiku) AM_CONDITIONAL(OS_WINDOWS, test "x$os" = xwindows) AC_CONFIG_HEADERS([config.h]) diff --git a/libusb/Makefile-manual b/libusb/Makefile-manual index c0fe868..0acf707 100644 --- a/libusb/Makefile-manual +++ b/libusb/Makefile-manual @@ -10,6 +10,10 @@ ifeq ($(OS), FreeBSD) FILE=Makefile.freebsd endif +ifeq ($(OS), Haiku) + FILE=Makefile.haiku +endif + ifeq ($(FILE), ) all: $(error Your platform ${OS} is not supported by hidapi/libusb at this time.) diff --git a/libusb/Makefile.am b/libusb/Makefile.am index 13c9d35..1da06bc 100644 --- a/libusb/Makefile.am +++ b/libusb/Makefile.am @@ -21,6 +21,13 @@ libhidapi_la_LDFLAGS = $(LTLDFLAGS) libhidapi_la_LIBADD = $(LIBS_LIBUSB) endif +if OS_HAIKU +lib_LTLIBRARIES = libhidapi.la +libhidapi_la_SOURCES = hid.c +libhidapi_la_LDFLAGS = $(LTLDFLAGS) +libhidapi_la_LIBADD = $(LIBS_LIBUSB) +endif + hdrdir = $(includedir)/hidapi hdr_HEADERS = $(top_srcdir)/hidapi/hidapi.h diff --git a/libusb/Makefile.haiku b/libusb/Makefile.haiku new file mode 100644 index 0000000..975e8ba --- /dev/null +++ b/libusb/Makefile.haiku @@ -0,0 +1,39 @@ +########################################### +# Simple Makefile for HIDAPI test program +# +# Alan Ott +# Signal 11 Software +# 2010-06-01 +########################################### + +all: hidtest libs + +libs: libhidapi.so + +CC ?= cc +CFLAGS ?= -Wall -g -fPIC + +COBJS = hid.o ../hidtest/test.o +OBJS = $(COBJS) +INCLUDES = -I../hidapi -I/usr/local/include +LDFLAGS = -L/usr/local/lib +LIBS = -lusb -liconv -pthread + + +# Console Test Program +hidtest: $(OBJS) + $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ $(LIBS) + +# Shared Libs +libhidapi.so: $(COBJS) + $(CC) $(LDFLAGS) -shared -Wl,-soname,$@.0 $^ -o $@ $(LIBS) + +# Objects +$(COBJS): %.o: %.c + $(CC) $(CFLAGS) -c $(INCLUDES) $< -o $@ + + +clean: + rm -f $(OBJS) hidtest libhidapi.so ../hidtest/hidtest.o + +.PHONY: clean libs