Makefile
3.7 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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
TESTS?=paranoia
TESTDIR=.
LIBSRCDIR=../libs
BUILDDIR=BUILD
SIMDIR=MGSIM
# daifpu_dual_dpsp_divsqrt - DP,SP with div and sqrt functions in hardware
# daifpu_dual_dpsp_divonly - DP,SP with div function in hardware
# daifpu_dual_dpsp_none - DP,SP without div and sqrt
# daifpu_dual_sphp_divsqrt - SP,HP with div and sqrt functions in hardware
# daifpu_dual_sphp_divonly - SP,HP with div function in hardware
# daifpu_dual_sphp_none - SP,HP without div and sqrt
# daifpu_dp_divsqrt - DP with div and sqrt in FPU
# daifpu_dp_divonly - DP with div in FPU
# daifpu_dp_none - DP without div and sqrt
# daifpu_sp_divsqrt - SP with div and sqrt in FPU
# daifpu_sp_divonly - SP with div in FPU
# daifpu_sp_none - SP without div and sqrt
# daifpu_hp_divsqrt - HP with div and sqrt in FPU
# daifpu_hp_divonly - HP with div in FPU
# daifpu_hp_none - HP without div and sqrt
# daifpu_psp_divsqrt - SP,PSP with div and sqrt in FPU
# daifpu_psp_divonly - SP,PSP with div in FPU
# daifpu_psp_none - SP,PSP without div and sqrt
# daifpu_php_divsqrt - HP,PHP with div and sqrt in FPU
# daifpu_php_divonly - HP,PHP with div in FPU
# daifpu_php_none - HP,PHP without div and sqrt
# none - no FPU = all in soft-float (same as option -msoft-float)
# use llvm toolchain
TOOL?=llvm
# use default FPU
ifdef SWARCFG
FPUCFG=
TGTPATH=$(SWARCFG)
else
FPUCFG?=daifpu_divsqrt
TGTPATH=$(FPUCFG)
endif
# default no suffix in build directory
DSUFFIX?=
# user defines (without '-D', e.g. PREC=SINGLE WITHSIM )
USERDEFS?=
# user CFLAGS
UCFLAGS?=
# file ID
ID?=0
#TOOLCHAIN=sparc-daiteq-elf
CPUFREQ?=100000000
UARTBDR?=115200
TOP:=$(shell pwd)
DEFS=-DLEON2 -DCPUFREQ=$(CPUFREQ) -DUARTBDRATE=$(UARTBDR)
CFLAGS=$(DEFS) $(USERDEFS:%=-D%) $(UCFLAGS)
#CFLAGS=-target $(TOOLCHAIN) -Xassembler -Aleon $(DEFS)
#LDFLAGS=-T$(TOP)/scripts/$(LNKSCRIPT)
#include Makefile.fpu
#APPVER=$(subst $e ,_,$(USERDEFS:%=_%))
APPVER=-$(ID)-$(TGTPATH)
PROGS=$(TESTS:%=$(BUILDDIR)/$(TGTPATH)$(DSUFFIX)/%$(APPVER).elf)
PROJECTS=$(subst $(APPVER).elf,,$(PROGS))
all: $(PROGS)
@echo "Tests are built"
$(BUILDDIR)/$(TGTPATH)$(DSUFFIX)/%$(APPVER).elf: $(TOP)/$(TESTDIR)/%
@mkdir -p $(dir $@)include $(dir $@)lib
@make -C $< -f Makefile build TOP="$(TOP)" TOOL=$(TOOL) BUILD="$(TOP)/$(dir $@)" PRJ="$(notdir $<)" TSTDIR="$(TOP)/$(TESTDIR)" APP="$(TOP)/$@" VER="$(APPVER)" CF="$(CFLAGS)" FPUCFG=$(FPUCFG)
clean: $(TOP)/$(TESTDIR)/$(TESTS)
for t in $<; do \
make -C $${t} -f Makefile clean TOP="$(TOP)" BUILD="$(TOP)/$(dir $(PROGS))" PRJ="$(notdir $(basename $(PROGS)))" APP="$(TOP)/$(PROGS)" FPUCFG=$(FPUCFG) ; \
done
distclean:
rm -rf $(BUILDDIR) $(SIMDIR)
appclean:
for t in $(TESTS); do \
rm -rf `find $(BUILDDIR) -mindepth 2 -maxdepth 2 -name $${t}*`; \
done
libclean:
make -C $(LIBSRCDIR)/bsp -f Makefile clean
make -C $(LIBSRCDIR)/builtins -f Makefile clean
make -C $(LIBSRCDIR)/openlibm -f Makefile clean
make -C $(LIBSRCDIR)/softfloat/build/DAITEQ-LEON-LLVM -f Makefile clean
sim: $(PROGS)
@echo "Prepare and run simulation for $<"
@mkdir -p $(SIMDIR)/$(TGTPATH)$(DSUFFIX)
@make -C $(notdir $(basename $(PROJECTS))) -f Makefile sim TOP="$(TOP)" BUILD="$(TOP)/$(dir $<)" SIMDIR="$(TOP)/$(SIMDIR)/$(TGTPATH)$(DSUFFIX)" PRJ="$(notdir $(basename $(PROJECTS)))" TSTDIR="$(TOP)/$(TESTDIR)" APP="$(TOP)/$<" VER="$(APPVER)" CF="$(CFLAGS)" FPUCFG=$(FPUCFG)
inspect: $(PROGS:%.elf=%.fpi)
@echo "All inspections are generated"
$(BUILDDIR)/$(TGTPATH)$(DSUFFIX)/%.fpi:
make -C . -f Makefile.rules $(TOP)/$@ TOP="$(TOP)" BUILD="$(TOP)/$(dir $@)" PRJ="$(notdir $(basename $@))" TSTDIR="$(TOP)/$(TESTDIR)" APP="$(TOP)/$(@:%.fpi=%.elf)" CF="$(CFLAGS)" FPUCFG=$(FPUCFG)