require 'rake' require 'rake/clean' require 'rake/tasklib' require 'leaves/core_ext/string' require 'leaves/rake_ext/tasklib' require 'leaves/version' module Rake module Leaves class MakeTask < TaskLib attr_accessor :makefile attr_accessor :version attr_accessor :disable_shared attr_accessor :c_flags attr_accessor :do_not_configure def initialize(name = nil) @name = name yield self if block_given? define end def define desc "Build using GNU toolchain." task upaste("build", @name) => [upaste("compile", @name)] task upaste("compile", @name) do cmd = "make" cmd << " -f #{@makefile}" if @makefile sh cmd end task upaste("compile", @name) => [:dot_configure] unless @do_not_configure # autoreconf is used to generate configuration files. As a result of its # execution, a configure script will be generated. If the configure # script already exists, there is no reason to execute the command. unless @do_not_configure file_create "configure" do sh "autoreconf -i" end task :autoreconf => ["configure"] end # A configuration script is used during the system detection and makefile # generation phases. As a result of its execution, a makefile will be # generated, which can be used to build the program. If a makefile # already exists, there is no reason to execute the configure script. # # NOTE: The task is named "dot_configure" to avoid a conflict with the # file creation task that must be named "configure" unless @do_not_configure file_create "Makefile" do cmd = "" cmd << "CFLAGS=\"#{@c_flags}\" " if @c_flags cmd << "./configure" cmd << " --with-version=\"#{@version}\"" if @version cmd << " --disable-shared" if @disable_shared sh cmd end task :dot_configure => [:autoreconf, "Makefile"] end task :clean do sh "make clean" end task :clobber do sh "make distclean" end self end end end end