-
Notifications
You must be signed in to change notification settings - Fork 1
/
make.sh
98 lines (76 loc) · 3.4 KB
/
make.sh
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
#!/bin/bash
CC="gcc -pthread"
F=("-g" "-Iinclude" "-DDCC_PRIVATE_API")
LF=""
out_bin="bin/dcc"
obj_path="build/dcc"
CC_DCC="/cygdrive/e/c/dcc/dcc/bin/dcc.exe"
CC_DDC="/cygdrive/e/c/dcc/dcc/bin/ddc.exe"
if [ -f "$CC_DDC" ]; then
CC="$CC_DDC";
obj_path="build/ddd"
out_bin="bin/ddd.exe"
F+=("-D_VA_LIST_DEFINED")
F+=("-D__SSE2__")
F+=("-ID:/cygwin32/usr/include/w32api")
elif [ -f "$CC_DCC" ]; then
CC="$CC_DCC";
obj_path="build/ddc"
out_bin="bin/ddc.exe"
F+=("-D_VA_LIST_DEFINED")
F+=("-D__SSE2__")
F+=("-ID:/cygwin32/usr/include/w32api")
else
LF="$LF -ldl"
fi
build() { echo "$obj_path/$1"; }
out() { echo "$(build $1).o"; }
dep() { echo "$(build $1).d"; }
object_list=()
src_changed() {
inf="$1"
ouf="$(out $(basename "$inf"))"
dpf="$(dep $(basename "$inf"))"
[ -f "$ouf" ] || return 1
[ -f "$dpf" ] || return 1
ddt=`cat "$dpf" | tr -d '\\\\\n'`
first=1
for dep in $ddt; do
if [ "$first" == 1 ]; then first=0; else
if [ "$dep" -nt "$ouf" ]; then
echo "Dependency has changed:"
echo -e "\tinput file: $inf"
echo -e "\tdepends on: $dep"
return 1
fi
fi
done
return 0
}
src() {
for inf in $*; do
ouf="$(out $(basename "$inf"))"
object_list+=("$ouf")
if ! src_changed "$inf"; then
dpf="$(dep $(basename "$inf"))"
echo "Compiling: '$inf'"
echo $CC "${F[@]}" -MMD -MF "$dpf" -c -o "$ouf" "$inf" || exit $?
$CC "${F[@]}" -MMD -MF "$dpf" -c -o "$ouf" "$inf" || exit $?
else
echo "Unchanged: '$inf'"
fi
done
}
mkdir -p $(build "") || exit $?
# Compile DCC source files
src src/*.c
src src/dcc/*.c
src src/drt/*.c
src lib/src/a2l/addr2line-common.c
echo $CC -g -o "$out_bin" "${object_list[@]}" $LF
$CC -g -o "$out_bin" "${object_list[@]}" $LF
# -g -o ../bin/ddc.exe ../build/ddc/main.c.o ../build/ddc/addr2line.c.o ../build/ddc/assembler.c.o ../build/ddc/cmd-help.c.o ../build/ddc/cmd.c.o ../build/ddc/common.c.o ../build/ddc/compiler.c.o ../build/ddc/fundecl.c.o ../build/ddc/gen.c.o ../build/ddc/lexer.c.o ../build/ddc/linker.c.o ../build/ddc/preprocessor.c.o ../build/ddc/tpp-wrapper.c.o ../build/ddc/type.c.o ../build/ddc/unit-debug.c.o ../build/ddc/unit-export.c.o ../build/ddc/unit-import.c.o ../build/ddc/unit-merge.c.o ../build/ddc/unit.c.o ../build/ddc/vstack-ext.c.o ../build/ddc/vstack.c.o ../build/ddc/x86_util-instrlen.c.o ../build/ddc/addr2line-common.c.o
# -g -I../include -DDCC_PRIVATE_API -D_VA_LIST_DEFINED -D__SSE2__ -ID:/cygwin32/usr/include/w32api -MMD -MF ../build/ddc/assembler.c.d -c -o ../build/ddc/assembler.c.o ../src/dcc/assembler.c
# -g -I../include -DDCC_PRIVATE_API -D_VA_LIST_DEFINED -D__SSE2__ -ID:/cygwin32/usr/include/w32api -MMD -MF ../build/ddc/common.c.d -c -o ../build/ddc/common.c.o ../src/dcc/common.c
# -g -I../include -DDCC_PRIVATE_API -DDCC_PRIVATE_API -D_VA_LIST_DEFINED -D__SSE2__ -ID:/cygwin32/usr/include/w32api -MMD -MF ../build/ddc/main.c.d -c -o ../build/ddc/main.c.o ../src/main.c
# -g -o bin/ddc.exe build/ddc/main.c.o build/ddc/addr2line.c.o build/ddc/assembler.c.o build/ddc/cmd-help.c.o build/ddc/cmd.c.o build/ddc/common.c.o build/ddc/compiler.c.o build/ddc/fundecl.c.o build/ddc/gen.c.o build/ddc/lexer.c.o build/ddc/linker.c.o build/ddc/preprocessor.c.o build/ddc/tpp-wrapper.c.o build/ddc/type.c.o build/ddc/unit-debug.c.o build/ddc/unit-export.c.o build/ddc/unit-import.c.o build/ddc/unit-merge.c.o build/ddc/unit.c.o build/ddc/vstack-ext.c.o build/ddc/vstack.c.o build/ddc/x86_util-instrlen.c.o build/ddc/addr2line-common.c.o