2018-05-16 15:59:24 +00:00
|
|
|
|
2018-08-13 23:22:31 +00:00
|
|
|
all: test
|
2018-05-16 16:41:20 +00:00
|
|
|
|
2018-05-28 13:49:44 +00:00
|
|
|
SIGN = gpg --sign --detach
|
|
|
|
|
2018-06-07 16:22:49 +00:00
|
|
|
REPO := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
|
|
|
|
2018-09-15 11:37:46 +00:00
|
|
|
PREFIX ?= /usr/local
|
|
|
|
|
2018-11-03 13:19:18 +00:00
|
|
|
CC ?= cc
|
2018-06-28 15:10:25 +00:00
|
|
|
CXX ?= c++
|
2018-06-07 16:22:49 +00:00
|
|
|
|
2018-10-28 14:28:13 +00:00
|
|
|
SETCAP ?= which setcap && setcap cap_net_admin=+eip
|
|
|
|
|
2018-06-06 17:02:57 +00:00
|
|
|
SHADOW_ROOT ?= $(HOME)/.shadow
|
|
|
|
SHADOW_BIN=$(SHADOW_ROOT)/bin/shadow
|
2018-06-07 17:36:17 +00:00
|
|
|
SHADOW_CONFIG=$(REPO)/shadow.config.xml
|
|
|
|
SHADOW_PLUGIN=$(REPO)/libshadow-plugin-llarp.so
|
|
|
|
SHADOW_LOG=$(REPO)/shadow.log.txt
|
2018-06-06 17:02:57 +00:00
|
|
|
|
2018-08-12 17:22:29 +00:00
|
|
|
SHADOW_SRC ?= $(HOME)/local/shadow
|
2018-07-20 04:50:28 +00:00
|
|
|
SHADOW_PARSE ?= python $(SHADOW_SRC)/src/tools/parse-shadow.py - -m 0 --packet-data
|
|
|
|
SHADOW_PLOT ?= python $(SHADOW_SRC)/src/tools/plot-shadow.py -d $(REPO) LokiNET -c $(SHADOW_CONFIG) -r 10000 -e '.*'
|
|
|
|
|
|
|
|
TESTNET_ROOT=/tmp/lokinet_testnet_tmp
|
2018-06-07 16:22:49 +00:00
|
|
|
TESTNET_CONF=$(TESTNET_ROOT)/supervisor.conf
|
|
|
|
TESTNET_LOG=$(TESTNET_ROOT)/testnet.log
|
|
|
|
|
2018-08-12 17:22:29 +00:00
|
|
|
TESTNET_EXE=$(REPO)/lokinet-testnet
|
2018-07-12 13:43:37 +00:00
|
|
|
TESTNET_CLIENTS ?= 50
|
|
|
|
TESTNET_SERVERS ?= 50
|
|
|
|
TESTNET_DEBUG ?= 0
|
|
|
|
|
2018-11-06 13:03:10 +00:00
|
|
|
ANDROID_NDK ?= $(HOME)/Android/Ndk
|
|
|
|
ANDROID_SDK ?= $(HOME)/Android/Sdk
|
2018-11-06 13:14:14 +00:00
|
|
|
ANDROID_ABI ?= armeabi-v7a
|
2018-11-06 14:06:09 +00:00
|
|
|
ANDROID_API_LEVEL ?= 18
|
2018-11-06 13:03:10 +00:00
|
|
|
|
2018-11-06 14:27:25 +00:00
|
|
|
ANDROID_DIR=$(REPO)/android
|
|
|
|
JNI_DIR=$(ANDROID_DIR)/jni
|
|
|
|
ANDROID_MK=$(JNI_DIR)/Android.mk
|
|
|
|
ANDROID_PROPS=$(ANDROID_DIR)/gradle.properties
|
|
|
|
ANDROID_LOCAL_PROPS=$(ANDROID_DIR)/local.properties
|
|
|
|
|
|
|
|
GRADLE ?= gradle
|
|
|
|
JAVA_HOME ?= /usr/lib/jvm/default-java
|
|
|
|
|
2018-11-06 22:48:17 +00:00
|
|
|
JSONRPC ?= OFF
|
|
|
|
CXX17 ?= ON
|
2018-11-08 12:31:50 +00:00
|
|
|
AVX2 ?= ON
|
|
|
|
RPI ?= OFF
|
|
|
|
STATIC_LINK ?= OFF
|
2018-11-09 13:12:20 +00:00
|
|
|
CMAKE_GEN ?= Unix Makefiles
|
2018-10-27 12:41:04 +00:00
|
|
|
|
|
|
|
|
2018-10-23 11:29:37 +00:00
|
|
|
BUILD_ROOT = $(REPO)/build
|
|
|
|
|
2018-11-09 13:12:20 +00:00
|
|
|
CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "cmake -G'$(CMAKE_GEN)' -DSTATIC_LINK=$(STATIC_LINK) -DUSE_AVX2=$(AVX2) -DUSE_CXX17=$(CXX17) -DUSE_LIBABYSS=$(JSONRPC) -DRPI=$(RPI) '$(REPO)'")
|
2018-10-23 11:29:37 +00:00
|
|
|
|
2018-10-27 18:26:08 +00:00
|
|
|
SCAN_BUILD ?= scan-build
|
2018-11-05 11:31:43 +00:00
|
|
|
ANALYZE_CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "$(SCAN_BUILD) cmake -DUSE_LIBABYSS=$(JSONRPC) '$(REPO)'")
|
2018-10-27 18:26:08 +00:00
|
|
|
|
2018-10-23 11:29:37 +00:00
|
|
|
TARGETS = $(REPO)/lokinet
|
|
|
|
SIGS = $(TARGETS:=.sig)
|
|
|
|
EXE = $(BUILD_ROOT)/lokinet
|
|
|
|
TEST_EXE = $(BUILD_ROOT)/testAll
|
2018-10-24 18:02:42 +00:00
|
|
|
ABYSS_EXE = $(BUILD_ROOT)/abyss-main
|
2018-10-23 11:29:37 +00:00
|
|
|
|
2018-09-30 12:42:28 +00:00
|
|
|
DNS_PORT ?= 53
|
|
|
|
|
2018-10-23 11:29:37 +00:00
|
|
|
# PROCS ?= $(shell cat /proc/cpuinfo | grep processor | wc -l)
|
|
|
|
|
|
|
|
|
2018-09-28 14:29:34 +00:00
|
|
|
LINT_FILES = $(wildcard llarp/*.cpp)
|
|
|
|
|
|
|
|
LINT_CHECK = $(LINT_FILES:.cpp=.cpp-check)
|
|
|
|
|
2018-05-27 16:45:04 +00:00
|
|
|
clean:
|
2018-10-23 11:29:37 +00:00
|
|
|
rm -rf $(BUILD_ROOT)
|
2018-06-06 17:02:57 +00:00
|
|
|
rm -f $(SHADOW_PLUGIN) $(SHADOW_CONFIG)
|
2018-05-28 13:49:44 +00:00
|
|
|
rm -f *.sig
|
2018-08-02 21:26:14 +00:00
|
|
|
rm -f *.a *.so
|
2018-05-16 15:59:24 +00:00
|
|
|
|
2018-10-23 11:29:37 +00:00
|
|
|
debug-configure:
|
|
|
|
mkdir -p '$(BUILD_ROOT)'
|
2018-10-30 20:13:26 +00:00
|
|
|
$(CONFIG_CMD) -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) -DDNS_PORT=$(DNS_PORT) -DCMAKE_ASM_FLAGS='$(ASFLAGS)' -DCMAKE_C_FLAGS='$(CFLAGS)' -DCMAKE_CXX_FLAGS='$(CXXFLAGS)'
|
2018-05-16 15:59:24 +00:00
|
|
|
|
2018-05-28 13:49:44 +00:00
|
|
|
release-configure: clean
|
2018-11-03 13:19:18 +00:00
|
|
|
mkdir -p '$(BUILD_ROOT)'
|
2018-10-30 20:13:26 +00:00
|
|
|
$(CONFIG_CMD) -DSTATIC_LINK=ON -DCMAKE_BUILD_TYPE=Release -DRELEASE_MOTTO="$(shell cat motto.txt)" -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) -DCMAKE_ASM_FLAGS='$(ASFLAGS)' -DCMAKE_C_FLAGS='$(CFLAGS)' -DCMAKE_CXX_FLAGS='$(CXXFLAGS)'
|
2018-05-28 13:49:44 +00:00
|
|
|
|
2018-05-27 16:45:04 +00:00
|
|
|
debug: debug-configure
|
2018-10-23 11:29:37 +00:00
|
|
|
$(MAKE) -C $(BUILD_ROOT)
|
2018-10-23 12:41:29 +00:00
|
|
|
cp $(EXE) lokinet
|
2018-05-21 14:28:15 +00:00
|
|
|
|
2018-05-28 13:49:44 +00:00
|
|
|
release-compile: release-configure
|
2018-10-23 11:29:37 +00:00
|
|
|
$(MAKE) -C $(BUILD_ROOT)
|
|
|
|
cp $(EXE) lokinet
|
2018-05-28 13:49:44 +00:00
|
|
|
strip $(TARGETS)
|
|
|
|
|
|
|
|
$(TARGETS): release-compile
|
|
|
|
|
|
|
|
%.sig: $(TARGETS)
|
|
|
|
$(SIGN) $*
|
|
|
|
|
|
|
|
release: $(SIGS)
|
|
|
|
|
2018-06-06 13:17:03 +00:00
|
|
|
shadow-configure: clean
|
2018-11-08 15:15:02 +00:00
|
|
|
mkdir -p $(BUILD_ROOT)
|
2018-10-23 11:29:37 +00:00
|
|
|
$(CONFIG_CMD) -DCMAKE_BUILD_TYPE=Debug -DSHADOW=ON -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX)
|
2018-06-06 13:17:03 +00:00
|
|
|
|
2018-06-06 17:02:57 +00:00
|
|
|
shadow-build: shadow-configure
|
2018-10-23 11:29:37 +00:00
|
|
|
$(MAKE) -C $(BUILD_ROOT) clean
|
|
|
|
$(MAKE) -C $(BUILD_ROOT)
|
2018-06-06 13:17:03 +00:00
|
|
|
|
2018-07-20 04:50:28 +00:00
|
|
|
shadow-run: shadow-build
|
2018-06-06 17:02:57 +00:00
|
|
|
python3 contrib/shadow/genconf.py $(SHADOW_CONFIG)
|
2018-07-20 04:50:28 +00:00
|
|
|
bash -c "$(SHADOW_BIN) -w $$(cat /proc/cpuinfo | grep processor | wc -l) $(SHADOW_CONFIG) | $(SHADOW_PARSE)"
|
|
|
|
|
|
|
|
shadow-plot: shadow-run
|
|
|
|
$(SHADOW_PLOT)
|
|
|
|
|
|
|
|
shadow: shadow-plot
|
2018-06-07 16:22:49 +00:00
|
|
|
|
2018-08-02 00:48:43 +00:00
|
|
|
testnet-clean: clean
|
|
|
|
rm -rf $(TESTNET_ROOT)
|
|
|
|
|
|
|
|
testnet-configure: testnet-clean
|
2018-11-08 15:15:02 +00:00
|
|
|
mkdir -p $(BUILD_ROOT)
|
2018-10-23 11:29:37 +00:00
|
|
|
$(CONFIG_CMD) -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) -DTESTNET=1
|
2018-06-07 16:22:49 +00:00
|
|
|
|
|
|
|
testnet-build: testnet-configure
|
2018-10-23 11:29:37 +00:00
|
|
|
$(MAKE) -C $(BUILD_ROOT)
|
2018-06-07 16:22:49 +00:00
|
|
|
|
2018-07-27 04:07:22 +00:00
|
|
|
shared-configure: clean
|
2018-10-23 11:29:37 +00:00
|
|
|
$(CONFIG_CMD) -DCMAKE_BUILD_TYPE=Debug -DWITH_TESTS=ON -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) -DWITH_SHARED=ON
|
2018-07-27 04:07:22 +00:00
|
|
|
|
|
|
|
shared: shared-configure
|
2018-10-23 11:29:37 +00:00
|
|
|
$(MAKE) -C $(BUILD_ROOT)
|
2018-07-27 04:07:22 +00:00
|
|
|
|
2018-11-03 13:19:18 +00:00
|
|
|
testnet:
|
2018-08-12 17:22:29 +00:00
|
|
|
cp $(EXE) $(TESTNET_EXE)
|
2018-06-07 16:22:49 +00:00
|
|
|
mkdir -p $(TESTNET_ROOT)
|
2018-10-21 14:19:49 +00:00
|
|
|
python3 contrib/testnet/genconf.py --bin=$(TESTNET_EXE) --svc=$(TESTNET_SERVERS) --clients=$(TESTNET_CLIENTS) --dir=$(TESTNET_ROOT) --out $(TESTNET_CONF) --connect=4
|
2018-07-12 13:43:37 +00:00
|
|
|
LLARP_DEBUG=$(TESTNET_DEBUG) supervisord -n -d $(TESTNET_ROOT) -l $(TESTNET_LOG) -c $(TESTNET_CONF)
|
2018-06-06 13:17:03 +00:00
|
|
|
|
2018-08-13 23:22:31 +00:00
|
|
|
test: debug
|
|
|
|
$(TEST_EXE)
|
2018-06-14 14:04:42 +00:00
|
|
|
|
2018-11-06 14:27:25 +00:00
|
|
|
android-gradle-prepare:
|
|
|
|
rm -f $(ANDROID_PROPS)
|
|
|
|
rm -f $(ANDROID_LOCAL_PROPS)
|
|
|
|
echo "#auto generated don't modify kthnx" >> $(ANDROID_PROPS)
|
|
|
|
echo "lokinetCMake=$(REPO)/CMakeLists.txt" >> $(ANDROID_PROPS)
|
|
|
|
echo "org.gradle.parallel=true" >> $(ANDROID_PROPS)
|
|
|
|
echo "#auto generated don't modify kthnx" >> $(ANDROID_LOCAL_PROPS)
|
|
|
|
echo "sdk.dir=$(ANDROID_SDK)" >> $(ANDROID_LOCAL_PROPS)
|
|
|
|
echo "ndk.dir=$(ANDROID_NDK)" >> $(ANDROID_LOCAL_PROPS)
|
|
|
|
|
|
|
|
android-gradle: android-gradle-prepare
|
2018-11-07 12:23:06 +00:00
|
|
|
cd $(ANDROID_DIR) && JAVA_HOME=$(JAVA_HOME) $(GRADLE) clean assemble
|
2018-11-06 14:27:25 +00:00
|
|
|
|
|
|
|
android: android-gradle
|
2018-11-06 14:06:09 +00:00
|
|
|
|
2018-11-09 12:49:29 +00:00
|
|
|
windows-configure: clean
|
|
|
|
mkdir -p '$(BUILD_ROOT)'
|
|
|
|
$(CONFIG_CMD) -DCMAKE_CROSSCOMPILING=ON -DCMAKE_TOOLCHAIN_FILE='$(REPO)/contrib/cross/mingw.cmake' -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=i686-w64-mingw32-gcc-win32 -DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++-win32 -DDNS_PORT=$(DNS_PORT) -DCMAKE_ASM_FLAGS='$(ASFLAGS)' -DCMAKE_C_FLAGS='$(CFLAGS)' -DCMAKE_CXX_FLAGS='$(CXXFLAGS)'
|
|
|
|
|
|
|
|
windows: windows-configure
|
|
|
|
$(MAKE) -C '$(BUILD_ROOT)'
|
|
|
|
cp '$(BUILD_ROOT)/lokinet.exe' '$(REPO)/lokinet.exe'
|
|
|
|
|
2018-10-24 18:02:42 +00:00
|
|
|
abyss: debug
|
|
|
|
$(ABYSS_EXE)
|
|
|
|
|
2018-05-21 14:28:15 +00:00
|
|
|
format:
|
2018-10-25 22:16:03 +00:00
|
|
|
clang-format -i $$(find daemon llarp include libabyss | grep -E '\.[h,c](pp)?$$')
|
2018-09-15 11:37:46 +00:00
|
|
|
|
2018-11-05 11:31:43 +00:00
|
|
|
analyze-config: clean
|
2018-10-27 19:03:23 +00:00
|
|
|
mkdir -p '$(BUILD_ROOT)'
|
2018-11-05 11:31:43 +00:00
|
|
|
$(ANALYZE_CONFIG_CMD)
|
|
|
|
|
|
|
|
analyze: analyze-config
|
|
|
|
cd '$(BUILD_ROOT)'
|
|
|
|
$(SCAN_BUILD) $(MAKE)
|
2018-10-27 18:26:08 +00:00
|
|
|
|
2018-09-28 14:29:34 +00:00
|
|
|
lint: $(LINT_CHECK)
|
|
|
|
|
|
|
|
%.cpp-check: %.cpp
|
2018-11-05 11:31:43 +00:00
|
|
|
clang-tidy $^ -- -I$(REPO)/include -I$(REPO)/crypto/include -I$(REPO)/llarp -I$(REPO)/vendor/cppbackport-master/lib
|
2018-09-28 14:29:34 +00:00
|
|
|
|
2018-11-02 20:51:02 +00:00
|
|
|
docker-debian:
|
|
|
|
docker build -f docker/debian.Dockerfile .
|
|
|
|
|
|
|
|
docker-fedora:
|
|
|
|
docker build -f docker/fedora.Dockerfile .
|
|
|
|
|
2018-09-15 11:37:46 +00:00
|
|
|
install:
|
|
|
|
rm -f $(PREFIX)/bin/lokinet
|
|
|
|
cp $(EXE) $(PREFIX)/bin/lokinet
|
|
|
|
chmod 755 $(PREFIX)/bin/lokinet
|
2018-10-28 14:29:09 +00:00
|
|
|
$(SETCAP) $(PREFIX)/bin/lokinet || true
|
2018-10-24 11:57:21 +00:00
|
|
|
rm -f $(PREFIX)/bin/lokinet-bootstrap
|
|
|
|
cp $(REPO)/lokinet-bootstrap $(PREFIX)/bin/lokinet-bootstrap
|
|
|
|
chmod 755 $(PREFIX)/bin/lokinet-bootstrap
|
2018-11-03 13:19:18 +00:00
|
|
|
|
|
|
|
fuzz-configure: clean
|
|
|
|
cmake -GNinja -DCMAKE_BUILD_TYPE=Fuzz -DCMAKE_C_COMPILER=afl-gcc -DCMAKE_CXX_COMPILER=afl-g++
|
|
|
|
|
|
|
|
fuzz-build: fuzz-configure
|
|
|
|
ninja
|
|
|
|
|
|
|
|
fuzz: fuzz-build
|
|
|
|
$(EXE)
|