summaryrefslogtreecommitdiff
path: root/compile_make.sh
blob: 78bc6c0a01036161006ac2c5c9a883a398384bf1 (plain)
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
#!/bin/sh -e

defined() {
    [ x"$2" = x ] && echo $1 is undefined && exit 1
    echo $1 = $2
}

pexec() {
    echo $@
    $@
}

defined CC "$CC"
defined LD "$LD"

arch=x86_64

gcc_prefix=$(dirname $(gcc -print-libgcc-file-name))

tool_cflags="-Wall -nostdinc -Wno-main \
		-ffreestanding -fno-pic -fno-stack-protector \
		-Igenerated/include -Iarch/$arch \
		-I${gcc_prefix}/include -Iarch/generic"

cflags="$tool_cflags $CFLAGS"

pexec $CC $cflags -c -o tools/common.o tools/common.c
pexec $CC $cflags -c -o tools/make.o tools/make.c
pexec $LD -nostdlib -o tools/make tools/make.o tools/common.o