-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
104 lines (75 loc) · 3.93 KB
/
Makefile
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
98
99
100
101
102
103
104
REPO := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
BUILD_DIR=$(REPO)/build
EXE = $(REPO)/lokinet
DEP_PREFIX=$(BUILD_DIR)/prefix
PREFIX_SRC=$(DEP_PREFIX)/src
SODIUM_SRC=$(REPO)/deps/sodium
LLARPD_SRC=$(REPO)/deps/llarp
MOTTO=$(LLARPD_SRC)/motto.txt
SODIUM_BUILD=$(PREFIX_SRC)/sodium
SODIUM_CONFIG=$(SODIUM_SRC)/configure
SODIUM_LIB=$(DEP_PREFIX)/lib/libsodium.a
NDK ?= $(HOME)/android-ndk
NDK_INSTALL_DIR = $(BUILD_DIR)/ndk
CROSS_TARGET ?=arm-bcm2708hardfp-linux-gnueabi
CROSS_CC ?=$(CROSS_TARGET)-gcc
CROSS_CXX ?=$(CROSS_TARGET)-g++
MINGW_TOOLCHAIN = $(REPO)/contrib/cross/mingw.cmake
all: build
ensure: clean
mkdir -p $(BUILD_DIR)
mkdir -p $(DEP_PREFIX)
mkdir -p $(PREFIX_SRC)
mkdir -p $(SODIUM_BUILD)
sodium-configure: ensure
cd $(SODIUM_SRC) && $(SODIUM_SRC)/autogen.sh
cd $(SODIUM_BUILD) && $(SODIUM_CONFIG) --prefix=$(DEP_PREFIX) --enable-static --disable-shared
sodium: sodium-configure
$(MAKE) -C $(SODIUM_BUILD) clean
$(MAKE) -C $(SODIUM_BUILD) install CFLAGS=-fPIC
build: ensure sodium
cd $(BUILD_DIR) && cmake $(LLARPD_SRC) -DSODIUM_LIBRARIES=$(SODIUM_LIB) -DSODIUM_INCLUDE_DIR=$(DEP_PREFIX)/include -G "Unix Makefiles"
$(MAKE) -C $(BUILD_DIR)
cp $(BUILD_DIR)/llarpd $(EXE)
static-sodium-configure: ensure
cd $(SODIUM_SRC) && $(SODIUM_SRC)/autogen.sh
cd $(SODIUM_BUILD) && CC=ecc CXX=ecc++ $(SODIUM_CONFIG) --prefix=$(DEP_PREFIX) --enable-static --disable-shared
static-sodium: static-sodium-configure
$(MAKE) -C $(SODIUM_BUILD) clean
$(MAKE) -C $(SODIUM_BUILD) install CFLAGS=-fPIC CC=ecc CXX=ecc++
static: static-sodium
cd $(BUILD_DIR) && cmake $(LLARPD_SRC) -DSODIUM_LIBRARIES=$(SODIUM_LIB) -DSODIUM_INCLUDE_DIR=$(DEP_PREFIX)/include -DSTATIC_LINK=ON -DCMAKE_C_COMPILER=ecc -DCMAKE_CXX_COMPILER=ecc++
$(MAKE) -C $(BUILD_DIR)
cp $(BUILD_DIR)/llarpd $(EXE)
android-arm-sodium:
cd $(SODIUM_SRC) && $(SODIUM_SRC)/autogen.sh && LIBSODIUM_FULL_BUILD=1 ANDROID_NDK_HOME=$(NDK) $(SODIUM_SRC)/dist-build/android-arm.sh
android-arm-native: android-arm-sodium
$(NDK)/build/tools/make_standalone_toolchain.py --force --api=16 --arch=arm --install-dir=$(NDK_INSTALL_DIR)
cd $(BUILD_DIR) && cmake $(LLARPD_SRC) -DSODIUM_LIBRARIES=$(SODIUM_SRC)/libsodium-android-armv6/lib/libsodium.a -DSODIUM_INCLUDE_DIR=$(SODIUM_SRC)/libsodium-android-armv6/include -DCMAKE_C_COMPILER=$(NDK_INSTALL_DIR)/bin/clang -DCMAKE_CXX_COMPILER=$(NDK_INSTALL_DIR)/bin/clang++ -DCMAKE_SYSROOT=$(NDK_INSTALL_DIR)/sysroot -DANDROID=ON -DWITH_SHARED=ON
$(MAKE) -C $(BUILD_DIR)
android-arm: android-arm-native
cross-sodium: ensure
cd $(SODIUM_SRC) && $(SODIUM_SRC)/autogen.sh
cd $(SODIUM_BUILD) && $(SODIUM_CONFIG) --prefix=$(DEP_PREFIX) --enable-static --disable-shared --host=$(CROSS_TARGET)
$(MAKE) -C $(SODIUM_BUILD) install
cross: cross-sodium
cd $(BUILD_DIR) && cmake $(LLARPD_SRC) -DSTATIC_LINK=ON -DSODIUM_LIBRARIES=$(SODIUM_LIB) -DSODIUM_INCLUDE_DIR=$(DEP_PREFIX)/include -DCMAKE_C_COMPILER=$(CROSS_CC) -DCMAKE_CXX_COMPILER=$(CROSS_CXX) -DCMAKE_CROSS_COMPILING=ON
$(MAKE) -C $(BUILD_DIR)
cp $(BUILD_DIR)/llarpd $(EXE)
windows-sodium: ensure
cd $(SODIUM_SRC) && $(SODIUM_SRC)/autogen.sh
cd $(SODIUM_BUILD) && $(SODIUM_CONFIG) --prefix=$(DEP_PREFIX) --enable-static --disable-shared --host=x86_64-w64-mingw32
$(MAKE) -C $(SODIUM_BUILD) install
windows: windows-sodium
cd $(BUILD_DIR) && cmake $(LLARPD_SRC) -DSTATIC_LINK=ON -DSODIUM_LIBRARIES=$(SODIUM_LIB) -DSODIUM_INCLUDE_DIR=$(DEP_PREFIX)/include -DCMAKE_TOOLCHAIN_FILE=$(MINGW_TOOLCHAIN) -DHAVE_CXX17_FILESYSTEM=ON
$(MAKE) -C $(BUILD_DIR)
cp $(BUILD_DIR)/llarpd.exe $(EXE).exe
motto:
figlet "$(shell cat $(MOTTO))"
release: static-sodium motto
cd $(BUILD_DIR) && cmake $(LLARPD_SRC) -DSODIUM_LIBRARIES=$(SODIUM_LIB) -DSODIUM_INCLUDE_DIR=$(DEP_PREFIX)/include -DSTATIC_LINK=ON -DCMAKE_C_COMPILER=ecc -DCMAKE_CXX_COMPILER=ecc++ -DCMAKE_BUILD_TYPE=Release -DRELEASE_MOTTO="$(shell cat $(MOTTO))"
$(MAKE) -C $(BUILD_DIR)
cp $(BUILD_DIR)/llarpd $(EXE)
#gpg --sign --detach $(EXE)
clean:
rm -rf $(BUILD_DIR) $(EXE)