aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2016-04-11 14:44:44 -0400
committerPaul Selkirk <paul@psgd.org>2016-04-11 14:44:44 -0400
commit79b1ba7104dba52dbfacf11a07305702889f440b (patch)
tree75a08fdc6e3af427e953f319b3fdb0f9dcfdf80e /Makefile
parentd5669dac8c7ab2fbf6bd3c7faed7ce050c94ee1a (diff)
Reorganize Makefile and directory structure, because it's messy, and it's about to get messier.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile92
1 files changed, 35 insertions, 57 deletions
diff --git a/Makefile b/Makefile
index f4185bf..c653a4d 100644
--- a/Makefile
+++ b/Makefile
@@ -27,33 +27,25 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-# "stm32-native" projects
-SELF-TESTS = fmc-test led-test short-test uart-test fmc-perf
-vpath %.c self-test
-
-# apps originally written for unix-like environment
-#LIBHAL-TESTS = cores test-bus test-trng test-hash test-aes-key-wrap test-pbkdf2 test-ecdsa test-rsa
-#LIBHAL-TESTS = cores test-hash test-rpc_hash
-LIBHAL-TESTS = test-rpc_server
-vpath %.c libhal/tests libhal/utils
-
# absolute path, because we're going to be passing -I cflags to sub-makes
-TOPLEVEL = $(shell pwd)
+export TOPLEVEL = $(shell pwd)
# Location of the Libraries folder from the STM32F0xx Standard Peripheral Library
STD_PERIPH_LIB = $(TOPLEVEL)/Drivers
+export LIBS = $(STD_PERIPH_LIB)/libstmf4.a
# linker script
-LDSCRIPT = $(TOPLEVEL)/Device/ldscripts/stm32f429bitx.ld
+export LDSCRIPT = $(TOPLEVEL)/Device/ldscripts/stm32f429bitx.ld
# board-specific objects, to link into every project
-BOARD_OBJS = stm32f4xx_hal_msp.o stm32f4xx_it.o stm-fmc.o stm-init.o stm-uart.o \
- Device/startup_stm32f429xx.o Device/system_stm32f4xx.o
-
-# a few objects for libhal/test projects
-LIBC_OBJS = syscalls.o printf.o gettimeofday.o
-
-LIBS = $(STD_PERIPH_LIB)/libstmf4.a libhal/libhal.a thirdparty/libtfm/libtfm.a
+export BOARD_OBJS = $(TOPLEVEL)/stm32f4xx_hal_msp.o \
+ $(TOPLEVEL)/stm32f4xx_it.o \
+ $(TOPLEVEL)/stm-fmc.o \
+ $(TOPLEVEL)/stm-init.o \
+ $(TOPLEVEL)/stm-uart.o \
+ $(TOPLEVEL)/syscalls.o \
+ $(TOPLEVEL)/Device/startup_stm32f429xx.o \
+ $(TOPLEVEL)/Device/system_stm32f4xx.o
# cross-building tools
PREFIX=arm-none-eabi-
@@ -69,68 +61,54 @@ CFLAGS = -ggdb -O2 -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
+CFLAGS += -D__CORTEX_M4 -DTARGET_STM -DTARGET_STM32F4 -DTARGET_STM32F429ZI -DTOOLCHAIN_GCC -D__FPU_PRESENT=1
CFLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections
CFLAGS += -std=c99
-CFLAGS += -I $(TOPLEVEL) -I $(STD_PERIPH_LIB)
+CFLAGS += -I $(TOPLEVEL)
+CFLAGS += -I $(STD_PERIPH_LIB)
CFLAGS += -I $(STD_PERIPH_LIB)/CMSIS/Device/ST/STM32F4xx/Include
CFLAGS += -I $(STD_PERIPH_LIB)/CMSIS/Include
CFLAGS += -I $(STD_PERIPH_LIB)/STM32F4xx_HAL_Driver/Inc
-CFLAGS += -I libhal
export CFLAGS
-#all: lib self-test libhal-tests
-all: lib libhal-tests
+all: board-test libhal-test
init:
git submodule update --init --recursive
-lib: $(LIBS)
-
$(STD_PERIPH_LIB)/libstmf4.a:
$(MAKE) -C $(STD_PERIPH_LIB)
-thirdparty/libtfm/libtfm.a:
- $(MAKE) -C thirdparty/libtfm PREFIX=$(PREFIX)
+board-test: $(BOARD_OBJS) $(LIBS)
+ $(MAKE) -C projects/board-test
-libhal/libhal.a: thirdparty/libtfm/libtfm.a
- $(MAKE) -C libhal IO_BUS=fmc RPC_SERVER=yes RPC_TRANSPORT=serial KS=volatile libhal.a
-# $(MAKE) -C libhal RPC_CLIENT=local IO_BUS=fmc KS=volatile libhal.a
+LIBS_DIR = $(TOPLEVEL)/libraries
-self-test: $(SELF-TESTS:=.elf)
+export LIBTFM_DIR = $(LIBS_DIR)/thirdparty/libtfm
-%.elf: %.o $(BOARD_OBJS) $(STD_PERIPH_LIB)/libstmf4.a
- $(CC) $(CFLAGS) $^ -o $@ -T$(LDSCRIPT) -g -Wl,-Map=$*.map
- $(OBJCOPY) -O ihex $*.elf $*.hex
- $(OBJCOPY) -O binary $*.elf $*.bin
- $(OBJDUMP) -St $*.elf >$*.lst
- $(SIZE) $*.elf
+$(LIBTFM_DIR)/libtfm.a:
+ $(MAKE) -C $(LIBTFM_DIR) PREFIX=$(PREFIX)
-libhal-tests: $(LIBHAL-TESTS:=.bin)
+export LIBHAL_DIR = $(LIBS_DIR)/libhal
-# .mo extension for files with main() that need to be wrapped as __main()
-%.mo: %.c
- $(CC) -c $(CFLAGS) -Dmain=__main -o $@ $<
+$(LIBHAL_DIR)/libhal.a: $(LIBTFM_DIR)/libtfm.a
+# $(MAKE) -C $(LIBHAL_DIR) RPC_CLIENT=local IO_BUS=fmc KS=volatile libhal.a
+ $(MAKE) -C $(LIBHAL_DIR) IO_BUS=fmc RPC_SERVER=yes RPC_TRANSPORT=serial KS=volatile libhal.a
-%.bin: %.mo main.o $(BOARD_OBJS) $(LIBC_OBJS) $(LIBS)
- $(CC) $(CFLAGS) $^ -o $*.elf -T$(LDSCRIPT) -g -Wl,-Map=$*.map
- $(OBJCOPY) -O ihex $*.elf $*.hex
- $(OBJCOPY) -O binary $*.elf $*.bin
- $(OBJDUMP) -St $*.elf >$*.lst
- $(SIZE) $*.elf
+libhal-test: $(BOARD_OBJS) $(LIBS) $(LIBHAL_DIR)/libhal.a
+ $(MAKE) -C projects/libhal-test
# don't automatically delete objects, to avoid a lot of unnecessary rebuilding
-.SECONDARY: $(BOARD_OBJS) $(LIBC_OBJS)
+.SECONDARY: $(BOARD_OBJS)
+
+.PHONY: board-test libhal-test
clean:
- find ./ -name '*~' | xargs rm -f
- rm -f $(BOARD_OBJS) $(LIBC_OBJS) *.o *.mo
- rm -f *.elf
- rm -f *.hex
- rm -f *.bin
- rm -f *.map
- rm -f *.lst
+ rm -f $(BOARD_OBJS)
+ $(MAKE) -C projects/board-test clean
+ $(MAKE) -C projects/libhal-test clean
distclean: clean
$(MAKE) -C $(STD_PERIPH_LIB) clean
- $(MAKE) -C thirdparty/libtfm clean
- $(MAKE) -C libhal clean
+ $(MAKE) -C $(LIBHAL_DIR) clean
+ $(MAKE) -C $(LIBTFM_DIR) clean