Skip to content

Commit ec9481d

Browse files
committed
Support nmake
1 parent 50f98ec commit ec9481d

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

Rakefile

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,26 @@ def run_extconf(build_dir, extension_dir, *arguments)
1313
end
1414
end
1515

16+
def make_command
17+
if RUBY_PLATFORM =~ /mswin/
18+
"nmake"
19+
else
20+
ENV["MAKE"] || find_make
21+
end
22+
end
23+
24+
def find_make
25+
candidates = ["gmake", "make"]
26+
paths = ENV.fetch("PATH", "").split(File::PATH_SEPARATOR)
27+
exeext = RbConfig::CONFIG["EXEEXT"]
28+
candidates.each do |candidate|
29+
paths.each do |path|
30+
cmd = File.join(path, "#{candidate}#{exeext}")
31+
return cmd if File.executable?(cmd)
32+
end
33+
end
34+
end
35+
1636
Dir[File.expand_path('../tasks/**/*.rake', __FILE__)].each {|f| load f }
1737

1838
spec.extensions.each do |extension|
@@ -39,13 +59,13 @@ spec.extensions.each do |extension|
3959
desc "Compile"
4060
task compile: makefile do
4161
cd(build_dir) do
42-
sh("make")
62+
sh(make_command)
4363
end
4464
end
4565

4666
task :clean do
4767
cd(build_dir) do
48-
sh("make", "clean") if File.exist?("Makefile")
68+
sh(make_command, "clean") if File.exist?("Makefile")
4969
end
5070
end
5171
end

0 commit comments

Comments
 (0)