summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo
diff options
context:
space:
mode:
authorUdo Walter2019-07-16 16:06:41 +0200
committerUdo Walter2019-07-16 16:06:41 +0200
commit41ff429b1f39f107565365c206cfd6e11c875462 (patch)
tree567961d62970e3079ef7ce837a7215fc11b45a46 /modules-available/locationinfo
parent[inc/Render] Remove legacy functions (diff)
downloadslx-admin-41ff429b1f39f107565365c206cfd6e11c875462.tar.gz
slx-admin-41ff429b1f39f107565365c206cfd6e11c875462.tar.xz
slx-admin-41ff429b1f39f107565365c206cfd6e11c875462.zip
[locationinfo] Add ability to select the start day of the calendar
Diffstat (limited to 'modules-available/locationinfo')
-rw-r--r--modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php7
-rw-r--r--modules-available/locationinfo/lang/de/template-tags.json8
-rw-r--r--modules-available/locationinfo/lang/en/template-tags.json8
-rw-r--r--modules-available/locationinfo/page.inc.php3
-rwxr-xr-xmodules-available/locationinfo/templates/frontend-default.html10
-rw-r--r--modules-available/locationinfo/templates/page-config-panel-default.html34
6 files changed, 65 insertions, 5 deletions
diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php
index 7f84dd92..4664a011 100644
--- a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php
@@ -373,9 +373,10 @@ class CourseBackend_HisInOne extends CourseBackend
private function getCurrentWeekDates()
{
$returnValue = array();
- $startDate = time();
- for ($i = 0; $i < 7; $i++) {
- $returnValue[] = date('Y-m-d', strtotime("+{$i} day 12:00", $startDate));
+ $date = date('Y-m-d', strtotime('last Monday'));
+ for ($i = 0; $i < 14; $i++) {
+ $returnValue[] = $date;
+ $date = date('Y-m-d', strtotime($date.' +1 day'));
}
return $returnValue;
}
diff --git a/modules-available/locationinfo/lang/de/template-tags.json b/modules-available/locationinfo/lang/de/template-tags.json
index 950ac512..b63ffc5a 100644
--- a/modules-available/locationinfo/lang/de/template-tags.json
+++ b/modules-available/locationinfo/lang/de/template-tags.json
@@ -15,6 +15,7 @@
"lang_countRoomplan": "über Raumplaner",
"lang_createPanel": "Panel anlegen",
"lang_credentials": "Anmeldung",
+ "lang_currentDay": "Aktueller Tag",
"lang_day": "Tag",
"lang_daysToShow": "Tage",
"lang_daysToShowTooltip": "Legt die Anzahl an Tagen im Kalender fest, die angezeigt werden",
@@ -35,6 +36,7 @@
"lang_for": "f\u00fcr",
"lang_fourLocsHint": "Hier k\u00f6nnen Sie bis zu vier Orte ausw\u00e4hlen, die in diesem Panel angezeigt werden.",
"lang_free": "Ge\u00f6ffnet",
+ "lang_friday": "Freitag",
"lang_general": "Allgemein",
"lang_generalSettings": "Allgemeine Einstellungen",
"lang_ignoreSslTooltip": "Akzeptiere ung\u00fcltige, abgelaufene oder selbstsignierte SSL-Zertifikate",
@@ -62,6 +64,7 @@
"lang_mode3": "Raum",
"lang_mode4": "Wechselnd",
"lang_modeTooltip": "Die Anzeigemodi, welche das Frontend unterst\u00fctzt",
+ "lang_monday": "Montag",
"lang_monTilFr": "Montag - Freitag",
"lang_nameTooltip": "Legt den Namen des Servers fest",
"lang_noLocationsWarning": "Bitte w\u00e4hlen Sie mindestens einen Ort aus, der vom Panel angezeigt werden soll.",
@@ -118,11 +121,15 @@
"lang_shortWed": "Mi",
"lang_shortWednesday": "Mi",
"lang_showLog": "Log",
+ "lang_startDay": "Start Tag",
+ "lang_startDayTooltip": "Der Wochentag an dem der Kalender anfängt",
"lang_summaryPanel": "\u00dcbersichts-Panel",
"lang_summaryUpdateIntervalTooltip": "Aktualisierungsintervall (Sekunden)",
"lang_sunday": "Sonntag",
"lang_switchTime": "Wechselintervall",
"lang_switchTimeTooltip": "[1-120] Legt die Zeit fest, die vergeht bis ein Wechsel erfolgt (in Sekunden)",
+ "lang_thuesday": "Dienstag",
+ "lang_thursday": "Donnerstag",
"lang_to": "bis",
"lang_typeTooltip": "Legt fest um welchen Server-Typ es sich handelt",
"lang_updateRates": "Aktualisierungsintervall",
@@ -135,5 +142,6 @@
"lang_useRoomplanner": "Rechner zählen",
"lang_vertical": "Vertikaler Modus",
"lang_verticalTooltip": "Legt fest, ob Kalender und Raum \u00fcbereinander angezeigt werden sollen",
+ "lang_wednesday": "Mittwoch",
"lang_when": "Wann"
} \ No newline at end of file
diff --git a/modules-available/locationinfo/lang/en/template-tags.json b/modules-available/locationinfo/lang/en/template-tags.json
index 4820caf2..bf51b0b2 100644
--- a/modules-available/locationinfo/lang/en/template-tags.json
+++ b/modules-available/locationinfo/lang/en/template-tags.json
@@ -15,6 +15,7 @@
"lang_countRoomplan": "by Roomplanner",
"lang_createPanel": "Create panel",
"lang_credentials": "Login",
+ "lang_currentDay": "Current Day",
"lang_day": "Day",
"lang_daysToShow": "Days",
"lang_daysToShowTooltip": "Defines the amount of days to show in the calendar",
@@ -35,6 +36,7 @@
"lang_for": "for",
"lang_fourLocsHint": "You can pick up to four locations that will be shown in this panel.",
"lang_free": "Open",
+ "lang_friday": "Friday",
"lang_general": "General",
"lang_generalSettings": "General Settings",
"lang_ignoreSslTooltip": "Accept invalid, expired or self-signed ssl certificates",
@@ -62,6 +64,7 @@
"lang_mode3": "Room",
"lang_mode4": "Switching",
"lang_modeTooltip": "The display modes the frontend supports",
+ "lang_monday": "Monday",
"lang_monTilFr": "Monday - Friday",
"lang_nameTooltip": "Defines the name of the server",
"lang_noLocationsWarning": "Please select at least one location this panel should display.",
@@ -118,11 +121,15 @@
"lang_shortWed": "Wed",
"lang_shortWednesday": "Wed",
"lang_showLog": "Log",
+ "lang_startDay": "Start Day",
+ "lang_startDayTooltip": "The day of the week at which the calendar starts",
"lang_summaryPanel": "Summary panel",
"lang_summaryUpdateIntervalTooltip": "Update interval (seconds)",
"lang_sunday": "Sunday",
"lang_switchTime": "Switchtime",
"lang_switchTimeTooltip": "[1-120] Sets the time between switching (in seconds)",
+ "lang_thuesday": "Thuesday",
+ "lang_thursday": "Thursday",
"lang_to": "to",
"lang_typeTooltip": "Defines on which type of server you want to connect to",
"lang_updateRates": "Update rates",
@@ -135,5 +142,6 @@
"lang_useRoomplanner": "Count PCs",
"lang_vertical": "Vertical mode",
"lang_verticalTooltip": "Defines whether the room and calendar are shown above each other",
+ "lang_wednesday": "Wednesday",
"lang_when": "When"
} \ No newline at end of file
diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php
index 5292c40e..5ba555df 100644
--- a/modules-available/locationinfo/page.inc.php
+++ b/modules-available/locationinfo/page.inc.php
@@ -372,6 +372,7 @@ class Page_LocationInfo extends Page
'eco' => Request::post('eco', false, 'bool'),
'prettytime' => Request::post('prettytime', false, 'bool'),
'roomplanner' => Request::post('roomplanner', false, 'bool'),
+ 'startday' => Request::post('startday', 0, 'int'),
'scaledaysauto' => Request::post('scaledaysauto', false, 'bool'),
'daystoshow' => Request::post('daystoshow', 7, 'int'),
'rotation' => Request::post('rotation', 0, 'int'),
@@ -395,6 +396,7 @@ class Page_LocationInfo extends Page
'mode' => Request::post('override'.$locationids[$i].'mode', 1, 'int'),
'roomplanner' => Request::post('override'.$locationids[$i].'roomplanner', false, 'bool'),
'vertical' => Request::post('override'.$locationids[$i].'vertical', false, 'bool'),
+ 'startday' => Request::post('override'.$locationids[$i].'startday', 0, 'int'),
'scaledaysauto' => Request::post('override'.$locationids[$i].'scaledaysauto', false, 'bool'),
'daystoshow' => Request::post('override'.$locationids[$i].'daystoshow', 7, 'int'),
'rotation' => Request::post('override'.$locationids[$i].'rotation', 0, 'int'),
@@ -995,6 +997,7 @@ class Page_LocationInfo extends Page
'eco_checked' => $config['eco'] ? 'checked' : '',
'prettytime_checked' => $config['prettytime'] ? 'checked' : '',
'roomplanner' => $config['roomplanner'],
+ 'startday' => $config['startday'],
'scaledaysauto_checked' => $config['scaledaysauto'] ? 'checked' : '',
'daystoshow' => $config['daystoshow'],
'rotation' => $config['rotation'],
diff --git a/modules-available/locationinfo/templates/frontend-default.html b/modules-available/locationinfo/templates/frontend-default.html
index 98149bb9..c59679ee 100755
--- a/modules-available/locationinfo/templates/frontend-default.html
+++ b/modules-available/locationinfo/templates/frontend-default.html
@@ -499,7 +499,8 @@ optional:
if (!scaleFactor) {
scaleFactor = 1;
}
- if (!v || !isFinite(v) || isNaN(v) || v < min * scaleFactor || v > max * scaleFactor) {
+ if (v === null || !isFinite(v) || isNaN(v) || v < min * scaleFactor || v > max * scaleFactor) {
+ console.log(property)
config[property] = defaultval * scaleFactor;
}
}
@@ -522,6 +523,7 @@ optional:
setRoomConfigFromUrl(config, 'calupdate', PARAM_INT, 60 * 1000);
setRoomConfigFromUrl(config, 'roomupdate', PARAM_INT, 1000);
+ setRoomConfigFromUrl(config, 'startday', PARAM_INT);
setRoomConfigFromUrl(config, 'daystoshow', PARAM_INT);
setRoomConfigFromUrl(config, 'scaledaysauto', PARAM_BOOL);
setRoomConfigFromUrl(config, 'vertical', PARAM_BOOL);
@@ -535,6 +537,7 @@ optional:
// parameter validation
putInRange(config, 'switchtime', 5, 120, 6, 1000);
putInRange(config, 'scale', 10, 90, 50);
+ putInRange(config, 'startday', 0, 7, 0);
putInRange(config, 'daystoshow', 1, 7, 7);
putInRange(config, 'roomupdate', 15, 5 * 60, 60, 1000);
putInRange(config, 'calupdate', 1, 60, 30, 60 * 1000);
@@ -738,6 +741,9 @@ optional:
*/
function setUpCalendar(room) {
var daysToShow = room.config.daystoshow;
+ var startDay = room.config.startday;
+ var startDayDate = new Date();
+ if (startDay > 0) startDayDate.setDate((startDayDate.getDate() - (startDayDate.getDay() + 6) % 7) + (startDay - 1));
generateCalendarDiv(room);
room.$.calendar.weekCalendar({
timeslotsPerHour: 1,
@@ -765,7 +771,7 @@ optional:
$event.find(".time").css({"backgroundColor": "#25B002", "border": "1px solid #888"});
}
},
- date: MyDate(),
+ date: startDayDate,
dateFormat: "j.n",
timeFormat: "G:i",
scrollToHourMillis: 500,
diff --git a/modules-available/locationinfo/templates/page-config-panel-default.html b/modules-available/locationinfo/templates/page-config-panel-default.html
index 43a7db44..5e13190e 100644
--- a/modules-available/locationinfo/templates/page-config-panel-default.html
+++ b/modules-available/locationinfo/templates/page-config-panel-default.html
@@ -194,6 +194,31 @@
<div class="list-group-item m1-s m2-s m3-h m4-s">
<div class="row">
<div class="col-sm-3">
+ <label for="startday">{{lang_startDay}}</label>
+ </div>
+ <div class="col-sm-7">
+ <select class="form-control" id="startday" name="startday">
+ <option value="0">{{lang_currentDay}}</option>
+ <option value="1">{{lang_monday}}</option>
+ <option value="2">{{lang_thuesday}}</option>
+ <option value="3">{{lang_wednesday}}</option>
+ <option value="4">{{lang_thursday}}</option>
+ <option value="5">{{lang_friday}}</option>
+ <option value="6">{{lang_saturday}}</option>
+ <option value="7">{{lang_sunday}}</option>
+ </select>
+ </div>
+ <div class="col-sm-2">
+ <p class="btn btn-static helptext" title="{{lang_startDayTooltip}}">
+ <span class="glyphicon glyphicon-question-sign"></span>
+ </p>
+ </div>
+ </div>
+ </div>
+
+ <div class="list-group-item m1-s m2-s m3-h m4-s">
+ <div class="row">
+ <div class="col-sm-3">
<label for="scaledaysauto">{{lang_autoScale}}</label>
</div>
<div class="col-sm-7">
@@ -385,6 +410,7 @@ document.addEventListener("DOMContentLoaded", function () {
addLocation(lids[i], $name.text());
}
+ $('#startday option[value="{{startday}}"]').attr("selected", "selected");
$('#daystoshow option[value="{{daystoshow}}"]').attr("selected", "selected");
$('#rotation option[value="{{rotation}}"]').attr("selected", "selected");
$('#mode option[value="{{mode}}"]').attr("selected", "selected");
@@ -475,6 +501,11 @@ document.addEventListener("DOMContentLoaded", function () {
'<div class="col-sm-2"><p class="btn btn-static helptext" title="{{lang_verticalTooltip}}"><span class="glyphicon glyphicon-question-sign"></span></p></div>' +
'</div></div>'));
$content.append($('<div class="list-group-item om1-s om2-s om3-h om4-s"><div class="row">' +
+ '<div class="col-sm-3"><label for="override' + id + 'startday">{{lang_startDay}}</label></div>' +
+ '<div class="col-sm-7"><select class="form-control" id="override' + id + 'startday" name="override' + id + 'startday"><option value="0">{{lang_currentDay}}</option><option value="1">{{lang_monday}}</option><option value="2">{{lang_thuesday}}</option><option value="3">{{lang_wednesday}}</option><option value="4">{{lang_thursday}}</option><option value="5">{{lang_friday}}</option><option value="6">{{lang_saturday}}</option><option value="7">{{lang_sunday}}</option></select></div>' +
+ '<div class="col-sm-2"><p class="btn btn-static helptext" title="{{lang_startDayTooltip}}"><span class="glyphicon glyphicon-question-sign"></span></p></div>' +
+ '</div></div>'));
+ $content.append($('<div class="list-group-item om1-s om2-s om3-h om4-s"><div class="row">' +
'<div class="col-sm-3"><label for="override' + id + 'scaledaysauto">{{lang_autoScale}}</label></div>' +
'<div class="col-sm-7"><input id="override' + id + 'scaledaysauto" name="override' + id + 'scaledaysauto" type="checkbox"></div>' +
'<div class="col-sm-2"><p class="btn btn-static helptext" title="{{lang_autoscaleTooltip}}"><span class="glyphicon glyphicon-question-sign"></span></p></div>' +
@@ -514,6 +545,7 @@ document.addEventListener("DOMContentLoaded", function () {
$('#override' + id + 'roomplanner').val(overrides[id].roomplanner ? 1 : 0);
if (overrides[id].vertical) $('#override' + id + 'vertical').bootstrapSwitch('state', true);
if (overrides[id].scaledaysauto) $('#override' + id + 'scaledaysauto').bootstrapSwitch('state', true);
+ $('#override' + id + 'startday').val(overrides[id].startday);
$('#override' + id + 'daystoshow').val(overrides[id].daystoshow);
$('#override' + id + 'rotation').val(overrides[id].rotation);
scale.val(overrides[id].scale);
@@ -522,6 +554,8 @@ document.addEventListener("DOMContentLoaded", function () {
$('#override' + id + 'roomplanner').val($('#input-roomplanner').val());
if ($('#input-vertical').bootstrapSwitch('state')) $('#override' + id + 'vertical').bootstrapSwitch('state', true);
if ($('#scaledaysauto').bootstrapSwitch('state')) $('#override' + id + 'scaledaysauto').bootstrapSwitch('state', true);
+ console.log($('#startday').val())
+ $('#override' + id + 'startday').val($('#startday').val());
$('#override' + id + 'daystoshow').val($('#daystoshow').val());
$('#override' + id + 'rotation').val($('#rotation').val());
scale.val($('#input-scale').val());
/blame/toolchain/toolchain-external/ext-tool.mk?id=a991e3e143408d573aa3d0a3090cabfac65a570e'>^
6c492d5e7 ^
22e0698eb ^


6c492d5e7 ^
d1a9698be ^
6c492d5e7 ^
42c0fb4dc ^


951574555 ^
d1a9698be ^
951574555 ^
ae2364676 ^


69f34bafa ^
1459fc24c ^

d00bd2a1f ^


32a0dcea5 ^




b51b66472 ^
91d4336cb ^





6c492d5e7 ^




05c75314c ^

32a0dcea5 ^




91d4336cb ^
32a0dcea5 ^
























6c492d5e7 ^





2e57043b4 ^

e6633fd2e ^
32a0dcea5 ^
57692e253 ^
6c492d5e7 ^




9456b58a8 ^
c59d02475 ^
0729b544b ^

6c492d5e7 ^




c59d02475 ^
6c492d5e7 ^

c59d02475 ^
6c492d5e7 ^




e774eb0c9 ^
e6633fd2e ^
6c492d5e7 ^




0729b544b ^
































6c492d5e7 ^
0729b544b ^

6c492d5e7 ^



0729b544b ^



6c492d5e7 ^


0729b544b ^
6c492d5e7 ^

0729b544b ^
6c492d5e7 ^

0729b544b ^
6c492d5e7 ^


c85302622 ^
85dc57f6f ^





d64c4ed3f ^

85dc57f6f ^
85dc57f6f ^








b51b66472 ^







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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
 
 

                                                                     


                                                                      


                                         


                                                                     


                                      














                                                                      











                                                                      







                                                                     
 
                                                                                                                    
                                                                      
                                        
                                                

     
                                 
                                   

     
                                     
                                
                                  
                                  
                 

                    




































                                                                      
















                                                                                        
                                                     



                                                        
                                                      
                                                    


                                                      









                                                                              



                                                                 




                                                                 







                                                                                                                          








                                                   






                                                                      
                                                         
                                                                                                                  

                                                                                        
                                                                                                                  

                                                                                         
                                                                                                                  
                                                                                         
                                                              
                                                                                                                  
                                                                                         


                                                                                               
                                                           
                                                                                                           
                                                                               
                                                               

                                                                                                           
                                                                  
                                                                                                               
                                                                                          


                                                                                          
                                                             
                                                                                                           
                                                                                   


                                                                                                            
                                                                
                                                                                                         
                                                                                 


                                                                                                         
                                                               

                                                                                                               


                                                                                           




                                                                                          
                                                                                           





                                                                                           




                                                                     

     




                                                                      
                                                                                                            
























                                                                                                                       





                                                                                

                                                                                                       
                    
     
 




                                                                    
                                                    
                                                                        

                                                                                                         




                                                                                     
                                                                  

                                                          
                                                                     




                                                                  
          
                    




                                                                      
































                                                                                                         
                                                                        

                                                                                                         



                                                                                     



                                                                                                                                       


                                                                 
                                                                                                    

                                                  
                                                                                                        

                                                                
                                                                                                                


                                                     
                





                                                                               

                                  
                                           








                                                                          







                                                                   

#
# This file implements the support for external toolchains, i.e
# toolchains that have not been produced by Buildroot itself and that
# Buildroot can download from the Web or that are already available on
# the system on which Buildroot runs. So far, we have tested this
# with:
#
#  * Toolchains generated by Crosstool-NG
#  * Toolchains generated by Buildroot
#  * ARM, MIPS and PowerPC toolchains made available by
#    Codesourcery. For the MIPS toolchain, the -muclibc variant isn't
#    supported yet, only the default glibc-based variant is.
#
# The basic principle is the following
#
#  1. a. For toolchains downloaded from the Web, Buildroot already
#  knows their configuration, so it just downloads them and extract
#  them in $(TOOLCHAIN_EXTERNAL_DIR).
#
#  1. b. For pre-installed toolchains, perform some checks on the
#  conformity between the toolchain configuration described in the
#  Buildroot menuconfig system, and the real configuration of the
#  external toolchain. This is for example important to make sure that
#  the Buildroot configuration system knows whether the toolchain
#  supports RPC, IPv6, locales, large files, etc. Unfortunately, these
#  things cannot be detected automatically, since the value of these
#  options (such as BR2_INET_RPC) are needed at configuration time
#  because these options are used as dependencies for other
#  options. And at configuration time, we are not able to retrieve the
#  external toolchain configuration.
#
#  2. Copy the libraries needed at runtime to the target directory,
#  $(TARGET_DIR). Obviously, things such as the C library, the dynamic
#  loader and a few other utility libraries are needed if dynamic
#  applications are to be executed on the target system.
#
#  3. Copy the libraries and headers to the staging directory. This
#  will allow all further calls to gcc to be made using --sysroot
#  $(STAGING_DIR), which greatly simplifies the compilation of the
#  packages when using external toolchains. So in the end, only the
#  cross-compiler binaries remains external, all libraries and headers
#  are imported into the Buildroot tree.
#
#  4. Build a toolchain wrapper which executes the external toolchain
#  with a number of arguments (sysroot/march/mtune/..) hardcoded,
#  so we're sure the correct configuration is always used and the
#  toolchain behaves similar to an internal toolchain.
#  This toolchain wrapper and symlinks are installed into
#  $(HOST_DIR)/usr/bin like for the internal toolchains, and the rest
#  of Buildroot is handled identical for the 2 toolchain types.

LIB_EXTERNAL_LIBS=ld*.so libc.so libcrypt.so libdl.so libgcc_s.so libm.so libnsl.so libresolv.so librt.so libutil.so
LIB_EXTERNAL_LIBS+=$(call qstrip,$(BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS))
ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GLIBC),y)
LIB_EXTERNAL_LIBS+=libnss_files.so libnss_dns.so
endif

ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
USR_LIB_EXTERNAL_LIBS+=libstdc++.so
endif

ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
LIB_EXTERNAL_LIBS+=libpthread.so
ifeq ($(BR2_PACKAGE_GDB_SERVER),y)
LIB_EXTERNAL_LIBS+=libthread_db.so
endif # gdbserver
endif # ! no threads

# Details about sysroot directory selection.
#
# To find the sysroot directory:
#
#  * We first try the -print-sysroot option, available in gcc 4.4.x
#    and in some Codesourcery toolchains.
#
#  * If this option is not available, we fallback to the value of
#    --with-sysroot as visible in CROSS-gcc -v.
#
# When doing those tests, we don't pass any option to gcc that could
# select a multilib variant (such as -march) as we want the "main"
# sysroot, which contains all variants of the C library in the case of
# multilib toolchains. We use the TARGET_CC_NO_SYSROOT variable, which
# is the path of the cross-compiler, without the
# --sysroot=$(STAGING_DIR), since what we want to find is the location
# of the original toolchain sysroot. This "main" sysroot directory is
# stored in SYSROOT_DIR.
#
# Then, multilib toolchains are a little bit more complicated, since
# they in fact have multiple sysroots, one for each variant supported
# by the toolchain. So we need to find the particular sysroot we're
# interested in.
#
# To do so, we ask the compiler where its sysroot is by passing all
# flags (including -march and al.), except the --sysroot flag since we
# want to the compiler to tell us where its original sysroot
# is. ARCH_SUBDIR will contain the subdirectory, in the main
# SYSROOT_DIR, that corresponds to the selected architecture
# variant. ARCH_SYSROOT_DIR will contain the full path to this
# location.
#
# One might wonder why we don't just bother with ARCH_SYSROOT_DIR. The
# fact is that in multilib toolchains, the header files are often only
# present in the main sysroot, and only the libraries are available in
# each variant-specific sysroot directory.


TOOLCHAIN_EXTERNAL_PREFIX=$(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_PREFIX))
ifeq ($(BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD),y)
TOOLCHAIN_EXTERNAL_DIR=$(HOST_DIR)/opt/ext-toolchain
else
TOOLCHAIN_EXTERNAL_DIR=$(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_PATH))
endif

ifeq ($(TOOLCHAIN_EXTERNAL_DIR),)
# if no path set, figure it out from path
TOOLCHAIN_EXTERNAL_BIN:=$(shell dirname $(shell which $(TOOLCHAIN_EXTERNAL_PREFIX)-gcc))
else
TOOLCHAIN_EXTERNAL_BIN:=$(TOOLCHAIN_EXTERNAL_DIR)/bin
endif

TOOLCHAIN_EXTERNAL_CROSS=$(TOOLCHAIN_EXTERNAL_BIN)/$(TOOLCHAIN_EXTERNAL_PREFIX)-
TOOLCHAIN_EXTERNAL_CC=$(TOOLCHAIN_EXTERNAL_CROSS)gcc
TOOLCHAIN_EXTERNAL_CXX=$(TOOLCHAIN_EXTERNAL_CROSS)g++
TOOLCHAIN_EXTERNAL_WRAPPER_ARGS = \
	-DBR_CROSS_PATH='"$(TOOLCHAIN_EXTERNAL_BIN)/"' \
	-DBR_SYSROOT='"$(STAGING_DIR)"'

CC_TARGET_TUNE_:=$(call qstrip,$(BR2_GCC_TARGET_TUNE))
CC_TARGET_CPU_:=$(call qstrip,$(BR2_GCC_TARGET_CPU))
CC_TARGET_ARCH_:=$(call qstrip,$(BR2_GCC_TARGET_ARCH))
CC_TARGET_ABI_:=$(call qstrip,$(BR2_GCC_TARGET_ABI))

# march/mtune/floating point mode needs to be passed to the external toolchain
# to select the right multilib variant
ifneq ($(CC_TARGET_TUNE_),)
TOOLCHAIN_EXTERNAL_CFLAGS += -mtune=$(CC_TARGET_TUNE_)
TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_TUNE='"$(CC_TARGET_TUNE_)"'
endif
ifneq ($(CC_TARGET_ARCH_),)
TOOLCHAIN_EXTERNAL_CFLAGS += -march=$(CC_TARGET_ARCH_)
TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_ARCH='"$(CC_TARGET_ARCH_)"'
endif
ifneq ($(CC_TARGET_CPU_),)
TOOLCHAIN_EXTERNAL_CFLAGS += -mcpu=$(CC_TARGET_CPU_)
TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_CPU='"$(CC_TARGET_CPU_)"'
endif
ifneq ($(CC_TARGET_ABI_),)
TOOLCHAIN_EXTERNAL_CFLAGS += -mabi=$(CC_TARGET_ABI_)
TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_ABI='"$(CC_TARGET_ABI_)"'
endif

ifneq ($(BR2_TARGET_OPTIMIZATION),)
TOOLCHAIN_EXTERNAL_CFLAGS += $(call qstrip,$(BR2_TARGET_OPTIMIZATION))
# We create a list like '"-mfoo", "-mbar", "-mbarfoo"' so that each
# flag is a separate argument when used in execv() by the external
# toolchain wrapper.
TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_ADDITIONAL_CFLAGS='$(foreach f,$(call qstrip,$(BR2_TARGET_OPTIMIZATION)),"$(f)",)'
endif

ifeq ($(BR2_SOFT_FLOAT),y)
TOOLCHAIN_EXTERNAL_CFLAGS += -msoft-float
TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_SOFTFLOAT=1
endif

ifeq ($(BR2_VFP_FLOAT),y)
TOOLCHAIN_EXTERNAL_CFLAGS += -mfpu=vfp
TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_VFPFLOAT=1
endif

ifeq ($(BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD),y)
TOOLCHAIN_EXTERNAL_DEPENDENCIES = $(TOOLCHAIN_EXTERNAL_DIR)/.extracted
else
TOOLCHAIN_EXTERNAL_DEPENDENCIES = $(STAMP_DIR)/ext-toolchain-checked
endif

ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM2009Q3),y)
TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/arm/portal/package5383/public/arm-none-linux-gnueabi/
TOOLCHAIN_EXTERNAL_SOURCE=arm-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM2010Q1),y)
TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/arm/portal/package6488/public/arm-none-linux-gnueabi/
TOOLCHAIN_EXTERNAL_SOURCE=arm-2010q1-202-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM201009),y)
TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/arm/portal/package7851/public/arm-none-linux-gnueabi/
TOOLCHAIN_EXTERNAL_SOURCE=arm-2010.09-50-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM201103),y)
TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/arm/portal/package8739/public/arm-none-linux-gnueabi/
TOOLCHAIN_EXTERNAL_SOURCE=arm-2011.03-41-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM201109),y)
TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/public/gnu_toolchain/arm-none-linux-gnueabi/
TOOLCHAIN_EXTERNAL_SOURCE=arm-2011.09-70-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS44),y)
TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/mips/portal/package7401/public/mips-linux-gnu/
TOOLCHAIN_EXTERNAL_SOURCE=mips-4.4-303-mips-linux-gnu-i686-pc-linux-gnu.tar.bz2
else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201103),y)
TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/mips/portal/package9469/public/mips-linux-gnu/
TOOLCHAIN_EXTERNAL_SOURCE=mips-2011.03-110-mips-linux-gnu-i686-pc-linux-gnu.tar.bz2
else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_POWERPC201009),y)
TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/power/portal/package7703/public/powerpc-linux-gnu/
TOOLCHAIN_EXTERNAL_SOURCE=freescale-2010.09-55-powerpc-linux-gnu-i686-pc-linux-gnu.tar.bz2
else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_POWERPC201103),y)
TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/public/gnu_toolchain/powerpc-linux-gnu/
TOOLCHAIN_EXTERNAL_SOURCE=freescale-2011.03-38-powerpc-linux-gnu-i686-pc-linux-gnu.tar.bz2
else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_SH201009),y)
TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/superh/portal/package7783/public/sh-linux-gnu/
TOOLCHAIN_EXTERNAL_SOURCE=renesas-2010.09-45-sh-linux-gnu-i686-pc-linux-gnu.tar.bz2
else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_SH201103),y)
TOOLCHAIN_EXTERNAL_SITE=https://sourcery.mentor.com/sgpp/lite/superh/portal/package8759/public/sh-linux-gnu/
TOOLCHAIN_EXTERNAL_SOURCE=renesas-2011.03-37-sh-linux-gnu-i686-pc-linux-gnu.tar.bz2
else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_SH2A_201009),y)
TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/superh/portal/package7859/public/sh-uclinux/
TOOLCHAIN_EXTERNAL_SOURCE=renesas-2010.09-60-sh-uclinux-i686-pc-linux-gnu.tar.bz2
else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_SH2A_201103),y)
TOOLCHAIN_EXTERNAL_SITE=http://sourcery.mentor.com/sgpp/lite/superh/portal/package8749/public/sh-uclinux/
TOOLCHAIN_EXTERNAL_SOURCE=renesas-2011.03-36-sh-uclinux-i686-pc-linux-gnu.tar.bz2
else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_X86_201009),y)
TOOLCHAIN_EXTERNAL_SITE=https://sourcery.mentor.com/sgpp/lite/ia32/portal/package7682/public/i686-pc-linux-gnu/
TOOLCHAIN_EXTERNAL_SOURCE=ia32-2010.09-44-i686-pc-linux-gnu-i386-linux.tar.bz2
else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_X86_201109),y)
TOOLCHAIN_EXTERNAL_SITE=https://sourcery.mentor.com/public/gnu_toolchain/i686-pc-linux-gnu/
TOOLCHAIN_EXTERNAL_SOURCE=ia32-2011.09-24-i686-pc-linux-gnu-i386-linux.tar.bz2
else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2010RC1),y)
TOOLCHAIN_EXTERNAL_SITE_1   = http://blackfin.uclinux.org/gf/download/frsrelease/501/8378/
TOOLCHAIN_EXTERNAL_SOURCE_1 = blackfin-toolchain-2010R1-RC4.i386.tar.bz2
TOOLCHAIN_EXTERNAL_SITE_2   = http://blackfin.uclinux.org/gf/download/frsrelease/501/8386/
TOOLCHAIN_EXTERNAL_SOURCE_2 = blackfin-toolchain-uclibc-full-2010R1-RC4.i386.tar.bz2
TOOLCHAIN_EXTERNAL_SOURCE   = $(TOOLCHAIN_EXTERNAL_SOURCE_1) $(TOOLCHAIN_EXTERNAL_SOURCE_2)
else ifeq ($(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2011R1),y)
TOOLCHAIN_EXTERNAL_SITE_1   = http://blackfin.uclinux.org/gf/download/frsrelease/531/9509/
TOOLCHAIN_EXTERNAL_SOURCE_1 = blackfin-toolchain-2011R1-RC4.i386.tar.bz2
TOOLCHAIN_EXTERNAL_SITE_2   = http://blackfin.uclinux.org/gf/download/frsrelease/531/9517/
TOOLCHAIN_EXTERNAL_SOURCE_2 = blackfin-toolchain-uclibc-full-2011R1-RC4.i386.tar.bz2
TOOLCHAIN_EXTERNAL_SOURCE   = $(TOOLCHAIN_EXTERNAL_SOURCE_1) $(TOOLCHAIN_EXTERNAL_SOURCE_2)
else
# A value must be set (even if unused), otherwise the
# $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE) rule would override the main
# $(DL_DIR) rule
TOOLCHAIN_EXTERNAL_SOURCE=none
endif

# Special handling for Blackfin toolchain, because of the split in two
# tarballs, and the organization of tarball contents. The tarballs
# contain ./opt/uClinux/{bfin-uclinux,bfin-linux-uclibc} directories,
# which themselves contain the toolchain. This is why we strip more
# components than usual.
ifeq ($(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2010RC1)$(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2011R1),y)
$(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_1):
	$(call DOWNLOAD,$(TOOLCHAIN_EXTERNAL_SITE_1),$(TOOLCHAIN_EXTERNAL_SOURCE_1))

$(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_2):
	$(call DOWNLOAD,$(TOOLCHAIN_EXTERNAL_SITE_2),$(TOOLCHAIN_EXTERNAL_SOURCE_2))

$(TOOLCHAIN_EXTERNAL_DIR)/.extracted: $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_1) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_2)
	mkdir -p $(@D)
	$(INFLATE$(suffix $(TOOLCHAIN_EXTERNAL_SOURCE_1))) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_1) | \
		$(TAR) $(TAR_STRIP_COMPONENTS)=3 --hard-dereference -C $(@D) $(TAR_OPTIONS) -
	$(INFLATE$(suffix $(TOOLCHAIN_EXTERNAL_SOURCE_2))) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE_2) | \
		$(TAR) $(TAR_STRIP_COMPONENTS)=3 --hard-dereference -C $(@D) $(TAR_OPTIONS) -
ifeq ($(TOOLCHAIN_EXTERNAL_PREFIX),bfin-uclinux)
	rm -rf $(TOOLCHAIN_EXTERNAL_DIR)/bfin-linux-uclibc
	mv $(TOOLCHAIN_EXTERNAL_DIR)/bfin-uclinux $(TOOLCHAIN_EXTERNAL_DIR)/tmp
	mv $(TOOLCHAIN_EXTERNAL_DIR)/tmp/* $(TOOLCHAIN_EXTERNAL_DIR)/
	rmdir $(TOOLCHAIN_EXTERNAL_DIR)/tmp
else
	rm -rf $(TOOLCHAIN_EXTERNAL_DIR)/bfin-uclinux
	mv $(TOOLCHAIN_EXTERNAL_DIR)/bfin-linux-uclibc $(TOOLCHAIN_EXTERNAL_DIR)/tmp
	mv $(TOOLCHAIN_EXTERNAL_DIR)/tmp/* $(TOOLCHAIN_EXTERNAL_DIR)/
	rmdir $(TOOLCHAIN_EXTERNAL_DIR)/tmp
endif
	$(Q)touch $@
else
# Download and extraction of a toolchain
$(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE):
	$(call DOWNLOAD,$(TOOLCHAIN_EXTERNAL_SITE),$(TOOLCHAIN_EXTERNAL_SOURCE))

$(TOOLCHAIN_EXTERNAL_DIR)/.extracted: $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE)
	mkdir -p $(@D)
	$(INFLATE$(suffix $(TOOLCHAIN_EXTERNAL_SOURCE))) $^ | \
		$(TAR) $(TAR_STRIP_COMPONENTS)=1 --exclude='usr/lib/locale/*' -C $(@D) $(TAR_OPTIONS) -
	$(Q)touch $@
endif

# Checks for an already installed toolchain: check the toolchain
# location, check that it supports sysroot, and then verify that it
# matches the configuration provided in Buildroot: ABI, C++ support,
# type of C library and all C library features.
$(STAMP_DIR)/ext-toolchain-checked:
	@echo "Checking external toolchain settings"
	$(Q)$(call check_cross_compiler_exists,$(TOOLCHAIN_EXTERNAL_CC))
	$(Q)LIBC_A_LOCATION=`readlink -f $$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) -print-file-name=libc.a)` ; \
	SYSROOT_DIR=`echo $${LIBC_A_LOCATION} | sed -r -e 's:usr/lib(64)?/libc\.a::'` ; \
	if test -z "$${SYSROOT_DIR}" ; then \
		@echo "External toolchain doesn't support --sysroot. Cannot use." ; \
		exit 1 ; \
	fi ; \
	if test x$(BR2_arm) == x"y" ; then \
		$(call check_arm_abi,$(TOOLCHAIN_EXTERNAL_CC)) ; \
	fi ; \
	if test x$(BR2_INSTALL_LIBSTDCPP) == x"y" ; then \
		$(call check_cplusplus,$(TOOLCHAIN_EXTERNAL_CXX)) ; \
	fi ; \
	if test x$(BR2_TOOLCHAIN_EXTERNAL_UCLIBC) == x"y" ; then \
		$(call check_uclibc,$${SYSROOT_DIR}) ; \
	else \
		$(call check_glibc,$${SYSROOT_DIR}) ; \
	fi
	$(Q)touch $@

# Integration of the toolchain into Buildroot: find the main sysroot
# and the variant-specific sysroot, then copy the needed libraries to
# the $(TARGET_DIR) and copy the whole sysroot (libraries and headers)
# to $(STAGING_DIR).
#
# Variables are defined as follows:
#
#  LIBC_A_LOCATION:     location of the libc.a file in the default
#                       multilib variant (allows to find the main
#                       sysroot directory)
#                       Ex: /x-tools/mips-2011.03/mips-linux-gnu/libc/usr/lib/libc.a
#
#  SYSROOT_DIR:         the main sysroot directory, deduced from
#                       LIBC_A_LOCATION by removing the
#                       usr/lib[64]/libc.a part of the path.
#                       Ex: /x-tools/mips-2011.03/mips-linux-gnu/libc/
#
# ARCH_LIBC_A_LOCATION: location of the libc.a file in the selected
#                       multilib variant (taking into account the
#                       CFLAGS). Allows to find the sysroot of the
#                       selected multilib variant.
#                       Ex: /x-tools/mips-2011.03/mips-linux-gnu/libc/mips16/soft-float/el/usr/lib/libc.a
#
# ARCH_SYSROOT_DIR:     the sysroot of the selected multilib variant,
#                       deduced from ARCH_LIBC_A_LOCATION by removing
#                       usr/lib[64]/libc.a at the end of the path.
#                       Ex: /x-tools/mips-2011.03/mips-linux-gnu/libc/mips16/soft-float/el/
#
# ARCH_LIB_DIR:         'lib' or 'lib64' depending on where libraries are
#                       stored. Deduced from ARCH_LIBC_A_LOCATION by
#                       looking at usr/lib??/libc.a.
#                       Ex: lib
#
# ARCH_SUBDIR:          the relative location of the sysroot of the selected
#                       multilib variant compared to the main sysroot.
#			Ex: mips16/soft-float/el

$(STAMP_DIR)/ext-toolchain-installed: $(TOOLCHAIN_EXTERNAL_DEPENDENCIES)
	$(Q)LIBC_A_LOCATION=`readlink -f $$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) -print-file-name=libc.a)` ; \
	SYSROOT_DIR=`echo $${LIBC_A_LOCATION} | sed -r -e 's:usr/lib(64)?/libc\.a::'` ; \
	if test -z "$${SYSROOT_DIR}" ; then \
		@echo "External toolchain doesn't support --sysroot. Cannot use." ; \
		exit 1 ; \
	fi ; \
	ARCH_LIBC_A_LOCATION=`readlink -f $$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS) -print-file-name=libc.a)` ; \
	ARCH_SYSROOT_DIR=`echo $${ARCH_LIBC_A_LOCATION} | sed -r -e 's:usr/lib(64)?/libc\.a::'` ; \
	ARCH_LIB_DIR=`echo $${ARCH_LIBC_A_LOCATION} | sed -r -e 's:.*/usr/(lib(64)?)/libc.a:\1:'` ; \
	ARCH_SUBDIR=`echo $${ARCH_SYSROOT_DIR} | sed -r -e "s:^$${SYSROOT_DIR}(.*)/$$:\1:"` ; \
	mkdir -p $(TARGET_DIR)/lib ; \
	echo "Copy external toolchain libraries to target..." ; \
	for libs in $(LIB_EXTERNAL_LIBS); do \
		$(call copy_toolchain_lib_root,$${ARCH_SYSROOT_DIR},$${ARCH_LIB_DIR},$$libs,/lib); \
	done ; \
	for libs in $(USR_LIB_EXTERNAL_LIBS); do \
		$(call copy_toolchain_lib_root,$${ARCH_SYSROOT_DIR},$${ARCH_LIB_DIR},$$libs,/usr/lib); \
	done ; \
	echo "Copy external toolchain sysroot to staging..." ; \
	$(call copy_toolchain_sysroot,$${SYSROOT_DIR},$${ARCH_SYSROOT_DIR},$${ARCH_SUBDIR},$${ARCH_LIB_DIR}) ; \
	if [ -L $${ARCH_SYSROOT_DIR}/lib64 ] ; then \
		$(call create_lib64_symlinks) ; \
	fi ; \
	touch $@

# Build toolchain wrapper for preprocessor, C and C++ compiler, and setup
# symlinks for everything else
$(HOST_DIR)/usr/bin/ext-toolchain-wrapper: $(STAMP_DIR)/ext-toolchain-installed
	mkdir -p $(HOST_DIR)/usr/bin; cd $(HOST_DIR)/usr/bin; \
	for i in $(TOOLCHAIN_EXTERNAL_CROSS)*; do \
		base=$${i##*/}; \
		case "$$base" in \
		*cc|*cc-*|*++|*++-*|*cpp) \
			ln -sf $(@F) $$base; \
			;; \
		*) \
			ln -sf $$i .; \
			;; \
		esac; \
	done ;
	$(HOSTCC) $(HOST_CFLAGS) $(TOOLCHAIN_EXTERNAL_WRAPPER_ARGS) -s \
		toolchain/toolchain-external/ext-toolchain-wrapper.c -o $@

# 'uclibc' is the target to provide toolchain / staging dir
uclibc: dependencies $(HOST_DIR)/usr/bin/ext-toolchain-wrapper

ifeq ($(BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD),y)
# download ext toolchain if so configured
uclibc-source: $(addprefix $(DL_DIR)/,$(TOOLCHAIN_EXTERNAL_SOURCE))
endif