Updater/Makefile
Simon Rozman 46495773c2 Move keypair source out of source folder
This allows us to use `git clean` without risking to loose keypair,
since it is typically .gitignored and not included in the Git
repository.

Signed-off-by: Simon Rozman <simon@rozman.si>
2022-10-05 19:16:05 +02:00

52 lines
1.4 KiB
Makefile

# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright © 2016-2022 Amebis
KEY_DIR=..\include
######################################################################
# Main targets
######################################################################
All :: \
GenRSAKeypair
Clean ::
# Ommited intentionally not to delete keys accidentaly.
######################################################################
# Folder creation
######################################################################
"$(APPDATA)\Updater" \
"$(KEY_DIR)" :
if not exist $@ md $@
######################################################################
# Building
######################################################################
GenRSAKeypair :: \
"$(APPDATA)\Updater" \
"$(KEY_DIR)" \
"$(KEY_DIR)\UpdaterKeyPrivate.bin" \
"$(KEY_DIR)\UpdaterKeyPublic.bin"
"$(APPDATA)\Updater\Keypair.txt" :
openssl.exe genrsa -out $@ 4096
"$(KEY_DIR)\UpdaterKeyPrivate.bin" : "$(APPDATA)\Updater\Keypair.txt"
if exist $@ del /f /q $@
if exist "$(@:"=).tmp" del /f /q "$(@:"=).tmp"
openssl.exe rsa -in $** -inform PEM -outform DER -out "$(@:"=).tmp"
move /y "$(@:"=).tmp" $@ > NUL
"$(KEY_DIR)\UpdaterKeyPublic.bin" : "$(APPDATA)\Updater\Keypair.txt"
if exist $@ del /f /q $@
if exist "$(@:"=).tmp" del /f /q "$(@:"=).tmp"
openssl.exe rsa -in $** -inform PEM -outform DER -out "$(@:"=).tmp" -pubout
move /y "$(@:"=).tmp" $@ > NUL