From 97c92368bc0efe85d006e367d97fd88da5a13ecf Mon Sep 17 00:00:00 2001 From: alpha123 Date: Mon, 2 Nov 2015 13:22:00 -0700 Subject: [PATCH] Build on FreeBSD --- src/Makefile | 4 ++++ src/file.cc | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/Makefile b/src/Makefile index f3b32238d..78eb6d258 100644 --- a/src/Makefile +++ b/src/Makefile @@ -28,6 +28,10 @@ os := $(shell uname) ifeq ($(os),Darwin) LIBS += -lncurses -lboost_regex-mt +else ifeq ($(os),FreeBSD) + LIBS += -ltinfow -lncursesw -lboost_regex + CPPFLAGS += -I/usr/local/include + LDFLAGS += -L/usr/local/lib else ifeq ($(os),Haiku) LIBS += -lncursesw -lboost_regex -lnetwork -lbe else ifneq (,$(findstring CYGWIN,$(os))) diff --git a/src/file.cc b/src/file.cc index ced886142..0e6b1e61f 100644 --- a/src/file.cc +++ b/src/file.cc @@ -12,6 +12,10 @@ #include #include +#if defined(__FreeBSD__) +#include +#endif + #if defined(__APPLE__) #include #define st_mtim st_mtimespec @@ -491,6 +495,11 @@ String get_kak_binary_path() kak_assert(res != -1); buffer[res] = '\0'; return buffer; +#elif defined(__FreeBSD__) + int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; + size_t res = sizeof(buffer); + sysctl(mib, 4, buffer, &res, NULL, 0); + return buffer; #elif defined(__APPLE__) uint32_t bufsize = 2048; _NSGetExecutablePath(buffer, &bufsize);