aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile94
1 files changed, 94 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1f5b63f
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,94 @@
+# Top-level package build for Cryptech Alpha board.
+
+export CRYPTECH_VERSION := 2.0
+
+HEAD_TIME := $(shell git show -s --format=%ct HEAD)
+HEAD_HASH := $(shell git rev-parse HEAD)
+
+PACKAGE_NAME := cryptech-alpha
+PACKAGE_VERSION := ${CRYPTECH_VERSION}~${HEAD_TIME}~${HEAD_HASH}
+
+export GNUPGHOME := /home/aptbot/gnupg
+
+REPO_BASE := /home/aptbot/alpha
+REPO_UMASK := 002
+
+PBUILDER_BASE := ${HOME}/pbuilder
+PBUILDER_TARGETS := debian/jessie/i386 debian/jessie/amd64 ubuntu/xenial/i386 ubuntu/xenial/amd64
+
+REPO_UPLOAD_USER := aptbot
+REPO_UPLOAD_URI := rsync://apt.cryptech.is/alpha/
+
+# Yes, we really are putting the firmware tarball into the source package here.
+
+FIRMWARE_TARBALL := build/cryptech-alpha-firmware.tar.gz
+BITSTREAM := build/core/platform/alpha/build/alpha_fmc.bit
+ELVES := build/sw/stm32/projects/bootloader/bootloader.elf build/sw/stm32/projects/hsm/hsm.elf
+FIRMWARE_BINARY := ${ELVES} ${ELVES:.elf=.bin}
+FIRMWARE_ALL := ${BITSTREAM} ${FIRMWARE_BINARY}
+
+RTL_SOURCE := $(shell find source/core -name .git -prune -o -type f -print)
+SW_SOURCE := $(shell find source/sw source/user -name .git -prune -o -type f -print)
+
+# Command to generate a new changelog containing one entry.
+# Does nothing if the changelog already exists.
+
+DCH = test -f debian/changelog || \
+ EDITOR=true VISUAL=true TZ=UTC DEBEMAIL='APT Builder Robot <aptbot@cryptech.is>' \
+ dch --create --package ${PACKAGE_NAME} --newversion '${PACKAGE_VERSION}' \
+ '$(strip Version ${CRYPTECH_VERSION} package for Cryptech Alpha development board.)'
+
+all: init firmware dsc pbuilder homebrew
+
+enchilada: all upload
+
+init:
+ git submodule update --init --recursive
+
+clean:
+ git clean -dfx
+ git submodule foreach --recursive git clean -dfx
+
+sandblast: clean
+ git submodule deinit -f .
+
+firmware: shadow ${FIRMWARE_TARBALL}
+
+shadow: build
+ ./build-shadow-tree.py
+
+${FIRMWARE_TARBALL}: ${BITSTREAM} $(sort ${ELVES} ${ELVES:.elf=.bin})
+ ./build-firmware-package.py $(basename $@) $^
+ gzip -9f $(basename $@)
+
+bitstream: ${BITSTREAM}
+
+${BITSTREAM}: ${RTL_SOURCE}
+ ${MAKE} -C build/core/platform/alpha/build
+
+${ELVES:.elf=.bin}: shadow elves
+
+elves:
+ ${MAKE} -C build/core/sw/stm32 bootloader hsm
+
+dsc:
+ cd source; ${DCH}
+ cd source; debuild -S -uc -us
+
+pbuilder:
+ rm -f ${PBUILDER_BASE}/*result/*
+ umask ${REPO_UMASK}; \
+ for target in ${PBUILDER_TARGETS}; do echo $$target | tr '/' ' '; done | \
+ while read dist code arch; do \
+ reprepro -b ${REPO_BASE}/$$dist -A $$arch list $$code ${PACKAGE_NAME} | awk '{v = $$3} END {exit v != "${PACKAGE_VERSION}"}' && continue; \
+ pbuilder-dist $$code $$arch build ${PACKAGE_NAME}_${PACKAGE_VERSION}.dsc; \
+ reprepro -b ${REPO_BASE}/$$dist include $$code ${PBUILDER_BASE}/$${code}-$${arch}_result/${PACKAGE_NAME}_${PACKAGE_VERSION}_$${arch}.changes; \
+ done
+
+RSYNC := rsync --rsh 'ssh -l ${REPO_UPLOAD_USER}' --archive --itemize-changes
+
+upload:
+ ${RSYNC} --ignore-existing ${REPO_BASE}/ ${REPO_UPLOAD_URI}
+ ${RSYNC} --delete --delete-delay ${REPO_BASE}/ ${REPO_UPLOAD_URI}
+
+.PHONY: all init clean firmware shadow bitstream elves dsc pbuilder homebrew upload enchilada sandblast