2016-05-13 12:36:41 +02:00
|
|
|
#!/usr/bin/make -f
|
|
|
|
|
2017-03-02 13:01:32 +01:00
|
|
|
include common.mk
|
2016-07-04 23:38:04 +02:00
|
|
|
VERSION := $(MAJOR).$(MINOR).$(PATCH)
|
2016-07-04 23:38:05 +02:00
|
|
|
PREFIX ?= /usr/local
|
2016-05-23 17:21:37 +02:00
|
|
|
BUILD_DIR := build
|
2021-07-02 12:45:19 +02:00
|
|
|
RELEASE_OPTIMIZE_FLAGS ?= -O3
|
2016-05-23 16:58:18 +02:00
|
|
|
DEBUG_OPTIMIZE_FLAGS ?= -g -O0
|
2016-05-20 10:36:50 +02:00
|
|
|
JS_OPTIMIZE_FLAGS ?= -O3
|
2021-07-01 16:13:41 +02:00
|
|
|
FUZZER_OPTIMIZE_FLAGS ?= -O3
|
2016-05-13 12:36:41 +02:00
|
|
|
CC = gcc
|
2016-05-20 10:36:50 +02:00
|
|
|
EMCC = emcc
|
2020-05-07 18:40:29 +02:00
|
|
|
EMAR = emar
|
2017-03-16 20:20:16 +01:00
|
|
|
AR = ar
|
2016-09-05 12:56:53 +02:00
|
|
|
|
2018-09-20 12:31:09 +02:00
|
|
|
UNAME := $(shell uname)
|
|
|
|
ifeq ($(UNAME),Darwin)
|
|
|
|
SO := dylib
|
|
|
|
OLM_LDFLAGS :=
|
|
|
|
else
|
|
|
|
SO := so
|
|
|
|
OLM_LDFLAGS := -Wl,-soname,libolm.so.$(MAJOR) \
|
|
|
|
-Wl,--version-script,version_script.ver
|
|
|
|
endif
|
|
|
|
|
|
|
|
RELEASE_TARGET := $(BUILD_DIR)/libolm.$(SO).$(VERSION)
|
2017-03-16 20:20:16 +01:00
|
|
|
STATIC_RELEASE_TARGET := $(BUILD_DIR)/libolm.a
|
2018-09-20 12:31:09 +02:00
|
|
|
DEBUG_TARGET := $(BUILD_DIR)/libolm_debug.$(SO).$(VERSION)
|
2018-10-04 21:09:54 +02:00
|
|
|
JS_WASM_TARGET := javascript/olm.js
|
|
|
|
JS_ASMJS_TARGET := javascript/olm_legacy.js
|
2020-05-07 18:40:29 +02:00
|
|
|
WASM_TARGET := $(BUILD_DIR)/wasm/libolm.a
|
2016-05-20 10:36:50 +02:00
|
|
|
|
|
|
|
JS_EXPORTED_FUNCTIONS := javascript/exported_functions.json
|
2021-05-03 12:42:45 +02:00
|
|
|
JS_EXPORTED_RUNTIME_METHODS := [ALLOC_STACK]
|
2018-09-21 17:35:17 +02:00
|
|
|
JS_EXTERNS := javascript/externs.js
|
2016-05-20 10:36:50 +02:00
|
|
|
|
2021-11-02 17:49:52 +01:00
|
|
|
PUBLIC_HEADERS := include/olm/olm.h include/olm/outbound_group_session.h include/olm/inbound_group_session.h include/olm/pk.h include/olm/sas.h include/olm/error.h include/olm/olm_export.h
|
2016-05-13 12:36:41 +02:00
|
|
|
|
2016-05-25 18:08:44 +02:00
|
|
|
SOURCES := $(wildcard src/*.cpp) $(wildcard src/*.c) \
|
|
|
|
lib/crypto-algorithms/sha256.c \
|
|
|
|
lib/crypto-algorithms/aes.c \
|
|
|
|
lib/curve25519-donna/curve25519-donna.c
|
|
|
|
|
2021-07-01 13:37:45 +02:00
|
|
|
FUZZER_SOURCES := $(wildcard fuzzing/fuzzers/fuzz_*.cpp) $(wildcard fuzzing/fuzzers/fuzz_*.c)
|
2016-05-13 12:36:41 +02:00
|
|
|
TEST_SOURCES := $(wildcard tests/test_*.cpp) $(wildcard tests/test_*.c)
|
2016-05-25 18:08:44 +02:00
|
|
|
|
|
|
|
OBJECTS := $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCES)))
|
|
|
|
RELEASE_OBJECTS := $(addprefix $(BUILD_DIR)/release/,$(OBJECTS))
|
|
|
|
DEBUG_OBJECTS := $(addprefix $(BUILD_DIR)/debug/,$(OBJECTS))
|
|
|
|
FUZZER_OBJECTS := $(addprefix $(BUILD_DIR)/fuzzers/objects/,$(OBJECTS))
|
2021-05-05 12:00:30 +02:00
|
|
|
FUZZER_ASAN_OBJECTS := $(addprefix $(BUILD_DIR)/fuzzers/objects/,$(addprefix asan_,$(OBJECTS)))
|
|
|
|
FUZZER_MSAN_OBJECTS := $(addprefix $(BUILD_DIR)/fuzzers/objects/,$(addprefix msan_,$(OBJECTS)))
|
2021-07-01 13:37:45 +02:00
|
|
|
FUZZER_DEBUG_OBJECTS := $(addprefix $(BUILD_DIR)/fuzzers/objects/,$(addprefix debug_,$(OBJECTS)))
|
|
|
|
FUZZER_BINARIES := $(addprefix $(BUILD_DIR)/fuzzers/,$(basename $(notdir $(FUZZER_SOURCES))))
|
2021-05-05 12:00:30 +02:00
|
|
|
FUZZER_ASAN_BINARIES := $(addsuffix _asan,$(FUZZER_BINARIES))
|
|
|
|
FUZZER_MSAN_BINARIES := $(addsuffix _msan,$(FUZZER_BINARIES))
|
2016-05-25 18:08:44 +02:00
|
|
|
FUZZER_DEBUG_BINARIES := $(patsubst $(BUILD_DIR)/fuzzers/fuzz_%,$(BUILD_DIR)/fuzzers/debug_%,$(FUZZER_BINARIES))
|
|
|
|
TEST_BINARIES := $(patsubst tests/%,$(BUILD_DIR)/tests/%,$(basename $(TEST_SOURCES)))
|
|
|
|
JS_OBJECTS := $(addprefix $(BUILD_DIR)/javascript/,$(OBJECTS))
|
2020-05-07 18:40:29 +02:00
|
|
|
WASM_OBJECTS := $(addprefix $(BUILD_DIR)/wasm/,$(OBJECTS))
|
2018-09-25 18:13:29 +02:00
|
|
|
|
|
|
|
# pre & post are the js-pre/js-post options to emcc.
|
|
|
|
# They are injected inside the modularised code and
|
|
|
|
# processed by the optimiser.
|
2016-05-20 10:36:50 +02:00
|
|
|
JS_PRE := $(wildcard javascript/*pre.js)
|
2016-05-25 15:42:49 +02:00
|
|
|
JS_POST := javascript/olm_outbound_group_session.js \
|
|
|
|
javascript/olm_inbound_group_session.js \
|
2018-06-11 23:48:45 +02:00
|
|
|
javascript/olm_pk.js \
|
2019-01-22 05:21:41 +01:00
|
|
|
javascript/olm_sas.js \
|
2016-05-25 15:42:49 +02:00
|
|
|
javascript/olm_post.js
|
2018-09-25 18:13:29 +02:00
|
|
|
|
|
|
|
# The prefix & suffix are just added onto the start & end
|
|
|
|
# of what comes out emcc, so are outside of the modularised
|
|
|
|
# code and not seen by the opimiser.
|
|
|
|
JS_PREFIX := javascript/olm_prefix.js
|
|
|
|
JS_SUFFIX := javascript/olm_suffix.js
|
|
|
|
|
2016-07-11 15:50:49 +02:00
|
|
|
DOCS := tracing/README.html \
|
2016-09-22 12:04:19 +02:00
|
|
|
docs/megolm.html \
|
2016-07-11 15:50:49 +02:00
|
|
|
docs/olm.html \
|
2016-10-27 12:53:55 +02:00
|
|
|
docs/signing.html \
|
2016-07-11 15:50:49 +02:00
|
|
|
README.html \
|
|
|
|
CHANGELOG.html
|
2016-05-13 12:36:41 +02:00
|
|
|
|
2016-09-01 14:35:23 +02:00
|
|
|
CPPFLAGS += -Iinclude -Ilib \
|
|
|
|
-DOLMLIB_VERSION_MAJOR=$(MAJOR) -DOLMLIB_VERSION_MINOR=$(MINOR) \
|
|
|
|
-DOLMLIB_VERSION_PATCH=$(PATCH)
|
|
|
|
|
2016-05-24 15:36:07 +02:00
|
|
|
# we rely on <stdint.h>, which was introduced in C99
|
2019-09-30 14:50:35 +02:00
|
|
|
CFLAGS += -Wall -Werror -std=c99
|
|
|
|
CXXFLAGS += -Wall -Werror -std=c++11
|
2016-05-18 19:03:28 +02:00
|
|
|
LDFLAGS += -Wall -Werror
|
2016-05-13 12:36:41 +02:00
|
|
|
|
2019-09-30 14:50:35 +02:00
|
|
|
CFLAGS_NATIVE = -fPIC
|
|
|
|
CXXFLAGS_NATIVE = -fPIC
|
|
|
|
|
2018-09-21 17:01:51 +02:00
|
|
|
EMCCFLAGS = --closure 1 --memory-init-file 0 -s NO_FILESYSTEM=1 -s INVOKE_RUN=0 -s MODULARIZE=1
|
2016-05-20 10:36:50 +02:00
|
|
|
|
2018-09-25 18:13:29 +02:00
|
|
|
# Olm generally doesn't need a lot of memory to encrypt / decrypt its usual
|
|
|
|
# payloads (ie. Matrix messages), but we do need about 128K of heap to encrypt
|
|
|
|
# a 64K event (enough to store the ciphertext and the plaintext, bearing in
|
|
|
|
# mind that the plaintext can only be 48K because base64). We also have about
|
|
|
|
# 36K of statics. So let's have 256K of memory.
|
|
|
|
# (This can't be changed by the app with wasm since it's baked into the wasm).
|
2018-10-04 21:09:54 +02:00
|
|
|
# (emscripten also mandates at least 16MB of memory for asm.js now, so
|
|
|
|
# we don't use this for the legacy build.)
|
|
|
|
EMCCFLAGS_WASM += -s TOTAL_STACK=65536 -s TOTAL_MEMORY=262144
|
2018-09-25 18:13:29 +02:00
|
|
|
|
2018-10-04 21:09:54 +02:00
|
|
|
EMCCFLAGS_ASMJS += -s WASM=0
|
2018-09-25 18:13:29 +02:00
|
|
|
|
2021-11-25 13:48:26 +01:00
|
|
|
EMCC.c = $(EMCC) $(CFLAGS) $(CPPFLAGS) -c -DNDEBUG -DOLM_STATIC_DEFINE=1
|
|
|
|
EMCC.cc = $(EMCC) $(CXXFLAGS) $(CPPFLAGS) -c -DNDEBUG -DOLM_STATIC_DEFINE=1
|
2016-05-20 10:36:50 +02:00
|
|
|
EMCC_LINK = $(EMCC) $(LDFLAGS) $(EMCCFLAGS)
|
|
|
|
|
2021-05-05 12:00:30 +02:00
|
|
|
AFL_CC = afl-clang-fast
|
|
|
|
AFL_CXX = afl-clang-fast++
|
|
|
|
|
2016-05-23 18:32:24 +02:00
|
|
|
AFL.c = $(AFL_CC) $(CFLAGS) $(CPPFLAGS) -c
|
|
|
|
AFL.cc = $(AFL_CXX) $(CXXFLAGS) $(CPPFLAGS) -c
|
|
|
|
AFL_LINK.c = $(AFL_CC) $(LDFLAGS) $(CFLAGS) $(CPPFLAGS)
|
|
|
|
AFL_LINK.cc = $(AFL_CXX) $(LDFLAGS) $(CXXFLAGS) $(CPPFLAGS)
|
2021-05-05 12:00:30 +02:00
|
|
|
AFL_ASAN.c = AFL_USE_ASAN=1 $(AFL_CC) -m32 $(CFLAGS) $(CPPFLAGS) -c
|
|
|
|
AFL_ASAN.cc = AFL_USE_ASAN=1 $(AFL_CXX) -m32 $(CXXFLAGS) $(CPPFLAGS) -c
|
|
|
|
AFL_LINK_ASAN.c = AFL_USE_ASAN=1 $(AFL_CC) -m32 $(LDFLAGS) $(CFLAGS) $(CPPFLAGS)
|
|
|
|
AFL_LINK_ASAN.cc = AFL_USE_ASAN=1 $(AFL_CXX) -m32 $(LDFLAGS) $(CXXFLAGS) $(CPPFLAGS)
|
|
|
|
AFL_MSAN.c = AFL_USE_MSAN=1 $(AFL_CC) $(CFLAGS) $(CPPFLAGS) -c
|
|
|
|
AFL_MSAN.cc = AFL_USE_MSAN=1 $(AFL_CXX) $(CXXFLAGS) $(CPPFLAGS) -c
|
|
|
|
AFL_LINK_MSAN.c = AFL_USE_MSAN=1 $(AFL_CC) $(LDFLAGS) $(CFLAGS) $(CPPFLAGS)
|
|
|
|
AFL_LINK_MSAN.cc = AFL_USE_MSAN=1 $(AFL_CXX) $(LDFLAGS) $(CXXFLAGS) $(CPPFLAGS)
|
2016-05-23 18:32:24 +02:00
|
|
|
|
2016-05-13 12:36:41 +02:00
|
|
|
# generate .d files when compiling
|
|
|
|
CPPFLAGS += -MMD
|
|
|
|
|
|
|
|
### per-target variables
|
|
|
|
|
2019-09-30 14:50:35 +02:00
|
|
|
$(RELEASE_OBJECTS): CFLAGS += $(RELEASE_OPTIMIZE_FLAGS) $(CFLAGS_NATIVE)
|
|
|
|
$(RELEASE_OBJECTS): CXXFLAGS += $(RELEASE_OPTIMIZE_FLAGS) $(CXXFLAGS_NATIVE)
|
2016-05-23 16:58:18 +02:00
|
|
|
$(RELEASE_TARGET): LDFLAGS += $(RELEASE_OPTIMIZE_FLAGS)
|
|
|
|
|
2019-09-30 14:50:35 +02:00
|
|
|
$(DEBUG_OBJECTS): CFLAGS += $(DEBUG_OPTIMIZE_FLAGS) $(CFLAGS_NATIVE)
|
|
|
|
$(DEBUG_OBJECTS): CXXFLAGS += $(DEBUG_OPTIMIZE_FLAGS) $(CXXFLAGS_NATIVE)
|
2016-05-23 16:58:18 +02:00
|
|
|
$(DEBUG_TARGET): LDFLAGS += $(DEBUG_OPTIMIZE_FLAGS)
|
2016-05-13 12:36:41 +02:00
|
|
|
|
|
|
|
$(TEST_BINARIES): CPPFLAGS += -Itests/include
|
2016-05-24 17:28:14 +02:00
|
|
|
$(TEST_BINARIES): LDFLAGS += $(DEBUG_OPTIMIZE_FLAGS) -L$(BUILD_DIR)
|
2016-05-13 12:36:41 +02:00
|
|
|
|
2021-07-01 13:37:45 +02:00
|
|
|
$(FUZZER_OBJECTS): CFLAGS += $(FUZZER_OPTIMIZE_FLAGS) -D OLM_FUZZING=1
|
|
|
|
$(FUZZER_OBJECTS): CXXFLAGS += $(FUZZER_OPTIMIZE_FLAGS) -D OLM_FUZZING=1
|
|
|
|
$(FUZZER_DEBUG_OBJECTS): CFLAGS += $(DEBUG_OPTIMIZE_FLAGS) $(CFLAGS_NATIVE) -D OLM_FUZZING=1
|
|
|
|
$(FUZZER_DEBUG_OBJECTS): CXXFLAGS += $(DEBUG_OPTIMIZE_FLAGS) $(CXXFLAGS_NATIVE) -D OLM_FUZZING=1
|
|
|
|
$(FUZZER_ASAN_OBJECTS): CFLAGS += $(FUZZER_OPTIMIZE_FLAGS) -D OLM_FUZZING=1
|
|
|
|
$(FUZZER_ASAN_OBJECTS): CXXFLAGS += $(FUZZER_OPTIMIZE_FLAGS) -D OLM_FUZZING=1
|
|
|
|
$(FUZZER_MSAN_OBJECTS): CFLAGS += $(FUZZER_OPTIMIZE_FLAGS) -D OLM_FUZZING=1
|
|
|
|
$(FUZZER_MSAN_OBJECTS): CXXFLAGS += $(FUZZER_OPTIMIZE_FLAGS) -D OLM_FUZZING=1
|
|
|
|
|
|
|
|
$(FUZZER_BINARIES): CPPFLAGS += -Ifuzzing/fuzzers/include
|
2021-07-13 13:13:15 +02:00
|
|
|
$(FUZZER_BINARIES): LDFLAGS += $(FUZZER_OPTIMIZE_FLAGS) -L$(BUILD_DIR) -lstdc++
|
2021-07-01 13:37:45 +02:00
|
|
|
$(FUZZER_ASAN_BINARIES): CPPFLAGS += -Ifuzzing/fuzzers/include
|
2021-07-13 13:13:15 +02:00
|
|
|
$(FUZZER_ASAN_BINARIES): LDFLAGS += $(FUZZER_OPTIMIZE_FLAGS) -L$(BUILD_DIR) -lstdc++
|
2021-07-01 13:37:45 +02:00
|
|
|
$(FUZZER_MSAN_BINARIES): CPPFLAGS += -Ifuzzing/fuzzers/include
|
2021-07-13 13:13:15 +02:00
|
|
|
$(FUZZER_MSAN_BINARIES): LDFLAGS += $(FUZZER_OPTIMIZE_FLAGS) -L$(BUILD_DIR) -lstdc++
|
2021-07-01 13:37:45 +02:00
|
|
|
$(FUZZER_DEBUG_BINARIES): CPPFLAGS += -Ifuzzing/fuzzers/include
|
2021-07-13 13:13:15 +02:00
|
|
|
$(FUZZER_DEBUG_BINARIES): LDFLAGS += $(DEBUG_OPTIMIZE_FLAGS) -lstdc++
|
2016-05-23 18:32:24 +02:00
|
|
|
|
2016-05-20 10:36:50 +02:00
|
|
|
$(JS_OBJECTS): CFLAGS += $(JS_OPTIMIZE_FLAGS)
|
|
|
|
$(JS_OBJECTS): CXXFLAGS += $(JS_OPTIMIZE_FLAGS)
|
2018-10-04 21:09:54 +02:00
|
|
|
$(JS_WASM_TARGET): LDFLAGS += $(JS_OPTIMIZE_FLAGS)
|
|
|
|
$(JS_ASMJS_TARGET): LDFLAGS += $(JS_OPTIMIZE_FLAGS)
|
2016-05-20 10:36:50 +02:00
|
|
|
|
2018-04-12 11:51:16 +02:00
|
|
|
### Fix to make mkdir work on windows and linux
|
|
|
|
ifeq ($(shell echo "check_quotes"),"check_quotes")
|
|
|
|
WINDOWS := yes
|
|
|
|
else
|
|
|
|
WINDOWS := no
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(WINDOWS),yes)
|
|
|
|
mkdir = mkdir $(subst /,\,$(1)) > nul 2>&1 || (exit 0)
|
|
|
|
else
|
|
|
|
mkdir = mkdir -p $(1)
|
|
|
|
endif
|
|
|
|
|
2016-05-13 12:36:41 +02:00
|
|
|
### top-level targets
|
|
|
|
|
2016-09-01 14:35:23 +02:00
|
|
|
lib: $(RELEASE_TARGET)
|
2016-05-20 16:28:54 +02:00
|
|
|
.PHONY: lib
|
|
|
|
|
2016-05-23 16:58:18 +02:00
|
|
|
$(RELEASE_TARGET): $(RELEASE_OBJECTS)
|
2021-11-02 21:16:07 +01:00
|
|
|
@echo
|
|
|
|
@echo '****************************************************************************'
|
|
|
|
@echo '* WARNING: Building olm with make is deprecated. Please use cmake instead. *'
|
|
|
|
@echo '****************************************************************************'
|
|
|
|
@echo
|
|
|
|
|
2016-05-23 16:58:18 +02:00
|
|
|
$(CXX) $(LDFLAGS) --shared -fPIC \
|
2018-09-20 12:31:09 +02:00
|
|
|
$(OLM_LDFLAGS) \
|
2016-05-23 16:58:18 +02:00
|
|
|
$(OUTPUT_OPTION) $(RELEASE_OBJECTS)
|
2018-09-20 12:31:09 +02:00
|
|
|
ln -sf libolm.$(SO).$(VERSION) $(BUILD_DIR)/libolm.$(SO).$(MAJOR)
|
2018-10-12 23:02:51 +02:00
|
|
|
ln -sf libolm.$(SO).$(VERSION) $(BUILD_DIR)/libolm.$(SO)
|
2016-05-23 16:58:18 +02:00
|
|
|
|
2016-09-01 14:35:23 +02:00
|
|
|
debug: $(DEBUG_TARGET)
|
2016-05-23 16:58:18 +02:00
|
|
|
.PHONY: debug
|
|
|
|
|
|
|
|
$(DEBUG_TARGET): $(DEBUG_OBJECTS)
|
2016-05-20 13:01:18 +02:00
|
|
|
$(CXX) $(LDFLAGS) --shared -fPIC \
|
2018-09-20 12:31:09 +02:00
|
|
|
$(OLM_LDFLAGS) \
|
2016-05-23 16:58:18 +02:00
|
|
|
$(OUTPUT_OPTION) $(DEBUG_OBJECTS)
|
2018-09-20 12:31:09 +02:00
|
|
|
ln -sf libolm_debug.$(SO).$(VERSION) $(BUILD_DIR)/libolm_debug.$(SO).$(MAJOR)
|
2016-07-04 23:38:04 +02:00
|
|
|
|
2017-03-16 20:20:16 +01:00
|
|
|
static: $(STATIC_RELEASE_TARGET)
|
|
|
|
.PHONY: static
|
|
|
|
|
|
|
|
$(STATIC_RELEASE_TARGET): $(RELEASE_OBJECTS)
|
2017-03-29 11:44:54 +02:00
|
|
|
$(AR) rcs $@ $^
|
2017-03-16 20:20:16 +01:00
|
|
|
|
2018-10-04 21:09:54 +02:00
|
|
|
js: $(JS_WASM_TARGET) $(JS_ASMJS_TARGET)
|
2016-05-20 10:36:50 +02:00
|
|
|
.PHONY: js
|
|
|
|
|
2020-05-07 18:40:29 +02:00
|
|
|
wasm: $(WASM_TARGET)
|
|
|
|
.PHONY: wasm
|
|
|
|
|
|
|
|
$(WASM_TARGET): $(WASM_OBJECTS)
|
|
|
|
$(EMAR) rcs $@ $^
|
|
|
|
|
2021-06-08 20:57:05 +02:00
|
|
|
javascript/olm_prefix.js: javascript/olm_prefix.js.in Makefile common.mk
|
2021-03-31 22:09:36 +02:00
|
|
|
sed s/@VERSION@/$(VERSION)/ javascript/olm_prefix.js.in > $@
|
|
|
|
|
2018-09-25 18:13:29 +02:00
|
|
|
# Note that the output file we give to emcc determines the name of the
|
|
|
|
# wasm file baked into the js, hence messing around outputting to olm.js
|
|
|
|
# and then renaming it.
|
2018-10-04 21:09:54 +02:00
|
|
|
$(JS_WASM_TARGET): $(JS_OBJECTS) $(JS_PRE) $(JS_POST) $(JS_EXPORTED_FUNCTIONS) $(JS_PREFIX) $(JS_SUFFIX)
|
2021-09-15 00:18:26 +02:00
|
|
|
EMCC_CLOSURE_ARGS="--externs $(CURDIR)/$(JS_EXTERNS)" $(EMCC_LINK) \
|
2018-10-04 21:09:54 +02:00
|
|
|
$(EMCCFLAGS_WASM) \
|
|
|
|
$(foreach f,$(JS_PRE),--pre-js $(f)) \
|
|
|
|
$(foreach f,$(JS_POST),--post-js $(f)) \
|
2020-09-26 18:24:58 +02:00
|
|
|
$(foreach f,$(JS_PREFIX),--extern-pre-js $(f)) \
|
|
|
|
$(foreach f,$(JS_SUFFIX),--extern-post-js $(f)) \
|
2018-10-04 21:09:54 +02:00
|
|
|
-s "EXPORTED_FUNCTIONS=@$(JS_EXPORTED_FUNCTIONS)" \
|
2021-05-03 12:42:45 +02:00
|
|
|
-s "EXPORTED_RUNTIME_METHODS=$(JS_EXPORTED_RUNTIME_METHODS)" \
|
2020-05-19 21:09:15 +02:00
|
|
|
-o $@ $(JS_OBJECTS)
|
2018-10-04 21:09:54 +02:00
|
|
|
|
|
|
|
$(JS_ASMJS_TARGET): $(JS_OBJECTS) $(JS_PRE) $(JS_POST) $(JS_EXPORTED_FUNCTIONS) $(JS_PREFIX) $(JS_SUFFIX)
|
2021-09-15 00:18:26 +02:00
|
|
|
EMCC_CLOSURE_ARGS="--externs $(CURDIR)/$(JS_EXTERNS)" $(EMCC_LINK) \
|
2018-10-04 21:09:54 +02:00
|
|
|
$(EMCCFLAGS_ASMJS) \
|
2016-05-25 15:42:49 +02:00
|
|
|
$(foreach f,$(JS_PRE),--pre-js $(f)) \
|
|
|
|
$(foreach f,$(JS_POST),--post-js $(f)) \
|
2020-10-06 09:48:15 +02:00
|
|
|
$(foreach f,$(JS_PREFIX),--extern-pre-js $(f)) \
|
|
|
|
$(foreach f,$(JS_SUFFIX),--extern-post-js $(f)) \
|
2016-05-23 16:58:18 +02:00
|
|
|
-s "EXPORTED_FUNCTIONS=@$(JS_EXPORTED_FUNCTIONS)" \
|
2021-05-03 12:42:45 +02:00
|
|
|
-s "EXPORTED_RUNTIME_METHODS=$(JS_EXPORTED_RUNTIME_METHODS)" \
|
2020-05-19 21:09:15 +02:00
|
|
|
-o $@ $(JS_OBJECTS)
|
2016-05-20 10:36:50 +02:00
|
|
|
|
2016-05-13 12:36:41 +02:00
|
|
|
build_tests: $(TEST_BINARIES)
|
|
|
|
|
|
|
|
test: build_tests
|
|
|
|
for i in $(TEST_BINARIES); do \
|
|
|
|
echo $$i; \
|
2016-05-20 13:01:18 +02:00
|
|
|
$$i || exit $$?; \
|
2016-05-13 12:36:41 +02:00
|
|
|
done
|
|
|
|
|
2020-10-01 15:40:22 +02:00
|
|
|
test_mem: build_tests
|
|
|
|
for i in $(TEST_BINARIES); do \
|
|
|
|
echo $$i; \
|
|
|
|
valgrind -q --leak-check=yes --exit-on-first-error=yes --error-exitcode=1 $$i || exit $$?; \
|
|
|
|
done
|
|
|
|
|
2021-05-05 12:00:30 +02:00
|
|
|
fuzzers: $(FUZZER_BINARIES) $(FUZZER_ASAN_BINARIES) $(FUZZER_MSAN_BINARIES) $(FUZZER_DEBUG_BINARIES)
|
2016-05-23 18:32:24 +02:00
|
|
|
.PHONY: fuzzers
|
|
|
|
|
2016-05-20 10:36:50 +02:00
|
|
|
$(JS_EXPORTED_FUNCTIONS): $(PUBLIC_HEADERS)
|
2018-10-03 17:06:15 +02:00
|
|
|
./exports.py $^ > $@.tmp
|
2016-05-20 10:36:50 +02:00
|
|
|
mv $@.tmp $@
|
|
|
|
|
2016-07-11 15:50:49 +02:00
|
|
|
all: test js lib debug doc
|
2016-05-25 18:08:44 +02:00
|
|
|
.PHONY: all
|
|
|
|
|
2016-09-21 19:08:05 +02:00
|
|
|
install-headers: $(PUBLIC_HEADERS)
|
2018-04-12 11:51:16 +02:00
|
|
|
test -d $(DESTDIR)$(PREFIX)/include/olm || $(call mkdir,$(DESTDIR)$(PREFIX)/include/olm)
|
2020-05-15 04:06:08 +02:00
|
|
|
install $(PUBLIC_HEADERS) $(DESTDIR)$(PREFIX)/include/olm/
|
2016-09-23 13:22:34 +02:00
|
|
|
.PHONY: install-headers
|
2016-09-21 19:08:05 +02:00
|
|
|
|
|
|
|
install-debug: debug install-headers
|
2018-04-12 11:51:16 +02:00
|
|
|
test -d $(DESTDIR)$(PREFIX)/lib || $(call mkdir,$(DESTDIR)$(PREFIX)/lib)
|
2020-05-15 04:06:08 +02:00
|
|
|
install $(DEBUG_TARGET) $(DESTDIR)$(PREFIX)/lib/libolm_debug.$(SO).$(VERSION)
|
2019-08-07 21:22:09 +02:00
|
|
|
ln -sf libolm_debug.$(SO).$(VERSION) $(DESTDIR)$(PREFIX)/lib/libolm_debug.$(SO).$(MAJOR)
|
|
|
|
ln -sf libolm_debug.$(SO).$(VERSION) $(DESTDIR)$(PREFIX)/lib/libolm_debug.$(SO)
|
2016-07-04 23:38:05 +02:00
|
|
|
.PHONY: install-debug
|
|
|
|
|
2016-09-21 19:08:05 +02:00
|
|
|
install: lib install-headers
|
2018-04-12 11:51:16 +02:00
|
|
|
test -d $(DESTDIR)$(PREFIX)/lib || $(call mkdir,$(DESTDIR)$(PREFIX)/lib)
|
2020-05-15 04:06:08 +02:00
|
|
|
install $(RELEASE_TARGET) $(DESTDIR)$(PREFIX)/lib/libolm.$(SO).$(VERSION)
|
2019-08-07 21:22:09 +02:00
|
|
|
ln -sf libolm.$(SO).$(VERSION) $(DESTDIR)$(PREFIX)/lib/libolm.$(SO).$(MAJOR)
|
|
|
|
ln -sf libolm.$(SO).$(VERSION) $(DESTDIR)$(PREFIX)/lib/libolm.$(SO)
|
2016-07-04 23:38:05 +02:00
|
|
|
.PHONY: install
|
|
|
|
|
2016-05-25 18:08:44 +02:00
|
|
|
clean:;
|
2016-07-11 15:50:49 +02:00
|
|
|
rm -rf $(BUILD_DIR) $(DOCS)
|
2016-05-25 18:08:44 +02:00
|
|
|
.PHONY: clean
|
2016-05-20 16:28:54 +02:00
|
|
|
|
2016-07-11 15:50:49 +02:00
|
|
|
doc: $(DOCS)
|
|
|
|
.PHONY: doc
|
|
|
|
|
2016-05-13 12:36:41 +02:00
|
|
|
### rules for building objects
|
2016-05-25 18:08:44 +02:00
|
|
|
$(BUILD_DIR)/release/%.o: %.c
|
2018-04-12 11:51:16 +02:00
|
|
|
$(call mkdir,$(dir $@))
|
2016-05-23 16:58:18 +02:00
|
|
|
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
|
|
|
|
2016-05-25 18:08:44 +02:00
|
|
|
$(BUILD_DIR)/release/%.o: %.cpp
|
2018-04-12 11:51:16 +02:00
|
|
|
$(call mkdir,$(dir $@))
|
2016-05-23 16:58:18 +02:00
|
|
|
$(COMPILE.cc) $(OUTPUT_OPTION) $<
|
|
|
|
|
2016-05-25 18:08:44 +02:00
|
|
|
$(BUILD_DIR)/debug/%.o: %.c
|
2018-04-12 11:51:16 +02:00
|
|
|
$(call mkdir,$(dir $@))
|
2016-05-13 12:36:41 +02:00
|
|
|
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
|
|
|
|
2016-05-25 18:08:44 +02:00
|
|
|
$(BUILD_DIR)/debug/%.o: %.cpp
|
2018-04-12 11:51:16 +02:00
|
|
|
$(call mkdir,$(dir $@))
|
2016-05-13 12:36:41 +02:00
|
|
|
$(COMPILE.cc) $(OUTPUT_OPTION) $<
|
|
|
|
|
2016-05-25 18:08:44 +02:00
|
|
|
$(BUILD_DIR)/javascript/%.o: %.c
|
2018-04-12 11:51:16 +02:00
|
|
|
$(call mkdir,$(dir $@))
|
2016-05-20 10:36:50 +02:00
|
|
|
$(EMCC.c) $(OUTPUT_OPTION) $<
|
|
|
|
|
2016-05-25 18:08:44 +02:00
|
|
|
$(BUILD_DIR)/javascript/%.o: %.cpp
|
2018-04-12 11:51:16 +02:00
|
|
|
$(call mkdir,$(dir $@))
|
2016-05-20 10:36:50 +02:00
|
|
|
$(EMCC.cc) $(OUTPUT_OPTION) $<
|
|
|
|
|
2020-05-07 18:40:29 +02:00
|
|
|
$(BUILD_DIR)/wasm/%.o: %.c
|
|
|
|
$(call mkdir,$(dir $@))
|
|
|
|
$(EMCC.c) $(OUTPUT_OPTION) $<
|
|
|
|
|
|
|
|
$(BUILD_DIR)/wasm/%.o: %.cpp
|
|
|
|
$(call mkdir,$(dir $@))
|
|
|
|
$(EMCC.cc) $(OUTPUT_OPTION) $<
|
|
|
|
|
2016-05-23 16:58:18 +02:00
|
|
|
$(BUILD_DIR)/tests/%: tests/%.c $(DEBUG_OBJECTS)
|
2018-04-12 11:51:16 +02:00
|
|
|
$(call mkdir,$(dir $@))
|
2020-05-19 21:09:15 +02:00
|
|
|
$(LINK.c) -o $@ $< $(DEBUG_OBJECTS) $(LOADLIBES) $(LDLIBS)
|
2016-05-13 12:36:41 +02:00
|
|
|
|
2016-05-23 16:58:18 +02:00
|
|
|
$(BUILD_DIR)/tests/%: tests/%.cpp $(DEBUG_OBJECTS)
|
2018-04-12 11:51:16 +02:00
|
|
|
$(call mkdir,$(dir $@))
|
2020-05-19 21:09:15 +02:00
|
|
|
$(LINK.cc) -o $@ $< $(DEBUG_OBJECTS) $(LOADLIBES) $(LDLIBS)
|
2016-05-13 12:36:41 +02:00
|
|
|
|
2016-05-25 18:08:44 +02:00
|
|
|
$(BUILD_DIR)/fuzzers/objects/%.o: %.c
|
2018-04-12 11:51:16 +02:00
|
|
|
$(call mkdir,$(dir $@))
|
2016-05-23 18:32:24 +02:00
|
|
|
$(AFL.c) $(OUTPUT_OPTION) $<
|
|
|
|
|
2016-05-25 18:08:44 +02:00
|
|
|
$(BUILD_DIR)/fuzzers/objects/%.o: %.cpp
|
2018-04-12 11:51:16 +02:00
|
|
|
$(call mkdir,$(dir $@))
|
2016-05-23 18:32:24 +02:00
|
|
|
$(AFL.cc) $(OUTPUT_OPTION) $<
|
|
|
|
|
2021-05-05 12:00:30 +02:00
|
|
|
$(BUILD_DIR)/fuzzers/objects/asan_%.o: %.c
|
|
|
|
$(call mkdir,$(dir $@))
|
|
|
|
$(AFL_ASAN.c) $(OUTPUT_OPTION) $<
|
|
|
|
|
|
|
|
$(BUILD_DIR)/fuzzers/objects/asan_%.o: %.cpp
|
|
|
|
$(call mkdir,$(dir $@))
|
|
|
|
$(AFL_ASAN.cc) $(OUTPUT_OPTION) $<
|
|
|
|
|
|
|
|
$(BUILD_DIR)/fuzzers/objects/msan_%.o: %.c
|
|
|
|
$(call mkdir,$(dir $@))
|
|
|
|
$(AFL_MSAN.c) $(OUTPUT_OPTION) $<
|
|
|
|
|
|
|
|
$(BUILD_DIR)/fuzzers/objects/msan_%.o: %.cpp
|
|
|
|
$(call mkdir,$(dir $@))
|
|
|
|
$(AFL_MSAN.cc) $(OUTPUT_OPTION) $<
|
|
|
|
|
2021-07-01 13:37:45 +02:00
|
|
|
$(BUILD_DIR)/fuzzers/objects/debug_%.o: %.c
|
|
|
|
$(call mkdir,$(dir $@))
|
|
|
|
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
|
|
|
|
|
|
|
$(BUILD_DIR)/fuzzers/objects/debug_%.o: %.cpp
|
|
|
|
$(call mkdir,$(dir $@))
|
|
|
|
$(COMPILE.cc) $(OUTPUT_OPTION) $<
|
|
|
|
|
|
|
|
|
|
|
|
$(BUILD_DIR)/fuzzers/fuzz_%: fuzzing/fuzzers/fuzz_%.c $(FUZZER_OBJECTS)
|
2020-05-19 21:09:15 +02:00
|
|
|
$(AFL_LINK.c) -o $@ $< $(FUZZER_OBJECTS) $(LOADLIBES) $(LDLIBS)
|
2016-05-23 18:32:24 +02:00
|
|
|
|
2021-07-01 13:37:45 +02:00
|
|
|
$(BUILD_DIR)/fuzzers/fuzz_%: fuzzing/fuzzers/fuzz_%.cpp $(FUZZER_OBJECTS)
|
2020-05-19 21:09:15 +02:00
|
|
|
$(AFL_LINK.cc) -o $@ $< $(FUZZER_OBJECTS) $(LOADLIBES) $(LDLIBS)
|
2016-05-23 18:32:24 +02:00
|
|
|
|
2021-07-01 13:37:45 +02:00
|
|
|
$(BUILD_DIR)/fuzzers/debug_%: fuzzing/fuzzers/fuzz_%.c $(FUZZER_DEBUG_OBJECTS)
|
|
|
|
$(LINK.c) -o $@ $< $(FUZZER_DEBUG_OBJECTS) $(LOADLIBES) $(LDLIBS)
|
2016-05-23 18:32:24 +02:00
|
|
|
|
2021-07-01 13:37:45 +02:00
|
|
|
$(BUILD_DIR)/fuzzers/debug_%: fuzzing/fuzzers/fuzz_%.cpp $(FUZZER_DEBUG_OBJECTS)
|
|
|
|
$(LINK.cc) -o $@ $< $(FUZZER_DEBUG_OBJECTS) $(LOADLIBES) $(LDLIBS)
|
2016-05-13 12:36:41 +02:00
|
|
|
|
2021-07-01 13:37:45 +02:00
|
|
|
$(BUILD_DIR)/fuzzers/fuzz_%_asan: fuzzing/fuzzers/fuzz_%.c $(FUZZER_ASAN_OBJECTS)
|
2021-05-05 12:00:30 +02:00
|
|
|
$(AFL_LINK_ASAN.c) -o $@ $< $(FUZZER_ASAN_OBJECTS) $(LOADLIBES) $(LDLIBS)
|
|
|
|
|
2021-07-01 13:37:45 +02:00
|
|
|
$(BUILD_DIR)/fuzzers/fuzz_%_asan: fuzzing/fuzzers/fuzz_%.cpp $(FUZZER_ASAN_OBJECTS)
|
2021-05-05 12:00:30 +02:00
|
|
|
$(AFL_LINK_ASAN.cc) -o $@ $< $(FUZZER_ASAN_OBJECTS) $(LOADLIBES) $(LDLIBS)
|
|
|
|
|
2021-07-01 13:37:45 +02:00
|
|
|
$(BUILD_DIR)/fuzzers/fuzz_%_msan: fuzzing/fuzzers/fuzz_%.c $(FUZZER_MSAN_OBJECTS)
|
2021-05-05 12:00:30 +02:00
|
|
|
$(AFL_LINK_MSAN.c) -o $@ $< $(FUZZER_MSAN_OBJECTS) $(LOADLIBES) $(LDLIBS)
|
|
|
|
|
2021-07-01 13:37:45 +02:00
|
|
|
$(BUILD_DIR)/fuzzers/fuzz_%_msan: fuzzing/fuzzers/fuzz_%.cpp $(FUZZER_MSAN_OBJECTS)
|
2021-05-05 12:00:30 +02:00
|
|
|
$(AFL_LINK_MSAN.cc) -o $@ $< $(FUZZER_MSAN_OBJECTS) $(LOADLIBES) $(LDLIBS)
|
|
|
|
|
2016-07-11 15:50:49 +02:00
|
|
|
%.html: %.rst
|
|
|
|
rst2html $< $@
|
|
|
|
|
2022-01-14 17:08:58 +01:00
|
|
|
%.html: %.md
|
|
|
|
pandoc --from markdown --to html5 --standalone --lua-filter gitlab-math.lua --katex -o $@ $<
|
|
|
|
|
2016-05-13 12:36:41 +02:00
|
|
|
### dependencies
|
|
|
|
|
2016-05-23 16:58:18 +02:00
|
|
|
-include $(RELEASE_OBJECTS:.o=.d)
|
|
|
|
-include $(DEBUG_OBJECTS:.o=.d)
|
2016-05-25 18:08:44 +02:00
|
|
|
-include $(JS_OBJECTS:.o=.d)
|
2016-05-13 12:36:41 +02:00
|
|
|
-include $(TEST_BINARIES:=.d)
|
2016-05-23 18:32:24 +02:00
|
|
|
-include $(FUZZER_OBJECTS:.o=.d)
|
2021-07-01 13:37:45 +02:00
|
|
|
-include $(FUZZER_DEBUG_OBJECTS:.o=.d)
|
2021-05-05 12:00:30 +02:00
|
|
|
-include $(FUZZER_ASAN_OBJECTS:.o=.d)
|
|
|
|
-include $(FUZZER_MSAN_OBJECTS:.o=.d)
|
2016-05-23 18:32:24 +02:00
|
|
|
-include $(FUZZER_BINARIES:=.d)
|
2021-05-05 12:00:30 +02:00
|
|
|
-include $(FUZZER_ASAN_BINARIES:=.d)
|
|
|
|
-include $(FUZZER_MSAN_BINARIES:=.d)
|
2016-05-23 18:32:24 +02:00
|
|
|
-include $(FUZZER_DEBUG_BINARIES:=.d)
|