diff --git a/Makefile b/Makefile index 03d77ed3e..ead045fe5 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,9 @@ ifeq ($(shell uname -s),Darwin) CONFIG_DARWIN=y endif +ifeq ($(shell uname -s),FreeBSD) +CONFIG_FREEBSD=y +endif # Windows cross compilation from Linux #CONFIG_WIN32=y # use link time optimization (smaller and faster executables but slower build) @@ -57,6 +60,12 @@ ifdef CONFIG_DARWIN CONFIG_CLANG=y CONFIG_DEFAULT_AR=y endif +ifdef CONFIG_FREEBSD +# use clang instead of gcc +CONFIG_CLANG=y +CONFIG_DEFAULT_AR=y +CONFIG_LTO= +endif ifdef CONFIG_WIN32 ifdef CONFIG_M32 diff --git a/qjs.c b/qjs.c index bcee95762..033289598 100644 --- a/qjs.c +++ b/qjs.c @@ -36,6 +36,8 @@ #include #elif defined(__linux__) #include +#elif defined(__FreeBSD__) +#include #endif #include "cutils.h" diff --git a/quickjs-libc.c b/quickjs-libc.c index 7eea0d716..2e779504f 100644 --- a/quickjs-libc.c +++ b/quickjs-libc.c @@ -47,8 +47,15 @@ #include #include -#if defined(__APPLE__) +#if defined(__FreeBSD__) +extern char **environ; +#endif + +#if defined(__APPLE__) || defined(__FreeBSD__) typedef sig_t sighandler_t; +#endif + +#if defined(__APPLE__) #if !defined(environ) #include #define environ (*_NSGetEnviron())