This repository has been archived by the owner on Oct 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·92 lines (71 loc) · 2.32 KB
/
configure
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
84
85
86
87
88
89
90
91
92
#!/bin/sh
set -e
generate_ninja () {
echo -n > build.ninja
cat << EOF >> build.ninja
rule cc
command = $CC -c \$in -O2 -Wall -Werror -Iliblpe -MD -MF \$out.d -o \$out
depfile = \$out.d
description = Compiling C object \$out
rule ar
command = $AR rcs \$out \$in
description = Creating library \$out
rule ld
EOF
if [ "$1" = "wasm32" ]; then
cat << EOF >> build.ninja
command = $WASM_LD \$in -s --no-entry --export-all --allow-undefined -Llib -llpe -o \$out
EOF
else
cat << EOF >> build.ninja
command = $CC \$in -s -Llib -llpe -o \$out
EOF
fi
cat << EOF >> build.ninja
description = Linking executable \$out
rule install
command = install \$in \$out
description = Installing \$out
build build/liblpe/liblpe.o: cc liblpe/liblpe.c
build lib/liblpe.a: ar build/liblpe/liblpe.o
build liblpe: phony lib/liblpe.a
EOF
if [ "$1" != "wasm32" ]; then
cat << EOF >> build.ninja
build $PREFIX/lib/liblpe.a: install lib/liblpe.a
build $PREFIX/include/liblpe.h: install liblpe/liblpe.h
build install-liblpe: phony $PREFIX/lib/liblpe.a $PREFIX/include/liblpe.h
build build/lpe-utils/bitmap2lpe.o: cc lpe-utils/bitmap2lpe.c
build bin/bitmap2lpe: ld build/lpe-utils/bitmap2lpe.o | liblpe
build build/lpe-utils/lpe2bitmap.o: cc lpe-utils/lpe2bitmap.c
build bin/lpe2bitmap: ld build/lpe-utils/lpe2bitmap.o | liblpe
build build/lpe-utils/lpe2bmp.o: cc lpe-utils/lpe2bmp.c
build bin/lpe2bmp: ld build/lpe-utils/lpe2bmp.o | liblpe
build lpe-utils: phony bin/bitmap2lpe bin/lpe2bitmap bin/lpe2bmp
build $PREFIX/bin/bitmap2lpe: install bin/bitmap2lpe
build $PREFIX/bin/lpe2bitmap: install bin/lpe2bitmap
build $PREFIX/bin/lpe2bmp: install bin/lpe2bmp
build install-lpe-utils: phony $PREFIX/bin/bitmap2lpe $PREFIX/bin/lpe2bitmap $PREFIX/bin/lpe2bmp
build install: phony install-liblpe install-lpe-utils
default liblpe lpe-utils
EOF
else
cat << EOF >> build.ninja
build build/lpe-web/wrapper.o: cc lpe-web/wrapper.c
build bin/lpe-web/lpe-web.js: install lpe-web/loader.js
build bin/lpe-web/lpe-web.wasm: ld build/lpe-web/wrapper.o | liblpe
build lpe-web: phony bin/lpe-web/lpe-web.js bin/lpe-web/lpe-web.wasm
default liblpe lpe-web
EOF
fi
}
if [ "$1" = "wasm32" ]; then
CC=${CC:-clang --target=wasm32}
AR=${AR:-llvm-ar}
WASM_LD=${WASM_LD:-wasm-ld}
else
CC=${CC:-gcc}
AR=${AR:-ar}
PREFIX=${PREFIX:-/usr/local}
fi
generate_ninja "$1"