mirror of
https://github.com/urbit/shrub.git
synced 2024-12-22 18:31:44 +03:00
99 lines
2.0 KiB
Bash
Executable File
99 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
URBIT_VERSION="0.10.3"
|
|
|
|
deps=" \
|
|
curl gmp sigsegv argon2 ed25519 ent h2o scrypt sni uv murmur3 secp256k1 \
|
|
softfloat3 ncurses ssl crypto z lmdb ge-additions \
|
|
"
|
|
|
|
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 -p)
|
|
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
|
|
;;
|
|
*)
|
|
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
|