Search code examples
ruby-on-railsrubymakefilerake

calling gnu makefiles from ruby script?


calling the command "make" within a directory where a gnu makefile is placed is done easily within a batch script using just the command:

make

Is there a way to execute the command "make" from a ruby script?


Solution

  • If you want to make a make file using ruby

    mkmf.rb is used by ruby C extensions to generate a Makefile which will correctly compile and link the C extension to ruby and a third-party library.

    create_makefile('test/foo', 'test')
    

    That will set the target_prefix in the generated Makefile to “test”. That, in turn, will create the following file tree when installed via the make install command: /path/to/ruby/sitearchdir/test/foo.so

    More on it MKMF

    I you want to execute any commands use Kernel#system

    system("make")