aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile75
-rw-r--r--src/ed25519.c (renamed from src/libs.c)3
2 files changed, 38 insertions, 40 deletions
diff --git a/Makefile b/Makefile
index fca9576..49bec6a 100644
--- a/Makefile
+++ b/Makefile
@@ -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 \
+ lib/curve25519-donna/curve25519-donna.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)
lib: $(RELEASE_TARGET)
.PHONY: lib
-# Make sure that the build directory exists.
-# We can't check the build directory into git because it is empty.
-makedirs:
- mkdir -p $(BUILD_DIR)/release $(BUILD_DIR)/debug $(BUILD_DIR)/javascript\
- $(BUILD_DIR)/tests $(BUILD_DIR)/fuzzers/objects
-.PHONY: makedirs
-
-
$(RELEASE_TARGET): $(RELEASE_OBJECTS)
$(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)
-s "EXPORTED_FUNCTIONS=@$(JS_EXPORTED_FUNCTIONS)" \
$(JS_OBJECTS) -o $@
-clean:;
- rm -rf $(RELEASE_OBJECTS) $(RELEASE_OBJECTS:.o=.d) \
- $(DEBUG_OBJECTS) $(DEBUG_OBJECTS:.o=.d) \
- $(TEST_BINARIES) $(TEST_BINARIES:=.d) \
- $(JS_OBJECTS) $(JS_OBJECTS:.bc=.d) $(JS_TARGET) \
- $(JS_EXPORTED_FUNCTIONS)\
- $(RELEASE_TARGET) $(DEBUG_TARGET)\
- $(FUZZER_OBJECTS) $(FUZZER_OBJECTS:.o=.d)\
- $(FUZZER_BINARIES) $(FUZZER_BINARIES:=.d)\
- $(FUZZER_DEBUG_BINARIES) $(FUZZER_DEBUG_BINARIES:=.d)\
-
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
+
+clean:;
+ 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 $@)
$(COMPILE.c) $(OUTPUT_OPTION) $<
-$(BUILD_DIR)/release/%.o: src/%.cpp | makedirs
+$(BUILD_DIR)/release/%.o: %.cpp
+ mkdir -p $(dir $@)
$(COMPILE.cc) $(OUTPUT_OPTION) $<
-$(BUILD_DIR)/debug/%.o: src/%.c | makedirs
+$(BUILD_DIR)/debug/%.o: %.c
+ mkdir -p $(dir $@)
$(COMPILE.c) $(OUTPUT_OPTION) $<
-$(BUILD_DIR)/debug/%.o: src/%.cpp | makedirs
+$(BUILD_DIR)/debug/%.o: %.cpp
+ mkdir -p $(dir $@)
$(COMPILE.cc) $(OUTPUT_OPTION) $<
-$(BUILD_DIR)/javascript/%.js.bc: src/%.c | makedirs
+$(BUILD_DIR)/javascript/%.o: %.c
+ mkdir -p $(dir $@)
$(EMCC.c) $(OUTPUT_OPTION) $<
-$(BUILD_DIR)/javascript/%.js.bc: src/%.cpp | makedirs
+$(BUILD_DIR)/javascript/%.o: %.cpp
+ mkdir -p $(dir $@)
$(EMCC.cc) $(OUTPUT_OPTION) $<
$(BUILD_DIR)/tests/%: tests/%.c $(DEBUG_OBJECTS)
+ mkdir -p $(dir $@)
$(LINK.c) $< $(DEBUG_OBJECTS) $(LOADLIBES) $(LDLIBS) -o $@
$(BUILD_DIR)/tests/%: tests/%.cpp $(DEBUG_OBJECTS)
+ mkdir -p $(dir $@)
$(LINK.cc) $< $(DEBUG_OBJECTS) $(LOADLIBES) $(LDLIBS) -o $@
-$(BUILD_DIR)/fuzzers/objects/%.o: src/%.c | makedirs
+$(BUILD_DIR)/fuzzers/objects/%.o: %.c
+ mkdir -p $(dir $@)
$(AFL.c) $(OUTPUT_OPTION) $<
-$(BUILD_DIR)/fuzzers/objects/%.o: src/%.cpp | makedirs
+$(BUILD_DIR)/fuzzers/objects/%.o: %.cpp
+ mkdir -p $(dir $@)
$(AFL.cc) $(OUTPUT_OPTION) $<
$(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)
diff --git a/src/libs.c b/src/ed25519.c
index 4304354..f4f910d 100644
--- a/src/libs.c
+++ b/src/ed25519.c
@@ -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"