Professional Web Applications Themes

[OT] Compiler and OS considerations - PERL Modules

Hi, Say I want to determine (in a Makefile.PL) whether there's a functional $Config{cc} compiler on the machine that's attempting to build the module. I can do this by including a simple C file (let's call it 'simple.c') in the source distro and have my Makefile.PL do: ----------------------------------------------- use Config; my ($have_compiler, $null); if($^O =~ /mswin32/i) { $null = 'NUL'} else {$null = '/dev/null'} my $cmd = "-o simple.exe simple.c >$null 2>&1"; if(system("$Config{cc} $cmd") == 0) { $have_compiler = 1; } else {die "No compiler"} ----------------------------------------------- The redirections and the '$null' stuff is there (obviously) just to hide the output ...

  1. #1

    Default [OT] Compiler and OS considerations

    Hi,

    Say I want to determine (in a Makefile.PL) whether there's a functional
    $Config{cc} compiler on the machine that's attempting to build the module.

    I can do this by including a simple C file (let's call it 'simple.c') in
    the source distro and have my Makefile.PL do:

    -----------------------------------------------
    use Config;
    my ($have_compiler, $null);
    if($^O =~ /mswin32/i) { $null = 'NUL'}
    else {$null = '/dev/null'}
    my $cmd = "-o simple.exe simple.c >$null 2>&1";
    if(system("$Config{cc} $cmd") == 0) {
    $have_compiler = 1;
    }
    else {die "No compiler"}
    -----------------------------------------------

    The redirections and the '$null' stuff is there (obviously) just to hide
    the output of the system command.

    'simple.c' looks like:

    #include <stdio.h>
    int main(void) {
    printf("DONE\n");
    return 0;
    }

    Are there any bugs so far ?
    Obviously if there's a non-MSWindows OS that doesn't have a '/dev/null'
    or a shell that doesn't understand '2>&1' then we've already hit one
    bug. (Is there such a non-Windows OS ?)

    The Windows 9x 'command.com' shell doesn't understand '2>&1' iirc. I've
    yet to decide how/if that should be dealt with ... anyway, I'm already
    aware of *that* caveat.

    And if there's some compiler/OS combo that doesn't understand the syntax
    of $cmd, then that's another bug. (Is there such a compiler/OS combo ?)

    And let's say I want to go further and have my Makefile.PL collect the
    output of running 'simple.exe'. Then the Makefile.PL would continue with:

    -------------------------------------------
    my $out;
    if($^O =~ /mswin32/i) {$out = `simple.exe`}
    else { $out = `./simple.exe`}
    unless($out =~ /DONE/) {die "Wrong output"}
    -------------------------------------------

    Any bugs there ?
    There is if there exists a non-Windows OS where './simple.exe' is not
    valid command line syntax. (Is there such an OS ?)

    Is there a resource that I can readily check to find the answers to
    those questions ? 'Google' comes to mind ... though I'm not so sure that
    it will provide the answers *readily* ... which is the reason that I
    haven't yet tried it.

    Thanks for any answers/pointers/constructive abuse/etc, on this.

    I think I've got it pretty right for Linux and Windows (apart from that
    9x issue) - but then there's the BSD, HP-UX, MacOS and VMS variants (to
    name a few) about which I know absolutely nothing.

    Cheers,
    Rob

    --
    To reply by email u have to take out the u in kalinaubears.

    Sisyphus Guest

  2. #2

    Default Re: [OT] Compiler and OS considerations

    Hi Rob!

    Now these are nice questions. ;-)

    S>my $cmd = "-o simple.exe simple.c >$null 2>&1";

    There might be another problem here, not every C compiler understands
    the -o (notably Microsoft's).

    The last time I worked on a VMS machine is 13 years ago but I think
    you couldn't redirect output like that.

    To support you with results from another exotic platform I'll try your
    tests on a BS2000 next week.

    Regards, Thomas
    --
    To reply by email u have to take out the u in kalinaubears.

    td@umbra.opacus Guest

  3. #3

    Default Re: [OT] Compiler and OS considerations

    [email]tdumbra.opac[/email]us wrote:
    > Hi Rob!
    >
    > Now these are nice questions. ;-)
    >
    > S>my $cmd = "-o simple.exe simple.c >$null 2>&1";
    >
    > There might be another problem here, not every C compiler understands
    > the -o (notably Microsoft's).
    >
    Microsoft compilers understand the '-o' in *that* situation and permit
    you to control the name of the executable in that way. At least that's
    the way it is with my MSVC++6.0 and MSVC++7. It is behaviour that's
    undoented, afaict, and I know that you *can't* use '-o' to control
    the name of object files with Microsoft's compilers.
    > The last time I worked on a VMS machine is 13 years ago but I think
    > you couldn't redirect output like that.
    >
    Ok - I'll check on that one.
    > To support you with results from another exotic platform I'll try your
    > tests on a BS2000 next week.
    >
    Thanks Thomas.

    Cheers,
    Rob

    --
    To reply by email u have to take out the u in kalinaubears.

    Sisyphus Guest

Similar Threads

  1. Contribute Considerations.......
    By rubbish in forum Macromedia Contribute General Discussion
    Replies: 2
    Last Post: July 6th, 08:43 PM
  2. Considerations on Connecting to MS SQL Server from PHP/Linux
    By Google Mike in forum PHP Development
    Replies: 0
    Last Post: December 7th, 02:20 PM
  3. Deployment considerations for web services
    By Mark Norgate in forum ASP.NET Web Services
    Replies: 1
    Last Post: September 10th, 06:25 PM
  4. 64bit - 32 bit AIX 5.1 considerations
    By Tim Bruijnzeels in forum AIX
    Replies: 5
    Last Post: August 7th, 05:17 PM
  5. Replies: 0
    Last Post: July 21st, 10:49 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139