brcm2708: add support for the new Raspberry Pi Zero W
[openwrt/openwrt.git] / package / libs / toolchain / Makefile
1 #
2 # Copyright (C) 2007-2014 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9 PKG_NAME:=toolchain
10 PKG_RELEASE:=1
11
12 PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
13 PKG_LICENSE:=GPL-3.0-with-GCC-exception
14
15 PKG_FLAGS:=hold essential nonshared
16
17 include $(INCLUDE_DIR)/package.mk
18
19 ifneq ($(DUMP),1)
20 LIBGCC_VERSION:=$(GCC_VERSION)
21 else
22 LIBC_VERSION:=<LIBC_VERSION>
23 LIBGCC_VERSION:=<LIBGCC_VERSION>
24 endif
25
26 define Package/gcc/Default
27 SECTION:=libs
28 CATEGORY:=Base system
29 URL:=http://gcc.gnu.org/
30 VERSION:=$(LIBGCC_VERSION)-$(PKG_RELEASE)
31 endef
32
33 define Package/libgcc
34 $(call Package/gcc/Default)
35 TITLE:=GCC support library
36 endef
37
38 define Package/libgcc/config
39 menu "Configuration"
40 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
41
42 config LIBGCC_ROOT_DIR
43 string
44 prompt "libgcc shared library base directory"
45 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
46 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
47 default "/" if NATIVE_TOOLCHAIN
48
49 config LIBGCC_FILE_SPEC
50 string
51 prompt "libgcc shared library files (use wildcards)"
52 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
53 default "./lib/libgcc_s.so.*"
54
55 endmenu
56 endef
57
58 define Package/libatomic
59 $(call Package/gcc/Default)
60 DEPENDS:=+libgcc
61 TITLE:=Atomic support library
62 endef
63
64 define Package/libatomic/config
65 menu "Configuration"
66 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libatomic
67
68 config LIBATOMIC_ROOT_DIR
69 string
70 prompt "libatomic shared library base directory"
71 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libatomic
72 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
73 default "/" if NATIVE_TOOLCHAIN
74
75 config LIBATOMIC_FILE_SPEC
76 string
77 prompt "libatomic shared library files (use wildcards)"
78 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libatomic
79 default "./lib/libatomic.so.*"
80
81 endmenu
82 endef
83
84 define Package/libssp
85 $(call Package/gcc/Default)
86 DEPENDS+=@SSP_SUPPORT
87 TITLE:=GCC support library
88 endef
89
90 define Package/libssp/config
91 menu "Configuration"
92 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libssp
93
94 config LIBSSP_ROOT_DIR
95 string
96 prompt "libssp shared library base directory"
97 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libssp
98 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
99 default "/" if NATIVE_TOOLCHAIN
100
101 config LIBSSP_FILE_SPEC
102 string
103 prompt "libssp shared library files (use wildcards)"
104 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libssp
105 default "./lib/libssp.so.*"
106
107 endmenu
108 endef
109
110
111 define Package/libstdcpp
112 $(call Package/gcc/Default)
113 NAME:=libstdc++
114 TITLE:=GNU Standard C++ Library v3
115 endef
116
117 define Package/libstdcpp/config
118 menu "Configuration"
119 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
120
121 config LIBSTDCPP_ROOT_DIR
122 string
123 prompt "libstdcpp shared library base directory"
124 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
125 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
126 default "/" if NATIVE_TOOLCHAIN
127
128 config LIBSTDCPP_FILE_SPEC
129 string
130 prompt "libstdc++ shared library files (use wildcards)"
131 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
132 default "./lib/libstdc++.so.*"
133
134 endmenu
135 endef
136
137
138 define Package/libc/Default
139 SECTION:=libs
140 CATEGORY:=Base system
141 VERSION:=$(LIBC_VERSION)-$(PKG_RELEASE)
142 DEPENDS:=+libgcc
143 URL:=$(LIBC_URL)
144 endef
145
146
147 define Package/libc
148 $(call Package/libc/Default)
149 TITLE:=C library
150 endef
151
152 define Package/libc/config
153 menu "Configuration"
154 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc
155
156 config LIBC_ROOT_DIR
157 string
158 prompt "libc shared library base directory"
159 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc
160 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
161 default "/" if NATIVE_TOOLCHAIN
162
163 config LIBC_FILE_SPEC
164 string
165 prompt "libc shared library files (use wildcards)"
166 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc
167 default "./lib/ld{*.so*,-linux*.so.*} ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
168
169 endmenu
170 endef
171
172
173 define Package/libpthread
174 $(call Package/libc/Default)
175 TITLE:=POSIX thread library
176 endef
177
178 define Package/libpthread/config
179 menu "Configuration"
180 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
181
182 config LIBPTHREAD_ROOT_DIR
183 string
184 prompt "libpthread shared library base directory"
185 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
186 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
187 default "/" if NATIVE_TOOLCHAIN
188
189 config LIBPTHREAD_FILE_SPEC
190 string
191 prompt "libpthread shared library files (use wildcards)"
192 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
193 default "./lib/libpthread{-*.so,.so.*}"
194
195 endmenu
196 endef
197
198
199 define Package/libthread-db
200 $(call Package/libc/Default)
201 DEPENDS:=@!USE_MUSL
202 TITLE:=POSIX thread library debugging support
203 endef
204
205 define Package/librt
206 $(call Package/libc/Default)
207 TITLE:=POSIX.1b RealTime extension library
208 DEPENDS:=+libpthread
209 endef
210
211 define Package/librt/config
212 menu "Configuration"
213 depends on EXTERNAL_TOOLCHAIN && PACKAGE_librt
214
215 config LIBRT_ROOT_DIR
216 string
217 prompt "librt shared library base directory"
218 depends on EXTERNAL_TOOLCHAIN && PACKAGE_librt
219 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
220 default "/" if NATIVE_TOOLCHAIN
221
222 config LIBRT_FILE_SPEC
223 string
224 prompt "librt shared library files (use wildcards)"
225 depends on EXTERNAL_TOOLCHAIN && PACKAGE_librt
226 default "./lib/librt{-*.so,.so.*}"
227
228 endmenu
229 endef
230
231
232 define Package/libgfortran
233 $(call Package/gcc/Default)
234 TITLE:=GFortran support library
235 DEPENDS+=@INSTALL_GFORTRAN
236 endef
237
238 define Package/libgfortran/config
239 menu "Configuration"
240 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
241
242 config LIBGFORTRAN_ROOT_DIR
243 string
244 prompt "libgfortran shared library base directory"
245 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
246 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
247 default "/" if NATIVE_TOOLCHAIN
248
249 config LIBGFORTRAN_FILE_SPEC
250 string
251 prompt "libgfortran shared library files (use wildcards)"
252 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
253 default "./usr/lib/libgfortran.so.*"
254
255 endmenu
256 endef
257
258 define Package/ldd
259 $(call Package/libc/Default)
260 DEPENDS:=@!USE_MUSL
261 SECTION:=utils
262 CATEGORY:=Utilities
263 TITLE:=LDD trace utility
264 endef
265
266 define Package/ldd/config
267 menu "Configuration"
268 depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldd
269
270 config LDD_ROOT_DIR
271 string
272 prompt "ldd trace utility base directory"
273 depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldd
274 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
275 default "/" if NATIVE_TOOLCHAIN
276
277 config LDD_FILE_SPEC
278 string
279 prompt "ldd trace utility file"
280 depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldd
281 default "./usr/bin/ldd"
282
283 endmenu
284 endef
285
286
287 define Package/ldconfig
288 $(call Package/libc/Default)
289 DEPENDS:=@!USE_MUSL
290 SECTION:=utils
291 CATEGORY:=Utilities
292 TITLE:=Shared library path configuration
293 endef
294
295 define Package/ldconfig/config
296 menu "Configuration"
297 depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
298
299 config LDCONFIG_ROOT_DIR
300 string
301 prompt "ldconfig base directory"
302 depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
303 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
304 default "/" if NATIVE_TOOLCHAIN
305
306 config LDCONFIG_FILE_SPEC
307 string
308 prompt "ldconfig file"
309 depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
310 default "./sbin/ldconfig"
311
312 endmenu
313 endef
314
315 define Build/Prepare
316 mkdir -p $(PKG_BUILD_DIR)
317 endef
318
319 LIBGCC_A=$(lastword $(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc_pic.a))
320 LIBGCC_MAP=$(lastword $(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc.map))
321 LIBGCC_SO=$(lastword $(wildcard $(TOOLCHAIN_DIR)/lib/libgcc_s.so.*))
322
323 define Build/Compile/uClibc
324 $(CP) \
325 $(TOOLCHAIN_DIR)/lib/libuClibc-*.so \
326 $(PKG_BUILD_DIR)/
327 endef
328 ifneq ($(LIBGCC_SO),)
329 define Build/Compile/libgcc
330 $(CP) $(LIBGCC_SO) $(PKG_BUILD_DIR)/
331 endef
332 endif
333
334 define Build/Compile/Default
335 $(call Build/Compile/libgcc)
336 $(call Build/Compile/$(LIBC))
337 endef
338 Build/Compile = $(Build/Compile/Default)
339
340 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
341
342 define Package/libgcc/install
343 $(INSTALL_DIR) $(1)/lib
344 $(CP) $(TOOLCHAIN_DIR)/lib/libgcc_s.so.* $(1)/lib/
345 endef
346
347 define Package/libatomic/install
348 $(INSTALL_DIR) $(1)/lib
349 $(CP) $(TOOLCHAIN_DIR)/lib/libatomic.so.* $(1)/lib/
350 endef
351
352 define Package/libgfortran/install
353 $(INSTALL_DIR) $(1)/usr/lib
354 $(CP) $(TOOLCHAIN_DIR)/lib/libgfortran.so.* $(1)/usr/lib/
355 endef
356
357 define Package/libssp/install
358 $(INSTALL_DIR) $(1)/lib
359 $(CP) $(TOOLCHAIN_DIR)/lib/libssp.so.* $(1)/lib/
360 endef
361
362 define Package/libstdcpp/install
363 $(INSTALL_DIR) $(1)/usr/lib
364 $(CP) $(TOOLCHAIN_DIR)/lib/libstdc++.so.* $(1)/usr/lib/
365 endef
366
367 define Package/glibc/install
368 $(CP) ./glibc-files/* $(1)/
369 rm -f $(1)/etc/localtime
370 $(LN) /tmp/localtime $(1)/etc/localtime
371 $(INSTALL_DIR) $(1)/lib
372 $(CP) \
373 $(TOOLCHAIN_DIR)/lib/ld*.so.* \
374 $(TOOLCHAIN_DIR)/lib/ld-$(LIBC_SO_VERSION).so \
375 $(1)/lib/
376 for file in libanl libc libcidn libcrypt libdl libm libnsl libnss_dns libnss_files libresolv libutil; do \
377 for file in $(TOOLCHAIN_DIR)/lib/$$$$file.so.* $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so; do \
378 if [ -e "$$$$file" ]; then \
379 $(CP) $$$$file $(1)/lib/; \
380 fi; \
381 done; \
382 done
383 endef
384
385 define Package/uClibc/install
386 $(INSTALL_DIR) $(1)/lib
387 $(CP) \
388 $(TOOLCHAIN_DIR)/lib/ld*-uClibc.so.* \
389 $(TOOLCHAIN_DIR)/lib/ld*-uClibc-$(LIBC_SO_VERSION).so \
390 $(1)/lib/
391 $(CP) \
392 $(TOOLCHAIN_DIR)/lib/libc.so.* \
393 $(TOOLCHAIN_DIR)/lib/libuClibc-$(LIBC_SO_VERSION).so \
394 $(1)/lib/
395 $(CP) \
396 $(PKG_BUILD_DIR)/libuClibc-* \
397 $(1)/lib/
398 endef
399
400 LD_MUSL_NAME = $(notdir $(firstword $(wildcard $(TOOLCHAIN_DIR)/lib/libc.so*)))
401
402 define Package/musl/install
403 $(INSTALL_DIR) $(1)/lib $(1)/usr/bin
404 $(CP) \
405 $(TOOLCHAIN_DIR)/lib/ld-musl-*.so* \
406 $(1)/lib/
407 $(CP) \
408 $(TOOLCHAIN_DIR)/lib/libc.so* \
409 $(1)/lib/
410 $(LN) ../../lib/$(LD_MUSL_NAME) $(1)/usr/bin/ldd
411 endef
412
413 define Package/libc/install
414 $(call Package/$(LIBC)/install,$1)
415 endef
416
417 define Package/libc/install_lib
418 $(CP) $(filter-out %/libdl_pic.a %/libpthread_pic.a %/libresolv_pic.a,$(wildcard $(TOOLCHAIN_DIR)/lib/lib*.a)) $(1)/lib/
419 $(if $(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libc_so.a $(1)/lib/libc_pic.a)
420 $(if $(LIBGCC_MAP), \
421 $(CP) $(LIBGCC_A) $(1)/lib/libgcc_s_pic.a; \
422 $(CP) $(LIBGCC_MAP) $(1)/lib/libgcc_s_pic.map \
423 )
424 endef
425
426 define Package/libpthread/install
427 $(INSTALL_DIR) $(1)/lib
428 ifneq ($(CONFIG_USE_MUSL)$(CONFIG_USE_UCLIBC),y)
429 $(CP) \
430 $(TOOLCHAIN_DIR)/lib/libpthread.so.* \
431 $(TOOLCHAIN_DIR)/lib/libpthread-$(LIBC_SO_VERSION).so \
432 $(1)/lib/
433 endif
434 endef
435
436 define Package/libthread-db/install
437 $(INSTALL_DIR) $(1)/lib
438 $(CP) \
439 $(TOOLCHAIN_DIR)/lib/libthread_db.so.* $(1)/lib
440 ifeq ($(CONFIG_USE_UCLIBC),y)
441 $(CP) \
442 $(TOOLCHAIN_DIR)/lib/libthread_db-$(LIBC_SO_VERSION).so \
443 $(1)/lib/
444 endif
445 endef
446
447 define Package/libpthread/install_lib
448 $(if $(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libpthread_so.a $(1)/lib/libpthread_pic.a)
449 endef
450
451 define Package/librt/install
452 $(INSTALL_DIR) $(1)/lib
453 ifneq ($(CONFIG_USE_MUSL)$(CONFIG_USE_UCLIBC),y)
454 $(CP) \
455 $(TOOLCHAIN_DIR)/lib/librt.so.* \
456 $(TOOLCHAIN_DIR)/lib/librt-$(LIBC_SO_VERSION).so \
457 $(1)/lib/
458 endif
459 endef
460
461 define Package/ldd/install
462 $(INSTALL_DIR) $(1)/usr/bin/
463 $(CP) $(TOOLCHAIN_DIR)/bin/ldd $(1)/usr/bin/
464 endef
465
466 define Package/ldconfig/install
467 $(INSTALL_DIR) $(1)/sbin/
468 $(CP) $(TOOLCHAIN_DIR)/sbin/ldconfig $(1)/sbin/
469 endef
470
471 else
472
473 define Package/libgcc/install
474 for file in $(call qstrip,$(CONFIG_LIBGCC_FILE_SPEC)); do \
475 $(INSTALL_DIR) $(1)/lib ; \
476 $(CP) $(call qstrip,$(CONFIG_LIBGCC_ROOT_DIR))/$$$$file $(1)/lib/ ; \
477 done ; \
478 exit 0
479 endef
480
481 define Package/libgfortran/install
482 for file in $(call qstrip,$(CONFIG_LIBGFORTRAN_FILE_SPEC)); do \
483 $(INSTALL_DIR) $(1)/lib ; \
484 $(CP) $(call qstrip,$(CONFIG_LIBGFORTRAN_ROOT_DIR))/$$$$file $(1)/lib/ ; \
485 done
486 endef
487
488 define Package/libssp/install
489 for file in $(call qstrip,$(CONFIG_LIBSSP_FILE_SPEC)); do \
490 $(INSTALL_DIR) $(1)/lib ; \
491 $(CP) $(call qstrip,$(CONFIG_LIBSSP_ROOT_DIR))/$$$$file $(1)/lib/ ; \
492 done ; \
493 exit 0
494 endef
495
496 define Package/libstdcpp/install
497 for file in $(call qstrip,$(CONFIG_LIBSTDCPP_FILE_SPEC)); do \
498 $(INSTALL_DIR) $(1)/lib ; \
499 $(CP) $(call qstrip,$(CONFIG_LIBSTDCPP_ROOT_DIR))/$$$$file $(1)/lib/ ; \
500 done ; \
501 exit 0
502 endef
503
504 define Package/libc/install
505 for file in $(call qstrip,$(CONFIG_LIBC_FILE_SPEC)); do \
506 $(INSTALL_DIR) $(1)/lib ; \
507 $(CP) $(call qstrip,$(CONFIG_LIBC_ROOT_DIR))/$$$$file $(1)/lib/ ; \
508 done ; \
509 exit 0
510 endef
511
512 define Package/libpthread/install
513 for file in $(call qstrip,$(CONFIG_LIBPTHREAD_FILE_SPEC)); do \
514 $(INSTALL_DIR) $(1)/lib ; \
515 $(CP) $(call qstrip,$(CONFIG_LIBPTHREAD_ROOT_DIR))/$$$$file $(1)/lib/ ; \
516 done ; \
517 exit 0
518 endef
519
520 define Package/librt/install
521 for file in $(call qstrip,$(CONFIG_LIBRT_FILE_SPEC)); do \
522 $(INSTALL_DIR) $(1)/lib ; \
523 $(CP) $(call qstrip,$(CONFIG_LIBRT_ROOT_DIR))/$$$$file $(1)/lib/ ; \
524 done ; \
525 exit 0
526 endef
527
528 define Package/libatomic/install
529 for file in $(call qstrip,$(CONFIG_LIBATOMIC_FILE_SPEC)); do \
530 $(INSTALL_DIR) $(1)/lib ; \
531 $(CP) $(call qstrip,$(CONFIG_LIBATOMIC_ROOT_DIR))/$$$$file $(1)/lib/ ; \
532 done ; \
533 exit 0
534 endef
535
536 define Package/ldd/install
537 for file in $(call qstrip,$(CONFIG_LDD_FILE_SPEC)); do \
538 dir=`dirname $$$$file` ; \
539 $(INSTALL_DIR) $(1)/$$$$dir ; \
540 $(CP) $(call qstrip,$(CONFIG_LDD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
541 done ; \
542 exit 0
543 endef
544
545 define Package/ldconfig/install
546 for file in $(call qstrip,$(CONFIG_LDCONFIG_FILE_SPEC)); do \
547 dir=`dirname $$$$file` ; \
548 $(INSTALL_DIR) $(1)/$$$$dir ; \
549 $(CP) $(call qstrip,$(CONFIG_LDCONFIG_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
550 done ; \
551 exit 0
552 endef
553
554 endif
555
556 $(eval $(call BuildPackage,libc))
557 $(eval $(call BuildPackage,libgcc))
558 $(eval $(call BuildPackage,libatomic))
559 $(eval $(call BuildPackage,libssp))
560 $(eval $(call BuildPackage,libstdcpp))
561 $(eval $(call BuildPackage,libpthread))
562 $(eval $(call BuildPackage,libthread-db))
563 $(eval $(call BuildPackage,librt))
564 $(eval $(call BuildPackage,libgfortran))
565 $(eval $(call BuildPackage,ldd))
566 $(eval $(call BuildPackage,ldconfig))