# Nim default variables

ifeq (@(TUP_ARCH),arm64)
	NIM_CPU = arm64
endif
ifeq (@(TUP_ARCH),i386)
	NIM_CPU = i386
endif
ifeq (@(TUP_ARCH),x86_64)
	NIM_CPU = amd64
endif

NIM_RELEASE_FLAG = -d:release
	# Drop the relase flag with the line "NIM_RELEASE_FLAG="

NIM_SRC_DIR = src
	# Build everything in this directory

BIN_VERSION = $(GIT_VERSION)
	# Use the git version as the binary package version

&NIMBLE_BINARIES_INCLUDE = binaries.tup
&NIMBLE_PACKAGE_INCLUDE = package.tup

!nim_build = | $(GENODE_DIR)/<pkg-config> $(GENODE_DIR)/<stub> \
|> ^o Nimble %B^ \
	PKG_CONFIG_PATH=`pwd`/$(PKG_CONFIG_DIR) \
	nimble cpp $(NIM_RELEASE_FLAG) $(NIM_FLAGS) \
	--cpu:$(NIM_CPU) --os:genode -d:posix \
	--parallelBuild:1 --passL:-L`pwd`/$(STUB_DIR) -o:%B %f \
|> %B ./<binaries>
	# Nim may invoke the C++ compiler at an arbitrary location,
	# thus the relative $(PKG_CONFIG_DIR) is prepended with `pwd`
