m4-ccas revision 1.1.1.2 1 1.1 mrg #!/bin/sh
2 1.1 mrg #
3 1.1 mrg # A helper script for Makeasm.am .asm.lo rule.
4 1.1 mrg
5 1.1 mrg # Copyright 2001 Free Software Foundation, Inc.
6 1.1 mrg #
7 1.1.1.2 mrg # This file is part of the GNU MP Library.
8 1.1 mrg #
9 1.1.1.2 mrg # The GNU MP Library is free software; you can redistribute it and/or modify
10 1.1.1.2 mrg # it under the terms of either:
11 1.1 mrg #
12 1.1.1.2 mrg # * the GNU Lesser General Public License as published by the Free
13 1.1.1.2 mrg # Software Foundation; either version 3 of the License, or (at your
14 1.1.1.2 mrg # option) any later version.
15 1.1.1.2 mrg #
16 1.1.1.2 mrg # or
17 1.1.1.2 mrg #
18 1.1.1.2 mrg # * the GNU General Public License as published by the Free Software
19 1.1.1.2 mrg # Foundation; either version 2 of the License, or (at your option) any
20 1.1.1.2 mrg # later version.
21 1.1.1.2 mrg #
22 1.1.1.2 mrg # or both in parallel, as here.
23 1.1.1.2 mrg #
24 1.1.1.2 mrg # The GNU MP Library is distributed in the hope that it will be useful, but
25 1.1.1.2 mrg # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
26 1.1.1.2 mrg # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 1.1.1.2 mrg # for more details.
28 1.1.1.2 mrg #
29 1.1.1.2 mrg # You should have received copies of the GNU General Public License and the
30 1.1.1.2 mrg # GNU Lesser General Public License along with the GNU MP Library. If not,
31 1.1.1.2 mrg # see https://www.gnu.org/licenses/.
32 1.1 mrg
33 1.1 mrg
34 1.1 mrg # Usage: m4-ccas --m4=M4 CC ... file.asm ...
35 1.1 mrg #
36 1.1 mrg # Process file.asm with the given M4 plus any -D arguments, then
37 1.1 mrg # assemble with the given CC plus all arguments.
38 1.1 mrg #
39 1.1 mrg # The M4 command must be in a single --m4= argument, and will be split
40 1.1 mrg # on whitespace. When CC is invoked file.asm is replaced with a
41 1.1 mrg # temporary .s file which is the M4 output.
42 1.1 mrg #
43 1.1 mrg # To allow parallel builds, the temp file name is based on the .asm
44 1.1 mrg # file name, which will be the output object filename for all uses we
45 1.1 mrg # put this script to.
46 1.1 mrg
47 1.1 mrg M4=
48 1.1 mrg CC=
49 1.1 mrg DEFS=
50 1.1 mrg ASM=
51 1.1 mrg SEEN_O=no
52 1.1 mrg
53 1.1 mrg for i in "$@"; do
54 1.1 mrg case $i in
55 1.1 mrg --m4=*)
56 1.1 mrg M4=`echo "$i" | sed 's/^--m4=//'`
57 1.1 mrg ;;
58 1.1 mrg -D*)
59 1.1 mrg DEFS="$DEFS $i"
60 1.1 mrg CC="$CC $i"
61 1.1 mrg ;;
62 1.1 mrg *.asm)
63 1.1 mrg if test -n "$ASM"; then
64 1.1 mrg echo "Only one .asm file permitted"
65 1.1 mrg exit 1
66 1.1 mrg fi
67 1.1 mrg BASENAME=`echo "$i" | sed -e 's/\.asm$//' -e 's/^.*[\\/:]//'`
68 1.1 mrg TMP=tmp-$BASENAME.s
69 1.1 mrg ASM=$i
70 1.1 mrg CC="$CC $TMP"
71 1.1 mrg ;;
72 1.1 mrg -o)
73 1.1 mrg SEEN_O=yes
74 1.1 mrg CC="$CC $i"
75 1.1 mrg ;;
76 1.1 mrg *)
77 1.1 mrg CC="$CC $i"
78 1.1 mrg ;;
79 1.1 mrg esac
80 1.1 mrg done
81 1.1 mrg
82 1.1 mrg if test -z "$M4"; then
83 1.1 mrg echo "No --m4 specified"
84 1.1 mrg exit 1
85 1.1 mrg fi
86 1.1 mrg
87 1.1 mrg if test -z "$ASM"; then
88 1.1 mrg echo "No .asm specified"
89 1.1 mrg exit 1
90 1.1 mrg fi
91 1.1 mrg
92 1.1 mrg # Libtool adds it's own -o when sending output to .libs/foo.o, but not
93 1.1 mrg # when just wanting foo.o in the current directory. We need an
94 1.1 mrg # explicit -o in both cases since we're assembling tmp-foo.s.
95 1.1 mrg #
96 1.1 mrg if test $SEEN_O = no; then
97 1.1 mrg CC="$CC -o $BASENAME.o"
98 1.1 mrg fi
99 1.1 mrg
100 1.1 mrg echo "$M4 $DEFS $ASM >$TMP"
101 1.1 mrg $M4 $DEFS $ASM >$TMP || exit
102 1.1 mrg
103 1.1 mrg echo "$CC"
104 1.1 mrg $CC || exit
105 1.1 mrg
106 1.1 mrg # Comment this out to preserve .s intermediates
107 1.1 mrg rm -f $TMP
108