blackmagic/src/Makefile

198 lines
4.4 KiB
Makefile
Raw Normal View History

PROBE_HOST ?= native
PLATFORM_DIR = platforms/$(PROBE_HOST)
2020-04-16 15:27:26 +00:00
VPATH += $(PLATFORM_DIR) target
ENABLE_DEBUG ?=
2011-02-04 07:23:52 +00:00
2015-03-07 18:32:52 +00:00
ifneq ($(V), 1)
MAKEFLAGS += --no-print-dir
Q := @
endif
CFLAGS += -Wall -Wextra -Werror -Wno-char-subscripts \
2020-04-16 15:27:26 +00:00
-std=gnu99 -g3 -MD -I./target \
-I. -Iinclude -I$(PLATFORM_DIR)
ifeq ($(ENABLE_DEBUG), 1)
CFLAGS += -DENABLE_DEBUG
endif
2011-02-04 07:23:52 +00:00
2012-11-03 08:33:28 +00:00
SRC = \
2011-02-04 07:23:52 +00:00
adiv5.c \
2012-11-03 08:33:28 +00:00
adiv5_jtagdp.c \
2011-02-04 07:23:52 +00:00
adiv5_swdp.c \
command.c \
2016-04-18 18:30:25 +00:00
cortexa.c \
2012-11-03 08:33:28 +00:00
cortexm.c \
crc32.c \
efm32.c \
exception.c \
2012-11-03 08:33:28 +00:00
gdb_if.c \
gdb_main.c \
gdb_hostio.c \
2012-11-03 08:33:28 +00:00
gdb_packet.c \
hex_utils.c \
jtag_devs.c \
2020-04-16 17:38:32 +00:00
jtag_scan.c \
2011-02-04 07:23:52 +00:00
lmi.c \
lpc_common.c \
2013-06-17 04:06:03 +00:00
lpc11xx.c \
2018-03-25 19:53:30 +00:00
lpc17xx.c \
2016-06-09 22:20:07 +00:00
lpc15xx.c \
2012-11-03 08:33:28 +00:00
lpc43xx.c \
2020-09-30 07:44:03 +00:00
lpc546xx.c \
kinetis.c \
2012-11-03 08:33:28 +00:00
main.c \
morse.c \
msp432.c \
2014-04-25 21:34:58 +00:00
nrf51.c \
nxpke04.c \
2012-11-03 08:33:28 +00:00
platform.c \
remote.c \
rp.c \
2012-11-03 08:33:28 +00:00
sam3x.c \
sam4l.c \
2015-01-18 22:40:02 +00:00
samd.c \
samx5x.c \
2012-11-03 08:33:28 +00:00
stm32f1.c \
2022-04-07 12:12:21 +00:00
ch32f1.c \
stm32f4.c \
stm32h7.c \
stm32l0.c \
stm32l4.c \
stm32g0.c \
target.c \
2011-02-04 07:23:52 +00:00
include $(PLATFORM_DIR)/Makefile.inc
ifneq ($(PC_HOSTED),1)
# Output memory usage information
LDFLAGS += -Wl,--print-memory-usage
endif
OPT_FLAGS ?= -Os
CFLAGS += $(OPT_FLAGS)
LDFLAGS += $(OPT_FLAGS)
ifndef TARGET
ifdef PC_HOSTED
TARGET = blackmagic
else
TARGET = blackmagic.elf
endif
endif
2011-02-04 07:23:52 +00:00
ifdef NO_OWN_LL
SRC += jtagtap_generic.c swdptap_generic.c
endif
ifdef PC_HOSTED
CFLAGS += -DPC_HOSTED=1
else
SRC += swdptap.c jtagtap.c
CFLAGS += -DPC_HOSTED=0
2020-04-16 15:27:26 +00:00
VPATH += platforms/common
CFLAGS += -Iplatforms/common
endif
2021-11-28 13:13:24 +00:00
ifeq ($(ENABLE_RTT), 1)
CFLAGS += -DENABLE_RTT
SRC += rtt.c rtt_if.c
endif
ifdef RTT_IDENT
CFLAGS += -DRTT_IDENT=$(RTT_IDENT)
endif
OBJ = $(patsubst %.S,%.o,$(patsubst %.c,%.o,$(SRC)))
2011-02-04 07:23:52 +00:00
$(TARGET): include/version.h $(OBJ)
2015-03-07 18:32:52 +00:00
@echo " LD $@"
$(Q)$(CC) -o $@ $(OBJ) $(LDFLAGS)
2015-03-07 18:32:52 +00:00
%.o: %.c
@echo " CC $<"
$(Q)$(CC) $(CFLAGS) -c $< -o $@
2011-02-04 07:23:52 +00:00
%.o: %.S
@echo " AS $<"
$(Q)$(CC) $(CFLAGS) -c $< -o $@
ifndef PC_HOSTED
%.bin: %.elf
2015-03-07 18:32:52 +00:00
@echo " OBJCOPY $@"
$(Q)$(OBJCOPY) -O binary $^ $@
%.hex: %.elf
2015-03-07 18:32:52 +00:00
@echo " OBJCOPY $@"
$(Q)$(OBJCOPY) -O ihex $^ $@
endif
.PHONY: clean host_clean all_platforms clang-format FORCE
2011-02-04 07:23:52 +00:00
clean: host_clean
2015-03-07 18:32:52 +00:00
$(Q)echo " CLEAN"
-$(Q)$(RM) *.o *.d *.elf *~ $(TARGET) $(HOSTFILES)
-$(Q)$(RM) platforms/*/*.o platforms/*/*.d mapfile include/version.h
2011-02-04 07:23:52 +00:00
all_platforms:
$(Q)if [ ! -f ../libopencm3/Makefile ]; then \
echo "Initialising git submodules..." ;\
git submodule init ;\
git submodule update ;\
fi
$(Q)$(MAKE) $(MFLAGS) -C ../libopencm3 lib/stm32/f1 lib/stm32/f4 lib/lm4f
2015-03-07 18:32:52 +00:00
$(Q)set -e ;\
mkdir -p artifacts/$(shell git describe --always --dirty --tags) ;\
2016-10-22 19:17:57 +00:00
echo "<html><body><ul>" > artifacts/index.html ;\
$(MAKE) clean ;\
for i in platforms/*/Makefile.inc ; do \
export DIRNAME=`dirname $$i` ;\
export PROBE_HOST=`basename $$DIRNAME` ;\
export CFLAGS=-Werror ;\
2015-03-07 18:32:52 +00:00
echo "Building for hardware platform: $$PROBE_HOST" ;\
$(MAKE);\
if [ -f blackmagic ]; then \
mv blackmagic artifacts/blackmagic-$$PROBE_HOST ;\
echo "<li><a href='blackmagic-$$PROBE_HOST'>$$PROBE_HOST</a></li>"\
>> artifacts/index.html ;\
fi ;\
if [ -f blackmagic.bin ]; then \
mv blackmagic.bin artifacts/blackmagic-$$PROBE_HOST.bin ;\
2016-10-22 19:17:57 +00:00
echo "<li><a href='blackmagic-$$PROBE_HOST.bin'>$$PROBE_HOST</a></li>"\
>> artifacts/index.html ;\
fi ;\
if [ -f blackmagic_dfu.bin ]; then \
mv blackmagic_dfu.bin artifacts/blackmagic_dfu-$$PROBE_HOST.bin ;\
echo "<li><a href='blackmagic_dfu-$$PROBE_HOST.bin'>$$PROBE_HOST DFU</a></li>"\
>> artifacts/index.html ;\
fi ;\
$(MAKE) clean ;\
2016-10-22 19:17:57 +00:00
done ;\
echo "</ul></body></html>" >> artifacts/index.html ;\
cp artifacts/blackmagic* artifacts/$(shell git describe --always --dirty --tags)
2016-10-22 19:17:57 +00:00
command.c: include/version.h
GIT_VERSION := $(shell git describe --always --dirty --tags)
VERSION_HEADER := \#define FIRMWARE_VERSION "$(GIT_VERSION)"
include/version.h: FORCE
@# If git isn't found then GIT_VERSION will be an empty string.
ifeq ($(GIT_VERSION),)
@echo Git not found, assuming up to date include/version.h
else
@# Note that when we echo the version to the header file, echo writes a final newline
@# to the file. This is fine and probably makes the file more human-readable, but
@# also means we have to account for that newline in this comparison.
$(Q)if [ ! -f $@ ] || [ "$$(cat $@)" != "$$(echo '$(VERSION_HEADER)\n')" ]; then \
echo " GEN $@"; \
echo '$(VERSION_HEADER)' > $@; \
fi
endif
clang-format:
$(Q)clang-format -i *.c */*.c */*/*.c *.h */*.h */*/*.h
-include *.d