Update Makefile to support building on Windows
The code for this change is taken from https://stackoverflow.com/a/30225575/4929236 This patch is Signed-Off-By: Marcel Radzio <marcel@radzio-sh.de>
This commit is contained in:
parent
3f5b9dd6d7
commit
4065c8e11a
1 changed files with 26 additions and 13 deletions
39
Makefile
39
Makefile
|
@ -100,6 +100,19 @@ $(JS_OBJECTS): CFLAGS += $(JS_OPTIMIZE_FLAGS)
|
||||||
$(JS_OBJECTS): CXXFLAGS += $(JS_OPTIMIZE_FLAGS)
|
$(JS_OBJECTS): CXXFLAGS += $(JS_OPTIMIZE_FLAGS)
|
||||||
$(JS_TARGET): LDFLAGS += $(JS_OPTIMIZE_FLAGS)
|
$(JS_TARGET): LDFLAGS += $(JS_OPTIMIZE_FLAGS)
|
||||||
|
|
||||||
|
### 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
|
||||||
|
|
||||||
### top-level targets
|
### top-level targets
|
||||||
|
|
||||||
lib: $(RELEASE_TARGET)
|
lib: $(RELEASE_TARGET)
|
||||||
|
@ -157,19 +170,19 @@ all: test js lib debug doc
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
|
|
||||||
install-headers: $(PUBLIC_HEADERS)
|
install-headers: $(PUBLIC_HEADERS)
|
||||||
test -d $(DESTDIR)$(PREFIX)/include/olm || mkdir -p $(DESTDIR)$(PREFIX)/include/olm
|
test -d $(DESTDIR)$(PREFIX)/include/olm || $(call mkdir,$(DESTDIR)$(PREFIX)/include/olm)
|
||||||
install -Dm644 $(PUBLIC_HEADERS) $(DESTDIR)$(PREFIX)/include/olm/
|
install -Dm644 $(PUBLIC_HEADERS) $(DESTDIR)$(PREFIX)/include/olm/
|
||||||
.PHONY: install-headers
|
.PHONY: install-headers
|
||||||
|
|
||||||
install-debug: debug install-headers
|
install-debug: debug install-headers
|
||||||
test -d $(DESTDIR)$(PREFIX)/lib || mkdir -p $(DESTDIR)$(PREFIX)/lib
|
test -d $(DESTDIR)$(PREFIX)/lib || $(call mkdir,$(DESTDIR)$(PREFIX)/lib)
|
||||||
install -Dm755 $(DEBUG_TARGET) $(DESTDIR)$(PREFIX)/lib/libolm_debug.so.$(VERSION)
|
install -Dm755 $(DEBUG_TARGET) $(DESTDIR)$(PREFIX)/lib/libolm_debug.so.$(VERSION)
|
||||||
ln -s libolm_debug.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libolm_debug.so.$(MAJOR)
|
ln -s libolm_debug.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libolm_debug.so.$(MAJOR)
|
||||||
ln -s libolm_debug.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libolm_debug.so
|
ln -s libolm_debug.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libolm_debug.so
|
||||||
.PHONY: install-debug
|
.PHONY: install-debug
|
||||||
|
|
||||||
install: lib install-headers
|
install: lib install-headers
|
||||||
test -d $(DESTDIR)$(PREFIX)/lib || mkdir -p $(DESTDIR)$(PREFIX)/lib
|
test -d $(DESTDIR)$(PREFIX)/lib || $(call mkdir,$(DESTDIR)$(PREFIX)/lib)
|
||||||
install -Dm755 $(RELEASE_TARGET) $(DESTDIR)$(PREFIX)/lib/libolm.so.$(VERSION)
|
install -Dm755 $(RELEASE_TARGET) $(DESTDIR)$(PREFIX)/lib/libolm.so.$(VERSION)
|
||||||
ln -s libolm.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libolm.so.$(MAJOR)
|
ln -s libolm.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libolm.so.$(MAJOR)
|
||||||
ln -s libolm.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libolm.so
|
ln -s libolm.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libolm.so
|
||||||
|
@ -184,43 +197,43 @@ doc: $(DOCS)
|
||||||
|
|
||||||
### rules for building objects
|
### rules for building objects
|
||||||
$(BUILD_DIR)/release/%.o: %.c
|
$(BUILD_DIR)/release/%.o: %.c
|
||||||
mkdir -p $(dir $@)
|
$(call mkdir,$(dir $@))
|
||||||
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
$(BUILD_DIR)/release/%.o: %.cpp
|
$(BUILD_DIR)/release/%.o: %.cpp
|
||||||
mkdir -p $(dir $@)
|
$(call mkdir,$(dir $@))
|
||||||
$(COMPILE.cc) $(OUTPUT_OPTION) $<
|
$(COMPILE.cc) $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
$(BUILD_DIR)/debug/%.o: %.c
|
$(BUILD_DIR)/debug/%.o: %.c
|
||||||
mkdir -p $(dir $@)
|
$(call mkdir,$(dir $@))
|
||||||
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
$(BUILD_DIR)/debug/%.o: %.cpp
|
$(BUILD_DIR)/debug/%.o: %.cpp
|
||||||
mkdir -p $(dir $@)
|
$(call mkdir,$(dir $@))
|
||||||
$(COMPILE.cc) $(OUTPUT_OPTION) $<
|
$(COMPILE.cc) $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
$(BUILD_DIR)/javascript/%.o: %.c
|
$(BUILD_DIR)/javascript/%.o: %.c
|
||||||
mkdir -p $(dir $@)
|
$(call mkdir,$(dir $@))
|
||||||
$(EMCC.c) $(OUTPUT_OPTION) $<
|
$(EMCC.c) $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
$(BUILD_DIR)/javascript/%.o: %.cpp
|
$(BUILD_DIR)/javascript/%.o: %.cpp
|
||||||
mkdir -p $(dir $@)
|
$(call mkdir,$(dir $@))
|
||||||
$(EMCC.cc) $(OUTPUT_OPTION) $<
|
$(EMCC.cc) $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
$(BUILD_DIR)/tests/%: tests/%.c $(DEBUG_OBJECTS)
|
$(BUILD_DIR)/tests/%: tests/%.c $(DEBUG_OBJECTS)
|
||||||
mkdir -p $(dir $@)
|
$(call mkdir,$(dir $@))
|
||||||
$(LINK.c) $< $(DEBUG_OBJECTS) $(LOADLIBES) $(LDLIBS) -o $@
|
$(LINK.c) $< $(DEBUG_OBJECTS) $(LOADLIBES) $(LDLIBS) -o $@
|
||||||
|
|
||||||
$(BUILD_DIR)/tests/%: tests/%.cpp $(DEBUG_OBJECTS)
|
$(BUILD_DIR)/tests/%: tests/%.cpp $(DEBUG_OBJECTS)
|
||||||
mkdir -p $(dir $@)
|
$(call mkdir,$(dir $@))
|
||||||
$(LINK.cc) $< $(DEBUG_OBJECTS) $(LOADLIBES) $(LDLIBS) -o $@
|
$(LINK.cc) $< $(DEBUG_OBJECTS) $(LOADLIBES) $(LDLIBS) -o $@
|
||||||
|
|
||||||
$(BUILD_DIR)/fuzzers/objects/%.o: %.c
|
$(BUILD_DIR)/fuzzers/objects/%.o: %.c
|
||||||
mkdir -p $(dir $@)
|
$(call mkdir,$(dir $@))
|
||||||
$(AFL.c) $(OUTPUT_OPTION) $<
|
$(AFL.c) $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
$(BUILD_DIR)/fuzzers/objects/%.o: %.cpp
|
$(BUILD_DIR)/fuzzers/objects/%.o: %.cpp
|
||||||
mkdir -p $(dir $@)
|
$(call mkdir,$(dir $@))
|
||||||
$(AFL.cc) $(OUTPUT_OPTION) $<
|
$(AFL.cc) $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
$(BUILD_DIR)/fuzzers/fuzz_%: fuzzers/fuzz_%.c $(FUZZER_OBJECTS)
|
$(BUILD_DIR)/fuzzers/fuzz_%: fuzzers/fuzz_%.c $(FUZZER_OBJECTS)
|
||||||
|
|
Loading…
Reference in a new issue