#!/usr/bin/perl -w # ccwrap, wrapper for cc. # # I wrote this because whenever I try to ./configure something on OpenBSD, # it always fails. This is because OpenBSD's gcc doesn't look in # /usr/local/include by default, but OpenBSD's ports tree puts all the headers # in /usr/local/include as if they were going to be found there. Some # projects supply --with-foo=/usr/local or similar options on their configure # scripts, but many do not. Therefore, this program. # # This program accepts three environment variables: # CCWRAP_CC Name of the real compiler. Defaults to 'cc'. # CCWRAP_FLAGS Flags passed to the compiler. # # The CCWRAP_FLAGS are passed before the rest of the command-line arguments. # The full command is printed before it's executed, so you can see what's # happening... but only if stdout is a terminal. (This is because configure # does some funky things e.g. "gcc -print-prog-name=ld" behind the scenes, # and echoing the command can screw it up.) # # This program owes its inspiration to Debian's "pentium-builder" package. $CC = $ENV{CCWRAP_CC}; if (!defined($CC)) { $CC = "cc"; } # # Look for "-c" somewhere in our ARGV. # $compiling = 0; # foreach $arg (@ARGV) { # if ($arg eq "-c") { $compiling = 1; } # } # if ($compiling) { # @args = (); # if (defined($ENV{CCWRAP_CFLAGS})) { # push @args, split /[ \t]/,$ENV{CCWRAP_CFLAGS}; # } # push @args, @ARGV; # print $CC . " " . join " ", @args, "\n" if -t STDOUT; # exec ($CC, @args); # } else { @args = (); if (defined($ENV{CCWRAP_FLAGS})) { push @args, split /[ \t]/,$ENV{CCWRAP_FLAGS}; } push @args, @ARGV; print $CC . " " . join " ", @args, "\n" if -t STDOUT; exec ($CC, @args); # }