diff --git a/aclocal.m4 b/aclocal.m4 index c79cef4c414e134ceb112c3030499ad43c7fbc46..9ae64495b7ece6f88019a023ff7ee6c4c79e6505 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,4 +1,4 @@ -dnl $Id: aclocal.m4,v 1.42 1999/06/07 10:12:52 simonmar Exp $ +dnl $Id: aclocal.m4,v 1.43 1999/07/14 13:26:48 simonmar Exp $ dnl dnl Extra autoconf macros for the Glasgow fptools dnl @@ -303,36 +303,6 @@ HaveGcc=`echo $fptools_cv_have_gcc | sed 'y/yesno/YESNO/'` AC_SUBST(HaveGcc) ]) -dnl -dnl FPTOOLS_PROG_GNUCPP gathers the path to the cpp that the -dnl gcc driver calls upon. -dnl -dnl Substitutes: GNUCPP and RAWCPP (latter is 'GNUCPP -traditional') -dnl -AC_DEFUN(FPTOOLS_PROG_GNUCPP, -[AC_CACHE_CHECK([how to invoke GNU cpp directly], fptools_cv_gnu_cpp, -[if test "$HaveGcc" = "YES"; then - echo > conftest.c - $CC -v -E conftest.c >/dev/null 2>conftest.out - # \x5c = backslash - echo 'tr/\x5c/\//; /(\S+\/)cpp/ && print "[$]{1}cpp -iprefix [$]1";' > conftest.pl - fptools_cv_gnu_cpp="`eval $PerlCmd -n conftest.pl conftest.out`" - rm -fr conftest* - else - # We need to be able to invoke CPP directly, preferably - # with input from stdin (mkdependHS and hscpp depend on - # this at the moment). - # Take a guess at what to use, this probably won't work. - echo Warning: GNU cpp not found, using $CPP - fptools_cv_gnu_cpp = $CPP - fi -]) -GNUCPP=$fptools_cv_gnu_cpp -RAWCPP="$GNUCPP -traditional" -AC_SUBST(GNUCPP) -AC_SUBST(RAWCPP) -]) - dnl Small feature test for perl version. Assumes PerlCmd dnl contains path to perl binary dnl diff --git a/configure.in b/configure.in index 71730250582f68f74793ef25b8e264c097681206..e9a6e18ef6bdf824d73f7a448d4b92b0bce8a258 100644 --- a/configure.in +++ b/configure.in @@ -402,7 +402,6 @@ FPTOOLS_HAVE_GCC dnl ** figure out how to invoke cpp directly (gcc -E is no good) AC_PROG_CPP -FPTOOLS_PROG_GNUCPP dnl ** figure out how to do context diffs FPTOOLS_PROG_DIFF diff --git a/ghc/utils/hscpp/Makefile b/ghc/utils/hscpp/Makefile index e4af0ed35d3727c6b2f02833ffe511f44706d2e0..d9191865a7c58694539167b57c630380610e1e7b 100644 --- a/ghc/utils/hscpp/Makefile +++ b/ghc/utils/hscpp/Makefile @@ -3,17 +3,11 @@ include $(TOP)/mk/boilerplate.mk SCRIPT_PROG=hscpp SCRIPT_OBJS=hscpp.prl -SCRIPT_SUBST_VARS= - -ifneq "$(BIN_DIST)" "1" -SCRIPT_SUBST_VARS += RAWCPP -endif +SCRIPT_SUBST_VARS= RAWCPP # Note: might be overridden from cmd-line (see install rule below) INSTALLING=0 -# no INTERP: do *not* want #! script stuck on the front -# what's the deal? I'll add it for now -- SOF INTERP=perl # diff --git a/ghc/utils/hscpp/hscpp.prl b/ghc/utils/hscpp/hscpp.prl index 12d4038126ad2572ceb2035f74f90df15eb3d687..8d753e5553d68c5dfdf36b2dce8b32d155ea0ab9 100644 --- a/ghc/utils/hscpp/hscpp.prl +++ b/ghc/utils/hscpp/hscpp.prl @@ -10,46 +10,36 @@ # $Verbose = 0; +$file = ''; +@args = (); -while ( $#ARGV >= 0 && $ARGV[0] eq '-v' ) { - if ($ARGV[0] eq '-v') { - $Verbose = 1; - } else { - die "hscpp: unrecognised argument: $$ARGV[0]\n"; - } - shift(@ARGV); -} -#ToDo: print a version number ? - -$OrigCpp = ${RAWCPP}; - -if ( $OrigCpp =~ /(\S+)\s+(.*)/ ) { - $cmd = $1; - $rest = $2; - if ( -x $cmd ) { # cool - $Cpp = $OrigCpp; - } else { # oops; try to guess - $GccV = `gcc -v 2>&1`; - if ( $GccV =~ /Reading specs from (.*)\/specs/ ) { - $Cpp = "$1/cpp $rest"; +$Cpp = ${RAWCPP}; + +foreach (@ARGV) { + /^-v$/ && do { $Verbose = 1; next; }; + + /^[^-]/ && do { + if ($file ne '') { + die "usage: hscpp [arg...] file"; } else { - die "hscpp: don't know how to run cpp: $OrigCpp\n"; - } - } -} else { - $Cpp = $OrigCpp; -} + $file = $_; + }; + next; + }; -print STDERR "hscpp:CPP invoked: $Cpp @ARGV\n" if $Verbose; + push @args, $_; +} -open(INPIPE, "$Cpp @ARGV |") || die "Can't open C pre-processor pipe\n"; +print STDERR "hscpp:CPP invoked: $Cpp @args - <$file\n" if $Verbose; +open(INPIPE, "$Cpp @args - <$file |") + || die "Can't open C pre-processor pipe\n"; while (<INPIPE>) { # line directives come in flavo[u]rs: # s/^#\s*line\s+\d+$/\{\-# LINE \-\}/; IGNORE THIS ONE FOR NOW - s/^#\s*line\s+(\d+)\s+(\".+\")$/\{\-# LINE \1 \2 \-\}/; - s/^#\s*(\d+)\s+(\".*\").*/\{\-# LINE \1 \2 \-\}/; + s/^#\s*line\s+(\d+)\s+(\".+\")$/\{\-# LINE \1 \"$file\" \-\}/; + s/^#\s*(\d+)\s+(\".*\").*/\{\-# LINE \1 \"$file\" \-\}/; print $_; } diff --git a/ghc/utils/mkdependHS/Makefile b/ghc/utils/mkdependHS/Makefile index 61042ccc56f68a6d50f7a68de44962ac3b8c33cf..6f8fe79c051aeb7f926222a4e4ac734632e3149e 100644 --- a/ghc/utils/mkdependHS/Makefile +++ b/ghc/utils/mkdependHS/Makefile @@ -10,6 +10,7 @@ SCRIPT_OBJS=mkdependHS.prl SCRIPT_SUBST_VARS= \ TOP_PWD \ INSTALLING \ + RAWCPP \ HscIfaceFileVersion INTERP=perl @@ -20,7 +21,7 @@ INTERP=perl INSTALL_LIB_SCRIPTS += $(SCRIPT_PROG) ifneq "$(BIN_DIST)" "1" -SCRIPT_SUBST_VARS += libdir datadir RAWCPP TMPDIR SED +SCRIPT_SUBST_VARS += libdir datadir TMPDIR SED endif diff --git a/ghc/utils/mkdependHS/mkdependHS.prl b/ghc/utils/mkdependHS/mkdependHS.prl index cb3769559250eaf064d57e4c3c296c4759d2c0df..3cd94bdbffbec0674f6bebeffccf59e3a3c07a8b 100644 --- a/ghc/utils/mkdependHS/mkdependHS.prl +++ b/ghc/utils/mkdependHS/mkdependHS.prl @@ -390,7 +390,7 @@ sub slurp_file_for_imports { local ($open_cmd); if ($Cpp_flag_set) { # $open_cmd = "${SED} -e '/^# *include/{p;s/^# *include/!include/;};s/'\\''//g;s/\"//g' $file_to_read | $Cpp $Include_dirs -I$last_seen_dir @Defines |"; - &run_something("${SED} -e '/^# *include/{p;s/^# *include/!include/;};s/'\\''//g;s/\"//g' $file_to_read | $Cpp $Include_dirs -I$last_seen_dir @Defines 2>&1 > ${file_to_read}.i", $orig_src_file, 'cpp'); + &run_something("${SED} -e '/^# *include/{p;s/^# *include/!include/;};s/'\\''//g;s/\"//g' $file_to_read | $Cpp $Include_dirs -I$last_seen_dir @Defines - 2>&1 > ${file_to_read}.i", $orig_src_file, 'cpp'); $read_from_file="${file_to_read}.i"; $cleanup=1; } else {