-
Notifications
You must be signed in to change notification settings - Fork 55
/
Makefile.top
97 lines (69 loc) · 2.49 KB
/
Makefile.top
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
mkfile_path := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
ROOT_DIR := ${mkfile_path}
SCRIPTS_DIR := ${ROOT_DIR}/scripts
BUILD_DIR ?= ${ROOT_DIR}/build
BUILD_LINUX ?= ${BUILD_DIR}/linux
BUILD_WIN ?= ${BUILD_DIR}/win
INSTALL_DIR ?= ${ROOT_DIR}/install
RELEASE_DIR ?= ${ROOT_DIR}/release
WIN_RELEASE_DIR ?= ${RELEASE_DIR}/windows
LINUX_RELEASE_DIR ?= ${RELEASE_DIR}/linux
DEPS=cmake qtdeclarative5-dev libusb-1.0-0-dev
EXTRA_DEPS: rpm
#.PHONY: release prepare build clean windows windows-installer
.PHONY: deps prepare linux-clean windows-clean clean
prepare:
mkdir -p ${BUILD_LINUX}
mkdir -p ${BUILD_WIN}
mkdir -p ${INSTALL_DIR}
mkdir -p ${RELEASE_DIR}
$(BUILD_LINUX):
mkdir -p ${BUILD_LINUX}
$(BUILD_WIN):
mkdir -p ${BUILD_WIN}
$(INSTALL_DIR):
mkdir -p ${INSTALL_DIR}
$(LINUX_RELEASE_DIR):
mkdir -p ${LINUX_RELEASE_DIR}
$(WIN_RELEASE_DIR):
mkdir -p ${WIN_RELEASE_DIR}
deps:
sudo apt-get install ${DEPS}
### Linux
$(BUILD_LINUX)/nitrokey-app: | ${BUILD_LINUX}
cd ${BUILD_LINUX} && \
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} ${ROOT_DIR} && \
make
build: $(BUILD_LINUX)/nitrokey-app
install: build | ${INSTALL_DIR}
cd ${BUILD_LINUX} && make install
### Windows
$(BUILD_WIN)/release/nitrokey-app.exe: | ${BUILD_WIN}
export PATH=${MXE_ROOT}/usr/bin/:${PATH} && \
cd ${BUILD_WIN} && \
${MXE_ROOT}/usr/i686-w64-mingw32.static/qt5/bin/qmake -spec ${MXE_ROOT}/usr/i686-w64-mingw32.static/qt5/mkspecs/win32-g++ -o Makefile ${ROOT_DIR}/nitrokey-app-qt5.pro && \
make
windows: $(BUILD_WIN)/release/nitrokey-app.exe
### Releasing
linux-release: build | $(LINUX_RELEASE_DIR)
cd ${BUILD_LINUX} && \
make package && \
mv *.deb *.rpm ${LINUX_RELEASE_DIR} && cd ${LINUX_RELEASE_DIR} && \
find . -name *.deb -type f -printf '%f' | xargs -0 -n1 -I{} sh -c '${SCRIPTS_DIR}/fix-deb.sh {}' && \
find . -name *.deb -type f -printf "%f" | xargs -0 -n1 -I{} sh -c 'sha256sum -b {} > {}.sha256; md5sum -b {} > {}.md5' && \
find . -name *.rpm -type f -printf "%f" | xargs -0 -n1 -I{} sh -c 'sha256sum -b {} > {}.sha256; md5sum -b {} > {}.md5'
windows-release: windows | $(WIN_RELEASE_DIR)
cd ${ROOT_DIR}/nsis && \
cp ${BUILD_WIN}/release/nitrokey-app.exe . && \
makensis nitrokey-app.nsis && \
cp Nitrokey-App-Installer.exe ${BUILD_WIN}/release/
release-all: linux-release windows-release
### Cleaning
linux-clean:
cd ${BUILD_LINUX} && make clean
windows-clean:
cd ${BUILD_WIN} && make clean
clean: linux-clean windows-clean
purge:
rm -rf ${BUILD_DIR}
rm -rf ${RELEASE_DIR}