toolchain: gcc: enable sanitizers for glibc toolchain
[oweals/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:=2
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   ABI_VERSION:=1
37 endef
38
39 define Package/libgcc/config
40         menu "Configuration"
41                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
42
43         config LIBGCC_ROOT_DIR
44                 string
45                 prompt "libgcc shared library base directory"
46                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
47                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
48                 default "/"  if NATIVE_TOOLCHAIN
49
50         config LIBGCC_FILE_SPEC
51                 string
52                 prompt "libgcc shared library files (use wildcards)"
53                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
54                 default "./lib/libgcc_s.so.*"
55
56         endmenu
57 endef
58
59 define Package/libatomic
60 $(call Package/gcc/Default)
61   DEPENDS:=+libgcc
62   TITLE:=Atomic support library
63   ABI_VERSION:=1
64 endef
65
66 define Package/libatomic/config
67         menu "Configuration"
68                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libatomic
69
70         config LIBATOMIC_ROOT_DIR
71                 string
72                 prompt "libatomic shared library base directory"
73                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libatomic
74                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
75                 default "/"  if NATIVE_TOOLCHAIN
76
77         config LIBATOMIC_FILE_SPEC
78                 string
79                 prompt "libatomic shared library files (use wildcards)"
80                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libatomic
81                 default "./lib/libatomic.so.*"
82
83         endmenu
84 endef
85
86 define Package/libssp
87 $(call Package/gcc/Default)
88   DEPENDS+=@GCC_LIBSSP
89   TITLE:=GCC support library
90 endef
91
92 define Package/libssp/config
93         menu "Configuration"
94                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libssp
95
96         config LIBSSP_ROOT_DIR
97                 string
98                 prompt "libssp shared library base directory"
99                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libssp
100                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
101                 default "/"  if NATIVE_TOOLCHAIN
102
103         config LIBSSP_FILE_SPEC
104                 string
105                 prompt "libssp shared library files (use wildcards)"
106                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libssp
107                 default "./lib/libssp.so.*"
108
109         endmenu
110 endef
111
112
113 define Package/libstdcpp
114 $(call Package/gcc/Default)
115   NAME:=libstdc++
116   TITLE:=GNU Standard C++ Library v3
117   ABI_VERSION:=6
118 endef
119
120 define Package/libstdcpp/config
121         menu "Configuration"
122         depends on EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
123
124         config LIBSTDCPP_ROOT_DIR
125                 string
126                 prompt "libstdcpp shared library base directory"
127                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
128                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
129                 default "/"  if NATIVE_TOOLCHAIN
130
131         config LIBSTDCPP_FILE_SPEC
132                 string
133                 prompt "libstdc++ shared library files (use wildcards)"
134                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
135                 default "./lib/libstdc++.so.*"
136
137         endmenu
138 endef
139
140
141 define Package/libasan
142 $(call Package/gcc/Default)
143   NAME:=libasan
144   TITLE:=Runtime library for AddressSanitizer in GCC
145   DEPENDS:=@USE_GLIBC +librt +libstdcpp
146   ABI_VERSION:=5
147 endef
148
149 define Package/libasan/config
150         menu "Configuration"
151         depends on EXTERNAL_TOOLCHAIN && PACKAGE_libasan
152
153         config LIBASAN_ROOT_DIR
154                 string
155                 prompt "libasan shared library base directory"
156                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libasan
157                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
158                 default "/"  if NATIVE_TOOLCHAIN
159
160         config LIBASAN_FILE_SPEC
161                 string
162                 prompt "libasan shared library files (use wildcards)"
163                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libasan
164                 default "./lib/libasan.so.*"
165
166         endmenu
167 endef
168
169
170 define Package/libtsan
171 $(call Package/gcc/Default)
172   NAME:=libtsan
173   TITLE:=Runtime library for ThreadSanitizer in GCC
174   DEPENDS:=@USE_GLIBC +librt +libstdcpp
175   ABI_VERSION:=0
176 endef
177
178 define Package/libtsan/config
179         menu "Configuration"
180         depends on EXTERNAL_TOOLCHAIN && PACKAGE_libtsan
181
182         config LIBTSAN_ROOT_DIR
183                 string
184                 prompt "libtsan shared library base directory"
185                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libtsan
186                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
187                 default "/"  if NATIVE_TOOLCHAIN
188
189         config LIBTSAN_FILE_SPEC
190                 string
191                 prompt "libtsan shared library files (use wildcards)"
192                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libtsan
193                 default "./lib/libtsan.so.*"
194
195         endmenu
196 endef
197
198
199 define Package/liblsan
200 $(call Package/gcc/Default)
201   NAME:=liblsan
202   TITLE:=Runtime library for LeakSanitizer in GCC
203   DEPENDS:=@USE_GLIBC +librt +libstdcpp
204   ABI_VERSION:=0
205 endef
206
207 define Package/liblsan/config
208         menu "Configuration"
209         depends on EXTERNAL_TOOLCHAIN && PACKAGE_liblsan
210
211         config LIBLSAN_ROOT_DIR
212                 string
213                 prompt "liblsan shared library base directory"
214                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_liblsan
215                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
216                 default "/"  if NATIVE_TOOLCHAIN
217
218         config LIBLSAN_FILE_SPEC
219                 string
220                 prompt "liblsan shared library files (use wildcards)"
221                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_liblsan
222                 default "./lib/liblsan.so.*"
223
224         endmenu
225 endef
226
227
228 define Package/libubsan
229 $(call Package/gcc/Default)
230   NAME:=libubsan
231   TITLE:=Runtime library for UndefinedBehaviorSanitizer in GCC
232   DEPENDS:=@USE_GLIBC +librt +libstdcpp
233   ABI_VERSION:=1
234 endef
235
236 define Package/libubsan/config
237         menu "Configuration"
238         depends on EXTERNAL_TOOLCHAIN && PACKAGE_libubsan
239
240         config LIBUBSAN_ROOT_DIR
241                 string
242                 prompt "libubsan shared library base directory"
243                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libubsan
244                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
245                 default "/"  if NATIVE_TOOLCHAIN
246
247         config LIBUBSAN_FILE_SPEC
248                 string
249                 prompt "libubsan shared library files (use wildcards)"
250                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libubsan
251                 default "./lib/libubsan.so.*"
252
253         endmenu
254 endef
255
256
257 define Package/libc/Default
258   SECTION:=libs
259   CATEGORY:=Base system
260   VERSION:=$(LIBC_VERSION)-$(PKG_RELEASE)
261   DEPENDS:=+libgcc
262   URL:=$(LIBC_URL)
263 endef
264
265
266 define Package/libc
267 $(call Package/libc/Default)
268   TITLE:=C library
269 endef
270
271 define Package/libc/config
272         menu "Configuration"
273         depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc
274
275         config LIBC_ROOT_DIR
276                 string
277                 prompt "libc shared library base directory"
278                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc
279                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
280                 default "/"  if NATIVE_TOOLCHAIN
281
282         config LIBC_FILE_SPEC
283                 string
284                 prompt "libc shared library files (use wildcards)"
285                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc
286                 default "./lib/ld{*.so*,-linux*.so.*} ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*,.so}"
287
288         endmenu
289 endef
290
291
292 define Package/libpthread
293 $(call Package/libc/Default)
294   TITLE:=POSIX thread library
295 endef
296
297 define Package/libpthread/config
298         menu "Configuration"
299         depends on EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
300
301         config LIBPTHREAD_ROOT_DIR
302                 string
303                 prompt "libpthread shared library base directory"
304                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
305                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
306                 default "/"  if NATIVE_TOOLCHAIN
307
308         config LIBPTHREAD_FILE_SPEC
309                 string
310                 prompt "libpthread shared library files (use wildcards)"
311                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
312                 default "./lib/libpthread{-*.so,.so.*}"
313
314         endmenu
315 endef
316
317
318 define Package/libthread-db
319 $(call Package/libc/Default)
320   DEPENDS:=@!USE_MUSL
321   TITLE:=POSIX thread library debugging support
322 endef
323
324 define Package/libthread-db/config
325         menu "Configuration"
326         depends on EXTERNAL_TOOLCHAIN && PACKAGE_libthread-db
327
328         config LIBTHREAD_DB_ROOT_DIR
329                 string
330                 prompt "POSIX thread debugging shared library base directory"
331                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libthread-db
332                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
333                 default "/"  if NATIVE_TOOLCHAIN
334
335         config LIBTHREAD_DB_FILE_SPEC
336                 string
337                 prompt "POSIX thread debugging shared library files (use wildcards)"
338                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libthread-db
339                 default "./lib/libthread_db{-*.so,.so.*}"
340
341         endmenu
342 endef
343
344 define Package/librt
345 $(call Package/libc/Default)
346   TITLE:=POSIX.1b RealTime extension library
347   DEPENDS:=+libpthread
348 endef
349
350 define Package/librt/config
351         menu "Configuration"
352         depends on EXTERNAL_TOOLCHAIN && PACKAGE_librt
353
354         config LIBRT_ROOT_DIR
355                 string
356                 prompt "librt shared library base directory"
357                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_librt
358                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
359                 default "/"  if NATIVE_TOOLCHAIN
360
361         config LIBRT_FILE_SPEC
362                 string
363                 prompt "librt shared library files (use wildcards)"
364                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_librt
365                 default "./lib/librt{-*.so,.so.*}"
366
367         endmenu
368 endef
369
370
371 define Package/libgfortran
372 $(call Package/gcc/Default)
373   TITLE:=GFortran support library
374   DEPENDS+=@INSTALL_GFORTRAN
375 endef
376
377 define Package/libgfortran/config
378         menu "Configuration"
379                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
380
381         config LIBGFORTRAN_ROOT_DIR
382                 string
383                 prompt "libgfortran shared library base directory"
384                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
385                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
386                 default "/"  if NATIVE_TOOLCHAIN
387
388         config LIBGFORTRAN_FILE_SPEC
389                 string
390                 prompt "libgfortran shared library files (use wildcards)"
391                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
392                 default "./usr/lib/libgfortran.so.*"
393
394         endmenu
395 endef
396
397 define Package/libgomp
398 $(call Package/gcc/Default)
399   TITLE:=OpenMP support library
400 endef
401
402 define Package/libgomp/config
403         menu "Configuration"
404                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgomp
405
406         config LIBGOMP_ROOT_DIR
407                 string
408                 prompt "libgomp shared library base directory"
409                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgomp
410                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
411                 default "/"  if NATIVE_TOOLCHAIN
412
413         config LIBGOMP_FILE_SPEC
414                 string
415                 prompt "libgomp shared library files (use wildcards)"
416                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgomp
417                 default "./lib/libgomp.so*"
418
419         endmenu
420 endef
421
422
423 define Package/ldd
424 $(call Package/libc/Default)
425   DEPENDS:=@!USE_MUSL
426   SECTION:=utils
427   CATEGORY:=Utilities
428   TITLE:=LDD trace utility
429 endef
430
431 define Package/ldd/config
432         menu "Configuration"
433                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldd
434
435         config LDD_ROOT_DIR
436                 string
437                 prompt "ldd trace utility base directory"
438                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldd
439                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
440                 default "/"  if NATIVE_TOOLCHAIN
441
442         config LDD_FILE_SPEC
443                 string
444                 prompt "ldd trace utility file"
445                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldd
446                 default "./usr/bin/ldd"
447
448         endmenu
449 endef
450
451
452 define Package/ldconfig
453 $(call Package/libc/Default)
454   DEPENDS:=@!USE_MUSL
455   SECTION:=utils
456   CATEGORY:=Utilities
457   TITLE:=Shared library path configuration
458 endef
459
460 define Package/ldconfig/config
461         menu "Configuration"
462                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
463
464         config LDCONFIG_ROOT_DIR
465                 string
466                 prompt "ldconfig base directory"
467                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
468                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
469                 default "/"  if NATIVE_TOOLCHAIN
470
471         config LDCONFIG_FILE_SPEC
472                 string
473                 prompt "ldconfig file"
474                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
475                 default "./sbin/ldconfig"
476
477         endmenu
478 endef
479
480 define Build/Prepare
481         mkdir -p $(PKG_BUILD_DIR)
482 endef
483
484 LIBGCC_A=$(lastword $(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc_pic.a))
485 LIBGCC_MAP=$(lastword $(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc.map))
486 LIBGCC_SO=$(lastword $(wildcard $(TOOLCHAIN_DIR)/lib/libgcc_s.so.*))
487
488 define Build/Compile/uClibc
489         $(CP) \
490                 $(TOOLCHAIN_DIR)/lib/libuClibc-*.so \
491                 $(PKG_BUILD_DIR)/
492 endef
493 ifneq ($(LIBGCC_SO),)
494     define Build/Compile/libgcc
495         $(CP) $(LIBGCC_SO) $(PKG_BUILD_DIR)/
496     endef
497 endif
498
499 define Build/Compile/Default
500         $(call Build/Compile/libgcc)
501         $(call Build/Compile/$(LIBC))
502 endef
503 Build/Compile = $(Build/Compile/Default)
504
505 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
506
507   define Package/libgcc/install
508         $(INSTALL_DIR) $(1)/lib
509         $(CP) $(TOOLCHAIN_DIR)/lib/libgcc_s.so.* $(1)/lib/
510   endef
511
512   define Package/libatomic/install
513         $(INSTALL_DIR) $(1)/lib
514         $(CP) $(TOOLCHAIN_DIR)/lib/libatomic.so.* $(1)/lib/
515   endef
516
517   define Package/libgfortran/install
518         $(INSTALL_DIR) $(1)/usr/lib
519         $(CP) $(TOOLCHAIN_DIR)/lib/libgfortran.so.* $(1)/usr/lib/
520   endef
521
522   define Package/libssp/install
523         $(INSTALL_DIR) $(1)/lib
524         $(CP) $(TOOLCHAIN_DIR)/lib/libssp.so.* $(1)/lib/
525   endef
526
527   define Package/libstdcpp/install
528         $(INSTALL_DIR) $(1)/usr/lib
529         $(CP) $(TOOLCHAIN_DIR)/lib/libstdc++.so.* $(1)/usr/lib/
530   endef
531
532   define Package/libasan/install
533         $(INSTALL_DIR) $(1)/lib
534         $(CP) $(TOOLCHAIN_DIR)/lib/libasan.so.* $(1)/lib/
535   endef
536
537   define Package/libtsan/install
538         $(INSTALL_DIR) $(1)/lib
539         $(CP) $(TOOLCHAIN_DIR)/lib/libtsan.so.* $(1)/lib/
540   endef
541
542   define Package/liblsan/install
543         $(INSTALL_DIR) $(1)/lib
544         $(CP) $(TOOLCHAIN_DIR)/lib/liblsan.so.* $(1)/lib/
545   endef
546
547   define Package/libubsan/install
548         $(INSTALL_DIR) $(1)/lib
549         $(CP) $(TOOLCHAIN_DIR)/lib/libubsan.so.* $(1)/lib/
550   endef
551
552   define Package/glibc/install
553         $(CP) ./glibc-files/* $(1)/
554         rm -f $(1)/etc/localtime
555         $(LN) /tmp/localtime $(1)/etc/localtime
556         $(INSTALL_DIR) $(1)/lib
557         $(CP) \
558                 $(TOOLCHAIN_DIR)/lib/ld*.so.* \
559                 $(TOOLCHAIN_DIR)/lib/ld-$(LIBC_SO_VERSION).so \
560                 $(1)/lib/
561         for file in libanl libc libcidn libcrypt libdl libm libnsl libnss_dns libnss_files libresolv libutil; do \
562                 for file in $(TOOLCHAIN_DIR)/lib/$$$$file.so.* $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so; do \
563                         if [ -e "$$$$file" ]; then \
564                                 $(CP) $$$$file $(1)/lib/; \
565                         fi; \
566                 done; \
567         done
568   endef
569
570   define Package/uClibc/install
571         $(INSTALL_DIR) $(1)/lib
572         $(CP) \
573                 $(TOOLCHAIN_DIR)/lib/ld*-uClibc.so.* \
574                 $(TOOLCHAIN_DIR)/lib/ld*-uClibc-$(LIBC_SO_VERSION).so \
575                 $(1)/lib/
576         $(CP) \
577                 $(TOOLCHAIN_DIR)/lib/libc.so.* \
578                 $(TOOLCHAIN_DIR)/lib/libuClibc-$(LIBC_SO_VERSION).so \
579                 $(1)/lib/
580         $(CP) \
581                 $(PKG_BUILD_DIR)/libuClibc-* \
582                 $(1)/lib/
583   endef
584
585   LD_MUSL_NAME = $(notdir $(firstword $(wildcard $(TOOLCHAIN_DIR)/lib/libc.so*)))
586
587   define Package/musl/install
588         $(INSTALL_DIR) $(1)/lib $(1)/usr/bin
589         $(CP) \
590                 $(TOOLCHAIN_DIR)/lib/ld-musl-*.so* \
591                 $(1)/lib/
592         $(CP) \
593                 $(TOOLCHAIN_DIR)/lib/libc.so* \
594                 $(1)/lib/
595         $(LN) ../../lib/$(LD_MUSL_NAME) $(1)/usr/bin/ldd
596   endef
597
598   define Package/libc/install
599     $(call Package/$(LIBC)/install,$1)
600   endef
601
602   define Package/libc/install_lib
603         $(CP) $(filter-out %/libdl_pic.a %/libpthread_pic.a %/libresolv_pic.a,$(wildcard $(TOOLCHAIN_DIR)/lib/lib*.a)) $(1)/lib/
604         $(if $(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libc_so.a $(1)/lib/libc_pic.a)
605         $(if $(LIBGCC_MAP), \
606                 $(CP) $(LIBGCC_A) $(1)/lib/libgcc_s_pic.a; \
607                 $(CP) $(LIBGCC_MAP) $(1)/lib/libgcc_s_pic.map \
608         )
609   endef
610
611   define Package/libpthread/install
612         $(INSTALL_DIR) $(1)/lib
613   ifneq ($(CONFIG_USE_MUSL)$(CONFIG_USE_UCLIBC),y)
614         $(CP) \
615                 $(TOOLCHAIN_DIR)/lib/libpthread.so.* \
616                 $(TOOLCHAIN_DIR)/lib/libpthread-$(LIBC_SO_VERSION).so \
617                 $(1)/lib/
618   endif
619   endef
620
621   define Package/libthread-db/install
622         $(INSTALL_DIR) $(1)/lib
623         $(CP) \
624                 $(TOOLCHAIN_DIR)/lib/libthread_db.so.* $(1)/lib
625   ifeq ($(CONFIG_USE_UCLIBC),y)
626         $(CP) \
627                 $(TOOLCHAIN_DIR)/lib/libthread_db-$(LIBC_SO_VERSION).so \
628                 $(1)/lib/
629   endif
630   endef
631
632   define Package/libpthread/install_lib
633         $(if $(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libpthread_so.a $(1)/lib/libpthread_pic.a)
634   endef
635
636   define Package/librt/install
637         $(INSTALL_DIR) $(1)/lib
638   ifneq ($(CONFIG_USE_MUSL)$(CONFIG_USE_UCLIBC),y)
639         $(CP) \
640                 $(TOOLCHAIN_DIR)/lib/librt.so.* \
641                 $(TOOLCHAIN_DIR)/lib/librt-$(LIBC_SO_VERSION).so \
642                 $(1)/lib/
643   endif
644   endef
645
646   define Package/ldd/install
647         $(INSTALL_DIR) $(1)/usr/bin/
648         $(CP) $(TOOLCHAIN_DIR)/bin/ldd $(1)/usr/bin/
649   endef
650
651   define Package/ldconfig/install
652         $(INSTALL_DIR) $(1)/sbin/
653         $(CP) $(TOOLCHAIN_DIR)/sbin/ldconfig $(1)/sbin/
654   endef
655
656 else
657
658   define Package/libgcc/install
659         for file in $(call qstrip,$(CONFIG_LIBGCC_FILE_SPEC)); do \
660                 $(INSTALL_DIR) $(1)/lib ; \
661                 $(CP) $(call qstrip,$(CONFIG_LIBGCC_ROOT_DIR))/$$$$file $(1)/lib/ ; \
662         done ; \
663         exit 0
664   endef
665
666   define Package/libgfortran/install
667         for file in $(call qstrip,$(CONFIG_LIBGFORTRAN_FILE_SPEC)); do \
668                 $(INSTALL_DIR) $(1)/lib ; \
669                 $(CP) $(call qstrip,$(CONFIG_LIBGFORTRAN_ROOT_DIR))/$$$$file $(1)/lib/ ; \
670         done
671   endef
672
673   define Package/libssp/install
674         for file in $(call qstrip,$(CONFIG_LIBSSP_FILE_SPEC)); do \
675                 $(INSTALL_DIR) $(1)/lib ; \
676                 $(CP) $(call qstrip,$(CONFIG_LIBSSP_ROOT_DIR))/$$$$file $(1)/lib/ ; \
677         done ; \
678         exit 0
679   endef
680
681   define Package/libstdcpp/install
682         for file in $(call qstrip,$(CONFIG_LIBSTDCPP_FILE_SPEC)); do \
683                 $(INSTALL_DIR) $(1)/lib ; \
684                 $(CP) $(call qstrip,$(CONFIG_LIBSTDCPP_ROOT_DIR))/$$$$file $(1)/lib/ ; \
685         done ; \
686         exit 0
687   endef
688
689   define Package/libasan/install
690         for file in $(call qstrip,$(CONFIG_LIBASAN_FILE_SPEC)); do \
691                 $(INSTALL_DIR) $(1)/lib ; \
692                 $(CP) $(call qstrip,$(CONFIG_LIBASAN_ROOT_DIR))/$$$$file $(1)/lib/ ; \
693         done ; \
694         exit 0
695   endef
696
697   define Package/libtsan/install
698         for file in $(call qstrip,$(CONFIG_LIBTSAN_FILE_SPEC)); do \
699                 $(INSTALL_DIR) $(1)/lib ; \
700                 $(CP) $(call qstrip,$(CONFIG_LIBTSAN_ROOT_DIR))/$$$$file $(1)/lib/ ; \
701         done ; \
702         exit 0
703   endef
704
705   define Package/liblsan/install
706         for file in $(call qstrip,$(CONFIG_LIBLSAN_FILE_SPEC)); do \
707                 $(INSTALL_DIR) $(1)/lib ; \
708                 $(CP) $(call qstrip,$(CONFIG_LIBLSAN_ROOT_DIR))/$$$$file $(1)/lib/ ; \
709         done ; \
710         exit 0
711   endef
712
713   define Package/libubsan/install
714         for file in $(call qstrip,$(CONFIG_LIBUBSAN_FILE_SPEC)); do \
715                 $(INSTALL_DIR) $(1)/lib ; \
716                 $(CP) $(call qstrip,$(CONFIG_LIBUBSAN_ROOT_DIR))/$$$$file $(1)/lib/ ; \
717         done ; \
718         exit 0
719   endef
720
721   define Package/libc/install
722         for file in $(call qstrip,$(CONFIG_LIBC_FILE_SPEC)); do \
723                 $(INSTALL_DIR) $(1)/lib ; \
724                 $(CP) $(call qstrip,$(CONFIG_LIBC_ROOT_DIR))/$$$$file $(1)/lib/ ; \
725         done ; \
726         exit 0
727   endef
728
729   define Package/libpthread/install
730         for file in $(call qstrip,$(CONFIG_LIBPTHREAD_FILE_SPEC)); do \
731                 $(INSTALL_DIR) $(1)/lib ; \
732                 $(CP) $(call qstrip,$(CONFIG_LIBPTHREAD_ROOT_DIR))/$$$$file $(1)/lib/ ; \
733         done ; \
734         exit 0
735   endef
736
737   define Package/libthread-db/install
738         for file in $(call qstrip,$(CONFIG_LIBTHREAD_DB_FILE_SPEC)); do \
739                 $(INSTALL_DIR) $(1)/lib ; \
740                 $(CP) $(call qstrip,$(CONFIG_LIBTHREAD_DB_ROOT_DIR))/$$$$file $(1)/lib/ ; \
741         done ; \
742         exit 0
743   endef
744
745   define Package/librt/install
746         for file in $(call qstrip,$(CONFIG_LIBRT_FILE_SPEC)); do \
747                 $(INSTALL_DIR) $(1)/lib ; \
748                 $(CP) $(call qstrip,$(CONFIG_LIBRT_ROOT_DIR))/$$$$file $(1)/lib/ ; \
749         done ; \
750         exit 0
751   endef
752
753   define Package/libatomic/install
754         for file in $(call qstrip,$(CONFIG_LIBATOMIC_FILE_SPEC)); do \
755                 $(INSTALL_DIR) $(1)/lib ; \
756                 $(CP) $(call qstrip,$(CONFIG_LIBATOMIC_ROOT_DIR))/$$$$file $(1)/lib/ ; \
757         done ; \
758         exit 0
759   endef
760
761   define Package/libgomp/install
762         for file in $(call qstrip,$(CONFIG_LIBGOMP_FILE_SPEC)); do \
763                 $(INSTALL_DIR) $(1)/lib ; \
764                 $(CP) $(call qstrip,$(CONFIG_LIBGOMP_ROOT_DIR))/$$$$file $(1)/lib/ ; \
765         done ; \
766         exit 0
767   endef
768
769   define Package/ldd/install
770         for file in $(call qstrip,$(CONFIG_LDD_FILE_SPEC)); do \
771                 dir=`dirname $$$$file` ; \
772                 $(INSTALL_DIR) $(1)/$$$$dir ; \
773                 $(CP) $(call qstrip,$(CONFIG_LDD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
774         done ; \
775         exit 0
776   endef
777
778   define Package/ldconfig/install
779         for file in $(call qstrip,$(CONFIG_LDCONFIG_FILE_SPEC)); do \
780                 dir=`dirname $$$$file` ; \
781                 $(INSTALL_DIR) $(1)/$$$$dir ; \
782                 $(CP) $(call qstrip,$(CONFIG_LDCONFIG_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
783         done ; \
784         exit 0
785   endef
786
787 endif
788
789 $(eval $(call BuildPackage,libc))
790 $(eval $(call BuildPackage,libgcc))
791 $(eval $(call BuildPackage,libatomic))
792 $(eval $(call BuildPackage,libssp))
793 $(eval $(call BuildPackage,libstdcpp))
794 $(eval $(call BuildPackage,libasan))
795 $(eval $(call BuildPackage,libtsan))
796 $(eval $(call BuildPackage,liblsan))
797 $(eval $(call BuildPackage,libubsan))
798 $(eval $(call BuildPackage,libpthread))
799 $(eval $(call BuildPackage,libthread-db))
800 $(eval $(call BuildPackage,librt))
801 $(eval $(call BuildPackage,libgfortran))
802 $(eval $(call BuildPackage,libgomp))
803 $(eval $(call BuildPackage,ldd))
804 $(eval $(call BuildPackage,ldconfig))