savvy-bindgen 0.10.0

Parse Rust functions, and generate C and R code
Documentation
TARGET = @TARGET@

PROFILE = @PROFILE@
FEATURE_FLAGS = @FEATURE_FLAGS@

# Add flags if necessary
RUSTFLAGS = 

TARGET_DIR = $(CURDIR)/rust/target
LIBDIR = $(TARGET_DIR)/$(TARGET)/$(subst dev,debug,$(PROFILE))
STATLIB = $(LIBDIR)/lib{}.a
PKG_LIBS = -L$(LIBDIR) -l{}

CARGO_BUILD_ARGS = --lib --profile $(PROFILE) $(FEATURE_FLAGS) --manifest-path=./rust/Cargo.toml --target-dir $(TARGET_DIR)

all: $(SHLIB) clean_intermediate

$(SHLIB): $(STATLIB)

$(STATLIB):
	# In some environments, ~/.cargo/bin might not be included in PATH, so we need
	# to set it here to ensure cargo can be invoked. It is appended to PATH and
	# therefore is only used if cargo is absent from the user's PATH.
	export PATH="$(PATH):$(HOME)/.cargo/bin" && \
	  export CC="$(CC)" && \
	  export CFLAGS="$(CFLAGS)" && \
	  export RUSTFLAGS="$(RUSTFLAGS)" && \
	  if [ "$(TARGET)" != "wasm32-unknown-emscripten" ]; then \
	    cargo build $(CARGO_BUILD_ARGS); \
	  else \
	    export CARGO_PROFILE_DEV_PANIC="abort" && \
	    export CARGO_PROFILE_RELEASE_PANIC="abort" && \
	    export RUSTFLAGS="$(RUSTFLAGS) -Zdefault-visibility=hidden" && \
	    cargo +nightly build $(CARGO_BUILD_ARGS) --target $(TARGET) -Zbuild-std=panic_abort,std; \
	  fi

clean_intermediate: $(SHLIB)
	rm -f $(STATLIB)

clean:
	rm -Rf $(SHLIB) $(OBJECTS) $(STATLIB) ./rust/target

.PHONY: all clean_intermediate clean