forked from andrewchambers/janetsh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.do
executable file
·81 lines (72 loc) · 1.95 KB
/
default.do
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
#! /bin/sh
set -eu
exec 1>&2
target="$1"
out="$3"
if ! test -d ./support
then
echo "please build from the janetsh base directory."
exit 1
fi
if ! test -f ./config.inc
then
echo "please run configure first."
exit 1
fi
. ./config.inc
shlib_csrcs="src/shlib/shlib.c"
shlib_chdrs=""
if test "$WITH_READNOISE" = "y"
then
shlib_csrcs="$(echo $shlib_csrcs src/readnoise/*.c)"
shlib_chdrs="$(echo $shlib_chdrs src/readnoise/*.h)"
fi
shlib_objs="$(echo "$shlib_csrcs" | sed 's/\.c/\.o/g')"
v () {
echo $@
$@
}
case $target in
all)
redo-ifchange src/shlib.so
;;
install)
redo-ifchange all
mkdir -p "$PREFIX/bin/"
mkdir -p "$PREFIX/lib/janetsh"
v install ./src/shlib.so "$PREFIX/lib/janetsh/"
v install ./src/*.janet "$PREFIX/lib/janetsh/"
v install ./src/janetsh-posix-wrapper "$PREFIX/bin"
echo "writing $PREFIX/bin/janetsh"
head -n 1 ./src/janetsh > "$PREFIX/bin/janetsh"
echo "(array/concat module/paths [" >> "$PREFIX/bin/janetsh"
echo " [\"$PREFIX/lib/janetsh/:all:.janet\" :source]" >> "$PREFIX/bin/janetsh"
echo " [\"$PREFIX/lib/janetsh/:all:.:native:\" :native]])" >> "$PREFIX/bin/janetsh"
tail -n +2 ./src/janetsh >> "$PREFIX/bin/janetsh"
v chmod +x "$PREFIX/bin/janetsh"
;;
uninstall)
v rm -rf "$PREFIX/lib/janetsh"
v rm -f "$PREFIX/bin/janetsh"
;;
format)
v clang-format "-style=file" -i $(find ./src/ -name "*.c" -or -name "*.h")
;;
src/readnoise/*.o)
cfile=src/readnoise/$(basename $target .o).c
redo-ifchange $cfile $shlib_chdrs
v $CC -fPIC $READLINE_CFLAGS $CFLAGS -c -o $out $cfile
;;
src/shlib/*.o)
cfile=src/shlib/$(basename $target .o).c
redo-ifchange $cfile $shlib_chdrs
v $CC -fPIC $JANET_HEADER_CFLAGS $READLINE_CFLAGS $CFLAGS -c -o $out $cfile
;;
src/shlib.so)
redo-ifchange $shlib_objs
v $CC -shared $shlib_objs $LDFLAGS $READLINE_LDFLAGS -o $out
;;
*)
echo "don't know how to build $target"
exit 1 ;;
esac