Skip to content
Snippets Groups Projects
Commit a9778107 authored by Simon Marlow's avatar Simon Marlow
Browse files

[project @ 1999-07-14 13:26:48 by simonmar]

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.
parent d4c4c40f
No related branches found
No related tags found
No related merge requests found
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
......
......@@ -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
......
......@@ -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
#
......
......@@ -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 $_;
}
......
......@@ -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
......
......@@ -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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment