arm: improve makefile

This commit is contained in:
Paul Mathieu 2024-05-07 14:02:14 -07:00
parent 8c25ce8d21
commit 1e852ec1de
2 changed files with 26 additions and 7 deletions

View File

@ -28,7 +28,11 @@ app_objects = app_init.o crash.o main.o uart.o stdlib.o async.o trace.o $(source
CPPFLAGS += $(includes)
all: bootloader.elf app.bin
.PHONY: app
app: app.bin ## Build the main app
.PHONY: bootloader ## Build the bootloader
bootloader: bootloader.elf
%.bin: %.elf
$(OBJCOPY) -O binary $< $@
@ -39,8 +43,6 @@ bootloader.elf: $(bootloader_objects) bootloader.ld
app.elf: $(app_objects) app.ld
$(LD) -Wl,-Tapp.ld $(LDFLAGS) -o $@ $(app_objects)
.PHONY: clean test
deps = $(app_objects:.o=.d) $(bootloader_objects:.o=.d)
HOSTCXX = clang++
@ -56,7 +58,8 @@ ASAN_CFLAGS = $(HOSTCFLAGS) -fsanitize=address -fsanitize=leak
tests = ring_buffer_test.run async_test_asan.run async_test_tsan.run uart_test_tsan.run
test: $(tests)
.PHONY: test
test: $(tests) ## Run tests
test/async_test_asan: async_test.cc async.host.o lock.host.o
test/async_test_tsan: async_test.cc async.host.o lock.host.o
@ -78,15 +81,30 @@ test/%_asan: | mktest
test/%_tsan: | mktest
$(HOSTCXX) $(TSAN_CFLAGS) -o $@ $^ $(HOSTLDFLAGS)
.PHONY: mktest
mktest:
mkdir -p test
test_deps = async.host.d lock.host.d fake_uart.host.d
.PHONY: dev-image
dev-image:
docker build -t arm-dev -f dev.dockerfile .
clean:
.PHONY: dev
dev: dev-image ## Run a dev container
docker run -it --rm -v $(CURDIR):/workspace -w /workspace arm-dev
.PHONY: clean
clean: ## Remove generated files
rm -rf *.elf *.bin $(app_objects) $(bootloader_objects) $(deps)
rm -rf test/ *.dSYM $(test_deps) *.o
-include $(deps)
-include $(test_deps)
.PHONY: help
help: ## Show this help
@echo Noteworthy targets:
@egrep '^[a-zA-Z_-]+:.*?## .*$$' $(firstword $(MAKEFILE_LIST)) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := help
#-include $(deps)
#-include $(test_deps)

View File

@ -1,5 +1,6 @@
#pragma once
#include <cstdint>
#include <span>
#include <string_view>