diff --git a/Makefile b/Makefile index 9c5e09b..795983f 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,9 @@ ifeq ($(lua),) lua=5.2 endif +WGET_PATH = $(shell which wget) +WGET_OPTS = -O + TARGET_EXEC ?= ocvm INC_DIRS ?= ./ @@ -40,7 +43,13 @@ ifeq ($(shell uname -s 2>/dev/null),Haiku) SRCS+=$(wildcard $(SRC_DIRS)haiku/*.cpp) endif -ifeq (, $(shell which wget)) +ifeq ($(shell uname -s 2>/dev/null), FreeBSD) + WGET_PATH = $(shell which fetch) + WGET_OPTS = -o + CXX = g++ +endif + +ifeq (, $(WGET_PATH)) SRCS := $(filter-out $(SRC_DIRS)drivers/internet_http.cpp,$(SRCS)) endif @@ -64,10 +73,10 @@ system/.keep: @echo Downloading OpenComputers system files mkdir -p system touch system/.keep - command -v svn && svn checkout https://github.com/MightyPirates/OpenComputers/trunk/src/main/resources/assets/opencomputers/loot system/loot || echo "\n\e[36;1mwarning: svn not found. The build will continue, you can manually prepare \`.system/\`\e[m\n" - wget https://raw.githubusercontent.com/MightyPirates/OpenComputers/master-MC1.7.10/src/main/resources/assets/opencomputers/lua/machine.lua -O system/machine.lua - wget https://raw.githubusercontent.com/MightyPirates/OpenComputers/master-MC1.7.10/src/main/resources/assets/opencomputers/lua/bios.lua -O system/bios.lua - wget https://raw.githubusercontent.com/MightyPirates/OpenComputers/master-MC1.7.10/src/main/resources/assets/opencomputers/font.hex -O system/font.hex + @command -v svn && svn checkout https://github.com/MightyPirates/OpenComputers/trunk/src/main/resources/assets/opencomputers/loot system/loot || echo "\n\e[36;1mwarning: svn not found. The build will continue, you can manually prepare \`.system/\`\e[m\n" + $(WGET_PATH) https://raw.githubusercontent.com/MightyPirates/OpenComputers/master-MC1.7.10/src/main/resources/assets/opencomputers/lua/machine.lua $(WGET_OPTS) system/machine.lua + $(WGET_PATH) https://raw.githubusercontent.com/MightyPirates/OpenComputers/master-MC1.7.10/src/main/resources/assets/opencomputers/lua/bios.lua $(WGET_OPTS) system/bios.lua + $(WGET_PATH) https://raw.githubusercontent.com/MightyPirates/OpenComputers/master-MC1.7.10/src/main/resources/assets/opencomputers/font.hex $(WGET_OPTS) system/font.hex .PHONY: clean diff --git a/drivers/fs_utils.cpp b/drivers/fs_utils.cpp index 7c16773..f52b3ae 100644 --- a/drivers/fs_utils.cpp +++ b/drivers/fs_utils.cpp @@ -12,6 +12,11 @@ using std::ofstream; #include #endif +#ifdef __FreeBSD__ +#include +#include +#endif + #include #include #include @@ -300,6 +305,11 @@ string proc_root() auto len = path.size(); auto reduced = len < size ? len : size; ::memcpy(buf, path.data(), reduced); +#elif __FreeBSD__ + int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; + size_t len = sizeof(buf); + sysctl(mib, 4, buf, &len, NULL, 0); + #else ssize_t len = ::readlink("/proc/self/exe", buf, size); if (len >= size) // yikes, abort @@ -311,6 +321,7 @@ string proc_root() buf[len] = 0; path = buf; + cerr << path << endl; // remove proc file name size_t last_slash = path.find_last_of("/"); diff --git a/drivers/raw_tty.cpp b/drivers/raw_tty.cpp index b23a355..6146fc9 100644 --- a/drivers/raw_tty.cpp +++ b/drivers/raw_tty.cpp @@ -25,6 +25,10 @@ #define KDSKBMODE 0x4B45 /* sets current keyboard mode */ #endif +#ifdef __FreeBSD__ +#include /* KDGKBMODE and KDSKBMODE */ +#endif + #include #include // memset #include