Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Adding a compile rule to mkmf.rb

Reply
Thread Tools

Adding a compile rule to mkmf.rb

 
 
Gerardo Santana Gómez Garrido
Guest
Posts: n/a
 
      03-08-2006
I want to write an extconf.rb file for a Ruby extension. The problem
is that my source file has a suffix that is not any of the expected by
mkmf.rb: ec. The suffixes expected are:

SRC_EXT =3D ["c", "cc", "m", "cxx", "cpp", "C"]

I could add the suffix:

SRC_EXT << "ec"

and even define my own COMPILE_EC rule:

COMPILE_EC =3D '$(ESQL) $(CFLAGS) -c $<'

but how can I extend create_makefile to use this rule, without
modifying mkmf.rb?

--
Gerardo Santana
"Between individuals, as between nations, respect for the rights of
others is peace" - Don Benito Ju=E1rez
http://santanatechnotes.blogspot.com/


 
Reply With Quote
 
 
 
 
Logan Capaldo
Guest
Posts: n/a
 
      03-08-2006

On Mar 7, 2006, at 10:04 PM, Gerardo Santana G=F3mez Garrido wrote:

> I want to write an extconf.rb file for a Ruby extension. The problem
> is that my source file has a suffix that is not any of the expected by
> mkmf.rb: ec. The suffixes expected are:
>
> SRC_EXT =3D ["c", "cc", "m", "cxx", "cpp", "C"]
>
> I could add the suffix:
>
> SRC_EXT << "ec"
>
> and even define my own COMPILE_EC rule:
>
> COMPILE_EC =3D '$(ESQL) $(CFLAGS) -c $<'
>
> but how can I extend create_makefile to use this rule, without
> modifying mkmf.rb?
>
> --
> Gerardo Santana
> "Between individuals, as between nations, respect for the rights of
> others is peace" - Don Benito Ju=E1rez
> http://santanatechnotes.blogspot.com/
>


I don't think you can . I just looked at mkmf, and it looks like =20
the only way to make an extension for ruby as far as mkmf is =20
concerned with C or C++. mkmf doesn't really look for anything =20
dynamically, those constants seem to be more to save typing than =20
anything else. It's too bad, it would be neat if mkmf was =20
extendable in this manner.



 
Reply With Quote
 
 
 
 
rickhg12hs
Guest
Posts: n/a
 
      03-08-2006
Don't know how you could extend mkmf.rb as you describe, but you could
take the approach that SWIG offers. In the installation of SWIG,
you'll find Makefile.swig and extconf.rb skeletons (in
/usr/share/swig/1.3.25/ruby/ for my installation).

Makefile.swig has rules for creating the SWIG wrapper (generates a C or
C++ source file wrapper using swig) and also for creating the Makefile
(using ruby,mkmf.rb, and your extconf.rb). Your extconf.rb will
typically check for your library, etc., so that it will be linked into
your extension.

[from Makefile.swig]
# File : Makefile.swig
# Makefile for a SWIG module. Use this file if you are
# producing a Ruby extension for general use or distribution.
#
# 1. Prepare extconf.rb.
# 2. Modify this file as appropriate.
# 3. Type 'make -f Makefile.swig' to generate wrapper code and
Makefile.
# 4. Type 'make' to build your extension.
# 5. Type 'make install' to install your extension.

Perhaps you could create an appropriate Makefile.whatever and an
extconf.rb that will create your extension.

Good luck!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
compile directive for conditional compile for Java 1.4 versus Java 5 timjowers Java 7 02-02-2011 12:08 AM
computation at compile time i.e. compile time functions usingtemplates Carter C++ 2 03-04-2009 06:43 PM
Compile versus not compile (VS 2005)?? stupid48@gmail.com ASP .Net 1 04-11-2008 08:24 PM
cant compile on linux system.cant compile on cant compile onlinux system. Nagaraj C++ 1 03-01-2007 11:18 AM
how to add validation rule for url in the validation-rule.xml ,I added some thing like this but......... shailajabtech@gmail.com Java 0 10-12-2006 08:36 AM



Advertisments