-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
78 lines (58 loc) · 1.67 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
68
69
70
71
72
73
74
75
76
77
78
CPPFLAGS += -Istackman $(PLATFORMFLAGS)
CFLAGS += -fPIC -g $(PLATFORMFLAGS)
CXXFLAGS += -fPIC -g $(PLATFORMFLAGS)
LDFLAGS += -L$(LIB) -g $(PLATFORMFLAGS)
# add flag to disable Intel CET
NO_CET := $(shell ./disable_cet $(CC))
CFLAGS += $(NO_CET)
CXXFLAGS += $(NO_CET)
OLDCC := $(CC)
ifdef PLATFORM_PREFIX
CC = $(PLATFORM_PREFIX)-gcc
CXX = $(PLATFORM_PREFIX)-g++
LD = $(PLATFORM_PREFIX)-ld
AR = $(PLATFORM_PREFIX)-ar
endif
# run c preprocessor with any cflags to get cross compilation result, then run regular compile in native
ABI := $(shell sh tools/abiname.sh "$(CC)" "$(CFLAGS)")
ifndef ABI
$(error Could not determine platform)
endif
LIB := lib/$(ABI)
all: $(LIB)/libstackman.a
# echo the abiname, for build tools.
.PHONY: abiname
abiname:
@echo $(ABI)
obj = stackman/stackman.o stackman/stackman_s.o
$(LIB)/libstackman.a: lib $(obj)
$(info ABI is $(ABI))
$(AR) $(ARFLAGS) -s $@ $(obj)
.PHONY: lib clean
lib:
mkdir -p $(LIB) bin
clean:
rm -f stackman/*.o tests/*.o
rm -f bin/*
rm -rf tmp tools/tmp
DEBUG = #-DDEBUG_DUMP
.PHONY: test tests
test: tests
$(EMULATOR) bin/test
$(EMULATOR) bin/test_cc
$(EMULATOR) bin/test_static
$(EMULATOR) bin/test_asm
@echo "*** All test suites passed ***"
tests: bin/test
tests: bin/test_cc
tests: bin/test_static
tests: bin/test_asm
tests: LDLIBS := -lstackman
bin/test: tests/test.o $(LIB)/libstackman.a
$(CC) $(LDFLAGS) -static -o $@ $< ${DEBUG} $(LDLIBS)
bin/test_cc: tests/test_cc.o $(LIB)/libstackman.a
$(CXX) $(LDFLAGS) -static -o $@ $< ${DEBUG} $(LDLIBS)
bin/test_static: tests/test_static.o
$(CC) $(LDFLAGS) -static -o $@ $^ ${DEBUG}
bin/test_asm: tests/test_asm.o tests/test_asm_s.o
$(CC) $(LDFLAGS) -static -o $@ $^ ${DEBUG}