summaryrefslogtreecommitdiffstats
path: root/wine/build/wine_winebuild-CCAS.patch
blob: 3971ddd362c902beca83c7778ab13ec7a362d3ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
From 57c57e9dfae50f045503ae9f3107fa3748512483 Mon Sep 17 00:00:00 2001
From: Alexandre Rostovtsev <tetromino@gentoo.org>
Date: Sun, 3 Feb 2013 19:19:36 -0500
Subject: [PATCH] winebuild: Use $CCAS to assemble if found

Commit c14bdaf1 made winebuild use Clang to assemble if found.

However, just because a user has some version of Clang installed, it
does not mean that she wants to use Clang to assemble Wine. For example,
a user who has both Clang and GAS installed may want to use GAS to avoid
textrels (see https://bugs.gentoo.org/show_bug.cgi?id=455308).

This patch allows the user to override which assembler gets used by
exporting CCAS at Wine configure time; the name CCAS was chosen for
compatibility with automake's standard AM_PROG_AS macro.
---
 configure                   | 106 ++++++++++++++++++++++++++++++++++++++++++++
 configure.ac                |   4 ++
 tools/winebuild/Makefile.in |   5 ++-
 tools/winebuild/utils.c     |  12 +++++
 4 files changed, 126 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index e3253ee..d0b7777 100755
--- a/configure
+++ b/configure
@@ -732,6 +732,8 @@ FLEX
 TOOLSDIR
 WOW64_DISABLE
 TARGETFLAGS
+ac_ct_CCAS
+CCAS
 CPPBIN
 ac_ct_CXX
 CXXFLAGS
@@ -861,6 +863,7 @@ CPPFLAGS
 CXX
 CXXFLAGS
 CCC
+CCAS
 CPP
 XMKMF'
 
@@ -1549,6 +1552,7 @@ Some influential environment variables:
               you have headers in a nonstandard directory <include dir>
   CXX         C++ compiler command
   CXXFLAGS    C++ compiler flags
+  CCAS        Assembler command
   CPP         C preprocessor
   XMKMF       Path to xmkmf, Makefile generator for X Window System
 
@@ -4075,6 +4079,108 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+
+if test -n "$ac_tool_prefix"; then
+  for ac_prog in clang gas as
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CCAS+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CCAS"; then
+  ac_cv_prog_CCAS="$CCAS" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CCAS="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CCAS=$ac_cv_prog_CCAS
+if test -n "$CCAS"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CCAS" >&5
+$as_echo "$CCAS" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$CCAS" && break
+  done
+fi
+if test -z "$CCAS"; then
+  ac_ct_CCAS=$CCAS
+  for ac_prog in clang gas as
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CCAS+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CCAS"; then
+  ac_cv_prog_ac_ct_CCAS="$ac_ct_CCAS" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CCAS="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CCAS=$ac_cv_prog_ac_ct_CCAS
+if test -n "$ac_ct_CCAS"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CCAS" >&5
+$as_echo "$ac_ct_CCAS" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CCAS" && break
+done
+
+  if test "x$ac_ct_CCAS" = x; then
+    CCAS=""$CC""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CCAS=$ac_ct_CCAS
+  fi
+fi
+
+
 case $host in
   *-darwin*)
     if test "x$enable_win64" = "xyes"
diff --git a/configure.ac b/configure.ac
index c93cd08..760f325 100644
--- a/configure.ac
+++ b/configure.ac
@@ -126,6 +126,10 @@ dnl We can't use AC_PROG_CPP for winegcc, it uses by default $(CC) -E
 AC_CHECK_TOOL(CPPBIN,cpp,cpp)
 AC_DEFINE_UNQUOTED(EXEEXT,["$ac_exeext"],[Define to the file extension for executables.])
 
+dnl Analogous to AM_PROG_AS
+AC_ARG_VAR([CCAS],[Assembler command])
+AC_CHECK_TOOLS(CCAS,[clang gas as],["$CC"])
+
 case $host in
   *-darwin*)
     if test "x$enable_win64" = "xyes"
diff --git a/tools/winebuild/Makefile.in b/tools/winebuild/Makefile.in
index 2017129..3fe47a3 100644
--- a/tools/winebuild/Makefile.in
+++ b/tools/winebuild/Makefile.in
@@ -1,4 +1,7 @@
-DEFS      = -D__WINESRC__ $(EXTRADEFS)
+DEFS      = \
+	-DCCAS="\"@CCAS@\"" \
+	-D__WINESRC__ \
+	$(EXTRADEFS)
 
 PROGRAMS = winebuild$(EXEEXT)
 MANPAGE  = winebuild.man
diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c
index 262ff3a..1c5f918 100644
--- a/tools/winebuild/utils.c
+++ b/tools/winebuild/utils.c
@@ -352,6 +352,18 @@ struct strarray *get_as_command(void)
     static int as_is_clang = 0;
     struct strarray *args = strarray_init();
 
+    if (!as_command && strlen( CCAS ))
+    {
+        struct stat st;
+
+        if (!stat( CCAS, &st ))
+            as_command = CCAS;
+        else
+            as_command = find_tool( CCAS, NULL );
+
+        if (as_command && strstr( as_command, "clang" )) as_is_clang = 1;
+    }
+
     if (!as_command)
     {
         as_command = find_tool( "clang", NULL );
-- 
1.8.1.2