| @@ -1,90 +1,91 @@ | | | @@ -1,90 +1,91 @@ |
1 | # $NetBSD: buildcmd,v 1.6 2012/04/13 06:36:08 wiz Exp $ | | 1 | # $NetBSD: buildcmd,v 1.7 2015/04/25 22:15:38 tnn Exp $ |
2 | # | | 2 | # |
3 | # Copyright (c) 2004 The NetBSD Foundation, Inc. | | 3 | # Copyright (c) 2004 The NetBSD Foundation, Inc. |
4 | # All rights reserved. | | 4 | # All rights reserved. |
5 | # | | 5 | # |
6 | # This code is derived from software contributed to The NetBSD Foundation | | 6 | # This code is derived from software contributed to The NetBSD Foundation |
7 | # by Johnny C. Lam. | | 7 | # by Johnny C. Lam. |
8 | # | | 8 | # |
9 | # Redistribution and use in source and binary forms, with or without | | 9 | # Redistribution and use in source and binary forms, with or without |
10 | # modification, are permitted provided that the following conditions | | 10 | # modification, are permitted provided that the following conditions |
11 | # are met: | | 11 | # are met: |
12 | # 1. Redistributions of source code must retain the above copyright | | 12 | # 1. Redistributions of source code must retain the above copyright |
13 | # notice, this list of conditions and the following disclaimer. | | 13 | # notice, this list of conditions and the following disclaimer. |
14 | # 2. Redistributions in binary form must reproduce the above copyright | | 14 | # 2. Redistributions in binary form must reproduce the above copyright |
15 | # notice, this list of conditions and the following disclaimer in the | | 15 | # notice, this list of conditions and the following disclaimer in the |
16 | # documentation and/or other materials provided with the distribution. | | 16 | # documentation and/or other materials provided with the distribution. |
17 | # 3. All advertising materials mentioning features or use of this software | | 17 | # 3. All advertising materials mentioning features or use of this software |
18 | # must display the following acknowledgement: | | 18 | # must display the following acknowledgement: |
19 | # This product includes software developed by the NetBSD | | 19 | # This product includes software developed by the NetBSD |
20 | # Foundation, Inc. and its contributors. | | 20 | # Foundation, Inc. and its contributors. |
21 | # 4. Neither the name of The NetBSD Foundation nor the names of its | | 21 | # 4. Neither the name of The NetBSD Foundation nor the names of its |
22 | # contributors may be used to endorse or promote products derived | | 22 | # contributors may be used to endorse or promote products derived |
23 | # from this software without specific prior written permission. | | 23 | # from this software without specific prior written permission. |
24 | # | | 24 | # |
25 | # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 25 | # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
26 | # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 26 | # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
27 | # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 27 | # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
28 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 28 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
29 | # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 29 | # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
30 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 30 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
31 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 31 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
32 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 32 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
33 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 33 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
34 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 34 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
35 | # POSSIBILITY OF SUCH DAMAGE. | | 35 | # POSSIBILITY OF SUCH DAMAGE. |
36 | | | 36 | |
37 | case $arg in | | 37 | case $arg in |
38 | ###################################################################### | | 38 | ###################################################################### |
39 | # Don't append empty arguments to the command line. | | 39 | # Don't append empty arguments to the command line. |
40 | ###################################################################### | | 40 | ###################################################################### |
41 | "") | | 41 | "") |
42 | ;; | | 42 | ;; |
43 | ###################################################################### | | 43 | ###################################################################### |
44 | # Reduce command length by not appending options that we've already | | 44 | # Reduce command length by not appending options that we've already |
45 | # seen. We also ensure that all of the -l options come after the -L | | 45 | # seen. We also ensure that all of the -l options come after the -L |
46 | # options, and suppress consecutive repeated libraries. | | 46 | # options, and suppress consecutive repeated libraries. |
47 | ###################################################################### | | 47 | ###################################################################### |
48 | -[DILR]*|-Wl,-R*|-Wl,-*,/*) | | 48 | -[DILR]*|-Wl,-R*|-Wl,-*,/*) |
49 | case $cmd in | | 49 | case $cmd in |
50 | *" "$arg|*" "$arg" "*) | | 50 | *" "$arg|*" "$arg" "*) |
51 | ;; | | 51 | ;; |
52 | *) | | 52 | *) |
53 | shquote "$arg"; arg="$shquoted" | | 53 | shquote "$arg"; arg="$shquoted" |
54 | cmd="$cmd $arg" | | 54 | cmd="$cmd $arg" |
55 | ;; | | 55 | ;; |
56 | esac | | 56 | esac |
57 | ;; | | 57 | ;; |
58 | ###################################################################### | | 58 | ###################################################################### |
59 | # Preserve the -Wl,-Bstatic / -Wl,-Bdynamic arguments, but also | | 59 | # Preserve the -Wl,-Bstatic / -Wl,-Bdynamic arguments, but also |
60 | # duplicate them into the list of libraries. Someone may want to mix | | 60 | # duplicate them into the list of libraries. Someone may want to mix |
61 | # static and dynamic linking. | | 61 | # static and dynamic linking. |
62 | ###################################################################### | | 62 | ###################################################################### |
63 | -Wl,-Bdynamic|-Wl,-Bstatic) | | 63 | -Wl,-Bdynamic|-Wl,-Bstatic) |
64 | shquote "$arg"; arg="$shquoted" | | 64 | shquote "$arg"; arg="$shquoted" |
65 | cmd="$cmd $arg" | | 65 | cmd="$cmd $arg" |
66 | libs="$libs $arg" | | 66 | libs="$libs $arg" |
67 | ;; | | 67 | ;; |
68 | ###################################################################### | | 68 | ###################################################################### |
69 | # Treat the '--as-needed' and '--no-as-needed' arguments to ld as if | | 69 | # Treat the '--as-needed' and '--no-as-needed' arguments to ld as if |
70 | # thay are libraries so that they still surround the given library. | | 70 | # thay are libraries so that they still surround the given library. |
| | | 71 | # Same for '-Wl,--whole-archive' and '-Wl,--no-whole-archive'. |
71 | # WARNING: this may not work if the wrapper reorders libraries. | | 72 | # WARNING: this may not work if the wrapper reorders libraries. |
72 | ###################################################################### | | 73 | ###################################################################### |
73 | -l*|--as-needed|--no-as-needed) | | 74 | -l*|--as-needed|--no-as-needed|-Wl,--whole-archive|-Wl,--no-whole-archive) |
74 | case $libs in | | 75 | case $libs in |
75 | *" "$arg) | | 76 | *" "$arg) |
76 | ;; | | 77 | ;; |
77 | *) | | 78 | *) |
78 | shquote "$arg"; arg="$shquoted" | | 79 | shquote "$arg"; arg="$shquoted" |
79 | libs="$libs $arg" | | 80 | libs="$libs $arg" |
80 | ;; | | 81 | ;; |
81 | esac | | 82 | esac |
82 | ;; | | 83 | ;; |
83 | ###################################################################### | | 84 | ###################################################################### |
84 | # Append $arg to $cmd to build up the command line to be executed. | | 85 | # Append $arg to $cmd to build up the command line to be executed. |
85 | ###################################################################### | | 86 | ###################################################################### |
86 | *) | | 87 | *) |
87 | shquote "$arg"; arg="$shquoted" | | 88 | shquote "$arg"; arg="$shquoted" |
88 | cmd="$cmd $arg" | | 89 | cmd="$cmd $arg" |
89 | ;; | | 90 | ;; |
90 | esac | | 91 | esac |