db48x/Makefile

275 lines
7 KiB
Makefile
Raw Normal View History

2018-07-03 15:54:10 +02:00
######################################
# target
######################################
TARGET = DB48X
2018-07-03 15:54:10 +02:00
######################################
# building variables
######################################
ifdef DEBUG
OPT=debug
else
OPT=release
2018-07-03 15:54:10 +02:00
endif
# Warning: macOSX only
MOUNTPOINT=/Volumes/DM42/
EJECT=hdiutil eject $(MOUNTPOINT)
#==============================================================================
#
# Primary build rules
#
#==============================================================================
# default action: build all
all: $(TARGET).pgm help/$(TARGET).md
install: all help/$(TARGET).md
(tar cf - $(TARGET).pgm help/$(TARGET).md | \
(cd $(MOUNTPOINT) && tar xvf -)) && $(EJECT)
sim: sim/simulator.mak recorder/config.h help/$(TARGET).md .ALWAYS
cd sim; make -f $(<F)
sim/simulator.mak: sim/simulator.pro
cd sim; qmake $(<F) -o $(@F) CONFIG+=$(OPT)
ttf2font: tools/ttf2fonts/ttf2fonts
tools/ttf2fonts/ttf2fonts: tools/ttf2font/ttf2font.cpp tools/ttf2font/Makefile
cd tools/ttf2font; $(MAKE)
#BASE_FONT=fonts/C43StandardFont.ttf
BASE_FONT=fonts/FogSans-ddd.ttf
fonts/EditorFont.cc: ttf2font $(BASE_FONT)
tools/ttf2font/ttf2font -s 48 -S 80 -y -10 EditorFont $(BASE_FONT) $@
fonts/StackFont.cc: ttf2font $(BASE_FONT)
tools/ttf2font/ttf2font -s 32 -S 80 -y -8 StackFont $(BASE_FONT) $@
fonts/HelpFont.cc: ttf2font $(BASE_FONT)
tools/ttf2font/ttf2font -s 18 -S 80 -y -3 HelpFont $(BASE_FONT) $@
help/$(TARGET).md: $(wildcard doc/*.md doc/calc-help/*.md doc/commands/*.md)
cat $^ > $@
debug-%:
$(MAKE) $* OPT=debug
release-%:
$(MAKE) $* OPT=release
2018-07-03 15:54:10 +02:00
#######################################
# pathes
#######################################
# Build path
BUILD = build/$(OPT)
2018-07-03 15:54:10 +02:00
# Path to aux build scripts (including trailing /)
# Leave empty for scripts in PATH
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
C_INCLUDES += -Isrc/dm42 -Isrc -Iinc
2018-07-03 15:54:10 +02:00
# C sources
C_SOURCES +=
2018-07-03 15:54:10 +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
CXX_SOURCES += \
src/dm42/target.cc \
src/dm42/sysmenu.cc \
src/dm42/main.cc \
src/input.cc \
src/stack.cc \
src/util.cc \
src/renderer.cc \
src/settings.cc \
src/runtime.cc \
src/object.cc \
src/command.cc \
src/compare.cc \
src/logical.cc \
src/integer.cc \
src/bignum.cc \
src/fraction.cc \
src/decimal128.cc \
$(DECIMAL_SOURCES) \
src/text.cc \
src/symbol.cc \
src/algebraic.cc \
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 \
src/variables.cc \
src/catalog.cc \
src/menu.cc \
src/list.cc \
src/loops.cc \
src/font.cc \
fonts/HelpFont.cc \
fonts/EditorFont.cc \
fonts/StackFont.cc
# 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
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
# 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
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
DBGFLAGS = -g
2018-07-03 15:54:10 +02:00
CFLAGS_debug += -O0 -DDEBUG
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
LDSCRIPT = src/stm32_program.ld
2018-07-03 15:54:10 +02:00
LIBDIR =
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
2018-07-03 15:54:10 +02:00
#######################################
# build the application
#######################################
# list of objects
OBJECTS = $(addprefix $(BUILD)/,$(notdir $(C_SOURCES:.c=.o)))
2018-07-03 15:54:10 +02:00
vpath %.c $(sort $(dir $(C_SOURCES)))
# C++ sources
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
OBJECTS += $(addprefix $(BUILD)/,$(notdir $(ASM_SOURCES:.s=.o)))
2018-07-03 15:54:10 +02:00
vpath %.s $(sort $(dir $(ASM_SOURCES)))
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti -Wno-packed-bitfield-compat
2018-07-03 15:54:10 +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
$(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
$(BUILD)/%.o: %.s Makefile | $(BUILD)
2018-07-03 15:54:10 +02:00
$(AS) -c $(CFLAGS) $< -o $@
$(BUILD)/$(TARGET).elf: $(OBJECTS) Makefile
2018-07-03 15:54:10 +02:00
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
$(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 $@
$(OBJECTS): $(DECIMAL_SOURCES)
$(BUILD)/%.hex: $(BUILD)/%.elf | $(BUILD)
2018-07-03 15:54:10 +02:00
$(HEX) $< $@
$(BUILD)/%.bin: $(BUILD)/%.elf | $(BUILD)
2018-07-03 15:54:10 +02:00
$(BIN) $< $@
$(BUILD):
2018-07-03 15:54:10 +02:00
mkdir -p $@
#######################################
# clean up
#######################################
clean:
-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
.ALWAYS:
2018-07-03 15:54:10 +02:00
# *** EOF ***