github.com/aergoio/aergo@v1.3.1/libtool/src/gmp-6.1.2/mpn/m4-ccas (about) 1 #!/bin/sh 2 # 3 # A helper script for Makeasm.am .asm.lo rule. 4 5 # Copyright 2001 Free Software Foundation, Inc. 6 # 7 # This file is part of the GNU MP Library. 8 # 9 # The GNU MP Library is free software; you can redistribute it and/or modify 10 # it under the terms of either: 11 # 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. 15 # 16 # or 17 # 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. 21 # 22 # or both in parallel, as here. 23 # 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. 28 # 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/. 32 33 34 # Usage: m4-ccas --m4=M4 CC ... file.asm ... 35 # 36 # Process file.asm with the given M4 plus any -D arguments, then 37 # assemble with the given CC plus all arguments. 38 # 39 # The M4 command must be in a single --m4= argument, and will be split 40 # on whitespace. When CC is invoked file.asm is replaced with a 41 # temporary .s file which is the M4 output. 42 # 43 # To allow parallel builds, the temp file name is based on the .asm 44 # file name, which will be the output object filename for all uses we 45 # put this script to. 46 47 M4= 48 CC= 49 DEFS= 50 ASM= 51 SEEN_O=no 52 53 for i in "$@"; do 54 case $i in 55 --m4=*) 56 M4=`echo "$i" | sed 's/^--m4=//'` 57 ;; 58 -D*) 59 DEFS="$DEFS $i" 60 CC="$CC $i" 61 ;; 62 *.asm) 63 if test -n "$ASM"; then 64 echo "Only one .asm file permitted" 65 exit 1 66 fi 67 BASENAME=`echo "$i" | sed -e 's/\.asm$//' -e 's/^.*[\\/:]//'` 68 TMP=tmp-$BASENAME.s 69 ASM=$i 70 CC="$CC $TMP" 71 ;; 72 -o) 73 SEEN_O=yes 74 CC="$CC $i" 75 ;; 76 *) 77 CC="$CC $i" 78 ;; 79 esac 80 done 81 82 if test -z "$M4"; then 83 echo "No --m4 specified" 84 exit 1 85 fi 86 87 if test -z "$ASM"; then 88 echo "No .asm specified" 89 exit 1 90 fi 91 92 # Libtool adds it's own -o when sending output to .libs/foo.o, but not 93 # when just wanting foo.o in the current directory. We need an 94 # explicit -o in both cases since we're assembling tmp-foo.s. 95 # 96 if test $SEEN_O = no; then 97 CC="$CC -o $BASENAME.o" 98 fi 99 100 echo "$M4 $DEFS $ASM >$TMP" 101 $M4 $DEFS $ASM >$TMP || exit 102 103 echo "$CC" 104 $CC || exit 105 106 # Comment this out to preserve .s intermediates 107 rm -f $TMP