aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile47
1 files changed, 34 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 99c8e65..12ae4ef 100644
--- a/Makefile
+++ b/Makefile
@@ -85,8 +85,19 @@ export OBJCOPY=$(PREFIX)objcopy
export OBJDUMP=$(PREFIX)objdump
export SIZE=$(PREFIX)size
+# The Alpha is a development platform, so set GCC optimization to a
+# level suitable for debugging. Recent versions of GCC have a special
+# optimization setting -Og for exactly this purpose, so we use it, along
+# with the flag to enable gdb symbols.
+#
+# If you really want optimization without debugging support, try -O2 or
+# (maybe) -O3.
+
+#STM32_CFLAGS_OPTIMIZATION ?= -O2
+STM32_CFLAGS_OPTIMIZATION ?= -ggdb -Og
+
# whew, that's a lot of cflags
-CFLAGS = -ggdb -O2 -Wall -Warray-bounds #-Wextra
+CFLAGS = $(STM32_CFLAGS_OPTIMIZATION) -Wall -Warray-bounds #-Wextra
CFLAGS += -mcpu=cortex-m4 -mthumb -mlittle-endian -mthumb-interwork
CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
CFLAGS += -DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DSTM32F429xx
@@ -110,37 +121,37 @@ export CFLAGS
all: board-test cli-test libhal-test hsm bootloader
-$(MBED_DIR)/libstmf4.a:
+$(MBED_DIR)/libstmf4.a: .FORCE
$(MAKE) -C $(MBED_DIR)
-board-test: $(BOARD_OBJS) $(LIBS)
+board-test: $(BOARD_OBJS) $(LIBS) .FORCE
$(MAKE) -C projects/board-test
-cli-test: $(BOARD_OBJS) $(LIBS) $(LIBCLI_BLD)/libcli.a $(LIBHAL_BLD)/libhal.a $(RTOS_DIR)/librtos.a
+cli-test: $(BOARD_OBJS) $(LIBS) $(LIBCLI_BLD)/libcli.a $(LIBHAL_BLD)/libhal.a $(RTOS_DIR)/librtos.a .FORCE
$(MAKE) -C projects/cli-test
-$(RTOS_DIR)/librtos.a:
+$(RTOS_DIR)/librtos.a: .FORCE
$(MAKE) -C $(RTOS_DIR)
-rtos-test: $(RTOS_OBJS) $(LIBS) $(RTOS_DIR)/librtos.a
+rtos-test: $(RTOS_OBJS) $(LIBS) $(RTOS_DIR)/librtos.a .FORCE
$(MAKE) -C projects/rtos-test
-$(LIBTFM_BLD)/libtfm.a:
+$(LIBTFM_BLD)/libtfm.a: .FORCE
$(MAKE) -C $(LIBTFM_BLD) PREFIX=$(PREFIX)
-$(LIBHAL_BLD)/libhal.a: $(LIBTFM_BLD)/libtfm.a
+$(LIBHAL_BLD)/libhal.a: $(LIBTFM_BLD)/libtfm.a .FORCE
$(MAKE) -C $(LIBHAL_BLD) IO_BUS=fmc RPC_MODE=server RPC_TRANSPORT=serial KS=flash libhal.a
-$(LIBCLI_BLD)/libcli.a:
+$(LIBCLI_BLD)/libcli.a: .FORCE
$(MAKE) -C $(LIBCLI_BLD)
-libhal-test: $(BOARD_OBJS) $(LIBS) $(LIBHAL_BLD)/libhal.a
+libhal-test: $(BOARD_OBJS) $(LIBS) $(LIBHAL_BLD)/libhal.a .FORCE
$(MAKE) -C projects/libhal-test
-hsm: $(BOARD_OBJS) $(LIBS) $(LIBHAL_BLD)/libhal.a $(RTOS_DIR)/librtos.a $(LIBCLI_BLD)/libcli.a
+hsm: $(BOARD_OBJS) $(LIBS) $(LIBHAL_BLD)/libhal.a $(RTOS_DIR)/librtos.a $(LIBCLI_BLD)/libcli.a .FORCE
$(MAKE) -C projects/hsm
-bootloader: $(BOARD_OBJS) $(LIBS) $(LIBHAL_BLD)/libhal.a
+bootloader: $(BOARD_OBJS) $(LIBS) $(LIBHAL_BLD)/libhal.a .FORCE
$(MAKE) -C projects/bootloader
# don't automatically delete objects, to avoid a lot of unnecessary rebuilding
@@ -148,17 +159,27 @@ bootloader: $(BOARD_OBJS) $(LIBS) $(LIBHAL_BLD)/libhal.a
.PHONY: board-test rtos-test libhal-test cli-test hsm bootloader
+# We don't (and shouldn't) know enough about libraries and projects to
+# know whether they need rebuilding or not, so we let their Makefiles
+# decide that. Which means we always need to run all the sub-makes.
+# We could do this with .PHONY (which is supposedly more "efficient")
+# but using a .FORCE target is simpler once one takes inter-library
+# dependency specifications into account.
+
+.FORCE: # (sic)
+
clean:
rm -f $(BOARD_OBJS)
+ $(MAKE) -C $(LIBHAL_BLD) clean
$(MAKE) -C projects/board-test clean
$(MAKE) -C projects/cli-test clean
$(MAKE) -C projects/rtos-test clean
$(MAKE) -C projects/libhal-test clean
$(MAKE) -C projects/hsm clean
+ $(MAKE) -C projects/bootloader clean
distclean: clean
$(MAKE) -C $(MBED_DIR) clean
$(MAKE) -C $(RTOS_DIR) clean
- $(MAKE) -C $(LIBHAL_BLD) clean
$(MAKE) -C $(LIBTFM_BLD) clean
$(MAKE) -C $(LIBCLI_BLD) clean