Commit d0783928c423874d4eb6fb60031009826fd4f8a0

Thomas de Grivel 2023-03-06T17:01:27

libffi

diff --git a/lib/rbpkg/repo.rb b/lib/rbpkg/repo.rb
index 8e64a3b..1831b37 100644
--- a/lib/rbpkg/repo.rb
+++ b/lib/rbpkg/repo.rb
@@ -23,7 +23,7 @@ class Rbpkg::Repo
     if ! tag_present?("build-done")
       configure()
       if File.file?("#{src_dir}/Makefile")
-        cmd! "cd #{sh_quote(src_dir)} && make -j #{Rbpkg.ncpu}"
+        cmd! "cd #{sh_quote(src_dir)} && #{make} -j #{Rbpkg.ncpu}"
       elsif File.file?("#{src_dir}/CMakeLists.txt")
         cmd! "cmake -j #{Rbpkg.ncpu} --build #{sh_quote(obj_dir)}"
       end
@@ -84,7 +84,7 @@ class Rbpkg::Repo
   def clean_build
     verbose 3, "repo(#{name.inspect}).clean_build"
     if File.file?("#{src_dir}/Makefile")
-      cmd! "cd #{sh_quote(src_dir)} && make clean"
+      cmd! "cd #{sh_quote(src_dir)} && #{make} clean"
     end
     if File.directory?(obj_dir)
       cmd! "rm -rf #{sh_quote(obj_dir)}"
@@ -144,7 +144,7 @@ class Rbpkg::Repo
     if ! tag_present?("configure-done")
       autogen()
       r = if File.executable?("#{src_dir}/configure")
-            cmd! "cd #{sh_quote(src_dir)} && ./configure --prefix #{sh_quote(Rbpkg.prefix)}"
+            cmd! "cd #{sh_quote(src_dir)} && #{configure_env} ./configure --prefix #{sh_quote(Rbpkg.prefix)}"
           elsif File.exists?("#{src_dir}/configure.sh")
             cmd! "cd #{sh_quote(src_dir)} && sh configure.sh --prefix #{sh_quote(Rbpkg.prefix)}"
           elsif File.exists?("#{src_dir}/CMakeLists.txt")
@@ -155,6 +155,10 @@ class Rbpkg::Repo
     end
   end
 
+  def configure_env
+    ""
+  end
+
   def self.dependencies
     nil
   end
@@ -175,7 +179,7 @@ class Rbpkg::Repo
     end
     cmd! "mkdir -p #{sh_quote(fake_dir)}"
     if File.file?("#{src_dir}/Makefile")
-      cmd! "cd #{sh_quote(src_dir)} && make prefix=#{sh_quote(fake_dir)} install"
+      cmd! "cd #{sh_quote(src_dir)} && #{make} prefix=#{sh_quote(fake_dir)} install"
     elsif File.file?("#{src_dir}/CMakeLists.txt")
       cmd! "cmake --install #{sh_quote(obj_dir)} --prefix #{sh_quote(fake_dir)}"
     end
@@ -236,6 +240,8 @@ class Rbpkg::Repo
  src_parent_dir: #{src_parent_dir.inspect},
  head: #{head.inspect},
  hash: #{hash.inspect},
+ configure_env: #{configure_env.inspect},
+ make: #{make.inspect},
  version:           #{version.inspect},
  installed_version: #{installed_version.inspect},
  dependencies: #{dependencies.inspect},
@@ -297,6 +303,10 @@ class Rbpkg::Repo
     end
   end
 
+  def make
+    "make"
+  end
+
   def name
     self.class.repo_name
   end
diff --git a/lib/rbpkg/repos/libffi.rb b/lib/rbpkg/repos/libffi.rb
index dfa14a1..a1013c4 100644
--- a/lib/rbpkg/repos/libffi.rb
+++ b/lib/rbpkg/repos/libffi.rb
@@ -1,11 +1,17 @@
 class Rbpkg::Repos::Libffi < Rbpkg::Repo
 
-  def_name("libffi")
+  def self.repo_name
+    "libffi"
+  end
 
   def self.dependencies
     []
   end
 
+  def configure_env
+    "MAKE=gmake"
+  end
+
   def dir
     "libffi/libffi"
   end
@@ -13,4 +19,10 @@ class Rbpkg::Repos::Libffi < Rbpkg::Repo
   def git_url
     "https://git.kmx.io/c3-lang/libffi.git"
   end
+
+  def make
+    "gmake"
+  end
+
+  repo_register
 end