2025-05-29 16:48:53 +05:30
.PHONY : libsds
export BUILD_SYSTEM_DIR := vendor/nimbus-build-system
2025-06-17 09:59:46 +02:00
LINK_PCRE := 0
2025-05-29 16:48:53 +05:30
# we don't want an error here, so we can handle things later, in the ".DEFAULT" target
- i n c l u d e $( BUILD_SYSTEM_DIR ) / m a k e f i l e s / v a r i a b l e s . m k
i f e q ( $( NIM_PARAMS ) , )
# "variables.mk" was not included, so we update the submodules.
GIT_SUBMODULE_UPDATE := git submodule update --init --recursive
.DEFAULT :
+@ echo -e " Git submodules not found. Running ' $( GIT_SUBMODULE_UPDATE) '.\n " ; \
$( GIT_SUBMODULE_UPDATE) ; \
echo
# Now that the included *.mk files appeared, and are newer than this file, Make will restart itself:
# https://www.gnu.org/software/make/manual/make.html#Remaking-Makefiles
#
# After restarting, it will execute its original goal, so we don't have to start a child Make here
# with "$(MAKE) $(MAKECMDGOALS)". Isn't hidden control flow great?
e l s e # "variables.mk" was included. Business as usual until the end of this file.
# default target, because it's the first one that doesn't start with '.'
all : | libsds
sds.nims :
ln -s sds.nimble $@
update : | update -common
rm -rf sds.nims && \
$( MAKE) sds.nims $( HANDLE_OUTPUT)
clean :
rm -rf build
deps : | sds .nims
# must be included after the default target
- i n c l u d e $( BUILD_SYSTEM_DIR ) / m a k e f i l e s / t a r g e t s . m k
2025-06-17 09:59:46 +02:00
## Git version
GIT_VERSION ?= $( shell git describe --abbrev= 6 --always --tags)
## Compilation parameters. If defined in the CLI the assignments won't be executed
NIM_PARAMS := $( NIM_PARAMS) -d:git_version= \" $( GIT_VERSION) \"
i f e q ( $( DEBUG ) , 0 )
NIM_PARAMS := $( NIM_PARAMS) -d:release
e l s e
NIM_PARAMS := $( NIM_PARAMS) -d:debug
e n d i f
2025-05-29 16:48:53 +05:30
STATIC ?= 0
libsds : deps
rm -f build/libsds*
i f e q ( $( STATIC ) , 1 )
echo -e $( BUILD_MSG) " build/ $@ .a " && \
$( ENV_SCRIPT) nim libsdsStatic $( NIM_PARAMS) sds.nims
e l s e
echo -e $( BUILD_MSG) " build/ $@ .so " && \
$( ENV_SCRIPT) nim libsdsDynamic $( NIM_PARAMS) sds.nims
e n d i f
2025-08-24 23:56:14 +02:00
e n d i f
#####################
## Mobile Bindings ##
#####################
.PHONY : libsds -android \
libsds-android-precheck \
libsds-android-arm64 \
libsds-android-amd64 \
libsds-android-x86 \
libsds-android-arm \
rebuild-nat-libs \
build-libsds-for-android-arch
ANDROID_TARGET ?= 30
i f e q ( $( detected_OS ) , D a r w i n )
ANDROID_TOOLCHAIN_DIR := $( ANDROID_NDK_HOME) /toolchains/llvm/prebuilt/darwin-x86_64
e l s e
ANDROID_TOOLCHAIN_DIR := $( ANDROID_NDK_HOME) /toolchains/llvm/prebuilt/linux-x86_64
e n d i f
rebuild-nat-libs : | clean -cross nat -libs
libsds-android-precheck :
i f n d e f A N D R O I D _ N D K _ H O M E
$( error ANDROID_NDK_HOME is not set )
e n d i f
build-libsds-for-android-arch :
$( MAKE) rebuild-nat-libs CC = $( ANDROID_TOOLCHAIN_DIR) /bin/$( ANDROID_COMPILER) && \
./scripts/build_rln_android.sh $( CURDIR) /build $( LIBRLN_BUILDDIR) $( LIBRLN_VERSION) $( CROSS_TARGET) $( ABIDIR) && \
CPU = $( CPU) ABIDIR = $( ABIDIR) ANDROID_ARCH = $( ANDROID_ARCH) ANDROID_COMPILER = $( ANDROID_COMPILER) ANDROID_TOOLCHAIN_DIR = $( ANDROID_TOOLCHAIN_DIR) $( ENV_SCRIPT) nim libsdsAndroid $( NIM_PARAMS) sds.nims
libsds-android-arm64 : ANDROID_ARCH =aarch 64-linux -android
libsds-android-arm64 : CPU =arm 64
libsds-android-arm64 : ABIDIR =arm 64-v 8a
libsds-android-arm64 : | libsds -android -precheck build deps
$( MAKE) build-libsds-for-android-arch ANDROID_ARCH = $( ANDROID_ARCH) CROSS_TARGET = $( ANDROID_ARCH) CPU = $( CPU) ABIDIR = $( ABIDIR) ANDROID_COMPILER = $( ANDROID_ARCH) $( ANDROID_TARGET) -clang
libsds-android-amd64 : ANDROID_ARCH =x 86_ 64-linux -android
libsds-android-amd64 : CPU =amd 64
libsds-android-amd64 : ABIDIR =x 86_ 64
libsds-android-amd64 : | libsds -android -precheck build deps
$( MAKE) build-libsds-for-android-arch ANDROID_ARCH = $( ANDROID_ARCH) CROSS_TARGET = $( ANDROID_ARCH) CPU = $( CPU) ABIDIR = $( ABIDIR) ANDROID_COMPILER = $( ANDROID_ARCH) $( ANDROID_TARGET) -clang
libsds-android-x86 : ANDROID_ARCH =i 686-linux -android
libsds-android-x86 : CPU =i 386
libsds-android-x86 : ABIDIR =x 86
libsds-android-x86 : | libsds -android -precheck build deps
$( MAKE) build-libsds-for-android-arch ANDROID_ARCH = $( ANDROID_ARCH) CROSS_TARGET = $( ANDROID_ARCH) CPU = $( CPU) ABIDIR = $( ABIDIR) ANDROID_COMPILER = $( ANDROID_ARCH) $( ANDROID_TARGET) -clang
libsds-android-arm : ANDROID_ARCH =armv 7a -linux -androideabi
libsds-android-arm : CPU =arm
libsds-android-arm : ABIDIR =armeabi -v 7a
libsds-android-arm : | libsds -android -precheck build deps
# cross-rs target architecture name does not match the one used in android
$( MAKE) build-libsds-for-android-arch ANDROID_ARCH = $( ANDROID_ARCH) CROSS_TARGET = armv7-linux-androideabi CPU = $( CPU) ABIDIR = $( ABIDIR) ANDROID_COMPILER = $( ANDROID_ARCH) $( ANDROID_TARGET) -clang
libsds-android :
$( MAKE) libsds-android-amd64
$( MAKE) libsds-android-arm64
$( MAKE) libsds-android-x86
# This target is disabled because on recent versions of cross-rs complain with the following error
# relocation R_ARM_THM_ALU_PREL_11_0 cannot be used against symbol 'stack_init_trampoline_return'; recompile with -fPIC
# It's likely this architecture is not used so we might just not support it.
# $(MAKE) libsds-android-arm