X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=glafp-utils%2FmkdependC%2FmkdependC.prl;h=b8f853ab039218ce308145965772f5e518953c65;hb=4e4d6f3b2640d26b123e45fe8ecea53bca890093;hp=2bce81e1a77cc93375d22592373687e7b25c03fe;hpb=ee6b1aececd9396b1404558f673488cbf4145900;p=ghc-hetmet.git diff --git a/glafp-utils/mkdependC/mkdependC.prl b/glafp-utils/mkdependC/mkdependC.prl index 2bce81e1..b8f853a 100644 --- a/glafp-utils/mkdependC/mkdependC.prl +++ b/glafp-utils/mkdependC/mkdependC.prl @@ -1,8 +1,8 @@ # -# This stub of perl assumes that the following two -# variables are prepended: +# This perl script template assumes that definitions for +# the following variables are prepended: # -# DEFAULT_TMPDIR CPP +# DEFAULT_TMPDIR CPP BUILDPLATFORM # # ToDo: strip out all the .h junk # @@ -22,6 +22,12 @@ $Makefile = ''; @Src_files = (); @File_suffix = (); $baseName=''; +$ignore_output='> /dev/null'; + +if ( ${BUILDPLATFORM} eq "i386-unknown-mingw32" ) { + # Assuming the underlying perl uses cmd to exec system() calls. + $ignore_output = ">nul"; +} if ( $ENV{'TMPDIR'} ) { # where to make tmp file names $Tmp_prefix = $ENV{'TMPDIR'} . "/mkdependC$$"; @@ -73,6 +79,9 @@ rename($Makefile,"$Makefile.bak"); # and adding the new open(OMKF,"< $Makefile.bak") || die "$Pgm: can't open $Makefile.bak: $!\n"; open(NMKF,"> $Makefile") || die "$Pgm: can't open $Makefile: $!\n"; +binmode(OMKF); # Do not add stupid ^M's to the output on Win32 +binmode(NMKF); # Do not add stupid ^M's to the output on Win32 + select(NMKF); $_ = ; while ($_ && $_ ne $Begin_magic_str) { # copy through, 'til Begin_magic_str @@ -127,15 +136,8 @@ sub mangle_command_line_args { push(@Src_files, $_); } - } elsif ($Dashdashes_seen == 1) { - if ( /^-package-name$/ ) { - # Skip option argument - shift(@ARGV); - } elsif ( /^-/ ) { - # Ignore unknown option - } else { - push(@Src_files,$_); - } + } elsif ($Dashdashes_seen == 1) { # where we ignore unknown options + push(@Src_files,$_) if ! /^-/; } } } @@ -170,10 +172,16 @@ sub slurp_file { # follows an example in the `open' item in perl man page # ${CPP} better be 'gcc -E', or the -x option will fail... # ..and the -MM & -MMD. - $result = system("${CPP} -MM -MMD $Include_dirs @Defines -x c $fname >/dev/null"); + $result = system("${CPP} -MM -MMD $Include_dirs @Defines -x c $fname $ignore_output"); + if ($result != 0) { - unlink($tempfile); - exit($result); + # On the cheesy side..we do want to know what went wrong, so + # re-run the command. + $result = system("${CPP} -MM -MMD $Include_dirs @Defines -x c $fname "); + if ($result != 0) { + unlink($tempfile); + exit($result); + } }; local($dep_contents)='';