From b4207b3fd9704c4543e08e8bfc932fe95542fc8c Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sun, 20 Aug 2023 21:40:44 +0200 Subject: [PATCH] port: allow theoretical ARM builds this requires your device to support desktop GL3+ and might require manual setting of the TOOLCHAIN variable --- Makefile.port | 10 ++++++++-- src/include/platform.h | 26 ++++++++++++++++++-------- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Makefile.port b/Makefile.port index bd1a6f998..eb33847a1 100644 --- a/Makefile.port +++ b/Makefile.port @@ -132,10 +132,16 @@ ifneq (,$(findstring windows,$(TARGET_PLATFORM))) TARGET_CFLAGS := $(shell pkg-config sdl2 --cflags-only-I) TARGET_LDFLAGS := $(shell pkg-config sdl2 --libs) -lz -lopengl32 -static-libstdc++ # on windows/mingw we need this to be built with a 32-bit compiler so it finds the correct libs - TOOLCHAIN := i686-w64-mingw32- -else # TODO + TOOLCHAIN ?= i686-w64-mingw32- +else # assume *nix TARGET_CFLAGS := $(shell pkg-config sdl2 --cflags-only-I) TARGET_LDFLAGS := $(shell pkg-config sdl2 --libs) -lGL -lz + ifneq (,$(findstring arm,$(TARGET_PLATFORM))$(findstring aarch,$(TARGET_PLATFORM))) + # linux on arm or aarch64 + # TODO: detect soft/hardfloat abi + TARGET_LDFLAGS += -ldl + TOOLCHAIN ?= arm-linux-gnueabihf- + endif endif # On x86_64 gcc add -m32 to CFLAGS if building a 32-bit executable. diff --git a/src/include/platform.h b/src/include/platform.h index b77f09e81..7542a6815 100644 --- a/src/include/platform.h +++ b/src/include/platform.h @@ -4,14 +4,13 @@ // detect OS #if defined(_WIN32) #define PLATFORM_WIN32 1 -#else - // assume POSIX compatible +#elif defined(__linux__) #define PLATFORM_POSIX 1 - #if defined(__linux__) - #define PLATFORM_LINUX 1 - #else // TODO - #error "Unknown platform." - #endif + #define PLATFORM_LINUX 1 +#else + // assume POSIX-compatible + #define PLATFORM_POSIX 1 + #warning "Unknown OS. Please add it to platform.h." #endif // detect arch @@ -20,10 +19,21 @@ #define PLATFORM_64BIT 1 #elif defined(__i386__) || defined(_X86_) || defined(_M_IX86) #define PLATFORM_X86 1 -#else // TODO +#elif defined(__aarch64__) || defined(_M_ARM64) + #define PLATFORM_ARM 8 + #define PLATFORM_64BIT 1 +#elif defined(__arm__) || defined(_M_ARM) + // assume armv7 + #define PLATFORM_ARM 7 +#else #error "Unknown CPU arch." #endif +// TODO: remove this after 64-bit support is in place +#ifdef PLATFORM_64BIT + #error "64-bit platforms are currently not supported." +#endif + // detect endianness #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__