db48x/Makefile

426 lines
11 KiB
Makefile
Raw Normal View History

#######################################
# Target
2018-07-03 15:54:10 +02:00
######################################
TARGET = db48x
PLATFORM = dmcp
VARIANT = dm42
SDK = dmcp/dmcp
PGM = pgm
2018-07-03 15:54:10 +02:00
######################################
# Building variables
2018-07-03 15:54:10 +02:00
######################################
OPT=release
# Alternatives (on the command line)
# OPT=debug -g
# OPT=small -Os
# OPT=fast -O2
# OPT=faster -O3
# OPT=fastest -O4 -Ofast
# Experimentally, O2 performs best on DM42
# (see https://github.com/c3d/DB48X-on-DM42/issues/66)
2018-07-03 15:54:10 +02:00
# Warning: macOSX only
MOUNTPOINT=/Volumes/$(VARIANT)/
EJECT=sync; sync; sync; hdiutil eject $(MOUNTPOINT)
PRODUCT_NAME=$(shell echo $(TARGET) | tr "[:lower:]" "[:upper:]")
PRODUCT_MACHINE=$(shell echo $(VARIANT) | tr "[:lower:]" "[:upper:]")
#######################################
# Pathes
#######################################
# Build path
BUILD = build/$(VARIANT)/$(OPT)
# Path to aux build scripts (including trailing /)
# Leave empty for scripts in PATH
TOOLS = tools
# CRC adjustment
CRCFIX = $(TOOLS)/forcecrc32/forcecrc32
# Decimal mantissa encoding
DECIMIZE = $(TOOLS)/decimize/decimize
FLASH=$(BUILD)/$(TARGET)_flash.bin
QSPI =$(BUILD)/$(TARGET)_qspi.bin
VERSION=$(shell git describe --dirty=Z --abbrev=5| sed -e 's/^v//g' -e 's/-g/-/g')
VERSION_H=src/$(PLATFORM)/version.h
#==============================================================================
#
# Primary build rules
#
#==============================================================================
# default action: build all
all: $(TARGET).$(PGM) help/$(TARGET).md
@echo "# Built $(VERSION)"
dm32: dm32-all
dm32-%:
$(MAKE) PLATFORM=dmcp SDK=dmcp5/dmcp PGM=pg5 VARIANT=dm32 TARGET=db50x $*
# installation steps
COPY=cp
install: install-pgm install-qspi install-help install-demo install-config
$(EJECT)
@echo "# Installed $(VERSION)"
install-fast: install-pgm
$(EJECT)
install-pgm: all
$(COPY) $(TARGET).$(PGM) $(MOUNTPOINT)
install-qspi: all
$(COPY) $(QSPI) $(MOUNTPOINT)
install-help: help/$(TARGET).md
mkdir -p $(MOUNTPOINT)help/
$(COPY) help/$(TARGET).md $(MOUNTPOINT)help/
install-demo:
mkdir -p $(MOUNTPOINT)state/
$(COPY) state/*.48S $(MOUNTPOINT)state/
install-config:
mkdir -p $(MOUNTPOINT)config/
$(COPY) config/*.csv $(MOUNTPOINT)config/
sim: sim/$(TARGET).mak
cd sim; make -f $(<F)
sim/$(TARGET).mak: sim/$(TARGET).pro Makefile $(VERSION_H)
cd sim; qmake $(<F) -o $(@F) CONFIG+=$(QMAKE_$(OPT))
sim: sim/gcc111libbid.a \
recorder/config.h \
help/$(TARGET).md \
fonts/EditorFont.cc \
fonts/StackFont.cc \
fonts/HelpFont.cc \
keyboard \
.ALWAYS
clangdb: sim/$(TARGET).mak .ALWAYS
cd sim && rm -f *.o && compiledb make -f $(TARGET).mak && mv compile_commands.json ..
keyboard: Keyboard-Layout.png Keyboard-Cutout.png sim/keyboard-db48x.png help/keyboard.png doc/keyboard.png
Keyboard-Layout.png: DB48X-Keys/DB48X-Keys.001.png
cp $< $@
Keyboard-Cutout.png: DB48X-Keys/DB48X-Keys.002.png
cp $< $@
sim/keyboard-db48x.png: DB48X-Keys/DB48X-Keys.001.png
convert $< -crop 698x878+151+138 $@
%/keyboard.png: sim/keyboard-db48x.png
cp $< $@
QMAKE_debug=debug
QMAKE_release=release
QMAKE_small=release
QMAKE_fast=release
QMAKE_faster=release
QMAKE_fastest=release
TTF2FONT=$(TOOLS)/ttf2font/ttf2font
$(TTF2FONT): $(TTF2FONT).cpp $(TOOLS)/ttf2font/Makefile src/ids.tbl
cd $(TOOLS)/ttf2font; $(MAKE) TARGET=release
sim/gcc111libbid.a: sim/gcc111libbid-$(shell uname)-$(shell uname -m).a
cp $< $@
dist: all
cp $(BUILD)/$(TARGET)_qspi.bin .
tar cvfz $(TARGET)-v$(VERSION).tgz $(TARGET).$(PGM) $(TARGET)_qspi.bin \
help/*.md STATE/*.48S
@echo "# Distributing $(VERSION)"
$(VERSION_H): $(BUILD)/version-$(VERSION).h
cp $< $@
$(BUILD)/version-$(VERSION).h: $(BUILD)/.exists Makefile
echo "#define DB48X_VERSION \"$(VERSION)\"" > $@
#BASE_FONT=fonts/C43StandardFont.ttf
BASE_FONT=fonts/FogSans-ddd.ttf
fonts/EditorFont.cc: $(TTF2FONT) $(BASE_FONT)
$(TTF2FONT) -s 48 -S 80 -y -10 EditorFont $(BASE_FONT) $@
fonts/StackFont.cc: $(TTF2FONT) $(BASE_FONT)
$(TTF2FONT) -s 32 -S 80 -y -8 StackFont $(BASE_FONT) $@
fonts/HelpFont.cc: $(TTF2FONT) $(BASE_FONT)
$(TTF2FONT) -s 18 -S 80 -y -3 HelpFont $(BASE_FONT) $@
help/$(TARGET).md: $(wildcard doc/*.md doc/calc-help/*.md doc/commands/*.md)
mkdir -p help && \
cat $^ | \
sed -e '/<!--- $(PRODUCT_MACHINE) --->/,/<!--- !$(PRODUCT_MACHINE) --->/s/$(PRODUCT_MACHINE)/KEEP_IT/g' | \
sed -e '/<!--- DM.* --->/,/<!--- !DM.* --->/d' | \
sed -e '/<!--- KEEP_IT --->/d' | \
sed -e '/<!--- !KEEP_IT --->/d' | \
sed -e 's/KEEP_IT/$(PRODUCT_MACHINE)/g' | \
sed -e 's/DB48X/$(PRODUCT_NAME)/g' \
-e 's/DM42/$(PRODUCT_MACHINE)/g' > $@
cp doc/*.png help/
check-ids: help/$(TARGET).md
@for I in $$(cpp -xc++ -D'ID(n)=n' src/ids.tbl | \
sed -e 's/##//g' | sed -e 's/^#.*//g'); \
do \
if ! grep -q $$I src/ignored_menus.csv ; then \
grep -q "ID_$$I" src/menu.cc || \
echo "$$I not in menus"; \
fi; \
if ! grep -q $$I src/ignored_help.csv ; then \
grep -q "^#.*[[:<:]]$$I[[:>:]]" help/$(TARGET).md || \
echo "$$I not in help"; \
fi; \
done
debug-%:
$(MAKE) $* OPT=debug
release-%:
$(MAKE) $* OPT=release
small-%:
$(MAKE) $* OPT=small
fast-%:
$(MAKE) $* OPT=fast
faster-%:
$(MAKE) $* OPT=faster
fastest-%:
$(MAKE) $* OPT=fastest
2018-07-03 15:54:10 +02:00
######################################
# System sources
######################################
C_INCLUDES += -I$(SDK)
C_SOURCES += $(SDK)/sys/pgm_syscalls.c
ASM_SOURCES = $(SDK)/startup_pgm.s
2018-07-03 15:54:10 +02:00
#######################################
# Custom section
#######################################
# Includes
C_INCLUDES += -Isrc/$(VARIANT) -Isrc/$(PLATFORM) -Isrc -Iinc
2018-07-03 15:54:10 +02:00
# C sources
C_SOURCES +=
2018-07-03 15:54:10 +02:00
# C++ sources
CXX_SOURCES += \
src/$(PLATFORM)/target.cc \
src/$(PLATFORM)/sysmenu.cc \
src/$(PLATFORM)/main.cc \
src/user_interface.cc \
src/file.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/complex.cc \
src/decimal.cc \
src/text.cc \
src/comment.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/locals.cc \
src/catalog.cc \
src/menu.cc \
src/list.cc \
src/program.cc \
src/expression.cc \
src/unit.cc \
src/array.cc \
src/loops.cc \
src/conditionals.cc \
src/font.cc \
src/tag.cc \
src/files.cc \
src/graphics.cc \
src/grob.cc \
src/plot.cc \
src/stats.cc \
src/solve.cc \
src/integrate.cc \
fonts/HelpFont.cc \
fonts/EditorFont.cc \
fonts/StackFont.cc
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_$(VARIANT)) \
HELPFILE_NAME=\"/HELP/$(TARGET).md\"
DEFINES_debug=DEBUG
DEFINES_release=RELEASE
DEFINES_small=RELEASE
DEFINES_fast=RELEASE
DEFINES_faster=RELEASE
DEFINES_fastes=RELEASE
DEFINES_dm32 = DM32 \
CONFIG_FIXED_BASED_OBJECTS
DEFINES_dm42 = DM42
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 = $(DBGFLAGS_$(OPT))
DBGFLAGS_debug = -g
2018-07-03 15:54:10 +02:00
CFLAGS_debug += -Os -DDEBUG
CFLAGS_release += $(CFLAGS_release_$(VARIANT))
CFLAGS_release_dm42 = -O2
CFLAGS_release_dm32 = -O2
CFLAGS_small += -Os
CFLAGS_fast += -O2
CFLAGS_faster += -O3
CFLAGS_fastest += -O4
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/$(VARIANT)/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)/.exists
$(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)/.exists
$(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)/.exists
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 $(CRCFIX)
$(OBJCOPY) --remove-section .qspi -O binary $< $(FLASH)
$(OBJCOPY) --remove-section .qspi -O ihex $< $(FLASH:.bin=.hex)
$(OBJCOPY) --only-section .qspi -O binary $< $(QSPI)
$(OBJCOPY) --only-section .qspi -O ihex $< $(QSPI:.bin=.hex)
$(TOOLS)/adjust_crc $(CRCFIX) $(QSPI)
$(TOOLS)/check_qspi_crc $(TARGET) $(BUILD)/$(TARGET)_qspi.bin src/$(VARIANT)/qspi_crc.h || ( rm -rf build/$(VARIANT) && exit 1)
$(TOOLS)/add_pgm_chsum $(BUILD)/$(TARGET)_flash.bin $@
$(SIZE) $<
wc -c $@
$(OBJECTS): $(DECIMAL_SOURCES) $(VERSION_H)
sim: $(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)/.exists:
mkdir -p $(@D)
touch $@
2018-07-03 15:54:10 +02:00
$(CRCFIX): $(CRCFIX).c $(dir $(CRCFIX))/Makefile
cd $(dir $(CRCFIX)); $(MAKE)
$(DECIMIZE): $(DECIMIZE).cpp $(dir $(DECIMIZE))/Makefile
cd $(dir $(DECIMIZE)); $(MAKE)
2018-07-03 15:54:10 +02:00
#######################################
# 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 ***