Use MacPorts libffi and libxml2.
--- pre-config.rb.orig	2014-07-18 09:41:23.000000000 -0500
+++ pre-config.rb	2021-08-02 00:58:35.000000000 -0500
@@ -51,9 +51,9 @@
   File.exist?(File.join(sdkroot, path))
 end
 
-if lib_exist?('/usr/include/libxml2') and lib_exist?('/usr/lib/libxml2.dylib')
+if File.exist?('@PREFIX@/include/libxml2') and File.exist?('@PREFIX@/lib/libxml2.dylib')
   cflags << ' -DHAS_LIBXML2 '
-  other_header_search_paths << '/usr/include/libxml2'
+  other_header_search_paths << '@PREFIX@/include/libxml2'
   ldflags << ' -lxml2 '
 else
   raise "ERROR: libxml2 not found!"
@@ -62,15 +62,11 @@
 raise 'ERROR: ruby must be built as a shared library' if RbConfig::CONFIG["ENABLE_SHARED"] != 'yes'
 
 # Add the libffi library to the build process.
-if !lib_exist?('/usr/lib/libffi.a') and !lib_exist?('/usr/lib/libffi.dylib')
-  if lib_exist?('/usr/local/lib/libffi.a') and lib_exist?('/usr/local/include/ffi')
-    cflags << ' -I/usr/local/include/ffi '
-    ldflags << ' -L/usr/local/lib '
-  else
-    raise "ERROR: libffi not found!"
-  end
+if File.exist?('@PREFIX@/lib/libffi.dylib') and File.exist?('@PREFIX@/include/ffi.h')
+  cflags << ' -I@PREFIX@/include '
+  ldflags << ' -L@PREFIX@/lib '
 else
-  other_header_search_paths << '/usr/include/ffi'
+  raise "ERROR: libffi not found!"
 end
 cflags << ' -DMACOSX '
 ldflags << ' -lffi '
