solo1/Makefile

149 wiersze
4.5 KiB
Makefile
Czysty Zwykły widok Historia

2018-05-07 00:14:52 +00:00
#define uECC_arch_other 0
#define uECC_x86 1
#define uECC_x86_64 2
#define uECC_arm 3
#define uECC_arm_thumb 4
#define uECC_arm_thumb2 5
#define uECC_arm64 6
#define uECC_avr 7
ecc_platform=2
2018-05-07 00:14:52 +00:00
2019-03-06 19:05:44 +00:00
src = $(wildcard pc/*.c) $(wildcard fido2/*.c) $(wildcard fido2/extensions/*.c) \
$(wildcard crypto/sha256/*.c) crypto/tiny-AES-c/aes.c
2019-01-07 04:15:43 +00:00
obj = $(src:.c=.o) crypto/micro-ecc/uECC.o
2018-04-28 17:40:28 +00:00
LIBCBOR = tinycbor/lib/libtinycbor.a
2018-11-04 22:16:16 +00:00
2018-10-25 03:20:46 +00:00
ifeq ($(shell uname -s),Darwin)
export LDFLAGS = -Wl,-dead_strip
else
export LDFLAGS = -Wl,--gc-sections
endif
LDFLAGS += $(LIBCBOR)
2019-03-06 19:05:44 +00:00
VERSION_FULL:=$(shell git describe)
VERSION:=$(shell python -c 'print("$(VERSION_FULL)".split("-")[0])')
2019-03-06 19:05:44 +00:00
VERSION_MAJ:=$(shell python -c 'print("$(VERSION)".split(".")[0])')
VERSION_MIN:=$(shell python -c 'print("$(VERSION)".split(".")[1])')
VERSION_PAT:=$(shell python -c 'print("$(VERSION)".split(".")[2])')
VERSION_FLAGS= -DSOLO_VERSION_MAJ=$(VERSION_MAJ) -DSOLO_VERSION_MIN=$(VERSION_MIN) \
-DSOLO_VERSION_PATCH=$(VERSION_PAT) -DSOLO_VERSION=\"$(VERSION_FULL)\"
2019-04-24 15:45:30 +00:00
CFLAGS = -O2 -fdata-sections -ffunction-sections $(VERSION_FLAGS) -g
2018-09-13 02:32:58 +00:00
INCLUDES = -I./tinycbor/src -I./crypto/sha256 -I./crypto/micro-ecc/ -Icrypto/tiny-AES-c/ -I./fido2/ -I./pc -I./fido2/extensions
2019-02-26 19:16:38 +00:00
INCLUDES += -I./crypto/cifra/src
CFLAGS += $(INCLUDES)
# for crypto/tiny-AES-c
2019-10-08 15:58:23 +00:00
CFLAGS += -DAES256=1 -DAPP_CONFIG=\"app.h\" -DSOLO_EXPERIMENTAL=1
2018-04-28 17:40:28 +00:00
name = main
.PHONY: all $(LIBCBOR) black blackcheck cppcheck wink fido2-test clean full-clean travis test clean version
2018-11-23 16:51:38 +00:00
all: main
tinycbor/Makefile crypto/tiny-AES-c/aes.c:
git submodule update --init
.PHONY: cbor
cbor: $(LIBCBOR)
2019-01-06 19:48:18 +00:00
$(LIBCBOR):
2019-04-24 23:33:26 +00:00
cd tinycbor/ && $(MAKE) clean && $(MAKE) LDFLAGS='' -j8
version:
@git describe
2019-02-13 02:25:08 +00:00
test: venv
2019-01-06 19:48:18 +00:00
$(MAKE) clean
$(MAKE) -C . main
$(MAKE) clean
2019-10-25 02:44:51 +00:00
$(MAKE) -C ./targets/stm32l432 test PREFIX=$(PREFIX) "VENV=$(VENV)" VERSION_FULL=${VERSION_FULL}
2019-01-06 19:48:18 +00:00
$(MAKE) clean
$(MAKE) cppcheck
$(name): $(obj) $(LIBCBOR)
2018-04-28 17:40:28 +00:00
$(CC) $(LDFLAGS) -o $@ $(obj) $(LDFLAGS)
2018-05-03 02:52:41 +00:00
2019-01-07 04:15:43 +00:00
crypto/micro-ecc/uECC.o: ./crypto/micro-ecc/uECC.c
$(CC) -c -o $@ $^ -O2 -fdata-sections -ffunction-sections -DuECC_PLATFORM=$(ecc_platform) -I./crypto/micro-ecc/
2018-05-07 00:14:52 +00:00
2019-02-13 02:25:08 +00:00
venv:
python3 -m venv venv
venv/bin/pip -q install --upgrade pip
2019-02-13 02:25:08 +00:00
venv/bin/pip -q install --upgrade -r tools/requirements.txt
venv/bin/pip -q install --upgrade black
# selectively reformat our own code
2019-02-13 02:25:08 +00:00
black: venv
venv/bin/black --skip-string-normalization --check tools/
2019-02-13 02:25:08 +00:00
wink: venv
2019-02-26 17:58:58 +00:00
venv/bin/solo key wink
2019-02-13 02:25:08 +00:00
fido2-test: venv
venv/bin/python tools/ctap_test.py
update:
git fetch --tags
git checkout master
git rebase origin/master
git submodule update --init --recursive
DOCKER_TOOLCHAIN_IMAGE := "solokeys/solo-firmware-toolchain"
docker-build-toolchain:
docker build -t $(DOCKER_TOOLCHAIN_IMAGE) .
docker tag $(DOCKER_TOOLCHAIN_IMAGE):latest $(DOCKER_TOOLCHAIN_IMAGE):${VERSION}
docker tag $(DOCKER_TOOLCHAIN_IMAGE):latest $(DOCKER_TOOLCHAIN_IMAGE):${VERSION_MAJ}
docker tag $(DOCKER_TOOLCHAIN_IMAGE):latest $(DOCKER_TOOLCHAIN_IMAGE):${VERSION_MAJ}.${VERSION_MIN}
uncached-docker-build-toolchain:
docker build --no-cache -t $(DOCKER_TOOLCHAIN_IMAGE) .
docker tag $(DOCKER_TOOLCHAIN_IMAGE):latest $(DOCKER_TOOLCHAIN_IMAGE):${VERSION}
docker tag $(DOCKER_TOOLCHAIN_IMAGE):latest $(DOCKER_TOOLCHAIN_IMAGE):${VERSION_MAJ}
docker tag $(DOCKER_TOOLCHAIN_IMAGE):latest $(DOCKER_TOOLCHAIN_IMAGE):${VERSION_MAJ}.${VERSION_MIN}
docker-build-all:
2019-02-17 02:27:56 +00:00
docker run --rm -v "$(CURDIR)/builds:/builds" \
2019-10-24 06:55:59 +00:00
-v "$(CURDIR):/solo" \
$(DOCKER_TOOLCHAIN_IMAGE) "solo/in-docker-build.sh" ${VERSION_FULL}
2019-01-17 00:50:52 +00:00
CPPCHECK_FLAGS=--quiet --error-exitcode=2
cppcheck:
cppcheck $(CPPCHECK_FLAGS) crypto/aes-gcm
cppcheck $(CPPCHECK_FLAGS) crypto/sha256
cppcheck $(CPPCHECK_FLAGS) fido2
cppcheck $(CPPCHECK_FLAGS) pc
2018-05-03 02:52:41 +00:00
clean:
2018-11-23 16:51:38 +00:00
rm -f *.o main.exe main $(obj)
for f in crypto/tiny-AES-c/Makefile tinycbor/Makefile ; do \
if [ -f "$$f" ]; then \
(cd `dirname $$f` ; git checkout -- .) ;\
fi ;\
done
2019-01-06 19:48:18 +00:00
full-clean: clean
2019-02-13 02:25:08 +00:00
rm -rf venv
2019-01-07 01:42:50 +00:00
2019-10-25 03:27:58 +00:00
test-docker:
rm -rf builds/*
$(MAKE) uncached-docker-build-toolchain
# Check if there are 4 docker images/tas named "solokeys/solo-firmware-toolchain"
NTAGS=$$(docker images | grep -c "solokeys/solo-firmware-toolchain") && [ $$NTAGS -eq 4 ]
$(MAKE) docker-build-all
# Check that the builds were created
NFILES=$$(ls -l builds | grep -c "bootloader") && [ $$NFILES -eq 4 ]
NFILES=$$(ls -l builds | grep -c "bundle") && [ $$NFILES -eq 6 ]
NFILES=$$(ls -l builds | grep -c "firmware") && [ $$NFILES -eq 10 ]
2019-01-07 01:42:50 +00:00
travis:
2019-02-13 02:25:08 +00:00
$(MAKE) test VENV=". ../../venv/bin/activate;"
2019-10-25 03:27:58 +00:00
$(MAKE) test-docker
$(MAKE) black