[project @ 1999-07-14 13:26:48 by simonmar]
authorsimonmar <unknown>
Wed, 14 Jul 1999 13:26:52 +0000 (13:26 +0000)
committersimonmar <unknown>
Wed, 14 Jul 1999 13:26:52 +0000 (13:26 +0000)
Don't attempt to discover the exact location of cpp, instead use 'gcc
-E'.  With the right combination of flags, it seems we can get the
same behaviour as calling cpp directly.

aclocal.m4
configure.in
ghc/utils/hscpp/Makefile
ghc/utils/hscpp/hscpp.prl
ghc/utils/mkdependHS/Makefile
ghc/utils/mkdependHS/mkdependHS.prl

index c79cef4..9ae6449 100644 (file)
@@ -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
index 7173025..e9a6e18 100644 (file)
@@ -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
index e4af0ed..d919186 100644 (file)
@@ -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
 
 #
index 12d4038..8d753e5 100644 (file)
 #
 
 $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 $_;
 }
index 61042cc..6f8fe79 100644 (file)
@@ -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
 
 
index cb37695..3cd94bd 100644 (file)
@@ -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 {