Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Updating broken and possibly incomplete SWIG Perl module building tutorial on SWIG web site

by hermida (Scribe)
on Mar 26, 2011 at 16:44 UTC ( [id://895666]=note: print w/replies, xml ) Need Help??


in reply to Re: Updating broken and possibly incomplete SWIG Perl module building tutorial on SWIG web site
in thread Updating broken and possibly incomplete SWIG Perl module building tutorial on SWIG web site

I explained that this is for compiling a SWIG auto-generated XS and .pm binding code for specified C code, so it makes no sense to have to go through the additional hassle of creating and using a Makefile.PL when all you need are the gcc compile and gcc link commands that should be used for building a Perl module. ExtUtils::MakeMaker and Module::Build get the same gcc compile and gcc link flags from Perl core Config.pm no? They just put it into a Makefile as constants and during make they through them into the gcc compile and gcc link commands. I am doing the same but just shortcutting the parts I don't need.

The commands I provided produce the same gcc compile and link commands that you see when you install a CPAN module with C/C++ w/ XS code so how can this be wrong? Please check for yourself. The only flags that are excluded are not relevant to a SWIG Perl module build. CPAN modules with C/C++ w/ XS code are compiled like Perl itself was and should be, I don't know here if there is a misunderstanding here.

  • Comment on Re^2: Updating broken and possibly incomplete SWIG Perl module building tutorial on SWIG web site

Replies are listed 'Best First'.
Re^3: Updating broken and possibly incomplete SWIG Perl module building tutorial on SWIG web site
by Corion (Patriarch) on Mar 26, 2011 at 16:54 UTC

    Backticks won't work on Windows, but then, I don't know whether SWIG will work on (non-Cygwin) Windows at all either.

    And not all the world uses gcc.

    Personally, I would go the route of least resistance and change the SWIG "build" process to produce a Makefile through ExtUtils::MakeMaker (see WriteMakefile() in ExtUtils::MakeMaker - this is a tried and true mechanism that will know about the appropriate C compiler to use with This Perl and will also know about the options needed.

      How would you use all the goodies of ExtUtils::MakeMaker without starting with a manually written Makefile.PL? I just think having to write a Makefile.PL might be too much unnecessary hassle for the SWIG Perl build process.

      Or would this Makefile.PL be the same for every SWIG Perl build and I could send it to them for everyone to use with an updated SWIG Perl build process tutorial?

        Well, Makefile.PL is just a Perl program, so you can just incoroporate the relevant parts into your Perl program. Like I already pointed out, WriteMakefile(), which, maybe surprinsing to you, writes a Makefile. I'm not sure what else I can do other than point you to the documentation or to existing Makefile.PLs?

        Of course, the Makefile.PL will likely be similar for all modules, but it very much depends on the Perl configuration it will be used with, which can differ between every machine. Which is why it is usually done in the way of asking Perl to produce the appropriate Makefile. Which is what a Makefile.PL does once it calls WriteMakefile. I presume that including the following lines in your SWIG build process somewhere will produce an appropriate Makefile:

        use ExtUtils::MakeMaker; WriteMakefile( # ... appropriate options );

        As you will be targetting Perl, it's safe to assume that Perl is available for running code.

      You are totally right about doing something more elegant with ExtUtils modules, we talked about it on chatterbox, but as a first go I was updating the quick getting started tutorial on the SWIG web site and wanted the commands to be similar to what they already had, but correct and working this time.

      For Windows the tutorial wasn't covering that so just wanted to update what they already had which was for Unix/Linux

      True not all people use gcc, but this is what they had in the tutorial so stuck with that and I believe they assumed if you don't have gcc you see what is going on and can easily map it to your particular cc and ld program.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://895666]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-19 18:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found