Commit ee8172d8 authored by Richard van der Hoff's avatar Richard van der Hoff
Browse files

Compile some of the crypto libs directly

sha256.c and aes.c contain conflicting declarations, so we need to compile them
as separate units. This requires a bit more Makefile-shuffling; the build
directory now includes 'src' or 'lib' as appropriate, and we just mkdir -p
before each compilation.
parent 27b57c8d
......@@ -17,16 +17,22 @@ JS_EXPORTED_FUNCTIONS := javascript/exported_functions.json
PUBLIC_HEADERS := include/olm/olm.h
SOURCES := $(wildcard src/*.cpp) $(wildcard src/*.c)
RELEASE_OBJECTS := $(patsubst src/%,$(BUILD_DIR)/release/%,$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCES))))
DEBUG_OBJECTS := $(patsubst src/%,$(BUILD_DIR)/debug/%,$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCES))))
FUZZER_OBJECTS := $(patsubst src/%,$(BUILD_DIR)/fuzzers/objects/%,$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCES))))
SOURCES := $(wildcard src/*.cpp) $(wildcard src/*.c) \
lib/crypto-algorithms/sha256.c \
lib/crypto-algorithms/aes.c \
FUZZER_SOURCES := $(wildcard fuzzers/fuzz_*.cpp) $(wildcard fuzzers/fuzz_*.c)
FUZZER_BINARIES := $(patsubst fuzzers/%,$(BUILD_DIR)/fuzzers/%,$(patsubst %.c,%,$(patsubst %.cpp,%,$(FUZZER_SOURCES))))
FUZZER_DEBUG_BINARIES := $(patsubst $(BUILD_DIR)/fuzzers/fuzz_%,$(BUILD_DIR)/fuzzers/debug_%,$(FUZZER_BINARIES))
TEST_SOURCES := $(wildcard tests/test_*.cpp) $(wildcard tests/test_*.c)
TEST_BINARIES := $(patsubst tests/%,$(BUILD_DIR)/tests/%,$(patsubst %.c,%,$(patsubst %.cpp,%,$(TEST_SOURCES))))
JS_OBJECTS := $(patsubst src/%,$(BUILD_DIR)/javascript/%,$(patsubst %.c,%.js.bc,$(patsubst %.cpp,%.js.bc,$(SOURCES))))
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))
FUZZER_BINARIES := $(addprefix $(BUILD_DIR)/,$(basename $(FUZZER_SOURCES)))
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))
JS_PRE := $(wildcard javascript/*pre.js)
JS_POST := $(wildcard javascript/*post.js)
......@@ -82,14 +88,6 @@ $(JS_TARGET): LDFLAGS += $(JS_OPTIMIZE_FLAGS)
.PHONY: lib
# Make sure that the build directory exists.
# We can't check the build directory into git because it is empty.
mkdir -p $(BUILD_DIR)/release $(BUILD_DIR)/debug $(BUILD_DIR)/javascript\
$(BUILD_DIR)/tests $(BUILD_DIR)/fuzzers/objects
.PHONY: makedirs
$(CXX) $(LDFLAGS) --shared -fPIC \
-Wl,--version-script,version_script.ver \
......@@ -112,17 +110,6 @@ $(JS_TARGET): $(JS_OBJECTS) $(JS_PRE) $(JS_POST) $(JS_EXPORTED_FUNCTIONS)
$(JS_OBJECTS) -o $@
build_tests: $(TEST_BINARIES)
test: build_tests
......@@ -139,37 +126,51 @@ $(JS_EXPORTED_FUNCTIONS): $(PUBLIC_HEADERS)
mv $@.tmp $@
all: test js lib debug
.PHONY: lib
.PHONY: all
rm -rf $(BUILD_DIR)
.PHONY: clean
### rules for building objects
$(BUILD_DIR)/release/%.o: src/%.c | makedirs
$(BUILD_DIR)/release/%.o: %.c
mkdir -p $(dir $@)
$(BUILD_DIR)/release/%.o: src/%.cpp | makedirs
$(BUILD_DIR)/release/%.o: %.cpp
mkdir -p $(dir $@)
$(BUILD_DIR)/debug/%.o: src/%.c | makedirs
$(BUILD_DIR)/debug/%.o: %.c
mkdir -p $(dir $@)
$(BUILD_DIR)/debug/%.o: src/%.cpp | makedirs
$(BUILD_DIR)/debug/%.o: %.cpp
mkdir -p $(dir $@)
$(BUILD_DIR)/javascript/%.js.bc: src/%.c | makedirs
$(BUILD_DIR)/javascript/%.o: %.c
mkdir -p $(dir $@)
$(BUILD_DIR)/javascript/%.js.bc: src/%.cpp | makedirs
$(BUILD_DIR)/javascript/%.o: %.cpp
mkdir -p $(dir $@)
$(BUILD_DIR)/tests/%: tests/%.c $(DEBUG_OBJECTS)
mkdir -p $(dir $@)
$(BUILD_DIR)/tests/%: tests/%.cpp $(DEBUG_OBJECTS)
mkdir -p $(dir $@)
$(BUILD_DIR)/fuzzers/objects/%.o: src/%.c | makedirs
$(BUILD_DIR)/fuzzers/objects/%.o: %.c
mkdir -p $(dir $@)
$(BUILD_DIR)/fuzzers/objects/%.o: src/%.cpp | makedirs
$(BUILD_DIR)/fuzzers/objects/%.o: %.cpp
mkdir -p $(dir $@)
$(BUILD_DIR)/fuzzers/fuzz_%: fuzzers/fuzz_%.c $(FUZZER_OBJECTS)
......@@ -188,7 +189,7 @@ $(BUILD_DIR)/fuzzers/debug_%: fuzzers/fuzz_%.cpp $(DEBUG_OBJECTS)
-include $(RELEASE_OBJECTS:.o=.d)
-include $(DEBUG_OBJECTS:.o=.d)
-include $(JS_OBJECTS:.bc=.d)
-include $(JS_OBJECTS:.o=.d)
-include $(TEST_BINARIES:=.d)
-include $(FUZZER_OBJECTS:.o=.d)
-include $(FUZZER_BINARIES:=.d)
......@@ -12,9 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
#include "crypto-algorithms/sha256.c"
#include "crypto-algorithms/aes.c"
#include "curve25519-donna/curve25519-donna.c"
#define select ed25519_select
#include "ed25519/src/fe.c"
#include "ed25519/src/sc.c"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment