-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
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
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
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
#
#
$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 $_;
}
SCRIPT_SUBST_VARS= \
TOP_PWD \
INSTALLING \
+ RAWCPP \
HscIfaceFileVersion
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
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 {