beta-0.89.2
[luatex.git] / source / libs / gmp / gmp-src / mpn / cpp-ccas
blob25f7cdcbebd03562066e84b936fc891ce016fb04
1 #!/bin/sh
3 # A helper script for Makeasm.am .S.lo rule.
5 # Copyright 2001 Free Software Foundation, Inc.
7 # This file is part of the GNU MP Library.
9 # The GNU MP Library is free software; you can redistribute it and/or modify
10 # it under the terms of either:
12 # * the GNU Lesser General Public License as published by the Free
13 # Software Foundation; either version 3 of the License, or (at your
14 # option) any later version.
16 # or
18 # * the GNU General Public License as published by the Free Software
19 # Foundation; either version 2 of the License, or (at your option) any
20 # later version.
22 # or both in parallel, as here.
24 # The GNU MP Library is distributed in the hope that it will be useful, but
25 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
26 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 # for more details.
29 # You should have received copies of the GNU General Public License and the
30 # GNU Lesser General Public License along with the GNU MP Library. If not,
31 # see https://www.gnu.org/licenses/.
34 # Usage: cpp-cc --cpp=CPP CC ... file.S ...
36 # Process file.S with the given CPP command plus any -D options in the
37 # rest of the arguments, then assemble with the given CC plus all
38 # arguments.
40 # The CPP command must be in a single --cpp= argument, and will be
41 # split on whitespace. It should include -I options required.
43 # When CC is invoked, file.S is replaced with a temporary .s file
44 # which is the CPP output.
46 # Any lines starting with "#" are removed from the CPP output, usually
47 # these will be #line and #file markers from CPP, but they might also
48 # be comments from the .S.
50 # To allow parallel builds, the temp file name is based on the .S file
51 # name, which will be the output object filename for all uses we put
52 # this script to.
54 CPP=
55 CPPDEFS=
56 CC=
58 SEEN_O=no
60 for i in "$@"; do
61 case $i in
62 --cpp=*)
63 CPP=`echo "$i" | sed 's/^--cpp=//'`
65 -D*)
66 CPPDEFS="$CPPDEFS $i"
67 CC="$CC $i"
69 *.S)
70 if test -n "$S"; then
71 echo "Only one .S file permitted"
72 exit 1
74 BASENAME=`echo "$i" | sed -e 's/\.S$//' -e 's/^.*[\\/:]//'`
75 S=$i
76 TMP_I=tmp-$BASENAME.i
77 TMP_S=tmp-$BASENAME.s
78 CC="$CC $TMP_S"
80 -o)
81 SEEN_O=yes
82 CC="$CC $i"
85 CC="$CC $i"
87 esac
88 done
90 if test -z "$CPP"; then
91 echo "No --cpp specified"
92 exit 1
95 if test -z "$S"; then
96 echo "No .S specified"
97 exit 1
100 # Libtool adds it's own -o when sending output to .libs/foo.o, but not
101 # when just wanting foo.o in the current directory. We need an
102 # explicit -o in both cases since we're assembling tmp-foo.s.
104 if test $SEEN_O = no; then
105 CC="$CC -o $BASENAME.o"
108 echo "$CPP $CPPDEFS $S >$TMP_I"
109 $CPP $CPPDEFS $S >$TMP_I || exit
111 echo "grep -v '^#' $TMP_I >$TMP_S"
112 grep -v '^#' $TMP_I >$TMP_S
114 echo "$CC"
115 $CC || exit
117 # Comment this out to preserve .s intermediates
118 rm -f $TMP