2018-07-03 15:54:10 +02:00
|
|
|
######################################
|
|
|
|
# target
|
|
|
|
######################################
|
2022-10-10 20:15:22 +02:00
|
|
|
TARGET = DB48X
|
2018-07-03 15:54:10 +02:00
|
|
|
|
|
|
|
######################################
|
|
|
|
# building variables
|
|
|
|
######################################
|
|
|
|
ifdef DEBUG
|
2022-10-10 20:15:22 +02:00
|
|
|
OPT=debug
|
|
|
|
else
|
|
|
|
OPT=release
|
2018-07-03 15:54:10 +02:00
|
|
|
endif
|
|
|
|
|
2022-10-11 18:25:00 +02:00
|
|
|
# Warning: macOSX only
|
|
|
|
MOUNTPOINT=/Volumes/DM42/
|
|
|
|
EJECT=hdiutil eject $(MOUNTPOINT)
|
|
|
|
|
|
|
|
|
2022-10-16 13:18:19 +02:00
|
|
|
#==============================================================================
|
|
|
|
#
|
|
|
|
# Primary build rules
|
|
|
|
#
|
|
|
|
#==============================================================================
|
|
|
|
|
|
|
|
# default action: build all
|
|
|
|
all: $(TARGET).pgm help/$(TARGET).html
|
2022-10-26 02:03:59 +02:00
|
|
|
install: all help/$(TARGET).md
|
2022-10-26 07:51:23 +02:00
|
|
|
(tar cf - $(TARGET).pgm help/$(TARGET).md | \
|
2022-10-26 02:03:59 +02:00
|
|
|
(cd $(MOUNTPOINT) && tar xvf -)) && $(EJECT)
|
|
|
|
sim: sim/simulator.mak recorder/config.h help/$(TARGET).md .ALWAYS
|
2022-10-16 13:18:19 +02:00
|
|
|
cd sim; make -f $(<F)
|
|
|
|
sim/simulator.mak: sim/simulator.pro
|
|
|
|
cd sim; qmake $(<F) -o $(@F) CONFIG+=$(OPT)
|
2022-10-24 08:46:30 +02:00
|
|
|
ttf2font: tools/ttf2fonts/ttf2fonts
|
|
|
|
tools/ttf2fonts/ttf2fonts: tools/ttf2font/ttf2font.cpp tools/ttf2font/Makefile
|
|
|
|
cd tools/ttf2font; $(MAKE)
|
|
|
|
|
2022-10-27 23:33:33 +02:00
|
|
|
#BASE_FONT=fonts/C43StandardFont.ttf
|
|
|
|
BASE_FONT=fonts/FogSans-ddd.ttf
|
|
|
|
fonts/EditorFont.cc: ttf2font $(BASE_FONT)
|
2022-11-07 08:13:22 +01:00
|
|
|
tools/ttf2font/ttf2font -s 48 -S 80 -y -10 EditorFont $(BASE_FONT) $@
|
2022-10-27 23:33:33 +02:00
|
|
|
fonts/StackFont.cc: ttf2font $(BASE_FONT)
|
2022-11-07 08:13:22 +01:00
|
|
|
tools/ttf2font/ttf2font -s 32 -S 80 -y -8 StackFont $(BASE_FONT) $@
|
2022-10-27 23:33:33 +02:00
|
|
|
fonts/HelpFont.cc: ttf2font $(BASE_FONT)
|
2022-11-07 08:13:22 +01:00
|
|
|
tools/ttf2font/ttf2font -s 18 -S 80 -y -3 HelpFont $(BASE_FONT) $@
|
2022-10-27 23:33:33 +02:00
|
|
|
help/$(TARGET).md: $(wildcard doc/*.md doc/calc-help/*.md doc/commands/*.md)
|
2022-10-26 02:03:59 +02:00
|
|
|
cat $^ > $@
|
2022-10-16 13:18:19 +02:00
|
|
|
|
|
|
|
debug-%:
|
|
|
|
$(MAKE) $* OPT=debug
|
|
|
|
release-%:
|
|
|
|
$(MAKE) $* OPT=release
|
|
|
|
|
|
|
|
|
2018-07-03 15:54:10 +02:00
|
|
|
#######################################
|
|
|
|
# pathes
|
|
|
|
#######################################
|
|
|
|
# Build path
|
2022-10-10 20:15:22 +02:00
|
|
|
BUILD = build/$(OPT)
|
2018-07-03 15:54:10 +02:00
|
|
|
|
|
|
|
# Path to aux build scripts (including trailing /)
|
|
|
|
# Leave empty for scripts in PATH
|
2022-10-10 20:15:22 +02:00
|
|
|
TOOLS = tools
|
2018-07-03 15:54:10 +02:00
|
|
|
|
|
|
|
######################################
|
|
|
|
# System sources
|
|
|
|
######################################
|
|
|
|
C_INCLUDES += -Idmcp
|
|
|
|
C_SOURCES += dmcp/sys/pgm_syscalls.c
|
|
|
|
ASM_SOURCES = dmcp/startup_pgm.s
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
# Custom section
|
|
|
|
#######################################
|
|
|
|
|
|
|
|
# Includes
|
2022-10-22 13:02:24 +02:00
|
|
|
C_INCLUDES += -Isrc/dm42 -Isrc -Iinc
|
2018-07-03 15:54:10 +02:00
|
|
|
|
|
|
|
# C sources
|
2022-10-16 13:18:19 +02:00
|
|
|
C_SOURCES +=
|
2018-07-03 15:54:10 +02:00
|
|
|
|
2022-10-14 13:21:24 +02:00
|
|
|
# Floating point sizes
|
|
|
|
DECIMAL_SIZES=32 64
|
|
|
|
DECIMAL_SOURCES=$(DECIMAL_SIZES:%=src/decimal-%.cc)
|
|
|
|
|
2018-07-03 15:54:10 +02:00
|
|
|
# C++ sources
|
2022-10-14 13:21:24 +02:00
|
|
|
CXX_SOURCES += \
|
2022-10-22 13:02:24 +02:00
|
|
|
src/dm42/target.cc \
|
2022-10-31 07:15:32 +01:00
|
|
|
src/dm42/sysmenu.cc \
|
|
|
|
src/dm42/main.cc \
|
2022-10-14 21:47:32 +02:00
|
|
|
src/input.cc \
|
2022-10-15 22:22:35 +02:00
|
|
|
src/stack.cc \
|
2022-10-14 13:21:24 +02:00
|
|
|
src/util.cc \
|
|
|
|
src/settings.cc \
|
|
|
|
src/runtime.cc \
|
|
|
|
src/object.cc \
|
2022-10-17 13:50:47 +02:00
|
|
|
src/command.cc \
|
2022-10-14 13:21:24 +02:00
|
|
|
src/integer.cc \
|
|
|
|
src/decimal128.cc \
|
|
|
|
$(DECIMAL_SOURCES) \
|
2022-10-30 11:20:19 +01:00
|
|
|
src/text.cc \
|
2022-10-17 19:55:21 +02:00
|
|
|
src/symbol.cc \
|
2022-10-18 00:32:05 +02:00
|
|
|
src/algebraic.cc \
|
2022-10-23 01:16:26 +02:00
|
|
|
src/arithmetic.cc \
|
Connect the most common scientific functions
Connect functions like sin, cos, tan, log, etc.
The bad news is that the bid128 functions take _a lot_ of space.
I thought that all of the Intel decimal floating point library was put in the
QSPI, but apparently, only some tables are. The total of the Intel
floating-point code is roughly 1.49M, the code in the calculator roughly 423K.
The code is rather on the large-ish side, with some large chunks of code that
are really hard to explain, like bid128_pow taking a whopping 42K, which is over
5% of my total memory budget (unless I want to take over the QSPI).
00000004 T __bid128_rem
00000024 T __bid128_from_uint64
00000048 T __bid128_from_int64
00000062 T __bid128_isInf
00000082 T __bid128_copySign
00000104 T __bid128_fma
00000108 T __bid128_sub
00000180 T __bid128_isZero
00000348 T __bid128_atan
00000348 T __bid128_tanh
00000352 T __bid128_erf
00000376 T __bid32_to_bid128
00000404 T __bid128_expm1
00000516 T __bid128_asin
00000544 T __bid128_log1p
00000572 T __bid64_to_bid128
00000576 T __bid128_acos
00000604 T __bid128_cbrt
00000608 T __bid128_mul
00000608 T __bid128_tgamma
00000640 T __bid128_exp
00000648 T __bid128_asinh
00000656 T __bid128_log
00000668 T __bid128_log2
00000676 T __bid128_exp2
00000684 T __bid128_log10
00000768 T __bid128_cosh
00000784 T __bid128_atanh
00000784 r bid_coefflimits_bid128
00000880 T __bid128_sinh
00000900 T __bid128_acosh
00000968 T __bid128_exp10
00001016 T __bid128_lgamma
00001048 T __bid128_erfc
00001628 T __bid128_class
00001752 T __bid128_round_integral_zero
00002004 T __bid128_quiet_equal
00002176 T __bid128_round_integral_nearest_even
00002740 T __bid128_to_string
00003208 T __bid128_to_int32_rnint
00003680 T __bid128_tan
00003708 T __bid128_cos
00003728 T __bid128_to_int32_xrnint
00003736 T __bid128_quiet_greater
00003740 T __bid128_sin
00003748 T __bid128_quiet_less
00003748 T __bid128_quiet_less_equal
00004400 T __bid128_hypot
00004440 T __bid128_to_binary128
00004700 T bid128_to_binary128_2part
00004864 T __bid128_to_bid32
00005484 T __bid128_to_bid64
00005876 T __bid128_fmod
00008430 T __bid128_sqrt
00008592 T __bid128_from_string
00010140 T __binary128_to_bid128
00017348 T __bid128_div
00024390 T __bid128_add
00029524 t bid128_ext_fma
00042058 T __bid128_pow
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2022-10-28 01:19:53 +02:00
|
|
|
src/functions.cc \
|
2022-10-30 23:48:28 +01:00
|
|
|
src/variables.cc \
|
2022-11-02 13:02:48 +01:00
|
|
|
src/catalog.cc \
|
2022-10-31 08:45:36 +01:00
|
|
|
src/menu.cc \
|
2022-10-29 13:23:44 +02:00
|
|
|
src/list.cc \
|
2022-11-04 00:36:00 +01:00
|
|
|
src/loops.cc \
|
2022-10-24 08:46:30 +02:00
|
|
|
src/font.cc \
|
2022-10-27 23:33:33 +02:00
|
|
|
fonts/HelpFont.cc \
|
2022-10-24 20:05:01 +02:00
|
|
|
fonts/EditorFont.cc \
|
|
|
|
fonts/StackFont.cc
|
|
|
|
|
2022-10-24 08:46:30 +02:00
|
|
|
|
2022-10-12 09:28:36 +02:00
|
|
|
|
2022-10-14 13:21:24 +02:00
|
|
|
# Generate the sized variants of decimal128
|
|
|
|
src/decimal-%.cc: src/decimal128.cc src/decimal-%.h
|
|
|
|
sed -e s/decimal128.h/decimal-$*.h/g -e s/128/$*/g $< > $@
|
|
|
|
src/decimal-%.h: src/decimal128.h
|
|
|
|
sed -e s/128/$*/g -e s/leb$*/leb128/g $< > $@
|
2018-07-03 15:54:10 +02:00
|
|
|
|
|
|
|
# ASM sources
|
|
|
|
#ASM_SOURCES += src/xxx.s
|
|
|
|
|
|
|
|
# Additional defines
|
|
|
|
#C_DEFS += -DXXX
|
|
|
|
|
|
|
|
# Intel library related defines
|
2022-10-10 20:15:22 +02:00
|
|
|
DEFINES += \
|
|
|
|
DECIMAL_CALL_BY_REFERENCE \
|
|
|
|
DECIMAL_GLOBAL_ROUNDING \
|
|
|
|
DECIMAL_GLOBAL_ROUNDING_ACCESS_FUNCTIONS \
|
|
|
|
DECIMAL_GLOBAL_EXCEPTION_FLAGS \
|
|
|
|
DECIMAL_GLOBAL_EXCEPTION_FLAGS_ACCESS_FUNCTIONS \
|
|
|
|
$(DEFINES_$(OPT))
|
|
|
|
DEFINES_debug=DEBUG
|
|
|
|
DEFINES_release=RELEASE
|
|
|
|
|
|
|
|
C_DEFS += $(DEFINES:%=-D%)
|
2018-07-03 15:54:10 +02:00
|
|
|
|
|
|
|
# Libraries
|
|
|
|
LIBS += lib/gcc111libbid_hard.a
|
|
|
|
|
2022-10-16 10:20:10 +02:00
|
|
|
# Recorder and dependencies
|
|
|
|
recorder/config.h: recorder/recorder.h recorder/Makefile
|
|
|
|
cd recorder && $(MAKE)
|
|
|
|
$(BUILD)/recorder.o $(BUILD)/recorder_ring.o: recorder/config.h
|
|
|
|
|
2018-07-03 15:54:10 +02:00
|
|
|
# ---
|
|
|
|
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
# binaries
|
|
|
|
#######################################
|
|
|
|
CC = arm-none-eabi-gcc
|
|
|
|
CXX = arm-none-eabi-g++
|
|
|
|
AS = arm-none-eabi-gcc -x assembler-with-cpp
|
|
|
|
OBJCOPY = arm-none-eabi-objcopy
|
|
|
|
AR = arm-none-eabi-ar
|
|
|
|
SIZE = arm-none-eabi-size
|
|
|
|
HEX = $(OBJCOPY) -O ihex
|
|
|
|
BIN = $(OBJCOPY) -O binary -S
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
# CFLAGS
|
|
|
|
#######################################
|
|
|
|
# macros for gcc
|
|
|
|
AS_DEFS =
|
|
|
|
C_DEFS += -D__weak="__attribute__((weak))" -D__packed="__attribute__((__packed__))"
|
|
|
|
AS_INCLUDES =
|
|
|
|
|
|
|
|
|
|
|
|
CPUFLAGS += -mthumb -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
|
|
|
|
|
|
|
# compile gcc flags
|
2022-10-10 20:15:22 +02:00
|
|
|
ASFLAGS = $(CPUFLAGS) $(AS_DEFS) $(AS_INCLUDES) $(ASFLAGS_$(OPT)) -Wall -fdata-sections -ffunction-sections
|
|
|
|
CFLAGS = $(CPUFLAGS) $(C_DEFS) $(C_INCLUDES) $(CFLAGS_$(OPT)) -Wall -fdata-sections -ffunction-sections
|
2018-07-03 15:54:10 +02:00
|
|
|
CFLAGS += -Wno-misleading-indentation
|
2022-10-10 20:15:22 +02:00
|
|
|
DBGFLAGS = -g
|
2018-07-03 15:54:10 +02:00
|
|
|
|
2022-10-10 20:15:22 +02:00
|
|
|
CFLAGS_debug += -O0 -DDEBUG
|
2022-10-28 08:51:14 +02:00
|
|
|
CFLAGS_release += -O4 -Os
|
2018-07-03 15:54:10 +02:00
|
|
|
|
|
|
|
CFLAGS += $(DBGFLAGS)
|
|
|
|
LDFLAGS += $(DBGFLAGS)
|
|
|
|
|
|
|
|
# Generate dependency information
|
|
|
|
CFLAGS += -MD -MP -MF .dep/$(@F).d
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
# LDFLAGS
|
|
|
|
#######################################
|
|
|
|
# link script
|
2022-10-10 20:15:22 +02:00
|
|
|
LDSCRIPT = src/stm32_program.ld
|
2018-07-03 15:54:10 +02:00
|
|
|
LIBDIR =
|
2022-10-10 20:15:22 +02:00
|
|
|
LDFLAGS = $(CPUFLAGS) -T$(LDSCRIPT) $(LIBDIR) $(LIBS) \
|
|
|
|
-Wl,-Map=$(BUILD)/$(TARGET).map,--cref \
|
|
|
|
-Wl,--gc-sections \
|
|
|
|
-Wl,--wrap=_malloc_r
|
2018-07-03 15:54:10 +02:00
|
|
|
|
|
|
|
|
2022-10-10 20:15:22 +02:00
|
|
|
|
2018-07-03 15:54:10 +02:00
|
|
|
|
|
|
|
#######################################
|
|
|
|
# build the application
|
|
|
|
#######################################
|
|
|
|
# list of objects
|
2022-10-10 20:15:22 +02:00
|
|
|
OBJECTS = $(addprefix $(BUILD)/,$(notdir $(C_SOURCES:.c=.o)))
|
2018-07-03 15:54:10 +02:00
|
|
|
vpath %.c $(sort $(dir $(C_SOURCES)))
|
|
|
|
# C++ sources
|
2022-10-10 20:15:22 +02:00
|
|
|
OBJECTS += $(addprefix $(BUILD)/,$(notdir $(CXX_SOURCES:.cc=.o)))
|
2018-07-03 15:54:10 +02:00
|
|
|
vpath %.cc $(sort $(dir $(CXX_SOURCES)))
|
|
|
|
# list of ASM program objects
|
2022-10-10 20:15:22 +02:00
|
|
|
OBJECTS += $(addprefix $(BUILD)/,$(notdir $(ASM_SOURCES:.s=.o)))
|
2018-07-03 15:54:10 +02:00
|
|
|
vpath %.s $(sort $(dir $(ASM_SOURCES)))
|
|
|
|
|
2022-10-22 11:52:12 +02:00
|
|
|
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti -Wno-packed-bitfield-compat
|
2018-07-03 15:54:10 +02:00
|
|
|
|
2022-10-10 20:15:22 +02:00
|
|
|
$(BUILD)/%.o: %.c Makefile | $(BUILD)
|
|
|
|
$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD)/$(notdir $(<:.c=.lst)) $< -o $@
|
2018-07-03 15:54:10 +02:00
|
|
|
|
2022-10-10 20:15:22 +02:00
|
|
|
$(BUILD)/%.o: %.cc Makefile | $(BUILD)
|
|
|
|
$(CXX) -c $(CXXFLAGS) -Wa,-a,-ad,-alms=$(BUILD)/$(notdir $(<:.cc=.lst)) $< -o $@
|
2018-07-03 15:54:10 +02:00
|
|
|
|
2022-10-10 20:15:22 +02:00
|
|
|
$(BUILD)/%.o: %.s Makefile | $(BUILD)
|
2018-07-03 15:54:10 +02:00
|
|
|
$(AS) -c $(CFLAGS) $< -o $@
|
|
|
|
|
2022-10-10 20:15:22 +02:00
|
|
|
$(BUILD)/$(TARGET).elf: $(OBJECTS) Makefile
|
2018-07-03 15:54:10 +02:00
|
|
|
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
|
2022-10-10 20:15:22 +02:00
|
|
|
$(TARGET).pgm: $(BUILD)/$(TARGET).elf Makefile
|
|
|
|
$(OBJCOPY) --remove-section .qspi -O ihex $< $(BUILD)/$(TARGET)_flash.hex
|
|
|
|
$(OBJCOPY) --remove-section .qspi -O binary $< $(BUILD)/$(TARGET)_flash.bin
|
|
|
|
$(OBJCOPY) --only-section .qspi -O ihex $< $(BUILD)/$(TARGET)_qspi.hex
|
|
|
|
$(OBJCOPY) --only-section .qspi -O binary $< $(BUILD)/$(TARGET)_qspi.bin
|
|
|
|
$(TOOLS)/check_qspi_crc $(TARGET) $(BUILD)/$(TARGET)_qspi.bin src/qspi_crc.h || ( $(MAKE) clean && false )
|
|
|
|
$(TOOLS)/add_pgm_chsum $(BUILD)/$(TARGET)_flash.bin $@
|
|
|
|
$(SIZE) $<
|
|
|
|
wc -c $@
|
|
|
|
|
2022-10-14 13:21:24 +02:00
|
|
|
$(OBJECTS): $(DECIMAL_SOURCES)
|
2022-10-10 20:15:22 +02:00
|
|
|
|
|
|
|
$(BUILD)/%.hex: $(BUILD)/%.elf | $(BUILD)
|
2018-07-03 15:54:10 +02:00
|
|
|
$(HEX) $< $@
|
2022-10-10 20:15:22 +02:00
|
|
|
|
|
|
|
$(BUILD)/%.bin: $(BUILD)/%.elf | $(BUILD)
|
2018-07-03 15:54:10 +02:00
|
|
|
$(BIN) $< $@
|
2022-10-10 20:15:22 +02:00
|
|
|
|
|
|
|
$(BUILD):
|
2018-07-03 15:54:10 +02:00
|
|
|
mkdir -p $@
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
# clean up
|
|
|
|
#######################################
|
|
|
|
clean:
|
2022-10-16 11:37:10 +02:00
|
|
|
-rm -fR .dep build sim/*.o
|
|
|
|
|
2018-07-03 15:54:10 +02:00
|
|
|
|
|
|
|
#######################################
|
|
|
|
# dependencies
|
|
|
|
#######################################
|
|
|
|
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
|
|
|
|
|
|
|
|
.PHONY: clean all
|
2022-10-12 23:44:22 +02:00
|
|
|
.ALWAYS:
|
2018-07-03 15:54:10 +02:00
|
|
|
|
|
|
|
# *** EOF ***
|