-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
67 lines (54 loc) · 1.41 KB
/
makefile
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
#MAKEFLAGS+=--silent
R=64
A=lp64d
SRC=[ampbiv].c
GCC=$(shell env env which gcc-12||gcc-11||which gcc-10||env which gcc-9||env which gcc-8||echo gcc)
RV?=0
O=-O0 -g -UTEST
ifeq ($(RV),1)
O+= -DRV -march=rv$Rgc -mabi=$A
DIS=-m riscv:rv$R
else
DIS=-m i386 -M intel,x86-64
endif
CF=$O -Wall -Wno-deprecated-non-prototype -Wno-unused-variable -Wno-pointer-sign -Wno-strict-aliasing -Wno-parentheses -Wno-unused-function -Wno-misleading-indentation -Wno-unused-value
LF=
OD=objdump
ifeq ($(shell uname),Darwin)
CC=clang
LF+=-pagezero_size 0x4000
CF+=-I$(shell xcrun --show-sdk-path)/usr/include -L$(shell xcrun --show-sdk-path)/usr/lib
CF+= -arch x86_64 -msse
ifeq ($(shell uname -m),arm64)
OD=$(shell which objdump)
endif
endif
ifeq ($(shell uname -m),riscv64)
DIS=-m riscv:rv$R
CC=tcc
endif
OBJDUMP="$(OD) --adjust-vma=0x%llx -b binary $(DIS) -D ref/lnk.bin | tail -n+8"
CF+=-DOBJDUMP=\"$(OBJDUMP)\"
# default: build bcc w/clang and compile t.b
b: cln
clang -o $@ $(SRC) $(CF) $(LF) -Wno-unknown-warning-option
./$@ t.b
# debug t.b
d: b
lldb -b -o run -- ./b t.b
# clang build + reftest
l: cln *.c *.h makefile
clang -o $@ $(SRC) $(CF) $(LF) -Wno-unknown-warning-option
./$@ ref/t.b
# gcc build + reftest
g: cln *.c *.h makefile
$(GCC) -o $@ $(SRC) $(CF) $(LF)
./$@ ref/t.b
# tcc build + reftest
t: cln *.c *.h makefile
tcc -std=c99 $(SRC) $(CF) -O2 -o $@
./$@ ref/t.b
# cleanup
cln:
@rm -f l g t
.PHONY:all cln d