-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·52 lines (29 loc) · 1.07 KB
/
build.sh
File metadata and controls
executable file
·52 lines (29 loc) · 1.07 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
#!/usr/bin/env bash
COMPILER="gcc"
DIR=$(realpath $(dirname $0))
build_core() {
mkdir -p "${DIR}/lib/obj"
for FILE in ${DIR}/src/core/*.c; do
local FILENAME=$(basename ${FILE} .c)
${COMPILER} "${DIR}/src/core/${FILENAME}.c" -fpic -c -I "${DIR}/include/core" -o "${DIR}/lib/obj/${FILENAME}.o"
done
${COMPILER} ${DIR}/lib/obj/core_*.o -shared -o ${DIR}/lib/libcore.so
return $?
}
build_http() {
mkdir -p "${DIR}/lib/obj"
for FILE in ${DIR}/src/http/*.c; do
local FILENAME=$(basename ${FILE} .c)
${COMPILER} "${DIR}/src/http/${FILENAME}.c" -fpic -c -I "${DIR}/include/core" -I "${DIR}/include/http" -o "${DIR}/lib/obj/${FILENAME}.o"
done
${COMPILER} ${DIR}/lib/obj/http_*.o -shared -lcore -L ${DIR}/lib -o ${DIR}/lib/libhttp.so
return $?
}
compile() {
mkdir -p "${DIR}/bin"
${COMPILER} ${DIR}/src/main.c -o ${DIR}/bin/http-server -I ${DIR}/include/core -lcore -I ${DIR}/include/http -lhttp -Wl,-rpath,${DIR}/lib -L ${DIR}/lib
return $?
}
build_core
build_http
compile