|
root / lang / reef / build.sh
build.sh Bash 62 lines 1.9 KB
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/zsh
# Build script for Reef programming language
set -e
cd "$SRCDIR"

export PATH="$PREFIX/bin:$PATH"

# dune-installed libs live in $PREFIX/lib, not $PREFIX/lib/ocaml
export OCAMLPATH="$PREFIX/lib:${OCAMLPATH:-}"

# Force 64-bit compilation for the runtime
export CC="gcc -m64"
export CXX="g++ -m64"
export CFLAGS="-m64 -O2"
export CXXFLAGS="-m64 -O2"
export LDFLAGS="-m64 $LDFLAGS"

# Library paths (hammerhead BSD layout)
export LD_LIBRARY_PATH="/usr/lib:${LD_LIBRARY_PATH:-}"
export LIBRARY_PATH="/usr/lib:${LIBRARY_PATH:-}"

# Build sequentially — runtime then compiler — to avoid OOM on small VMs
# (gmake all would build both in parallel via -j flag)
echo "Building Reef runtime..."
gmake -j1 runtime
echo "Building Reef compiler..."
gmake -j1 compiler

# Manual install — Hammerhead's /usr/sbin/install (SVR4) breaks PATH
local COMPILER_DIR="$SRCDIR/reef-compiler"
local RUNTIME_DIR="$SRCDIR/reef-runtime"
local RUNTIME_BUILD="$RUNTIME_DIR/build"
local STDLIB_DIR="$SRCDIR/reef-stdlib"
local D="$PKGDIR$PREFIX"

# Compiler binary
mkdir -p "$D/bin"
cp "$COMPILER_DIR/_build/default/bin/reefc.exe" "$D/bin/reefc"
chmod 755 "$D/bin/reefc"

# Runtime headers
mkdir -p "$D/lib/reef/runtime/include"
cp "$RUNTIME_DIR"/include/*.h "$D/lib/reef/runtime/include/"

# Runtime libraries
mkdir -p "$D/lib/reef/runtime/lib"
cp "$RUNTIME_BUILD/libreef_runtime.a" "$D/lib/reef/runtime/lib/"
for lib in libreef_x11.a libreef_tls.a libcrypto.a libssl.a libtls.a; do
    [ -f "$RUNTIME_BUILD/$lib" ] && cp "$RUNTIME_BUILD/$lib" "$D/lib/reef/runtime/lib/"
done

# Standard library
mkdir -p "$D/lib/reef/stdlib"
cp -r "$STDLIB_DIR"/* "$D/lib/reef/stdlib/"
rm -rf "$D/lib/reef/stdlib/docs" 2>/dev/null || true
chmod -R a+rX "$D/lib/reef"

# Config file — substitute @PREFIX@ with actual prefix
mkdir -p "$PKGDIR$SYSCONFDIR/reef"
sed "s|@PREFIX@|$PREFIX|g" "$SRCDIR/etc/reefc.conf.in" > "$PKGDIR$SYSCONFDIR/reef/reefc.conf"
chmod 644 "$PKGDIR$SYSCONFDIR/reef/reefc.conf"