From 3e2a99abc8329bd1874842d177bd4024939f8ff5 Mon Sep 17 00:00:00 2001 From: ALTracer Date: Sat, 9 Dec 2023 21:16:08 +0300 Subject: [PATCH] general: Allow building on FreeBSD * Tested on NomadBSD 13.2-RELEASE * Use normal hidapi (without hidraw) which works with CMSIS-DAP --- src/include/general.h | 3 ++- src/platforms/hosted/Makefile.inc | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/include/general.h b/src/include/general.h index 6df94b1dc87..e4c0093924c 100644 --- a/src/include/general.h +++ b/src/include/general.h @@ -35,7 +35,8 @@ #endif #if defined(_WIN32) || defined(__CYGWIN__) #include -#else +/* `alloca()` on FreeBSD is visible from , and does not exist */ +#elif !defined(__FreeBSD__) #include #endif #include diff --git a/src/platforms/hosted/Makefile.inc b/src/platforms/hosted/Makefile.inc index 4247fc04732..9a3c4b632f8 100644 --- a/src/platforms/hosted/Makefile.inc +++ b/src/platforms/hosted/Makefile.inc @@ -44,6 +44,10 @@ HIDAPILIB = hidapi ifneq (,$(findstring linux,$(SYS))) SRC += serial_unix.c HIDAPILIB = hidapi-hidraw +else ifneq (,$(findstring freebsd,$(SYS))) + # On FreeBSD, only the hidapi on libusb-1.0 variant exists + SRC += serial_unix.c + HIDAPILIB = hidapi else ifneq (,$(findstring mingw,$(SYS))) FLAVOUR = $(shell which $(CC)) ifneq (,$(findstring ucrt64,$(FLAVOUR)))