PLUGIN := av
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
DLL := dylib
LDCONFIG := true
else
DLL := so
LDCONFIG := ldconfig
endif
TARGET_LIB := libmumu$(PLUGIN).$(DLL)
PREFIX ?= /usr/local
LIBDIR ?= $(PREFIX)/lib
CARGO ?= cargo
FEATURES ?= host
ifdef TARGET_TRIPLE
TARGET_FLAG := --target $(TARGET_TRIPLE)
else
TARGET_FLAG :=
endif
.PHONY: all debug release install install-debug uninstall clean print-target print-features
all: debug
debug:
$(CARGO) build $(TARGET_FLAG) --features "$(FEATURES)"
release:
$(CARGO) build $(TARGET_FLAG) --release --features "$(FEATURES)"
install: release
@echo "Installing $(TARGET_LIB) to $(LIBDIR)"
@if [ -n "$(TARGET_TRIPLE)" ]; then \
OUTDIR=target/$(TARGET_TRIPLE)/release; \
else \
OUTDIR=target/release; \
fi; \
sudo install -m 0755 $$OUTDIR/$(TARGET_LIB) $(LIBDIR)/$(TARGET_LIB)
-@$(LDCONFIG)
install-debug: debug
@echo "Installing (debug) $(TARGET_LIB) to $(LIBDIR)"
@if [ -n "$(TARGET_TRIPLE)" ]; then \
OUTDIR=target/$(TARGET_TRIPLE)/debug; \
else \
OUTDIR=target/debug; \
fi; \
sudo install -m 0755 $$OUTDIR/$(TARGET_LIB) $(LIBDIR)/$(TARGET_LIB)
-@$(LDCONFIG)
uninstall:
@echo "Removing $(LIBDIR)/$(TARGET_LIB)"
-sudo rm -f $(LIBDIR)/$(TARGET_LIB)
-@$(LDCONFIG)
clean:
$(CARGO) clean
print-target:
@echo $(TARGET_LIB)
print-features:
@echo $(FEATURES)