Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added FreeBSD build support. #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ ifeq ($(lua),)
lua=5.2
endif

WGET_PATH = $(shell which wget)
WGET_OPTS = -O

TARGET_EXEC ?= ocvm

INC_DIRS ?= ./
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down
11 changes: 11 additions & 0 deletions drivers/fs_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ using std::ofstream;
#include <mach-o/dyld.h>
#endif

#ifdef __FreeBSD__
#include <sys/types.h>
#include <sys/sysctl.h>
#endif

#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
Expand Down Expand Up @@ -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
Expand All @@ -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("/");
Expand Down
4 changes: 4 additions & 0 deletions drivers/raw_tty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#define KDSKBMODE 0x4B45 /* sets current keyboard mode */
#endif

#ifdef __FreeBSD__
#include <sys/kbio.h> /* KDGKBMODE and KDSKBMODE */
#endif

#include <signal.h>
#include <string.h> // memset
#include <time.h>
Expand Down