Repository navigation
Expand file tree
/
Copy pathbuild.sh
More file actions
83 lines (73 loc) · 1.99 KB
/
Copy pathbuild.sh
File metadata and controls
83 lines (73 loc) · 1.99 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# Convenience wrapper around the docker-based Makefile build.
#
# ./build.sh # build library + examples + tests
# ./build.sh clean # clean
# ./build.sh lib # library only
# ./build.sh tests # the test runner only
#
# Requires docker; pulls walkero/amigagccondocker:os4-gcc11 on first use.
set -euo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
cd "$HERE"
mkdir -p obj bin
CC="./docker-cc gcc"
SDK_INCLUDE=/sdk/include/include_h
SDK_NETINC=/sdk/include/netinclude
SDK_LOCAL=/sdk/local/clib4
CFLAGS=(-mcrt=clib4 -std=gnu11 -Wall -Wextra -Wno-unused-parameter
-O2 -g -fPIC
-Iinclude -Isrc
-I$SDK_INCLUDE -I$SDK_NETINC -I$SDK_LOCAL/include
'-DCLAUDELIB_VERSION="53.1"')
LIB_SOURCES=(library iface_main config conversation ask stream
transport markdown rexx_port tools cjson_mini)
LIB_OBJS=()
target=${1:-all}
case "$target" in
clean)
rm -rf obj bin
exit 0
;;
esac
build_lib() {
local src
for src in "${LIB_SOURCES[@]}"; do
echo "CC src/${src}.c"
$CC "${CFLAGS[@]}" -c "src/${src}.c" -o "obj/${src}.o"
LIB_OBJS+=("obj/${src}.o")
done
echo "LD bin/claude.library"
$CC -mcrt=clib4 -nostartfiles -shared \
-o bin/claude.library "${LIB_OBJS[@]}" \
-L"$SDK_LOCAL/lib" -lcurl -lssl -lcrypto
}
build_consumer() {
local name=$1 src=$2
echo "CC ${src} -> bin/${name}"
$CC "${CFLAGS[@]}" -o "bin/${name}" "$src" -lauto
}
case "$target" in
all)
build_lib
build_consumer claudesh examples/claudesh/main.c
build_consumer test_claude_library tests/test_claude_library/main.c
;;
lib)
build_lib
;;
examples)
build_lib
build_consumer claudesh examples/claudesh/main.c
;;
tests)
build_lib
build_consumer test_claude_library tests/test_claude_library/main.c
;;
*)
echo "build.sh: unknown target '$target'" >&2
echo "valid targets: all, lib, examples, tests, clean" >&2
exit 2
;;
esac
echo "OK"