shrub/pkg/urbit/configure
Brendan Hay 016b4a7244
vere: externalise version from configure script
This allows tooling such as ci expressions to easily inspect the
build's current version.
2020-10-27 14:28:05 +01:00

103 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
URBIT_VERSION="$(cat ./version)"
deps=" \
curl gmp sigsegv argon2 ed25519 ent h2o scrypt uv murmur3 secp256k1 \
softfloat3 ssl crypto z lmdb ge-additions aes_siv pthread \
"
headers=" \
ivory.h ca-bundle.h \
"
echo '#pragma once' >include/config.h
defmacro () {
echo "#define $1 $2" >>include/config.h
}
defmacro URBIT_VERSION "\"$URBIT_VERSION\""
[ -n "$MEMORY_DEBUG" ] && defmacro U3_MEMORY_DEBUG 1
[ -n "$MEMORY_LOG" ] && defmacro U3_MEMORY_LOG 1
[ -n "$CPU_DEBUG" ] && defmacro U3_CPU_DEBUG 1
[ -n "$EVENT_TIME_DEBUG" ] && defmacro U3_EVENT_TIME_DEBUG 1
if [ -n "${HOST-}" ]
then os=$(sed 's$^[^-]*-\([^-]*\)-.*$\1$' <<< "$HOST")
cpu=$(sed 's$-.*$$' <<< ${HOST})
else os=$(uname -s)
cpu=$(uname -m)
fi
case $(tr A-Z a-z <<< $cpu) in
unknown)
defmacro U3_OS_ENDIAN_little 1
;;
i386)
defmacro U3_OS_ENDIAN_little 1
;;
i686)
defmacro U3_OS_ENDIAN_little 1
;;
x86_64)
defmacro U3_OS_ENDIAN_little 1
;;
aarch64)
defmacro U3_OS_ENDIAN_little 1
defmacro U3_CPU_aarch64 1
;;
*)
echo "Unknown or unsupported CPU: '$cpu'" >&2
exit 1
;;
esac
# TODO Determine if the target cpu is little or big endian.
case $(tr A-Z a-z <<< $os) in
*linux*)
defmacro U3_OS_linux 1
;;
*darwin*)
defmacro U3_OS_osx 1
;;
*apple*)
defmacro U3_OS_osx 1
;;
*freebsd*)
defmacro U3_OS_bsd 1
osdeps="kvm"
;;
*openbsd*)
defmacro U3_OS_bsd 1
;;
*)
echo "Unknown or unsupported OS: '$os'" >&2
exit 1
;;
esac
for dep in ${osdeps-} $deps
do LDFLAGS="${LDFLAGS-} -l$dep"
${PKG_CONFIG-pkg-config} --cflags --libs $dep 2>/dev/null || true
done
for header in $headers
do LDFLAGS="${LDFLAGS-} -I$header"
done
cat >config.mk <<EOF
CFLAGS := ${CFLAGS-} -funsigned-char -ffast-math -std=gnu99
LDFLAGS := $LDFLAGS
CC := ${CC-cc}
EOF
echo == config.mk == >&2
cat config.mk >&2
echo == include/config.h == >&2
cat include/config.h >&2