1272343Sngie#!/bin/sh 2272343Sngie# 3272343Sngie# A helper script for Makeasm.am .asm.lo rule. 4272343Sngie 5272343Sngie# Copyright 2001 Free Software Foundation, Inc. 6272343Sngie# 7272343Sngie# This file is part of the GNU MP Library. 8272343Sngie# 9272343Sngie# The GNU MP Library is free software; you can redistribute it and/or modify 10272343Sngie# it under the terms of either: 11272343Sngie# 12272343Sngie# * the GNU Lesser General Public License as published by the Free 13272343Sngie# Software Foundation; either version 3 of the License, or (at your 14272343Sngie# option) any later version. 15272343Sngie# 16272343Sngie# or 17272343Sngie# 18272343Sngie# * the GNU General Public License as published by the Free Software 19272343Sngie# Foundation; either version 2 of the License, or (at your option) any 20272343Sngie# later version. 21272343Sngie# 22272343Sngie# or both in parallel, as here. 23272343Sngie# 24272343Sngie# The GNU MP Library is distributed in the hope that it will be useful, but 25272343Sngie# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 26272343Sngie# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 27272343Sngie# for more details. 28272343Sngie# 29272343Sngie# You should have received copies of the GNU General Public License and the 30272343Sngie# GNU Lesser General Public License along with the GNU MP Library. If not, 31272343Sngie# see https://www.gnu.org/licenses/. 32272343Sngie 33272343Sngie 34272343Sngie# Usage: m4-ccas --m4=M4 CC ... file.asm ... 35272343Sngie# 36272343Sngie# Process file.asm with the given M4 plus any -D arguments, then 37272343Sngie# assemble with the given CC plus all arguments. 38272343Sngie# 39272343Sngie# The M4 command must be in a single --m4= argument, and will be split 40272343Sngie# on whitespace. When CC is invoked file.asm is replaced with a 41272343Sngie# temporary .s file which is the M4 output. 42272343Sngie# 43272343Sngie# To allow parallel builds, the temp file name is based on the .asm 44272343Sngie# file name, which will be the output object filename for all uses we 45272343Sngie# put this script to. 46272343Sngie 47272343SngieM4= 48272343SngieCC= 49272343SngieDEFS= 50272343SngieASM= 51272343SngieSEEN_O=no 52272343Sngie 53272343Sngiefor i in "$@"; do 54276478Sngie case $i in 55276478Sngie --m4=*) 56276478Sngie M4=`echo "$i" | sed 's/^--m4=//'` 57272343Sngie ;; 58276478Sngie -D*) 59272343Sngie DEFS="$DEFS $i" 60272343Sngie CC="$CC $i" 61272343Sngie ;; 62272343Sngie *.asm) 63272343Sngie if test -n "$ASM"; then 64272343Sngie echo "Only one .asm file permitted" 65272343Sngie exit 1 66272343Sngie fi 67272343Sngie BASENAME=`echo "$i" | sed -e 's/\.asm$//' -e 's/^.*[\\/:]//'` 68272343Sngie TMP=tmp-$BASENAME.s 69272343Sngie ASM=$i 70272343Sngie CC="$CC $TMP" 71272343Sngie ;; 72272343Sngie -o) 73272343Sngie SEEN_O=yes 74272343Sngie CC="$CC $i" 75272343Sngie ;; 76272343Sngie *) 77272343Sngie CC="$CC $i" 78272343Sngie ;; 79272343Sngie esac 80272343Sngiedone 81272343Sngie 82272343Sngieif test -z "$M4"; then 83272343Sngie echo "No --m4 specified" 84272343Sngie exit 1 85272343Sngiefi 86272343Sngie 87272343Sngieif test -z "$ASM"; then 88272343Sngie echo "No .asm specified" 89272343Sngie exit 1 90272343Sngiefi 91272343Sngie 92272343Sngie# Libtool adds it's own -o when sending output to .libs/foo.o, but not 93272343Sngie# when just wanting foo.o in the current directory. We need an 94272343Sngie# explicit -o in both cases since we're assembling tmp-foo.s. 95272343Sngie# 96272343Sngieif test $SEEN_O = no; then 97272343Sngie CC="$CC -o $BASENAME.o" 98272343Sngiefi 99272343Sngie 100272343Sngieecho "$M4 $DEFS $ASM >$TMP" 101272343Sngie$M4 $DEFS $ASM >$TMP || exit 102272343Sngie 103272343Sngieecho "$CC" 104272343Sngie$CC || exit 105272343Sngie 106272343Sngie# Comment this out to preserve .s intermediates 107272343Sngierm -f $TMP 108272343Sngie