Blame mpn/m4-ccas

Packit 5c3484
#!/bin/sh
Packit 5c3484
#
Packit 5c3484
# A helper script for Makeasm.am .asm.lo rule.
Packit 5c3484
Packit 5c3484
# Copyright 2001 Free Software Foundation, Inc.
Packit 5c3484
#
Packit 5c3484
#  This file is part of the GNU MP Library.
Packit 5c3484
#
Packit 5c3484
#  The GNU MP Library is free software; you can redistribute it and/or modify
Packit 5c3484
#  it under the terms of either:
Packit 5c3484
#
Packit 5c3484
#    * the GNU Lesser General Public License as published by the Free
Packit 5c3484
#      Software Foundation; either version 3 of the License, or (at your
Packit 5c3484
#      option) any later version.
Packit 5c3484
#
Packit 5c3484
#  or
Packit 5c3484
#
Packit 5c3484
#    * the GNU General Public License as published by the Free Software
Packit 5c3484
#      Foundation; either version 2 of the License, or (at your option) any
Packit 5c3484
#      later version.
Packit 5c3484
#
Packit 5c3484
#  or both in parallel, as here.
Packit 5c3484
#
Packit 5c3484
#  The GNU MP Library is distributed in the hope that it will be useful, but
Packit 5c3484
#  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
Packit 5c3484
#  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
Packit 5c3484
#  for more details.
Packit 5c3484
#
Packit 5c3484
#  You should have received copies of the GNU General Public License and the
Packit 5c3484
#  GNU Lesser General Public License along with the GNU MP Library.  If not,
Packit 5c3484
#  see https://www.gnu.org/licenses/.
Packit 5c3484
Packit 5c3484
Packit 5c3484
# Usage: m4-ccas --m4=M4 CC ... file.asm ...
Packit 5c3484
#
Packit 5c3484
# Process file.asm with the given M4 plus any -D arguments, then
Packit 5c3484
# assemble with the given CC plus all arguments.
Packit 5c3484
#
Packit 5c3484
# The M4 command must be in a single --m4= argument, and will be split
Packit 5c3484
# on whitespace.  When CC is invoked file.asm is replaced with a
Packit 5c3484
# temporary .s file which is the M4 output.
Packit 5c3484
#
Packit 5c3484
# To allow parallel builds, the temp file name is based on the .asm
Packit 5c3484
# file name, which will be the output object filename for all uses we
Packit 5c3484
# put this script to.
Packit 5c3484
Packit 5c3484
M4=
Packit 5c3484
CC=
Packit 5c3484
DEFS=
Packit 5c3484
ASM=
Packit 5c3484
SEEN_O=no
Packit 5c3484
Packit 5c3484
for i in "$@"; do
Packit 5c3484
  case $i in
Packit 5c3484
    --m4=*)
Packit 5c3484
      M4=`echo "$i" | sed 's/^--m4=//'`
Packit 5c3484
      ;;
Packit 5c3484
    -D*)
Packit 5c3484
      DEFS="$DEFS $i"
Packit 5c3484
      CC="$CC $i"
Packit 5c3484
      ;;
Packit 5c3484
    *.asm)
Packit 5c3484
      if test -n "$ASM"; then
Packit 5c3484
        echo "Only one .asm file permitted"
Packit 5c3484
        exit 1
Packit 5c3484
      fi
Packit 5c3484
      BASENAME=`echo "$i" | sed -e 's/\.asm$//' -e 's/^.*[\\/:]//'`
Packit 5c3484
      TMP=tmp-$BASENAME.s
Packit 5c3484
      ASM=$i
Packit 5c3484
      CC="$CC $TMP"
Packit 5c3484
      ;;
Packit 5c3484
    -o)
Packit 5c3484
      SEEN_O=yes
Packit 5c3484
      CC="$CC $i"
Packit 5c3484
      ;;
Packit 5c3484
    *)
Packit 5c3484
      CC="$CC $i"
Packit 5c3484
      ;;
Packit 5c3484
  esac
Packit 5c3484
done
Packit 5c3484
Packit 5c3484
if test -z "$M4"; then
Packit 5c3484
  echo "No --m4 specified"
Packit 5c3484
  exit 1
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
if test -z "$ASM"; then
Packit 5c3484
  echo "No .asm specified"
Packit 5c3484
  exit 1
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
# Libtool adds it's own -o when sending output to .libs/foo.o, but not
Packit 5c3484
# when just wanting foo.o in the current directory.  We need an
Packit 5c3484
# explicit -o in both cases since we're assembling tmp-foo.s.
Packit 5c3484
#
Packit 5c3484
if test $SEEN_O = no; then
Packit 5c3484
  CC="$CC -o $BASENAME.o"
Packit 5c3484
fi
Packit 5c3484
Packit 5c3484
echo "$M4 $DEFS $ASM >$TMP"
Packit 5c3484
$M4 $DEFS $ASM >$TMP || exit
Packit 5c3484
Packit 5c3484
echo "$CC"
Packit 5c3484
$CC || exit
Packit 5c3484
Packit 5c3484
# Comment this out to preserve .s intermediates
Packit Service 473bb9
rm -f $TMP