av-mumu 0.1.0-rc.6

Audio/Video (AV) tools plugin for the Lava / MuMu language
Documentation
# Makefile — build & install the MuMu "av" plugin
# ------------------------------------------------------------------------
# Usage:
#   make                # debug (native)
#   make release        # release (native)
#   make install        # install release .so/.dylib to /usr/local/lib and ldconfig
#   make uninstall      # remove installed library
#   make print-target
#   make print-features
#
# Environment:
#   FEATURES="host"     # enable host-only backends (CPAL/Symphonia). Recommended for native.
#   TARGET_TRIPLE=...   # e.g. aarch64-apple-darwin, x86_64-unknown-linux-gnu
# ------------------------------------------------------------------------

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
# Optional: set a target triple to cross-compile
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)