summaryrefslogtreecommitdiff
path: root/mpn/cpp-ccas
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2001-10-05 03:37:55 +0200
committerKevin Ryde <user42@zip.com.au>2001-10-05 03:37:55 +0200
commitff90105ae06dae6bfd1836b3117bca803c471d07 (patch)
tree02fc8d7a486cd04c9de0f0ede569d148441e9739 /mpn/cpp-ccas
parent93c12cd2b3d41ea3cc5cd6592f5b23160a424e4a (diff)
downloadgmp-ff90105ae06dae6bfd1836b3117bca803c471d07.tar.gz
* mpn/cpp-ccas: New file.
Diffstat (limited to 'mpn/cpp-ccas')
-rwxr-xr-xmpn/cpp-ccas104
1 files changed, 104 insertions, 0 deletions
diff --git a/mpn/cpp-ccas b/mpn/cpp-ccas
new file mode 100755
index 000000000..3baea0e15
--- /dev/null
+++ b/mpn/cpp-ccas
@@ -0,0 +1,104 @@
+#!/bin/sh
+#
+# A helper script for Makeasm.am .S.lo rule.
+
+# Copyright 2001 Free Software Foundation, Inc.
+#
+# This file is part of the GNU MP Library.
+#
+# The GNU MP Library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or (at your
+# option) any later version.
+#
+# The GNU MP Library is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+# License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA.
+
+
+# Usage: cpp-cc --cpp=CPP CC ... file.S ...
+#
+# Process file.S with the given CPP command, then assemble with the
+# given CC plus all arguments.
+#
+# The CPP command must be in a single --cpp= argument, and will be
+# split on whitespace. It should include any -D or -I options
+# required.
+#
+# When CC is invoked, file.S is replaced with a temporary .s file
+# which is the CPP output.
+#
+# Any lines starting with "#" are removed from the CPP output, usually
+# these will be #line and #file markers from CPP, but they might also
+# be comments from the .S.
+#
+# To allow parallel builds, the temp file name is based on the .S file
+# name, which will be the output object filename for all uses we put
+# this script to.
+
+CPP=
+CC=
+S=
+SEEN_O=no
+
+for i in "$@"; do
+ case $i in
+ --cpp=*)
+ CPP=`echo "$i" | sed 's/^--cpp=//'`
+ ;;
+ *.S)
+ if test -n "$S"; then
+ echo "Only one .S file permitted"
+ exit 1
+ fi
+ BASENAME=`echo "$i" | sed -e 's/\.S$//' -e 's/^.*[\\/:]//'`
+ S=$i
+ TMP_I=tmp-$BASENAME.i
+ TMP_S=tmp-$BASENAME.s
+ CC="$CC $TMP_S"
+ ;;
+ -o)
+ SEEN_O=yes
+ CC="$CC $i"
+ ;;
+ *)
+ CC="$CC $i"
+ ;;
+ esac
+done
+
+if test -z "$CPP"; then
+ echo "No --cpp specified"
+ exit 1
+fi
+
+if test -z "$S"; then
+ echo "No .S specified"
+ exit 1
+fi
+
+# Libtool adds it's own -o when sending output to .libs/foo.o, but not
+# when just wanting foo.o in the current directory. We need an
+# explicit -o in both cases since we're assembling tmp-foo.s.
+#
+if test $SEEN_O = no; then
+ CC="$CC -o $BASENAME.o"
+fi
+
+echo "$CPP $S >$TMP_I"
+$CPP $S >$TMP_I || exit
+
+echo "grep -v '^#' $TMP_I >$TMP_S"
+grep -v '^#' $TMP_I >$TMP_S
+
+echo "$CC"
+$CC || exit
+
+# Comment this out to preserve .s intermediates
+rm -f $TMP