diff --git a/boards/native/Makefile.include b/boards/native/Makefile.include index e23dcdf117654..a15f3ab4925ed 100644 --- a/boards/native/Makefile.include +++ b/boards/native/Makefile.include @@ -10,10 +10,10 @@ export ELF = $(BINDIR)$(PROJECT).elf # toolchain: export PREFIX = export CC ?= $(PREFIX)gcc -export AR = $(PREFIX)ar -export AS = $(PREFIX)as -export LINK = $(PREFIX)gcc -export SIZE = $(PREFIX)size +export AR ?= $(PREFIX)ar +export AS ?= $(PREFIX)as +export LINK ?= $(PREFIX)gcc +export SIZE ?= $(PREFIX)size export OBJCOPY = true export DEBUGGER = gdb @@ -25,7 +25,15 @@ export GPROF ?= gprof # flags: export CFLAGS += -Wall -Wextra -pedantic -m32 -export LINKFLAGS += -m32 -gc -ldl +ifeq ($(shell uname -s),FreeBSD) +export CFLAGS += -DCOMPAT_32BIT -L/usr/lib32 -B/usr/lib32 +endif +export LINKFLAGS += -m32 -gc +ifeq ($(shell uname -s),FreeBSD) +export LINKFLAGS += -DCOMPAT_32BIT -L/usr/lib32 -B/usr/lib32 -L $(BINDIR) +else +export LINKFLAGS += -ldl +endif export ASFLAGS = export DEBUGGER_FLAGS = $(ELF) term-memcheck: export VALGRIND_FLAGS ?= --track-origins=yes diff --git a/boards/native/drivers/native-uart0.c b/boards/native/drivers/native-uart0.c index 1f2fb3c4081a4..358320ae12528 100644 --- a/boards/native/drivers/native-uart0.c +++ b/boards/native/drivers/native-uart0.c @@ -28,6 +28,7 @@ #include #include #include +#include #include diff --git a/cpu/native/hwtimer_cpu.c b/cpu/native/hwtimer_cpu.c index 86f593a7866ac..bd6550174bf1e 100644 --- a/cpu/native/hwtimer_cpu.c +++ b/cpu/native/hwtimer_cpu.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "hwtimer.h" #include "hwtimer_arch.h" diff --git a/cpu/native/irq_cpu.c b/cpu/native/irq_cpu.c index 2de537835cbc2..7151be91a05df 100644 --- a/cpu/native/irq_cpu.c +++ b/cpu/native/irq_cpu.c @@ -18,6 +18,7 @@ #include #include #include +#include #ifdef HAVE_VALGRIND_H #include @@ -340,7 +341,7 @@ void native_isr_entry(int sig, siginfo_t *info, void *context) #ifdef __MACH__ _native_saved_eip = ((ucontext_t *)context)->uc_mcontext->__ss.__eip; ((ucontext_t *)context)->uc_mcontext->__ss.__eip = (unsigned int)&_native_sig_leave_tramp; -#elif BSD +#elif defined(__FreeBSD__) _native_saved_eip = ((struct sigcontext *)context)->sc_eip; ((struct sigcontext *)context)->sc_eip = (unsigned int)&_native_sig_leave_tramp; #else diff --git a/cpu/native/lpm_cpu.c b/cpu/native/lpm_cpu.c index 6c474a1f546e4..9b3742e605cfd 100644 --- a/cpu/native/lpm_cpu.c +++ b/cpu/native/lpm_cpu.c @@ -24,6 +24,7 @@ #include #endif #include +#include #include "lpm.h" #include "debug.h" diff --git a/cpu/native/net/tap.c b/cpu/native/net/tap.c index 03920dc211772..800ea07098b02 100644 --- a/cpu/native/net/tap.c +++ b/cpu/native/net/tap.c @@ -24,6 +24,7 @@ #include #include #include +#include #ifdef __MACH__ #define _POSIX_C_SOURCE @@ -31,6 +32,13 @@ #undef _POSIX_C_SOURCE #include #include + +#elif defined(__FreeBSD__) +#include +#include +#include +#include + #else #include #include @@ -232,6 +240,9 @@ int tap_init(char *name) #ifdef __MACH__ /* OSX */ char clonedev[255] = "/dev/"; /* XXX bad size */ strncpy(clonedev+5, name, 250); +#elif defined(__FreeBSD__) + char clonedev[255] = "/dev/"; /* XXX bad size */ + strncpy(clonedev+5, name, 250); #else /* Linux */ struct ifreq ifr; const char *clonedev = "/dev/net/tun"; @@ -242,7 +253,7 @@ int tap_init(char *name) err(EXIT_FAILURE, "open(%s)", clonedev); } -#ifdef __MACH__ /* OSX */ +#if (defined(__MACH__) || defined(__FreeBSD__)) /* OSX/FreeBSD */ struct ifaddrs* iflist; if (getifaddrs(&iflist) == 0) { for (struct ifaddrs *cur = iflist; cur; cur = cur->ifa_next) { diff --git a/cpu/native/rtc/posix-rtc.c b/cpu/native/rtc/posix-rtc.c index d532afdcc402c..0554ad5397f9e 100644 --- a/cpu/native/rtc/posix-rtc.c +++ b/cpu/native/rtc/posix-rtc.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "debug.h" diff --git a/cpu/native/startup.c b/cpu/native/startup.c index 8620f8329f7b0..96494d697b844 100644 --- a/cpu/native/startup.c +++ b/cpu/native/startup.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "kernel_internal.h" #include "cpu.h" diff --git a/cpu/native/syscalls.c b/cpu/native/syscalls.c index 6e94aeba1bcb2..11af547d1746e 100644 --- a/cpu/native/syscalls.c +++ b/cpu/native/syscalls.c @@ -33,6 +33,7 @@ #ifdef MODULE_VTIMER #include #endif +#include #include "cpu.h" #include "irq.h" @@ -163,6 +164,9 @@ ssize_t _native_write(int fd, const void *buf, size_t count) return r; } +#if defined(__FreeBSD__) +#undef putchar +#endif int putchar(int c) { _native_write(STDOUT_FILENO, &c, 1); return 0;