Upload Tizen:Base source
[external/gmp.git] / mpn / Makeasm.am
1 ## Automake asm file rules.
2
3 # Copyright 1996, 1998, 1999, 2000, 2001, 2002 Free Software Foundation,
4 # Inc.
5 #
6 # This file is part of the GNU MP Library.
7 #
8 # The GNU MP Library is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU Lesser General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or (at your
11 # option) any later version.
12 #
13 # The GNU MP Library is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16 # License for more details.
17 #
18 # You should have received a copy of the GNU Lesser General Public License
19 # along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
20
21
22 # COMPILE minus CC.
23 #
24 COMPILE_FLAGS = $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
25         $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(ASMFLAGS)
26
27 # Flags used for preprocessing (in ansi2knr rules).
28 #
29 PREPROCESS_FLAGS = $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
30         $(CPPFLAGS)
31
32
33 # Recent versions of automake (1.5 and up for instance) append automake
34 # generated suffixes to this $(SUFFIXES) list.  This is essential for us,
35 # since .c must come after .s, .S and .asm.  If .c is before .s, for
36 # instance, then in the mpn directory "make" will see add_n.c mentioned in
37 # an explicit rule (the ansi2knr stuff) and decide it must have add_n.c,
38 # even if add_n.c doesn't exist but add_n.s does.  See GNU make
39 # documentation "(make)Implicit Rule Search", part 5c.
40 #
41 # On IRIX 6 native make this doesn't work properly though.  Somehow .c
42 # remains ahead of .s, perhaps because .c.s is a builtin rule.  .asm works
43 # fine though, and mpn/mips3 uses this.
44 #
45 SUFFIXES = .s .S .asm
46
47
48 # .s assembler, no preprocessing.
49 #
50 .s.o:
51         $(CCAS) $(COMPILE_FLAGS) `test -f '$<' || echo '$(srcdir)/'`$<
52 .s.obj:
53         $(CCAS) $(COMPILE_FLAGS) `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
54 .s.lo:
55         $(LIBTOOL) --mode=compile --tag=CC $(CCAS) $(COMPILE_FLAGS) `test -f '$<' || echo '$(srcdir)/'`$<
56
57
58 # can be overridden during development, eg. "make RM_TMP=: mul_1.lo"
59 RM_TMP = rm -f
60
61
62 # .S assembler, preprocessed with cpp.
63 #
64 # It's necessary to run $(CPP) separately, since it seems not all compilers
65 # recognise .S files, in particular "cc" on HP-UX 10 and 11 doesn't (and
66 # will silently do nothing if given a .S).
67 #
68 # For .lo we need a helper script, as described below for .asm.lo.
69 #
70 .S.o:
71         $(CPP) $(PREPROCESS_FLAGS) `test -f '$<' || echo '$(srcdir)/'`$< | grep -v '^#' >tmp-$*.s
72         $(CCAS) $(COMPILE_FLAGS) tmp-$*.s -o $@
73         $(RM_TMP) tmp-$*.s
74 .S.obj:
75         $(CPP) $(PREPROCESS_FLAGS) `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi` | grep -v '^#' >tmp-$*.s
76         $(CCAS) $(COMPILE_FLAGS) tmp-$*.s -o $@
77         $(RM_TMP) tmp-$*.s
78 .S.lo:
79         $(LIBTOOL) --mode=compile --tag=CC $(top_srcdir)/mpn/cpp-ccas --cpp="$(CPP) $(PREPROCESS_FLAGS)" $(CCAS) $(COMPILE_FLAGS) `test -f '$<' || echo '$(srcdir)/'`$<
80
81
82 # .asm assembler, preprocessed with m4.
83 #
84 # .o and .obj are non-PIC and just need m4 followed by a compile.
85 #
86 # .lo is a bit tricky.  Libtool (as of version 1.5) has foo.lo as a little
87 # text file, and .libs/foo.o and foo.o as the PIC and non-PIC objects,
88 # respectively.  It'd be asking for lots of trouble to try to create foo.lo
89 # ourselves, so instead arrange to invoke libtool like a --mode=compile, but
90 # with a special m4-ccas script which first m4 preprocesses, then compiles.
91 # --tag=CC is necessary since foo.asm is otherwise unknown to libtool.
92 #
93 # Libtool adds -DPIC when building a shared object and the .asm files look
94 # for that.  But it should be noted that the other PIC flags are on occasion
95 # important too, in particular FreeBSD 2.2.8 gas 1.92.3 requires -k before
96 # it accepts PIC constructs like @GOT, and gcc adds that flag only under
97 # -fPIC.  (Later versions of gas are happy to accept PIC stuff any time.)
98 #
99 .asm.o:
100         $(M4) -DOPERATION_$* `test -f '$<' || echo '$(srcdir)/'`$< >tmp-$*.s
101         $(CCAS) $(COMPILE_FLAGS) tmp-$*.s -o $@
102         $(RM_TMP) tmp-$*.s
103 .asm.obj:
104         $(M4) -DOPERATION_$* `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi` >tmp-$*.s
105         $(CCAS) $(COMPILE_FLAGS) tmp-$*.s -o $@
106         $(RM_TMP) tmp-$*.s
107 .asm.lo:
108         $(LIBTOOL) --mode=compile --tag=CC $(top_srcdir)/mpn/m4-ccas --m4="$(M4)" $(CCAS) $(COMPILE_FLAGS) `test -f '$<' || echo '$(srcdir)/'`$<