Skip to content

Commit

Permalink
Merge pull request #134 from DanielO/freebsd-port
Browse files Browse the repository at this point in the history
Update to compile on FreeBSD.
  • Loading branch information
mubes authored Jan 8, 2024
2 parents e88bb47 + b47d482 commit 3f72ca7
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 24 deletions.
14 changes: 7 additions & 7 deletions Inc/orbtraceIf.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
#include <sys/ioctl.h>
#include <libusb.h>
#include <termios.h>
#elif defined LINUX
#include <libusb-1.0/libusb.h>
#elif defined FREEBSD
#include <libusb.h>
#elif defined WIN32
#include <libusb.h>
#else
#if defined LINUX
#include <libusb-1.0/libusb.h>
#elif defined WIN32
#include <libusb.h>
#else
#error "Unknown OS"
#endif
#error "Unknown OS"
#endif

#ifdef __cplusplus
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand All @@ -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
===================

Expand Down
6 changes: 5 additions & 1 deletion Src/nwclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include <string.h>
#include <poll.h>
#endif
#ifdef FREEBSD
#include <sys/types.h>
#include <sys/socket.h>
#endif
#ifdef LINUX
#include <linux/tcp.h>
#endif
Expand All @@ -37,7 +41,7 @@
#define MSG_DONTWAIT 0
#endif

#ifdef OSX
#if defined OSX || defined FREEBSD
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
#endif
Expand Down
32 changes: 17 additions & 15 deletions Src/orbuculum.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,25 @@
#include <sys/ioctl.h>
#include <libusb.h>
#include <termios.h>
#else
#if defined LINUX
#include <libusb-1.0/libusb.h>
#include <asm/ioctls.h>
#if defined TCGETS2
#include <asm/termios.h>
/* Manual declaration to avoid conflict. */
extern int ioctl ( int __fd, unsigned long int __request, ... ) ;
#else
#include <sys/ioctl.h>
#include <termios.h>
#endif
#elif defined WIN32
#include <libusb.h>
#elif defined LINUX
#include <libusb-1.0/libusb.h>
#include <asm/ioctls.h>
#if defined TCGETS2
#include <asm/termios.h>
/* Manual declaration to avoid conflict. */
extern int ioctl ( int __fd, unsigned long int __request, ... ) ;
#else
#error "Unknown OS"
#include <sys/ioctl.h>
#include <termios.h>
#endif
#elif defined FREEBSD
#include <libusb.h>
#include <sys/ioctl.h>
#include <termios.h>
#elif defined WIN32
#include <libusb.h>
#else
#error "Unknown OS"
#endif
#include <signal.h>

Expand Down
4 changes: 4 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 3f72ca7

Please sign in to comment.