1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-15 15:53:55 +00:00

Updated for OpenBSD

This commit is contained in:
Bryan Roe
2021-08-30 12:06:36 -07:00
parent b496e192d9
commit 67a949207f
5 changed files with 43 additions and 1 deletions

View File

@@ -110,6 +110,7 @@
# make linux ARCHID=27 # Linux ARM 32 bit HardFloat NOKVM (Old Raspberry Pi on Raspian 7, 2015-02-02 build)
# gmake freebsd ARCHID=30 # FreeBSD x86 64 bit
# gmake freebsd ARCHID=31 # Reserved for FreeBSD x86 32 bit
# gmake openbsd ARCHID=34 # OpenBSD x86 64 bit
#
#
# Alpine Linux (MUSL)
@@ -485,6 +486,15 @@ KVM = 0
LMS = 0
endif
# Official OpenBSD x86-64
ifeq ($(ARCHID),34)
ARCHNAME = openbsd_x86-64
CC = clang
CFLAGS += -I/usr/local/include
KVM = 0
LMS = 0
endif
ifeq ($(WEBLOG),1)
CFLAGS += -D_REMOTELOGGINGSERVER -D_REMOTELOGGING
@@ -724,3 +734,9 @@ freebsd:
$(MAKE) EXENAME="$(EXENAME)_$(ARCHNAME)$(EXENAME2)" ADDITIONALSOURCES="$(LINUXKVMSOURCES)" AID="$(ARCHID)" CFLAGS="-std=gnu99 -Wall -DJPEGMAXBUF=$(KVMMaxTile) -DMESH_AGENTID=$(ARCHID) -D_POSIX -D_FREEBSD -D_NOHECI -D_NOILIBSTACKDEBUG -DMICROSTACK_PROXY -fno-strict-aliasing $(INCDIRS) $(CFLAGS) $(CEXTRA)" LDFLAGS="$(BSDSSL) $(BSDFLAGS) -L. -lpthread -ldl -lz -lutil $(LDFLAGS) $(LDEXTRA)"
$(SYMBOLCP)
$(STRIP)
openbsd:
$(MAKE) EXENAME="$(EXENAME)_$(ARCHNAME)$(EXENAME2)" ADDITIONALSOURCES="$(LINUXKVMSOURCES)" AID="$(ARCHID)" CFLAGS="-std=gnu99 -Wall -DJPEGMAXBUF=$(KVMMaxTile) -DMESH_AGENTID=$(ARCHID) -D_POSIX -D_FREEBSD -D_OPENBSD -DILIB_NO_TIMEDJOIN -D_NOHECI -D_NOILIBSTACKDEBUG -DMICROSTACK_PROXY -fno-strict-aliasing $(INCDIRS) $(CFLAGS) $(CEXTRA)" LDFLAGS="$(BSDSSL) $(BSDFLAGS) -L. -lpthread -lz -lutil $(LDFLAGS) $(LDEXTRA)"
$(SYMBOLCP)
$(STRIP)

View File

@@ -34,6 +34,11 @@ limitations under the License.
#include "microscript/ILibDuktape_Commit.h"
MeshAgentHostContainer *agentHost = NULL;
#ifdef _OPENBSD
#include <stdlib.h>
char __agentExecPath[1024] = { 0 };
#endif
#ifdef WIN32
BOOL CtrlHandler(DWORD fdwCtrlType)
@@ -81,6 +86,10 @@ int wmain(int argc, char **wargv)
int main(int argc, char **argv)
#endif
{
#ifdef _OPENBSD
realpath(argv[0], __agentExecPath);
#endif
// Check if .JS file is integrated with executable
char *integratedJavaScript = NULL;
int integratedJavaScriptLen = 0;

View File

@@ -5770,7 +5770,11 @@ int MeshAgent_Start(MeshAgentHostContainer *agentHost, int paramLen, char **para
#elif defined(NACL)
#else
#ifdef _FREEBSD
x = readlink("/proc/curproc/file", exePath, 1024);
#ifdef _OPENBSD
x = sprintf_s(exePath, 1024, "%s", __agentExecPath);
#else
x = readlink("/proc/curproc/file", exePath, 1024);
#endif
#else
x = readlink("/proc/self/exe", exePath, 1024);
#endif

View File

@@ -52,6 +52,11 @@ limitations under the License.
#include <sys/resource.h>
#endif
#ifdef _OPENBSD
extern char* __agentExecPath;
#endif
#include "ILibDuktape_ScriptContainer.h"
#include "ILibDuktapeModSearch.h"
#include "ILibDuktape_EventEmitter.h"
@@ -453,12 +458,16 @@ void ILibDuktape_ScriptContainer_CheckEmbedded(char **script, int *scriptLen)
int x = readlink("/proc/curproc/file", exePath, sizeof(exePath));
if (x < 0 || x >= sizeof(exePath))
{
#ifdef _OPENBSD
strcpy_s(exePath, sizeof(exePath), __agentExecPath);
#else
printf("\nYou'll need to mount procfs, which isn't mounted by default on FreeBSD.\n");
printf("Add the following line to /etc/fstab\n");
printf(" proc /proc procfs rw 0 0\n\n");
printf("If you don't reboot after, then you can manually mount with the command:\n");
printf(" mount -t procfs proc /proc\n\n");
ILIBCRITICALEXIT(246);
#endif
}
exePath[x] = 0;
#else

View File

@@ -42,7 +42,11 @@ limitations under the License.
#include <util.h>
#else
#include <termios.h>
#ifdef _OPENBSD
#include <util.h>
#else
#include <libutil.h>
#endif
#endif
#endif
#endif