Makefile: re-sign libjerboa_native.dylib on macOS in `make native`

ober

1e391766dce7a9ef244cecde1a7bfb4f83091531

diff --git a/Makefile b/Makefile
index a39bf7c..15d68eb 100644
--- a/Makefile
+++ b/Makefile
@@ -371,6 +371,13 @@ $(RUST_NATIVE_LIB): $(RUST_NATIVE_DIR)/src/*.rs $(RUST_NATIVE_DIR)/Cargo.toml
 
 native: $(RUST_NATIVE_LIB)
 	cp $(RUST_NATIVE_LIB) lib/
+ifeq ($(UNAME_S),Darwin)
+	@# Re-sign ad-hoc so dyld accepts the freshly-copied dylib.
+	@# Without this, Cargo's linker-signed signature can be left in an
+	@# inconsistent state (Invalid Page on dlopen → SIGKILL).
+	codesign --remove-signature lib/libjerboa_native.$(NATIVE_LIB_EXT) 2>/dev/null || true
+	codesign --sign - lib/libjerboa_native.$(NATIVE_LIB_EXT)
+endif
 
 clean-native:
 	cd $(RUST_NATIVE_DIR) && cargo clean