Makefile 3.77 KB
TEST?=paranoia


TESTDIR=.
LIBSRCDIR=../libs
BUILDDIR=BUILD
SIMDIR=MGSIM

# daifpu_divsqrt           - daifpu with functions div and sqrt in hardware
# daifpu_divonly           - daifpu with function div in hardware
# daifpu_none              - daifpu without div and sqrt
# 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
FPUCFG?=daifpu_divsqrt

# 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)-$(FPUCFG)


PROGS=$(TEST:%=$(BUILDDIR)/$(FPUCFG)$(DSUFFIX)/%$(APPVER).elf)

PROJECTS=$(subst $(APPVER).elf,,$(PROGS))

all: $(PROGS)
	@echo "Tests are built"


$(BUILDDIR)/$(FPUCFG)$(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: $(PROGS)
	make -C tests/$(notdir $(basename $<)) -f Makefile clean TOP="$(TOP)" BUILD="$(TOP)/$(dir $<)" PRJ="$(notdir $(basename $<))" APP="$(TOP)/$<" FPUCFG=$(FPUCFG)

distclean:
	rm -rf $(BUILDDIR) $(SIMDIR)

appclean:
	for t in $(TEST); 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)/$(FPUCFG)$(DSUFFIX)
	@make -C tests/$(notdir $(basename $(PROJECTS))) -f Makefile sim TOP="$(TOP)" BUILD="$(TOP)/$(dir $<)" SIMDIR="$(TOP)/$(SIMDIR)/$(FPUCFG)$(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)/$(FPUCFG)$(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)