AUTOMAKE_OPTIONS =

RUST_SRC = \
	src/ffi.rs \
	src/lib.rs

RUST_EXTRA = Cargo.toml

src/ffi.rs: ../wrlib/wraster.h patch_ffi.sed Makefile
	$(BINDGEN) ../wrlib/wraster.h \
		--no-recursive-allowlist \
		--allowlist-type "Bool" \
		--allowlist-type "R(Context|ContextAttributes|Image|RenderingMode|ScalingFilter|StdColormapMode|ImageFormat|Color)" \
		--allowlist-function "RGetClosestXColor" \
		--allowlist-function "RLoadImage|RReleaseImage" \
		-o src/ffi.rs \
		-- \
		-I../../wrlib \
		&& sed -i -r -f patch_ffi.sed src/ffi.rs

target/debug/wrlib_rs.a: $(RUST_SRC) $(RUST_EXTRA)
	$(CARGO) build

check-local:
	$(CARGO) test

clean-local:
	$(CARGO) clean
	rm -f src/ffi.rs

all: target/debug/wrlib_rs.a
