From b47d482ce92e0c6999ef8ae40c2130dce325d070 Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sat, 9 Dec 2023 15:36:52 +1030 Subject: [PATCH] Update to compile on FreeBSD. --- Inc/orbtraceIf.h | 14 +++++++------- README.md | 17 ++++++++++++++++- Src/nwclient.c | 6 +++++- Src/orbuculum.c | 32 +++++++++++++++++--------------- meson.build | 4 ++++ 5 files changed, 49 insertions(+), 24 deletions(-) diff --git a/Inc/orbtraceIf.h b/Inc/orbtraceIf.h index cbf1a0f5..6844b4ff 100644 --- a/Inc/orbtraceIf.h +++ b/Inc/orbtraceIf.h @@ -16,14 +16,14 @@ #include #include #include +#elif defined LINUX + #include +#elif defined FREEBSD + #include +#elif defined WIN32 + #include #else - #if defined LINUX - #include - #elif defined WIN32 - #include - #else - #error "Unknown OS" - #endif + #error "Unknown OS" #endif #ifdef __cplusplus diff --git a/README.md b/README.md index a86d0c17..78767046 100644 --- a/README.md +++ b/README.md @@ -270,7 +270,7 @@ A udev rules files is included in ```Support/60-orbcode.rules``` The default ins Building on OSX =============== -Recipie instructions courtesy of FrankTheTank; +Recipe instructions courtesy of FrankTheTank; * `brew install libusb zmq sdl2` @@ -286,6 +286,21 @@ mac. You need to watch out for Homebrew binutils...on a M1 Mac you must use the you need to do is move the homebrew binutils out of the way while you do the build....no big deal when you know about it. +Building on FreeBSD +=================== +Install dependencies: + +* `pkg install capstone libzmq3 ncurses libelf ninja meson` + +then build as normal: + +``` +>meson setup build +>ninja -C build +``` + +Note that you will have to alter permissions of the device in `/dev/usb` (run `usbconfig` to find the numbers). This could be automated with a `devd` file. + Building on Windows =================== diff --git a/Src/nwclient.c b/Src/nwclient.c index 39a5a941..606f5831 100644 --- a/Src/nwclient.c +++ b/Src/nwclient.c @@ -20,6 +20,10 @@ #include #include #endif +#ifdef FREEBSD + #include + #include +#endif #ifdef LINUX #include #endif @@ -37,7 +41,7 @@ #define MSG_DONTWAIT 0 #endif -#ifdef OSX +#if defined OSX || defined FREEBSD #ifndef MSG_NOSIGNAL #define MSG_NOSIGNAL 0 #endif diff --git a/Src/orbuculum.c b/Src/orbuculum.c index 43f0b5f8..e990041a 100644 --- a/Src/orbuculum.c +++ b/Src/orbuculum.c @@ -30,23 +30,25 @@ #include #include #include -#else - #if defined LINUX - #include - #include - #if defined TCGETS2 - #include - /* Manual declaration to avoid conflict. */ - extern int ioctl ( int __fd, unsigned long int __request, ... ) ; - #else - #include - #include - #endif - #elif defined WIN32 - #include +#elif defined LINUX + #include + #include + #if defined TCGETS2 + #include + /* Manual declaration to avoid conflict. */ + extern int ioctl ( int __fd, unsigned long int __request, ... ) ; #else - #error "Unknown OS" + #include + #include #endif +#elif defined FREEBSD + #include + #include + #include +#elif defined WIN32 + #include +#else + #error "Unknown OS" #endif #include diff --git a/meson.build b/meson.build index 2cc8501f..d7dac2a8 100644 --- a/meson.build +++ b/meson.build @@ -26,6 +26,10 @@ incdirs = include_directories(['Inc', 'Inc/external']) if host_machine.system() == 'windows' elif host_machine.system() == 'darwin' add_project_arguments('-DOSX', language: 'c') +elif host_machine.system() == 'freebsd' + add_project_arguments('-DFREEBSD', language: 'c') + add_project_arguments('-ggdb', language: 'c') + add_project_arguments('-D_GNU_SOURCE', language: 'c') else add_project_arguments('-DLINUX', language: 'c') add_project_arguments('-ggdb', language: 'c')