diff --git a/README.md b/README.md index 7f7c2f53..cf2e5f40 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,17 @@ Assuming an existing HomeBrew installation: % brew install boost cmake gcc libpcap pkg-config ragel sqlite ``` +### NetBSD +In NetBSD you will almost certainly need to have a newer compiler installed. +Using the example of gcc12 from pkgsrc, one will need to set three +environment variables before starting: +export CC="/usr/pkg/gcc12/bin/cc" +export CXX="/usr/pkg/gcc12/bin/g++" +export CXXFLAGS="-gdwarf-4" + +Then continue with the build as below. + + ## Configure & build In order to configure with `cmake` first create and cd into a build directory: diff --git a/cmake/osdetection.cmake b/cmake/osdetection.cmake index 59f2b342..0e730fe3 100644 --- a/cmake/osdetection.cmake +++ b/cmake/osdetection.cmake @@ -6,7 +6,11 @@ if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") set(FREEBSD true) endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") -if (ARCH_IA32 OR ARCH_X86_64) +if(CMAKE_SYSTEM_NAME MATCHES "NetBSD") + set(NETBSD true) +endif(CMAKE_SYSTEM_NAME MATCHES "NetBSD") + +if (LINUX AND (ARCH_IA32 OR ARCH_X86_64)) option(FAT_RUNTIME "Build a library that supports multiple microarchitectures" ON) else() option(FAT_RUNTIME "Build a library that supports multiple microarchitectures" OFF) diff --git a/examples/patbench.cc b/examples/patbench.cc index 8180d2a9..7bb5020a 100644 --- a/examples/patbench.cc +++ b/examples/patbench.cc @@ -134,7 +134,12 @@ #include #include #include +#ifdef __NetBSD__ +#include +#include +#else #include +#endif /* __NetBSD__ */ #include #include diff --git a/examples/pcapscan.cc b/examples/pcapscan.cc index 12b94438..349ef6a9 100644 --- a/examples/pcapscan.cc +++ b/examples/pcapscan.cc @@ -68,7 +68,12 @@ #include #include #include +#ifdef __NetBSD__ +#include +#include +#else #include +#endif /* __NetBSD__ */ #include #include diff --git a/src/util/popcount.h b/src/util/popcount.h index d90a0d50..e9f689e9 100644 --- a/src/util/popcount.h +++ b/src/util/popcount.h @@ -36,7 +36,12 @@ #include "ue2common.h" #include "util/arch.h" +#ifdef __NetBSD__ +#include +#endif + +#ifndef __NetBSD__ static really_inline u32 popcount32(u32 x) { return __builtin_popcount(x); @@ -51,6 +56,7 @@ u32 popcount32(u32 x) { // return (((x + (x >> 4)) & 0xf0f0f0f) * 0x1010101) >> 24; // #endif } +#endif /* __NetBSD__ */ static really_inline u32 popcount32x4(u32 const *x) { @@ -61,6 +67,7 @@ u32 popcount32x4(u32 const *x) { return sum; } +#ifndef __NetBSD__ static really_inline u32 popcount64(u64a x) { return __builtin_popcountll(x); @@ -81,6 +88,7 @@ u32 popcount64(u64a x) { // return popcount32(x >> 32) + popcount32(x); // #endif } +#endif /* __NetBSD__ */ static really_inline u32 popcount64x4(u64a const *x) {