Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: MakeMaker tailoring

by randyk (Parson)
on Jan 24, 2008 at 04:18 UTC ( [id://663934]=note: print w/replies, xml ) Need Help??


in reply to MakeMaker tailoring

Do you have to make and install the EnvProcessDll dll separately? If not, you might take the approach of Math::FFT; in this, there's an XS file (FFT.xs), plus a couple of pure C files (arrays.c and fft4g.c) to supply some needed functions. The associated Makefile.PL:
my %opts = ( 'NAME' => 'Math::FFT', 'VERSION_FROM' => 'FFT.pm', 'OBJECT' => 'FFT.o fft4g.o arrays.o', ); WriteMakefile(%opts);
writes a Makefile to compile and link all the files needed to build the extension.

Replies are listed 'Best First'.
Re^2: MakeMaker tailoring
by cdarke (Prior) on Jan 24, 2008 at 13:30 UTC
    If I understand you correctly, that will compile the files as seperate relocatable objects, and link them with perl.

    The idea of my code is that the DLL is "injected" into another process, which is probably non-perl. This is done by waving a magic wand and sacrificing a goat (but not necessarily in that order). The DLL has to be a discrete executable in order for the alien process to run it.

    Thanks anyway.
      I don't believe that the presence of the XS interface would preclude the use of the dll for injection into other processes. Just provide your normal dll interface for your other code in addition to the XS stuff. So one copy will be loaded with perl and use the XS interface, and when you inject the DLL into other processes, the other processes will use the other interface.

      Note: I'm assuming Windows here (where the above will work). I've not tried it in *NIX, though I don't know of any reason that it wouldn't work there.

      Alternatively, can't you just add your rule to build the other DLL and add it as a dependency to the XS DLL?

      ...roboticus

        OK, I see what you mean, but any idea how I do that using MakeMaker and Makefile.PL? Open the Makefile conventionally and change it long-hand? I was wondering if there was MakeMaker magic to do it.

        Yes, this is Windows. I have no idea how to do this from *NIX, it should be possible though since gdb -p and strace -p can.
      In this case, would something like the following work?
      package main; use strict; use warnings; use ExtUtils::MakeMaker qw( WriteMakefile ); my $parms = { NAME => 'Module::Name', }; WriteMakefile( %$parms ); package MY; sub postamble { return <<'MAKE_FRAG'; new_target: $(PERL) -e "print qq{Hello from new_target\n}" MAKE_FRAG } sub top_targets { my $inherited = shift->SUPER::top_targets(@_); $inherited =~ s/(\npure_all\s+::.+)/$1 new_target/; return $inherited; } 1;
      This adds a new new_target target, which is then carried out at the nmake stage, without having to specify nmake new_target explicitly.
        Excellent! That works! I didn't know about top_target, many thanks.
        randyk:

        Nice ++ you just saved me the trouble of learning MakeMaker for another month or two... ;^)

        ...roboticus

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-03-28 18:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found