From a1cfc095a7ad15551742c54983a782109699549f Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Sat, 8 Feb 2025 22:09:28 +0900 Subject: [PATCH 1/2] Compile on NetBSD --- source/makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/makefile b/source/makefile index 8e39f0a..fdf0f4b 100644 --- a/source/makefile +++ b/source/makefile @@ -21,6 +21,10 @@ ifeq ($(shell uname),Linux) SRC_TARGETEXT=.so SRC_LIBLINE=-shared -Wl,-rpath,. -Wl,--out-implib=$(SRC_OUTDIR)/lib$(SRC_TARGETNAME).a -Wl,--whole-archive $(SRC_OBJFILES) -Wl,--no-whole-archive CFLAGS+=-fPIC +else ifeq ($(shell uname),NetBSD) + SRC_TARGETEXT=.so + SRC_LIBLINE=-shared -Wl,-rpath,. -Wl,--out-implib=$(SRC_OUTDIR)/lib$(SRC_TARGETNAME).a -Wl,--whole-archive $(SRC_OBJFILES) -Wl,--no-whole-archive + CFLAGS+=-fPIC else ifeq ($(OS),Windows_NT) SRC_TARGETEXT=.dll SRC_LIBLINE=-shared -Wl,-rpath,. -Wl,--out-implib=$(SRC_OUTDIR)/lib$(SRC_TARGETNAME).a -Wl,--whole-archive $(SRC_OBJFILES) -Wl,--no-whole-archive -Wl,--export-all-symbols -Wl,--enable-auto-import From 1006b6e216803b3157fd5cfb9adf9db9b10c7637 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Sat, 8 Feb 2025 22:14:32 +0900 Subject: [PATCH 2/2] Add bitness definitions, and platform definitions --- makefile | 10 ++++++++++ source/toy_common.h | 6 ++++++ tests/cases/makefile | 2 ++ tests/integrations/makefile | 2 ++ 4 files changed, 20 insertions(+) diff --git a/makefile b/makefile index cc0dfa4..90544a1 100644 --- a/makefile +++ b/makefile @@ -87,6 +87,16 @@ ifeq ($(shell uname),Linux) find . -type f -name '*.dylib' -delete find . -type d -name 'out' -delete find . -type d -name 'obj' -delete +else ifeq ($(shell uname),NetBSD) + find . -type f -name '*.o' -delete + find . -type f -name '*.a' -delete + find . -type f -name '*.exe' -delete + find . -type f -name '*.dll' -delete + find . -type f -name '*.lib' -delete + find . -type f -name '*.so' -delete + find . -type f -name '*.dylib' -delete + find . -type d -name 'out' -delete + find . -type d -name 'obj' -delete else ifeq ($(OS),Windows_NT) $(RM) *.o *.a *.exe *.dll *.lib *.so *.dylib $(RM) out diff --git a/source/toy_common.h b/source/toy_common.h index edcd094..0f637c3 100644 --- a/source/toy_common.h +++ b/source/toy_common.h @@ -30,6 +30,12 @@ #else #define TOY_BITNESS 32 #endif +#elif defined(__NetBSD__) + #if defined(__LP64__) + #define TOY_BITNESS 64 + #else + #define TOY_BITNESS 32 + #endif #elif defined(_WIN32) || defined(_WIN64) #if defined(_WIN64) #define TOY_BITNESS 64 diff --git a/tests/cases/makefile b/tests/cases/makefile index 5c191dd..049acd5 100644 --- a/tests/cases/makefile +++ b/tests/cases/makefile @@ -6,6 +6,8 @@ LDFLAGS+= ifeq ($(shell uname),Linux) LDFLAGS=-Wl,--gc-sections +else ifeq ($(shell uname),NetBSD) +LDFLAGS=-Wl,--gc-sections else ifeq ($(OS),Windows_NT) LDFLAGS=-Wl,--gc-sections else ifeq ($(shell uname),Darwin) diff --git a/tests/integrations/makefile b/tests/integrations/makefile index 48e3ebc..1d8c362 100644 --- a/tests/integrations/makefile +++ b/tests/integrations/makefile @@ -6,6 +6,8 @@ LDFLAGS+= ifeq ($(shell uname),Linux) LDFLAGS=-Wl,--gc-sections +else ifeq ($(shell uname),NetBSD) +LDFLAGS=-Wl,--gc-sections else ifeq ($(OS),Windows_NT) LDFLAGS=-Wl,--gc-sections else ifeq ($(shell uname),Darwin)