From 1e852ec1de33a04edcfc7cb3cb881f807188b7a1 Mon Sep 17 00:00:00 2001 From: Paul Mathieu Date: Tue, 7 May 2024 14:02:14 -0700 Subject: [PATCH] arm: improve makefile --- arm/makefile | 32 +++++++++++++++++++++++++------- arm/uart.h | 1 + 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/arm/makefile b/arm/makefile index 6af48dd..ab11475 100644 --- a/arm/makefile +++ b/arm/makefile @@ -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) \ No newline at end of file +.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) diff --git a/arm/uart.h b/arm/uart.h index ea2c93a..f6d3a37 100644 --- a/arm/uart.h +++ b/arm/uart.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include