PLUGIN := tree
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)
OUTDIR_DBG := target/$(TARGET_TRIPLE)/debug
OUTDIR_REL := target/$(TARGET_TRIPLE)/release
else
TARGET_FLAG :=
OUTDIR_DBG := target/debug
OUTDIR_REL := target/release
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)"
sudo install -m 0755 $(OUTDIR_REL)/$(TARGET_LIB) $(LIBDIR)/$(TARGET_LIB)
-@$(LDCONFIG)
install-debug: debug
@echo "Installing (debug) $(TARGET_LIB) to $(LIBDIR)"
sudo install -m 0755 $(OUTDIR_DBG)/$(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)