2020-05-14 14:58:08 +00:00
|
|
|
# Copyright (c) 2019-2020 Status Research & Development GmbH. Licensed under
|
|
|
|
# either of:
|
|
|
|
# - Apache License, version 2.0
|
|
|
|
# - MIT license
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
|
|
# according to those terms.
|
2020-05-06 21:26:32 +00:00
|
|
|
|
2020-05-14 14:58:08 +00:00
|
|
|
SHELL := bash # the shell used internally by Make
|
2020-05-06 21:43:20 +00:00
|
|
|
|
2020-05-14 14:58:08 +00:00
|
|
|
# used inside the included makefiles
|
|
|
|
BUILD_SYSTEM_DIR := vendor/nimbus-build-system
|
|
|
|
|
|
|
|
# we don't want an error here, so we can handle things later, in the ".DEFAULT" target
|
|
|
|
-include $(BUILD_SYSTEM_DIR)/makefiles/variables.mk
|
|
|
|
|
|
|
|
.PHONY: \
|
|
|
|
all \
|
2020-06-04 20:56:44 +00:00
|
|
|
bottles \
|
|
|
|
bottles-dummy \
|
|
|
|
bottles-macos \
|
2020-05-14 14:58:08 +00:00
|
|
|
clean \
|
|
|
|
deps \
|
2020-05-25 02:18:37 +00:00
|
|
|
nim_status_client \
|
2020-06-04 20:56:44 +00:00
|
|
|
pkg \
|
|
|
|
pkg-linux \
|
|
|
|
pkg-macos \
|
2020-05-25 02:18:37 +00:00
|
|
|
run \
|
2020-05-14 14:58:08 +00:00
|
|
|
update
|
|
|
|
|
|
|
|
ifeq ($(NIM_PARAMS),)
|
|
|
|
# "variables.mk" was not included, so we update the submodules.
|
|
|
|
GIT_SUBMODULE_UPDATE := git submodule update --init --recursive
|
|
|
|
.DEFAULT:
|
|
|
|
+@ echo -e "Git submodules not found. Running '$(GIT_SUBMODULE_UPDATE)'.\n"; \
|
|
|
|
$(GIT_SUBMODULE_UPDATE); \
|
|
|
|
echo
|
|
|
|
# Now that the included *.mk files appeared, and are newer than this file, Make will restart itself:
|
|
|
|
# https://www.gnu.org/software/make/manual/make.html#Remaking-Makefiles
|
|
|
|
#
|
|
|
|
# After restarting, it will execute its original goal, so we don't have to start a child Make here
|
|
|
|
# with "$(MAKE) $(MAKECMDGOALS)". Isn't hidden control flow great?
|
|
|
|
|
|
|
|
else # "variables.mk" was included. Business as usual until the end of this file.
|
|
|
|
|
2020-05-25 02:18:37 +00:00
|
|
|
all: nim_status_client
|
|
|
|
|
|
|
|
# must be included after the default target
|
|
|
|
-include $(BUILD_SYSTEM_DIR)/makefiles/targets.mk
|
2020-05-14 14:58:08 +00:00
|
|
|
|
|
|
|
ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10...
|
2020-05-25 02:18:37 +00:00
|
|
|
detected_OS := Windows
|
2020-05-14 14:58:08 +00:00
|
|
|
else
|
2020-05-25 02:18:37 +00:00
|
|
|
detected_OS := $(strip $(shell uname))
|
2020-05-14 14:58:08 +00:00
|
|
|
endif
|
|
|
|
|
2020-06-04 20:56:44 +00:00
|
|
|
ifeq ($(detected_OS), Darwin)
|
|
|
|
BOTTLES_TARGET := bottles-macos
|
|
|
|
PKG_TARGET := pkg-macos
|
|
|
|
MACOSX_DEPLOYMENT_TARGET := 10.13
|
|
|
|
export MACOSX_DEPLOYMENT_TARGET
|
|
|
|
CGO_CFLAGS := -mmacosx-version-min=10.13
|
|
|
|
export CGO_CFLAGS
|
|
|
|
CFLAGS := -mmacosx-version-min=10.13
|
|
|
|
export CFLAGS
|
|
|
|
else
|
|
|
|
BOTTLES_TARGET := bottles-dummy
|
|
|
|
PKG_TARGET := pkg-linux
|
|
|
|
endif
|
|
|
|
|
|
|
|
bottles: $(BOTTLES_TARGET)
|
|
|
|
|
|
|
|
bottles-dummy: ;
|
|
|
|
|
|
|
|
BOTTLE_OPENSSL := bottles/openssl/INSTALL_RECEIPT.json
|
|
|
|
|
|
|
|
$(BOTTLE_OPENSSL):
|
|
|
|
rm -rf bottles/Downloads/openssl* bottles/openssl*
|
|
|
|
mkdir -p bottles/Downloads
|
|
|
|
cd bottles/Downloads && \
|
|
|
|
wget -O openssl.tar.gz "https://bintray.com/homebrew/bottles/download_file?file_path=openssl%401.1-1.1.1g.high_sierra.bottle.tar.gz" && \
|
|
|
|
tar xzf openssl* && \
|
|
|
|
mv openssl@1.1/1.1.1g ../openssl
|
|
|
|
|
|
|
|
BOTTLE_PCRE := bottles/pcre/INSTALL_RECEIPT.json
|
|
|
|
|
|
|
|
$(BOTTLE_PCRE):
|
|
|
|
rm -rf bottles/Downloads/pcre* bottles/pcre*
|
|
|
|
mkdir -p bottles/Downloads
|
|
|
|
cd bottles/Downloads && \
|
|
|
|
wget -O pcre.tar.gz "https://bintray.com/homebrew/bottles/download_file?file_path=pcre-8.44.high_sierra.bottle.tar.gz" && \
|
|
|
|
tar xzf pcre* && \
|
|
|
|
mv pcre/8.44 ../pcre
|
|
|
|
|
|
|
|
bottles-macos: | $(BOTTLE_OPENSSL) $(BOTTLE_PCRE)
|
|
|
|
rm -rf bottles/Downloads
|
|
|
|
|
2020-05-14 14:58:08 +00:00
|
|
|
ifeq ($(detected_OS), Darwin)
|
2020-05-25 02:18:37 +00:00
|
|
|
NIM_PARAMS := $(NIM_PARAMS) -L:"-framework Foundation -framework Security -framework IOKit -framework CoreServices"
|
2020-05-14 14:58:08 +00:00
|
|
|
endif
|
|
|
|
|
2020-06-04 20:56:44 +00:00
|
|
|
DOTHERSIDE := vendor/DOtherSide/build/lib/libDOtherSideStatic.a
|
2020-05-25 02:18:37 +00:00
|
|
|
|
|
|
|
# Qt5 dirs (we can't indent with tabs here)
|
|
|
|
QT5_PCFILEDIR := $(shell pkg-config --variable=pcfiledir Qt5Core 2>/dev/null)
|
|
|
|
QT5_LIBDIR := $(shell pkg-config --variable=libdir Qt5Core 2>/dev/null)
|
|
|
|
ifeq ($(QT5_PCFILEDIR),)
|
|
|
|
ifeq ($(QTDIR),)
|
|
|
|
$(error Can't find your Qt5 installation. Please run "$(MAKE) QTDIR=/path/to/your/Qt5/installation/prefix ...")
|
|
|
|
else
|
|
|
|
ifeq ($(detected_OS), Darwin)
|
|
|
|
QT5_PCFILEDIR := $(QTDIR)/clang_64/lib/pkgconfig
|
|
|
|
QT5_LIBDIR := $(QTDIR)/clang_64/lib
|
|
|
|
# some manually installed Qt5 instances have wrong paths in their *.pc files, so we pass the right one to the linker here
|
|
|
|
NIM_PARAMS += --passL:"-F$(QT5_LIBDIR)"
|
|
|
|
else
|
|
|
|
QT5_PCFILEDIR := $(QTDIR)/gcc_64/lib/pkgconfig
|
|
|
|
QT5_LIBDIR := $(QTDIR)/gcc_64/lib
|
|
|
|
NIM_PARAMS += --passL:"-L$(QT5_LIBDIR)"
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
export QT5_LIBDIR
|
|
|
|
# order matters here, due to "-Wl,-as-needed"
|
2020-06-04 20:56:44 +00:00
|
|
|
NIM_PARAMS += --passL:"$(DOTHERSIDE) $(shell PKG_CONFIG_PATH="$(QT5_PCFILEDIR)" pkg-config --libs Qt5Core Qt5Qml Qt5Gui Qt5Quick Qt5QuickControls2 Qt5Widgets Qt5Svg)"
|
2020-05-14 14:58:08 +00:00
|
|
|
|
2020-05-25 02:18:37 +00:00
|
|
|
# TODO: control debug/release builds with a Make var
|
|
|
|
# We need `-d:debug` to get Nim's default stack traces.
|
|
|
|
NIM_PARAMS += --outdir:./bin -d:debug
|
|
|
|
# Enable debugging symbols in DOtherSide, in case we need GDB backtraces from it.
|
|
|
|
CFLAGS += -g
|
|
|
|
CXXFLAGS += -g
|
2020-05-14 14:58:08 +00:00
|
|
|
|
2020-06-04 20:56:44 +00:00
|
|
|
deps: | deps-common bottles
|
2020-05-14 14:58:08 +00:00
|
|
|
|
|
|
|
update: | update-common
|
|
|
|
|
|
|
|
$(DOTHERSIDE): | deps
|
|
|
|
echo -e $(BUILD_MSG) "DOtherSide"
|
|
|
|
+ cd vendor/DOtherSide && \
|
2020-06-04 20:56:44 +00:00
|
|
|
mkdir -p build && \
|
|
|
|
cd build && \
|
2020-05-25 02:18:37 +00:00
|
|
|
rm -f CMakeCache.txt && \
|
2020-06-04 20:56:44 +00:00
|
|
|
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_DOCS=OFF -DENABLE_TESTS=OFF -DENABLE_DYNAMIC_LIBS=OFF -DENABLE_STATIC_LIBS=ON .. $(HANDLE_OUTPUT) && \
|
2020-05-25 02:18:37 +00:00
|
|
|
$(MAKE) VERBOSE=$(V) $(HANDLE_OUTPUT)
|
2020-05-14 14:58:08 +00:00
|
|
|
|
2020-05-14 20:19:01 +00:00
|
|
|
STATUSGO := vendor/status-go/build/bin/libstatus.a
|
|
|
|
|
|
|
|
$(STATUSGO): | deps
|
|
|
|
echo -e $(BUILD_MSG) "status-go"
|
|
|
|
+ cd vendor/status-go && \
|
2020-05-25 02:18:37 +00:00
|
|
|
$(MAKE) statusgo-library $(HANDLE_OUTPUT)
|
2020-05-14 14:58:08 +00:00
|
|
|
|
2020-05-25 02:18:37 +00:00
|
|
|
nim_status_client: | $(DOTHERSIDE) $(STATUSGO) deps
|
2020-05-14 14:58:08 +00:00
|
|
|
echo -e $(BUILD_MSG) "$@" && \
|
2020-05-25 02:18:37 +00:00
|
|
|
$(ENV_SCRIPT) nim c $(NIM_PARAMS) --passL:"$(STATUSGO)" --passL:"-lm" src/nim_status_client.nim
|
2020-05-14 20:19:01 +00:00
|
|
|
|
2020-06-04 20:56:44 +00:00
|
|
|
_APPIMAGE_TOOL := appimagetool-x86_64.AppImage
|
|
|
|
APPIMAGE_TOOL := tmp/linux/tools/$(_APPIMAGE_TOOL)
|
|
|
|
|
|
|
|
$(APPIMAGE_TOOL):
|
|
|
|
rm -rf tmp/linux
|
|
|
|
mkdir -p tmp/linux/tools
|
|
|
|
wget https://github.com/AppImage/AppImageKit/releases/download/continuous/$(_APPIMAGE_TOOL)
|
|
|
|
mv $(_APPIMAGE_TOOL) tmp/linux/tools/
|
|
|
|
chmod +x $(APPIMAGE_TOOL)
|
2020-05-19 15:32:48 +00:00
|
|
|
|
2020-06-04 20:56:44 +00:00
|
|
|
APPIMAGE := pkg/NimStatusClient-x86_64.AppImage
|
2020-05-14 20:19:01 +00:00
|
|
|
|
2020-06-04 20:56:44 +00:00
|
|
|
$(APPIMAGE): nim_status_client $(APPIMAGE_TOOL) nim-status.desktop
|
|
|
|
rm -rf pkg/*.AppImage
|
|
|
|
mkdir -p tmp/linux/dist/usr/bin
|
|
|
|
mkdir -p tmp/linux/dist/usr/lib
|
|
|
|
mkdir -p tmp/linux/dist/usr/qml
|
2020-05-18 16:51:29 +00:00
|
|
|
|
2020-05-15 13:00:49 +00:00
|
|
|
# General Files
|
2020-06-04 20:56:44 +00:00
|
|
|
cp bin/nim_status_client tmp/linux/dist/usr/bin
|
|
|
|
cp nim-status.desktop tmp/linux/dist/.
|
|
|
|
cp status.svg tmp/linux/dist/status.svg
|
|
|
|
cp -R ui tmp/linux/dist/usr/.
|
2020-05-15 13:00:49 +00:00
|
|
|
|
2020-05-14 20:19:01 +00:00
|
|
|
echo -e $(BUILD_MSG) "AppImage"
|
2020-06-04 20:56:44 +00:00
|
|
|
linuxdeployqt tmp/linux/dist/nim-status.desktop -no-translations -no-copy-copyright-files -qmldir=tmp/linux/dist/usr/ui -qmlimport=${QTDIR}/gcc_64/qml -bundle-non-qt-libs
|
|
|
|
|
|
|
|
rm tmp/linux/dist/AppRun
|
|
|
|
cp AppRun tmp/linux/dist/.
|
|
|
|
|
|
|
|
mkdir -p pkg
|
|
|
|
$(APPIMAGE_TOOL) tmp/linux/dist $(APPIMAGE)
|
|
|
|
|
|
|
|
DMG_TOOL := node_modules/.bin/create-dmg
|
2020-05-15 13:00:49 +00:00
|
|
|
|
2020-06-04 20:56:44 +00:00
|
|
|
$(DMG_TOOL):
|
|
|
|
npm i
|
2020-05-15 13:00:49 +00:00
|
|
|
|
2020-06-04 20:56:44 +00:00
|
|
|
MACOS_OUTER_BUNDLE := tmp/macos/dist/Status.app
|
|
|
|
MACOS_INNER_BUNDLE := $(MACOS_OUTER_BUNDLE)/Contents/Frameworks/QtWebEngineCore.framework/Versions/Current/Helpers/QtWebEngineProcess.app
|
2020-05-14 20:19:01 +00:00
|
|
|
|
2020-06-04 20:56:44 +00:00
|
|
|
DMG := pkg/Status.dmg
|
|
|
|
|
|
|
|
# it's not required to set MACOS_KEYCHAIN if MACOS_CODESIGN_IDENT can be found
|
|
|
|
# in e.g. your login keychain; this environment variable is primarily useful
|
|
|
|
# for CI; when specified MACOS_KEYCHAIN should be the path to a preferred
|
|
|
|
# keychain database file
|
|
|
|
ifneq ($(MACOS_KEYCHAIN),)
|
|
|
|
MACOS_KEYCHAIN_OPT := --keychain "$(MACOS_KEYCHAIN)"
|
|
|
|
endif
|
|
|
|
|
|
|
|
$(DMG): nim_status_client $(DMG_TOOL)
|
|
|
|
rm -rf tmp/macos pkg/*.dmg
|
|
|
|
mkdir -p $(MACOS_OUTER_BUNDLE)/Contents/MacOS
|
|
|
|
mkdir -p $(MACOS_OUTER_BUNDLE)/Contents/Resources
|
|
|
|
cp Info.plist $(MACOS_OUTER_BUNDLE)/Contents/
|
|
|
|
cp bin/nim_status_client $(MACOS_OUTER_BUNDLE)/Contents/MacOS/
|
|
|
|
cp nim_status_client.sh $(MACOS_OUTER_BUNDLE)/Contents/MacOS/
|
|
|
|
chmod +x $(MACOS_OUTER_BUNDLE)/Contents/MacOS/nim_status_client.sh
|
|
|
|
cp status-icon.icns $(MACOS_OUTER_BUNDLE)/Contents/Resources/
|
|
|
|
cp -R ui $(MACOS_OUTER_BUNDLE)/Contents/
|
|
|
|
|
|
|
|
macdeployqt \
|
|
|
|
$(MACOS_OUTER_BUNDLE) \
|
|
|
|
-executable=$(MACOS_OUTER_BUNDLE)/Contents/MacOS/nim_status_client \
|
|
|
|
-qmldir=ui
|
|
|
|
cp Info.runner.plist $(MACOS_OUTER_BUNDLE)/Contents/Info.plist
|
|
|
|
macdeployqt \
|
|
|
|
$(MACOS_INNER_BUNDLE) \
|
|
|
|
-executable=$(MACOS_INNER_BUNDLE)/Contents/MacOS/QtWebEngineProcess
|
|
|
|
|
|
|
|
# if MACOS_CODESIGN_IDENT is not set then the outer and inner .app
|
|
|
|
# bundles are not signed
|
|
|
|
[ -z "$(MACOS_CODESIGN_IDENT)" ] || \
|
|
|
|
codesign \
|
|
|
|
--sign "$(MACOS_CODESIGN_IDENT)" \
|
|
|
|
$(MACOS_KEYCHAIN_OPT) \
|
|
|
|
--options runtime \
|
|
|
|
--deep \
|
|
|
|
--force \
|
|
|
|
--verbose=4 \
|
|
|
|
$(MACOS_OUTER_BUNDLE)
|
|
|
|
[ -z "$(MACOS_CODESIGN_IDENT)" ] || \
|
|
|
|
codesign \
|
|
|
|
--sign "$(MACOS_CODESIGN_IDENT)" \
|
|
|
|
$(MACOS_KEYCHAIN_OPT) \
|
|
|
|
--entitlements QtWebEngineProcess.plist \
|
|
|
|
--options runtime \
|
|
|
|
--deep \
|
|
|
|
--force \
|
|
|
|
--verbose=4 \
|
|
|
|
$(MACOS_INNER_BUNDLE)
|
|
|
|
|
|
|
|
mkdir -p pkg
|
|
|
|
# See: https://github.com/sindresorhus/create-dmg#dmg-icon
|
|
|
|
# GraphicsMagick must be installed for create-dmg to make the custom
|
|
|
|
# DMG icon based on app icon, but should otherwise work without it
|
|
|
|
npx create-dmg \
|
|
|
|
--identity="NOBODY" \
|
|
|
|
$(MACOS_OUTER_BUNDLE) \
|
|
|
|
pkg || true
|
|
|
|
# `|| true` is used above because code signing will be done manually
|
|
|
|
# below (to allow for MACOS_KEYCHAIN_OPT) but create-dmg doesn't have
|
|
|
|
# an option to not attempt signing. To work around that limitation an
|
|
|
|
# unlikely identity (NOBODY) is specified; this results in a non-zero
|
|
|
|
# exit code even though the .dmg is created successfully (just not code
|
|
|
|
# signed); if the above command failed to create a .dmg then the
|
|
|
|
# following command should result in a non-zero exit code
|
|
|
|
mv "`ls pkg/*.dmg`" pkg/Status.dmg
|
|
|
|
|
|
|
|
# if MACOS_CODESIGN_IDENT is not set then the .dmg is not signed
|
|
|
|
[ -z "$(MACOS_CODESIGN_IDENT)" ] || \
|
|
|
|
codesign \
|
|
|
|
--sign "$(MACOS_CODESIGN_IDENT)" \
|
|
|
|
$(MACOS_KEYCHAIN_OPT) \
|
|
|
|
--verbose=4 \
|
|
|
|
pkg/Status.dmg
|
|
|
|
|
|
|
|
pkg: $(PKG_TARGET)
|
|
|
|
|
|
|
|
pkg-linux: $(APPIMAGE)
|
|
|
|
|
|
|
|
pkg-macos: $(DMG)
|
2020-05-14 14:58:08 +00:00
|
|
|
|
|
|
|
clean: | clean-common
|
2020-06-04 20:56:44 +00:00
|
|
|
rm -rf bin/* node_modules pkg/* tmp/* $(STATUSGO)
|
|
|
|
+ $(MAKE) -C vendor/DOtherSide/build --no-print-directory clean
|
|
|
|
|
|
|
|
run:
|
|
|
|
LD_LIBRARY_PATH="$(QT5_LIBDIR)" ./bin/nim_status_client
|
2020-05-14 14:58:08 +00:00
|
|
|
|
|
|
|
endif # "variables.mk" was not included
|