2023-08-02 00:10:41 +02:00
|
|
|
#######################################
|
2023-12-11 20:44:29 +01:00
|
|
|
# Target
|
2018-07-03 15:54:10 +02:00
|
|
|
######################################
|
2023-10-17 18:32:23 +02:00
|
|
|
TARGET = db48x
|
2023-08-02 00:10:41 +02:00
|
|
|
PLATFORM = dmcp
|
2023-09-30 23:07:28 +02:00
|
|
|
VARIANT = dm42
|
2023-08-04 07:18:07 +02:00
|
|
|
SDK = dmcp/dmcp
|
2023-08-02 00:10:41 +02:00
|
|
|
PGM = pgm
|
2018-07-03 15:54:10 +02:00
|
|
|
|
|
|
|
######################################
|
2023-12-11 20:44:29 +01:00
|
|
|
# Building variables
|
2018-07-03 15:54:10 +02:00
|
|
|
######################################
|
2022-10-10 20:15:22 +02:00
|
|
|
OPT=release
|
2023-07-04 20:38:13 +02:00
|
|
|
# Alternatives (on the command line)
|
|
|
|
# OPT=debug -g
|
|
|
|
# OPT=small -Os
|
|
|
|
# OPT=fast -O2
|
2023-07-05 08:32:34 +02:00
|
|
|
# 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
|
|
|
|
2022-10-11 18:25:00 +02:00
|
|
|
# Warning: macOSX only
|
2023-08-02 00:10:41 +02:00
|
|
|
MOUNTPOINT=/Volumes/$(VARIANT)/
|
2023-10-23 00:14:40 +02:00
|
|
|
EJECT=sync; sync; sync; hdiutil eject $(MOUNTPOINT)
|
2023-10-21 06:30:44 +02:00
|
|
|
PRODUCT_NAME=$(shell echo $(TARGET) | tr "[:lower:]" "[:upper:]")
|
|
|
|
PRODUCT_MACHINE=$(shell echo $(VARIANT) | tr "[:lower:]" "[:upper:]")
|
2022-10-11 18:25:00 +02:00
|
|
|
|
|
|
|
|
2023-06-21 08:08:40 +02:00
|
|
|
#######################################
|
2023-12-11 20:44:29 +01:00
|
|
|
# Pathes
|
2023-06-21 08:08:40 +02:00
|
|
|
#######################################
|
|
|
|
# Build path
|
2023-08-02 00:10:41 +02:00
|
|
|
BUILD = build/$(VARIANT)/$(OPT)
|
2023-06-21 08:08:40 +02:00
|
|
|
|
|
|
|
# Path to aux build scripts (including trailing /)
|
|
|
|
# Leave empty for scripts in PATH
|
|
|
|
TOOLS = tools
|
|
|
|
|
|
|
|
# CRC adjustment
|
|
|
|
CRCFIX = $(TOOLS)/forcecrc32/forcecrc32
|
|
|
|
|
2023-12-11 20:44:29 +01:00
|
|
|
# Decimal mantissa encoding
|
|
|
|
DECIMIZE = $(TOOLS)/decimize/decimize
|
|
|
|
|
2023-06-21 08:29:59 +02:00
|
|
|
FLASH=$(BUILD)/$(TARGET)_flash.bin
|
|
|
|
QSPI =$(BUILD)/$(TARGET)_qspi.bin
|
|
|
|
|
2023-07-02 15:41:57 +02:00
|
|
|
VERSION=$(shell git describe --dirty=Z --abbrev=5| sed -e 's/^v//g' -e 's/-g/-/g')
|
2023-08-02 00:10:41 +02:00
|
|
|
VERSION_H=src/$(PLATFORM)/version.h
|
2023-06-21 08:29:59 +02:00
|
|
|
|
2023-06-21 08:08:40 +02:00
|
|
|
|
2022-10-16 13:18:19 +02:00
|
|
|
#==============================================================================
|
|
|
|
#
|
|
|
|
# Primary build rules
|
|
|
|
#
|
|
|
|
#==============================================================================
|
|
|
|
|
|
|
|
# default action: build all
|
2023-08-02 00:10:41 +02:00
|
|
|
all: $(TARGET).$(PGM) help/$(TARGET).md
|
2023-08-07 23:19:04 +02:00
|
|
|
@echo "# Built $(VERSION)"
|
2023-08-02 00:10:41 +02:00
|
|
|
|
|
|
|
dm32: dm32-all
|
|
|
|
dm32-%:
|
2023-10-17 18:32:23 +02:00
|
|
|
$(MAKE) PLATFORM=dmcp SDK=dmcp5/dmcp PGM=pg5 VARIANT=dm32 TARGET=db50x $*
|
2023-06-22 19:34:38 +02:00
|
|
|
|
|
|
|
# installation steps
|
2023-10-01 14:01:42 +02:00
|
|
|
COPY=cp
|
2023-11-05 15:54:12 +01:00
|
|
|
install: install-pgm install-qspi install-help install-demo install-config
|
2023-06-22 19:34:38 +02:00
|
|
|
$(EJECT)
|
2023-08-07 23:19:04 +02:00
|
|
|
@echo "# Installed $(VERSION)"
|
2023-06-22 19:34:38 +02:00
|
|
|
install-fast: install-pgm
|
|
|
|
$(EJECT)
|
|
|
|
install-pgm: all
|
2023-10-01 14:01:42 +02:00
|
|
|
$(COPY) $(TARGET).$(PGM) $(MOUNTPOINT)
|
2023-06-22 19:34:38 +02:00
|
|
|
install-qspi: all
|
2023-10-01 14:01:42 +02:00
|
|
|
$(COPY) $(QSPI) $(MOUNTPOINT)
|
2023-06-22 19:34:38 +02:00
|
|
|
install-help: help/$(TARGET).md
|
2023-11-05 15:54:12 +01:00
|
|
|
mkdir -p $(MOUNTPOINT)help/
|
2023-10-01 14:01:42 +02:00
|
|
|
$(COPY) help/$(TARGET).md $(MOUNTPOINT)help/
|
2023-11-05 15:54:12 +01:00
|
|
|
install-demo:
|
|
|
|
mkdir -p $(MOUNTPOINT)state/
|
|
|
|
$(COPY) state/*.48S $(MOUNTPOINT)state/
|
|
|
|
install-config:
|
|
|
|
mkdir -p $(MOUNTPOINT)config/
|
|
|
|
$(COPY) config/*.csv $(MOUNTPOINT)config/
|
2023-06-22 19:34:38 +02:00
|
|
|
|
2023-10-17 18:32:23 +02:00
|
|
|
sim: sim/$(TARGET).mak
|
2022-10-16 13:18:19 +02:00
|
|
|
cd sim; make -f $(<F)
|
2023-10-17 18:32:23 +02:00
|
|
|
sim/$(TARGET).mak: sim/$(TARGET).pro Makefile $(VERSION_H)
|
2023-07-04 20:38:13 +02:00
|
|
|
cd sim; qmake $(<F) -o $(@F) CONFIG+=$(QMAKE_$(OPT))
|
2023-07-12 22:04:11 +02:00
|
|
|
|
|
|
|
sim: sim/gcc111libbid.a \
|
|
|
|
recorder/config.h \
|
|
|
|
help/$(TARGET).md \
|
|
|
|
fonts/EditorFont.cc \
|
|
|
|
fonts/StackFont.cc \
|
|
|
|
fonts/HelpFont.cc \
|
2023-10-05 18:41:52 +02:00
|
|
|
keyboard \
|
2023-07-12 22:04:11 +02:00
|
|
|
.ALWAYS
|
|
|
|
|
2023-10-17 18:32:23 +02:00
|
|
|
clangdb: sim/$(TARGET).mak .ALWAYS
|
|
|
|
cd sim && rm -f *.o && compiledb make -f $(TARGET).mak && mv compile_commands.json ..
|
2023-08-02 00:10:41 +02:00
|
|
|
|
2023-10-19 13:01:39 +02:00
|
|
|
keyboard: Keyboard-Layout.png Keyboard-Cutout.png sim/keyboard-db48x.png help/keyboard.png doc/keyboard.png
|
2023-10-05 18:41:52 +02:00
|
|
|
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 $@
|
2023-10-19 13:01:39 +02:00
|
|
|
%/keyboard.png: sim/keyboard-db48x.png
|
|
|
|
cp $< $@
|
2023-10-05 18:41:52 +02:00
|
|
|
|
2023-07-04 20:38:13 +02:00
|
|
|
QMAKE_debug=debug
|
|
|
|
QMAKE_release=release
|
|
|
|
QMAKE_small=release
|
|
|
|
QMAKE_fast=release
|
|
|
|
QMAKE_faster=release
|
|
|
|
QMAKE_fastest=release
|
2023-07-02 09:15:23 +02:00
|
|
|
|
2023-07-12 22:04:11 +02:00
|
|
|
TTF2FONT=$(TOOLS)/ttf2font/ttf2font
|
2023-07-13 22:33:58 +02:00
|
|
|
$(TTF2FONT): $(TTF2FONT).cpp $(TOOLS)/ttf2font/Makefile src/ids.tbl
|
2023-10-23 00:11:03 +02:00
|
|
|
cd $(TOOLS)/ttf2font; $(MAKE) TARGET=release
|
2023-06-28 12:33:00 +02:00
|
|
|
sim/gcc111libbid.a: sim/gcc111libbid-$(shell uname)-$(shell uname -m).a
|
|
|
|
cp $< $@
|
2022-10-24 08:46:30 +02:00
|
|
|
|
2023-07-01 09:45:10 +02:00
|
|
|
dist: all
|
2023-09-30 20:06:23 +02:00
|
|
|
cp $(BUILD)/$(TARGET)_qspi.bin .
|
|
|
|
tar cvfz $(TARGET)-v$(VERSION).tgz $(TARGET).$(PGM) $(TARGET)_qspi.bin \
|
2023-07-30 14:38:07 +02:00
|
|
|
help/*.md STATE/*.48S
|
2023-08-07 23:19:04 +02:00
|
|
|
@echo "# Distributing $(VERSION)"
|
2023-07-01 09:45:10 +02:00
|
|
|
|
2023-07-12 22:04:11 +02:00
|
|
|
$(VERSION_H): $(BUILD)/version-$(VERSION).h
|
|
|
|
cp $< $@
|
|
|
|
$(BUILD)/version-$(VERSION).h: $(BUILD)/.exists Makefile
|
2023-07-02 15:41:57 +02:00
|
|
|
echo "#define DB48X_VERSION \"$(VERSION)\"" > $@
|
|
|
|
|
|
|
|
|
2022-10-27 23:33:33 +02:00
|
|
|
#BASE_FONT=fonts/C43StandardFont.ttf
|
|
|
|
BASE_FONT=fonts/FogSans-ddd.ttf
|
2023-07-13 22:33:58 +02:00
|
|
|
fonts/EditorFont.cc: $(TTF2FONT) $(BASE_FONT)
|
2023-07-12 22:04:11 +02:00
|
|
|
$(TTF2FONT) -s 48 -S 80 -y -10 EditorFont $(BASE_FONT) $@
|
2023-07-13 22:33:58 +02:00
|
|
|
fonts/StackFont.cc: $(TTF2FONT) $(BASE_FONT)
|
2023-07-12 22:04:11 +02:00
|
|
|
$(TTF2FONT) -s 32 -S 80 -y -8 StackFont $(BASE_FONT) $@
|
2023-07-13 22:33:58 +02:00
|
|
|
fonts/HelpFont.cc: $(TTF2FONT) $(BASE_FONT)
|
2023-07-12 22:04:11 +02:00
|
|
|
$(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)
|
2023-10-21 06:30:44 +02:00
|
|
|
mkdir -p help && \
|
2023-10-21 11:40:20 +02:00
|
|
|
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/
|
2023-11-24 07:35:31 +01:00
|
|
|
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
|
2022-10-16 13:18:19 +02:00
|
|
|
|
|
|
|
debug-%:
|
|
|
|
$(MAKE) $* OPT=debug
|
|
|
|
release-%:
|
|
|
|
$(MAKE) $* OPT=release
|
2023-07-04 20:38:13 +02:00
|
|
|
small-%:
|
|
|
|
$(MAKE) $* OPT=small
|
|
|
|
fast-%:
|
|
|
|
$(MAKE) $* OPT=fast
|
|
|
|
faster-%:
|
|
|
|
$(MAKE) $* OPT=faster
|
|
|
|
fastest-%:
|
|
|
|
$(MAKE) $* OPT=fastest
|
2022-10-16 13:18:19 +02:00
|
|
|
|
|
|
|
|
2018-07-03 15:54:10 +02:00
|
|
|
######################################
|
|
|
|
# System sources
|
|
|
|
######################################
|
2023-08-02 00:10:41 +02:00
|
|
|
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
|
2023-09-30 23:07:28 +02:00
|
|
|
C_INCLUDES += -Isrc/$(VARIANT) -Isrc/$(PLATFORM) -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
|
|
|
|
|
|
|
# C++ sources
|
2022-10-14 13:21:24 +02:00
|
|
|
CXX_SOURCES += \
|
2023-08-02 00:10:41 +02:00
|
|
|
src/$(PLATFORM)/target.cc \
|
|
|
|
src/$(PLATFORM)/sysmenu.cc \
|
|
|
|
src/$(PLATFORM)/main.cc \
|
2023-07-07 23:46:20 +02:00
|
|
|
src/user_interface.cc \
|
2023-06-22 18:51:21 +02:00
|
|
|
src/file.cc \
|
2022-10-15 22:22:35 +02:00
|
|
|
src/stack.cc \
|
2022-10-14 13:21:24 +02:00
|
|
|
src/util.cc \
|
2022-11-17 00:01:22 +01:00
|
|
|
src/renderer.cc \
|
2022-10-14 13:21:24 +02:00
|
|
|
src/settings.cc \
|
|
|
|
src/runtime.cc \
|
|
|
|
src/object.cc \
|
2022-10-17 13:50:47 +02:00
|
|
|
src/command.cc \
|
2022-11-07 21:46:37 +01:00
|
|
|
src/compare.cc \
|
|
|
|
src/logical.cc \
|
2022-10-14 13:21:24 +02:00
|
|
|
src/integer.cc \
|
2022-11-16 00:29:18 +01:00
|
|
|
src/bignum.cc \
|
2022-11-19 18:24:39 +01:00
|
|
|
src/fraction.cc \
|
2023-07-12 23:36:34 +02:00
|
|
|
src/complex.cc \
|
2023-12-06 23:43:31 +01:00
|
|
|
src/decimal.cc \
|
2022-10-30 11:20:19 +01:00
|
|
|
src/text.cc \
|
2023-08-27 01:51:45 +02:00
|
|
|
src/comment.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 \
|
2023-07-02 14:43:14 +02:00
|
|
|
src/locals.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 \
|
2023-07-22 15:07:19 +02:00
|
|
|
src/program.cc \
|
2023-10-31 09:46:56 +01:00
|
|
|
src/expression.cc \
|
2023-10-22 12:46:34 +02:00
|
|
|
src/unit.cc \
|
2023-07-22 15:07:19 +02:00
|
|
|
src/array.cc \
|
2022-11-04 00:36:00 +01:00
|
|
|
src/loops.cc \
|
2023-08-03 21:50:23 +02:00
|
|
|
src/conditionals.cc \
|
2022-10-24 08:46:30 +02:00
|
|
|
src/font.cc \
|
2023-09-12 23:41:14 +02:00
|
|
|
src/tag.cc \
|
files: Allow `STO` and `RCL` to write to filesystem
When the argument describing the variable is a text, interpret that as
a file path on the disk. By default, data is stored in in a directory
named `data`, which will be created if necessary. For example, you can
use `3 "foo.48s" STO` to store the value `3` in a file named
`data/foo.48s` on disk.
How the file is stored depends on the extension given to the file:
* For `.txt` files, the object is stored as text
* For `.48s` files, the object is stored as DB48X source code
* For `.48b` files, the object is stored in binary format
* For `.csv` files, the object is stored in comma-separated format.
The binary format used for `.48b` includes a 4-byte magic number
identifying a DB48X format, and a 4-byte checksum used to ensure
binary compatibility between the firmware and the disk format.
At least during early days of development (prior to 1.0), it is quite
unlikely that the binary format for one version of the firmware would
be readable or writable by another version. If you need to recover
data from another version, you need to install that version and save
the object again in `.48s` (text) format.
Fixes: #375
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-14 07:23:58 +01:00
|
|
|
src/files.cc \
|
2023-08-04 01:29:39 +02:00
|
|
|
src/graphics.cc \
|
2023-09-13 22:27:16 +02:00
|
|
|
src/grob.cc \
|
2023-08-12 15:13:52 +02:00
|
|
|
src/plot.cc \
|
2023-11-11 01:28:46 +01:00
|
|
|
src/stats.cc \
|
2023-10-10 00:25:36 +02:00
|
|
|
src/solve.cc \
|
2023-10-12 22:59:20 +02:00
|
|
|
src/integrate.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
|
|
|
|
|
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 \
|
2023-08-02 00:10:41 +02:00
|
|
|
$(DEFINES_$(OPT)) \
|
2023-09-30 23:44:11 +02:00
|
|
|
$(DEFINES_$(VARIANT)) \
|
|
|
|
HELPFILE_NAME=\"/HELP/$(TARGET).md\"
|
2022-10-10 20:15:22 +02:00
|
|
|
DEFINES_debug=DEBUG
|
|
|
|
DEFINES_release=RELEASE
|
2023-07-04 20:38:13 +02:00
|
|
|
DEFINES_small=RELEASE
|
|
|
|
DEFINES_fast=RELEASE
|
|
|
|
DEFINES_faster=RELEASE
|
|
|
|
DEFINES_fastes=RELEASE
|
2023-10-18 23:34:17 +02:00
|
|
|
DEFINES_dm32 = DM32 \
|
|
|
|
CONFIG_FIXED_BASED_OBJECTS
|
2023-12-25 11:50:02 +01:00
|
|
|
DEFINES_dm42 = DM42
|
2022-10-10 20:15:22 +02:00
|
|
|
|
|
|
|
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
|
2023-07-04 06:59:58 +02:00
|
|
|
DBGFLAGS = $(DBGFLAGS_$(OPT))
|
|
|
|
DBGFLAGS_debug = -g
|
2018-07-03 15:54:10 +02:00
|
|
|
|
2023-11-04 20:26:55 +01:00
|
|
|
CFLAGS_debug += -Os -DDEBUG
|
2023-09-14 00:27:49 +02:00
|
|
|
CFLAGS_release += $(CFLAGS_release_$(VARIANT))
|
2023-12-20 23:41:40 +01:00
|
|
|
CFLAGS_release_dm42 = -O2
|
2023-09-30 23:07:28 +02:00
|
|
|
CFLAGS_release_dm32 = -O2
|
2023-07-04 20:38:13 +02:00
|
|
|
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
|
2023-08-02 00:10:41 +02:00
|
|
|
LDSCRIPT = src/$(VARIANT)/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
|
|
|
|
2023-07-12 22:04:11 +02:00
|
|
|
$(BUILD)/%.o: %.c Makefile | $(BUILD)/.exists
|
2022-10-10 20:15:22 +02:00
|
|
|
$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD)/$(notdir $(<:.c=.lst)) $< -o $@
|
2018-07-03 15:54:10 +02:00
|
|
|
|
2023-07-12 22:04:11 +02:00
|
|
|
$(BUILD)/%.o: %.cc Makefile | $(BUILD)/.exists
|
2022-10-10 20:15:22 +02:00
|
|
|
$(CXX) -c $(CXXFLAGS) -Wa,-a,-ad,-alms=$(BUILD)/$(notdir $(<:.cc=.lst)) $< -o $@
|
2018-07-03 15:54:10 +02:00
|
|
|
|
2023-07-12 22:04:11 +02:00
|
|
|
$(BUILD)/%.o: %.s Makefile | $(BUILD)/.exists
|
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 $@
|
2023-08-02 00:10:41 +02:00
|
|
|
$(TARGET).$(PGM): $(BUILD)/$(TARGET).elf Makefile $(CRCFIX)
|
2023-06-21 08:29:59 +02:00
|
|
|
$(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)
|
2023-09-30 23:07:28 +02:00
|
|
|
$(TOOLS)/check_qspi_crc $(TARGET) $(BUILD)/$(TARGET)_qspi.bin src/$(VARIANT)/qspi_crc.h || ( rm -rf build/$(VARIANT) && exit 1)
|
2022-10-10 20:15:22 +02:00
|
|
|
$(TOOLS)/add_pgm_chsum $(BUILD)/$(TARGET)_flash.bin $@
|
|
|
|
$(SIZE) $<
|
|
|
|
wc -c $@
|
|
|
|
|
2023-07-12 22:04:11 +02:00
|
|
|
$(OBJECTS): $(DECIMAL_SOURCES) $(VERSION_H)
|
2023-06-25 07:46:23 +02:00
|
|
|
sim: $(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
|
|
|
|
2023-07-12 22:04:11 +02:00
|
|
|
$(BUILD)/.exists:
|
|
|
|
mkdir -p $(@D)
|
|
|
|
touch $@
|
|
|
|
|
2018-07-03 15:54:10 +02:00
|
|
|
|
2023-06-21 08:08:40 +02:00
|
|
|
$(CRCFIX): $(CRCFIX).c $(dir $(CRCFIX))/Makefile
|
|
|
|
cd $(dir $(CRCFIX)); $(MAKE)
|
2023-12-11 20:44:29 +01:00
|
|
|
$(DECIMIZE): $(DECIMIZE).cpp $(dir $(DECIMIZE))/Makefile
|
|
|
|
cd $(dir $(DECIMIZE)); $(MAKE)
|
2023-06-21 08:08:40 +02:00
|
|
|
|
|
|
|
|
2018-07-03 15:54:10 +02:00
|
|
|
#######################################
|
|
|
|
# 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 ***
|