From e3db117ae05a248773abe4b7ec2ef95ed7203b8e Mon Sep 17 00:00:00 2001 From: Paul Selkirk Date: Sat, 25 Jun 2016 15:13:43 -0400 Subject: Split LIB*_DIR into _SRC and _BLD. Also rename all instances of GNUmakefile to Makefile. --- .gitignore | 1 - Makefile | 41 ++++++++++++++------------- libraries/libcli/Makefile | 16 ----------- libraries/libhal/GNUmakefile | 14 ---------- libraries/libhal/Makefile | 10 +++++++ libraries/libhal/tests/GNUmakefile | 10 ------- libraries/libhal/tests/Makefile | 10 +++++++ libraries/libhal/utils/GNUmakefile | 10 ------- libraries/libhal/utils/Makefile | 10 +++++++ libraries/libtfm/GNUmakefile | 46 ------------------------------- libraries/libtfm/Makefile | 46 +++++++++++++++++++++++++++++++ libraries/libtfm/tomsfastmath/GNUmakefile | 8 ------ libraries/libtfm/tomsfastmath/Makefile | 8 ++++++ projects/cli-test/Makefile | 6 ++-- projects/hsm/Makefile | 8 +++--- projects/libhal-test/Makefile | 6 ++-- 16 files changed, 116 insertions(+), 134 deletions(-) delete mode 100644 libraries/libhal/GNUmakefile create mode 100644 libraries/libhal/Makefile delete mode 100644 libraries/libhal/tests/GNUmakefile create mode 100644 libraries/libhal/tests/Makefile delete mode 100644 libraries/libhal/utils/GNUmakefile create mode 100644 libraries/libhal/utils/Makefile delete mode 100644 libraries/libtfm/GNUmakefile create mode 100644 libraries/libtfm/Makefile delete mode 100644 libraries/libtfm/tomsfastmath/GNUmakefile create mode 100644 libraries/libtfm/tomsfastmath/Makefile diff --git a/.gitignore b/.gitignore index 874b3a0..25ec77d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,4 @@ *.mo *.o *~ -libraries/libcli/libcli.h libraries/libtfm/tfm.h diff --git a/Makefile b/Makefile index 1cbb3ac..af50d13 100644 --- a/Makefile +++ b/Makefile @@ -29,19 +29,25 @@ # absolute path, because we're going to be passing things to sub-makes export TOPLEVEL = $(abspath .) +export CRYPTECH_ROOT = $(abspath ../..) # define board: dev-bridge or alpha BOARD = TARGET_CRYPTECH_ALPHA -# Location of the Libraries folder from the STM32F4 Standard Peripheral Library export LIBS_DIR = $(TOPLEVEL)/libraries export MBED_DIR = $(LIBS_DIR)/mbed export CMSIS_DIR = $(MBED_DIR)/targets/cmsis/TARGET_STM/TARGET_STM32F4 export BOARD_DIR = $(CMSIS_DIR)/$(BOARD) export RTOS_DIR = $(MBED_DIR)/rtos -export LIBTFM_DIR = $(LIBS_DIR)/libtfm -export LIBHAL_DIR = $(LIBS_DIR)/libhal -export LIBCLI_DIR = $(LIBS_DIR)/libcli + +export LIBHAL_SRC = $(CRYPTECH_ROOT)/sw/libhal +export LIBHAL_BLD = $(LIBS_DIR)/libhal + +export LIBCLI_SRC = $(CRYPTECH_ROOT)/user/ft/libcli +export LIBCLI_BLD = $(LIBS_DIR)/libcli + +export LIBTFM_SRC = $(CRYPTECH_ROOT)/sw/thirdparty/libtfm +export LIBTFM_BLD = $(LIBS_DIR)/libtfm export LIBS = $(MBED_DIR)/libstmf4.a @@ -104,16 +110,13 @@ export CFLAGS all: board-test cli-test libhal-test hsm bootloader -init: - git submodule update --init --recursive --remote - $(MBED_DIR)/libstmf4.a: $(MAKE) -C $(MBED_DIR) board-test: $(BOARD_OBJS) $(LIBS) $(MAKE) -C projects/board-test -cli-test: $(BOARD_OBJS) $(LIBS) $(LIBCLI_DIR)/libcli.a +cli-test: $(BOARD_OBJS) $(LIBS) $(LIBCLI_BLD)/libcli.a $(LIBHAL_BLD)/libhal.a $(RTOS_DIR)/librtos.a $(MAKE) -C projects/cli-test $(RTOS_DIR)/librtos.a: @@ -122,19 +125,19 @@ $(RTOS_DIR)/librtos.a: rtos-test: $(RTOS_OBJS) $(LIBS) $(RTOS_DIR)/librtos.a $(MAKE) -C projects/rtos-test -$(LIBTFM_DIR)/libtfm.a: - $(MAKE) -C $(LIBTFM_DIR) PREFIX=$(PREFIX) +$(LIBTFM_BLD)/libtfm.a: + $(MAKE) -C $(LIBTFM_BLD) PREFIX=$(PREFIX) -$(LIBHAL_DIR)/libhal.a: $(LIBTFM_DIR)/libtfm.a - $(MAKE) -C $(LIBHAL_DIR) IO_BUS=fmc RPC_MODE=server RPC_TRANSPORT=serial KS=flash libhal.a +$(LIBHAL_BLD)/libhal.a: $(LIBTFM_BLD)/libtfm.a + $(MAKE) -C $(LIBHAL_BLD) IO_BUS=fmc RPC_MODE=server RPC_TRANSPORT=serial KS=flash libhal.a -$(LIBCLI_DIR)/libcli.a: - $(MAKE) -C $(LIBCLI_DIR) +$(LIBCLI_BLD)/libcli.a: + $(MAKE) -C $(LIBCLI_BLD) -libhal-test: $(BOARD_OBJS) $(LIBS) $(LIBHAL_DIR)/libhal.a +libhal-test: $(BOARD_OBJS) $(LIBS) $(LIBHAL_BLD)/libhal.a $(MAKE) -C projects/libhal-test -hsm: $(BOARD_OBJS) $(LIBS) $(LIBHAL_DIR)/libhal.a $(RTOS_DIR)/librtos.a $(LIBCLI_DIR)/libcli.a +hsm: $(BOARD_OBJS) $(LIBS) $(LIBHAL_BLD)/libhal.a $(RTOS_DIR)/librtos.a $(LIBCLI_BLD)/libcli.a $(MAKE) -C projects/hsm bootloader: $(BOARD_OBJS) $(LIBS) @@ -156,6 +159,6 @@ clean: distclean: clean $(MAKE) -C $(MBED_DIR) clean $(MAKE) -C $(RTOS_DIR) clean - $(MAKE) -C $(LIBHAL_DIR) clean - $(MAKE) -C $(LIBTFM_DIR) clean - $(MAKE) -C $(LIBCLI_DIR) clean + $(MAKE) -C $(LIBHAL_BLD) clean + $(MAKE) -C $(LIBTFM_BLD) clean + $(MAKE) -C $(LIBCLI_BLD) clean diff --git a/libraries/libcli/Makefile b/libraries/libcli/Makefile index 509f493..bbd686d 100644 --- a/libraries/libcli/Makefile +++ b/libraries/libcli/Makefile @@ -8,19 +8,3 @@ vpath %.c ${REPO} vpath %.h ${REPO} include ${REPO}/Makefile - -# Kludge alert: -# -# We really should teach Makefiles that need libcli.h to look in the -# right place, but we don't want to wire the current location of -# libcli into too many Makefiles, since we intend to move it soon. -# -# So, for the moment, we just copy libcli.h. Clean this up after the -# the repository moves (and maybe do something about the general -# assumption that header files and libraries always live in the same -# directory, that's wrong in a VPATH-based world). - -all: $(abspath .)/libcli.h - -$(abspath .)/libcli.h: ${REPO}/libcli.h - cp -p $< $@ diff --git a/libraries/libhal/GNUmakefile b/libraries/libhal/GNUmakefile deleted file mode 100644 index 03b1636..0000000 --- a/libraries/libhal/GNUmakefile +++ /dev/null @@ -1,14 +0,0 @@ -ifndef CRYPTECH_ROOT - CRYPTECH_ROOT := $(abspath ../../../..) -endif - -REPO := ${CRYPTECH_ROOT}/sw/libhal - -TFMDIR := $(abspath ../libtfm) - -CFLAGS += -I${REPO} - -vpath %.c ${REPO} -vpath %.h ${REPO}:${LIBTFM_DIR} - -include ${CRYPTECH_ROOT}/sw/libhal/GNUmakefile diff --git a/libraries/libhal/Makefile b/libraries/libhal/Makefile new file mode 100644 index 0000000..fbc3473 --- /dev/null +++ b/libraries/libhal/Makefile @@ -0,0 +1,10 @@ +ifndef CRYPTECH_ROOT + CRYPTECH_ROOT := $(abspath ../../../..) +endif + +REPO := ${CRYPTECH_ROOT}/sw/libhal + +vpath %.c ${REPO} +vpath %.h ${REPO} + +include ${REPO}/Makefile diff --git a/libraries/libhal/tests/GNUmakefile b/libraries/libhal/tests/GNUmakefile deleted file mode 100644 index 1d7449a..0000000 --- a/libraries/libhal/tests/GNUmakefile +++ /dev/null @@ -1,10 +0,0 @@ -ifndef CRYPTECH_ROOT - CRYPTECH_ROOT := $(abspath ../../../../..) -endif - -TFMDIR := $(abspath ../../libtfm) - -vpath %.c ${CRYPTECH_ROOT}/sw/libhal/tests -vpath %.h ${CRYPTECH_ROOT}/sw/libhal/tests:${LIBTFM_DIR} - -include ${CRYPTECH_ROOT}/sw/libhal/tests/GNUmakefile diff --git a/libraries/libhal/tests/Makefile b/libraries/libhal/tests/Makefile new file mode 100644 index 0000000..7553427 --- /dev/null +++ b/libraries/libhal/tests/Makefile @@ -0,0 +1,10 @@ +ifndef CRYPTECH_ROOT + CRYPTECH_ROOT := $(abspath ../../../../..) +endif + +REPO := ${CRYPTECH_ROOT}/sw/libhal + +vpath %.c ${REPO}/tests +vpath %.h ${REPO}/tests + +include ${REPO}/tests/Makefile diff --git a/libraries/libhal/utils/GNUmakefile b/libraries/libhal/utils/GNUmakefile deleted file mode 100644 index 9d38efd..0000000 --- a/libraries/libhal/utils/GNUmakefile +++ /dev/null @@ -1,10 +0,0 @@ -ifndef CRYPTECH_ROOT - CRYPTECH_ROOT := $(abspath ../../../../..) -endif - -TFMDIR := $(abspath ../../libtfm) - -vpath %.c ${CRYPTECH_ROOT}/sw/libhal/utils -vpath %.h ${CRYPTECH_ROOT}/sw/libhal/utils:${LIBTFM_DIR} - -include ${CRYPTECH_ROOT}/sw/libhal/utils/GNUmakefile diff --git a/libraries/libhal/utils/Makefile b/libraries/libhal/utils/Makefile new file mode 100644 index 0000000..43fbe0d --- /dev/null +++ b/libraries/libhal/utils/Makefile @@ -0,0 +1,10 @@ +ifndef CRYPTECH_ROOT + CRYPTECH_ROOT := $(abspath ../../../../..) +endif + +REPO := ${CRYPTECH_ROOT}/sw/libhal + +vpath %.c ${REPO}/utils +vpath %.h ${REPO}/utils + +include ${REPO}/utils/Makefile diff --git a/libraries/libtfm/GNUmakefile b/libraries/libtfm/GNUmakefile deleted file mode 100644 index ca86f80..0000000 --- a/libraries/libtfm/GNUmakefile +++ /dev/null @@ -1,46 +0,0 @@ - -# This duplicates more of sw/thirdparty/libtfm/GNUmakefile than I -# would like, but it does the job. Prettier makefiles can wait for another day. - -ifndef CRYPTECH_ROOT - CRYPTECH_ROOT := $(abspath ../../../..) -endif - -REPO := ${CRYPTECH_ROOT}/sw/thirdparty/libtfm - -# vpath %.c ${REPO} -# vpath %.h ${REPO} - -BITS := 8192 - -HDR := ${REPO}/tomsfastmath/src/headers/tfm.h -LIB := tomsfastmath/libtfm.a - -#CFLAGS += -DTFM_X86 -#CFLAGS += -DTFM_NO_ASM - -CFLAGS += -fPIC -Wall -W -Wshadow -I${REPO}/tomsfastmath/src/headers -g3 -DFP_MAX_SIZE="(${BITS}*2+(8*DIGIT_BIT))" - -TARGETS := $(notdir ${HDR} ${LIB}) - -all: ${TARGETS} - -clean: - rm -rf ${TARGETS} $(notdir ${HDR}.tmp) ${LIB} tomsfastmath/src - -distclean: clean - rm -f TAGS - -$(notdir ${HDR}): ${HDR} - echo >$@.tmp '/* Configure size of largest bignum we want to handle -- see notes in tfm.pdf */' - echo >>$@.tmp '#define FP_MAX_SIZE (${BITS}*2+(8*DIGIT_BIT))' - echo >>$@.tmp '' - cat >>$@.tmp $^ - mv -f $@.tmp $@ - -$(notdir ${LIB}): ${LIB} - ln -f $^ $@ - -${LIB}: ${HDR} - (cd ${REPO} && find tomsfastmath/src -type d) | xargs mkdir -p - cd tomsfastmath; ${MAKE} CFLAGS='${CFLAGS}' diff --git a/libraries/libtfm/Makefile b/libraries/libtfm/Makefile new file mode 100644 index 0000000..4dfcb45 --- /dev/null +++ b/libraries/libtfm/Makefile @@ -0,0 +1,46 @@ + +# This duplicates more of sw/thirdparty/libtfm/Makefile than I +# would like, but it does the job. Prettier makefiles can wait for another day. + +ifndef CRYPTECH_ROOT + CRYPTECH_ROOT := $(abspath ../../../..) +endif + +REPO := ${CRYPTECH_ROOT}/sw/thirdparty/libtfm + +# vpath %.c ${REPO} +# vpath %.h ${REPO} + +BITS := 8192 + +HDR := ${REPO}/tomsfastmath/src/headers/tfm.h +LIB := tomsfastmath/libtfm.a + +#CFLAGS += -DTFM_X86 +#CFLAGS += -DTFM_NO_ASM + +CFLAGS += -fPIC -Wall -W -Wshadow -I${REPO}/tomsfastmath/src/headers -g3 -DFP_MAX_SIZE="(${BITS}*2+(8*DIGIT_BIT))" + +TARGETS := $(notdir ${HDR} ${LIB}) + +all: ${TARGETS} + +clean: + rm -rf ${TARGETS} $(notdir ${HDR}.tmp) ${LIB} tomsfastmath/src + +distclean: clean + rm -f TAGS + +$(notdir ${HDR}): ${HDR} + echo >$@.tmp '/* Configure size of largest bignum we want to handle -- see notes in tfm.pdf */' + echo >>$@.tmp '#define FP_MAX_SIZE (${BITS}*2+(8*DIGIT_BIT))' + echo >>$@.tmp '' + cat >>$@.tmp $^ + mv -f $@.tmp $@ + +$(notdir ${LIB}): ${LIB} + ln -f $^ $@ + +${LIB}: ${HDR} + (cd ${REPO} && find tomsfastmath/src -type d) | xargs mkdir -p + cd tomsfastmath; ${MAKE} CFLAGS='${CFLAGS}' diff --git a/libraries/libtfm/tomsfastmath/GNUmakefile b/libraries/libtfm/tomsfastmath/GNUmakefile deleted file mode 100644 index 7141763..0000000 --- a/libraries/libtfm/tomsfastmath/GNUmakefile +++ /dev/null @@ -1,8 +0,0 @@ -ifndef CRYPTECH_ROOT - CRYPTECH_ROOT := $(abspath ../../../../..) -endif - -vpath %.c ${CRYPTECH_ROOT}/sw/thirdparty/libtfm/tomsfastmath -vpath %.h ${CRYPTECH_ROOT}/sw/thirdparty/libtfm/tomsfastmath - -include ${CRYPTECH_ROOT}/sw/thirdparty/libtfm/tomsfastmath/makefile diff --git a/libraries/libtfm/tomsfastmath/Makefile b/libraries/libtfm/tomsfastmath/Makefile new file mode 100644 index 0000000..7141763 --- /dev/null +++ b/libraries/libtfm/tomsfastmath/Makefile @@ -0,0 +1,8 @@ +ifndef CRYPTECH_ROOT + CRYPTECH_ROOT := $(abspath ../../../../..) +endif + +vpath %.c ${CRYPTECH_ROOT}/sw/thirdparty/libtfm/tomsfastmath +vpath %.h ${CRYPTECH_ROOT}/sw/thirdparty/libtfm/tomsfastmath + +include ${CRYPTECH_ROOT}/sw/thirdparty/libtfm/tomsfastmath/makefile diff --git a/projects/cli-test/Makefile b/projects/cli-test/Makefile index e043566..ba80c88 100644 --- a/projects/cli-test/Makefile +++ b/projects/cli-test/Makefile @@ -1,6 +1,6 @@ TEST = cli-test -OBJS = crc32.o test_sdram.o mgmt-cli.o mgmt-dfu.c mgmt-fpga.c mgmt-misc.c mgmt-show.c mgmt-test.c +OBJS = crc32.o test_sdram.o mgmt-cli.o mgmt-dfu.c mgmt-fpga.c mgmt-misc.c mgmt-show.c mgmt-test.c mgmt-keystore.o BOARD_OBJS = \ $(TOPLEVEL)/stm-init.o \ @@ -18,10 +18,10 @@ BOARD_OBJS = \ $(BOARD_DIR)/stm32f4xx_hal_msp.o \ $(BOARD_DIR)/stm32f4xx_it_rtos.o -CFLAGS += -I$(LIBCLI_DIR) +CFLAGS += -I$(LIBCLI_SRC) -I$(LIBHAL_SRC) CFLAGS += -I$(RTOS_DIR)/rtos -I$(RTOS_DIR)/rtx/TARGET_CORTEX_M -LIBS += $(LIBCLI_DIR)/libcli.a $(RTOS_DIR)/librtos.a +LIBS += $(LIBCLI_BLD)/libcli.a $(LIBHAL_BLD)/libhal.a $(RTOS_DIR)/librtos.a all: $(TEST:=.elf) diff --git a/projects/hsm/Makefile b/projects/hsm/Makefile index b1718b3..06cfcc2 100644 --- a/projects/hsm/Makefile +++ b/projects/hsm/Makefile @@ -30,13 +30,13 @@ ifndef CRYPTECH_ROOT CRYPTECH_ROOT := $(abspath ../../../..) endif -CFLAGS += -I$(CRYPTECH_ROOT)/sw/libhal -CFLAGS += -I$(LIBCLI_DIR) +CFLAGS += -I$(LIBHAL_SRC) +CFLAGS += -I$(LIBCLI_SRC) CFLAGS += -I$(RTOS_DIR)/rtos -I$(RTOS_DIR)/rtx/TARGET_CORTEX_M -LIBS += $(LIBHAL_DIR)/libhal.a $(LIBTFM_DIR)/libtfm.a +LIBS += $(LIBHAL_BLD)/libhal.a $(LIBTFM_BLD)/libtfm.a +LIBS += $(LIBCLI_BLD)/libcli.a LIBS += $(RTOS_DIR)/librtos.a -LIBS += $(LIBCLI_DIR)/libcli.a all: $(PROJ:=.elf) diff --git a/projects/libhal-test/Makefile b/projects/libhal-test/Makefile index f58f480..7aa8d3e 100644 --- a/projects/libhal-test/Makefile +++ b/projects/libhal-test/Makefile @@ -1,12 +1,12 @@ TEST = cores test-bus test-trng test-hash test-aes-key-wrap test-pbkdf2 test-ecdsa test-rsa test-mkmif -CFLAGS += -I $(LIBHAL_DIR) +CFLAGS += -I $(LIBHAL_SRC) LIBC_OBJS = printf.o gettimeofday.o -LIBS += $(LIBHAL_DIR)/libhal.a $(LIBTFM_DIR)/libtfm.a +LIBS += $(LIBHAL_BLD)/libhal.a $(LIBTFM_BLD)/libtfm.a all: $(TEST:=.elf) -vpath %.c $(LIBHAL_DIR)/tests $(LIBHAL_DIR)/utils +vpath %.c $(LIBHAL_SRC)/tests $(LIBHAL_SRC)/utils # .mo extension for files with main() that need to be wrapped as __main() %.mo: %.c -- cgit v1.2.3