2 # Copyright (C) 2007-2014 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 include $(TOPDIR
)/rules.mk
12 PKG_MAINTAINER
:=Felix Fietkau
<nbd@nbd.name
>
13 PKG_LICENSE
:=GPL-3.0
-with-GCC-exception
15 PKG_FLAGS
:=hold essential nonshared
17 include $(INCLUDE_DIR
)/package.mk
20 LIBGCC_VERSION
:=$(GCC_VERSION
)
22 LIBC_VERSION
:=<LIBC_VERSION
>
23 LIBGCC_VERSION
:=<LIBGCC_VERSION
>
26 define Package
/gcc
/Default
29 URL
:=http
://gcc.gnu.org
/
30 VERSION
:=$(LIBGCC_VERSION
)-$(PKG_RELEASE
)
34 $(call Package
/gcc
/Default
)
35 TITLE
:=GCC support library
39 define Package
/libgcc
/config
41 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libgcc
43 config LIBGCC_ROOT_DIR
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
50 config LIBGCC_FILE_SPEC
52 prompt
"libgcc shared library files (use wildcards)"
53 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libgcc
54 default
"./lib/libgcc_s.so.*"
59 define Package
/libatomic
60 $(call Package
/gcc
/Default
)
62 TITLE
:=Atomic support library
66 define Package
/libatomic
/config
68 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libatomic
70 config LIBATOMIC_ROOT_DIR
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
77 config LIBATOMIC_FILE_SPEC
79 prompt
"libatomic shared library files (use wildcards)"
80 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libatomic
81 default
"./lib/libatomic.so.*"
86 define Package
/libstdcpp
87 $(call Package
/gcc
/Default
)
89 TITLE
:=GNU Standard C
++ Library v3
93 define Package
/libstdcpp
/config
95 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libstdcpp
97 config LIBSTDCPP_ROOT_DIR
99 prompt
"libstdcpp shared library base directory"
100 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libstdcpp
101 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
102 default
"/" if NATIVE_TOOLCHAIN
104 config LIBSTDCPP_FILE_SPEC
106 prompt
"libstdc++ shared library files (use wildcards)"
107 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libstdcpp
108 default
"./lib/libstdc++.so.*"
114 define Package
/libasan
115 $(call Package
/gcc
/Default
)
117 TITLE
:=Runtime library for AddressSanitizer in GCC
118 DEPENDS
:=@USE_GLIBC
+libstdcpp @
!mips64 @
!mips64el @
!arc
122 define Package
/libasan
/config
124 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libasan
126 config LIBASAN_ROOT_DIR
128 prompt
"libasan shared library base directory"
129 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libasan
130 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
131 default
"/" if NATIVE_TOOLCHAIN
133 config LIBASAN_FILE_SPEC
135 prompt
"libasan shared library files (use wildcards)"
136 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libasan
137 default
"./lib/libasan.so.*"
143 define Package
/libtsan
144 $(call Package
/gcc
/Default
)
146 TITLE
:=Runtime library for ThreadSanitizer in GCC
147 DEPENDS
:=@USE_GLIBC
+libstdcpp @
!mips @
!mipsel @
!mips64 @
!mips64el @
!arc
151 define Package
/libtsan
/config
153 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libtsan
155 config LIBTSAN_ROOT_DIR
157 prompt
"libtsan shared library base directory"
158 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libtsan
159 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
160 default
"/" if NATIVE_TOOLCHAIN
162 config LIBTSAN_FILE_SPEC
164 prompt
"libtsan shared library files (use wildcards)"
165 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libtsan
166 default
"./lib/libtsan.so.*"
172 define Package
/liblsan
173 $(call Package
/gcc
/Default
)
175 TITLE
:=Runtime library for LeakSanitizer in GCC
176 DEPENDS
:=@USE_GLIBC
+libstdcpp @
!mips @
!mipsel @
!mips64 @
!mips64el @
!arc
180 define Package
/liblsan
/config
182 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_liblsan
184 config LIBLSAN_ROOT_DIR
186 prompt
"liblsan shared library base directory"
187 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_liblsan
188 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
189 default
"/" if NATIVE_TOOLCHAIN
191 config LIBLSAN_FILE_SPEC
193 prompt
"liblsan shared library files (use wildcards)"
194 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_liblsan
195 default
"./lib/liblsan.so.*"
201 define Package
/libubsan
202 $(call Package
/gcc
/Default
)
204 TITLE
:=Runtime library for UndefinedBehaviorSanitizer in GCC
205 DEPENDS
:=@USE_GLIBC
+libstdcpp @
!mips64 @
!mips64el @
!arc
209 define Package
/libubsan
/config
211 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libubsan
213 config LIBUBSAN_ROOT_DIR
215 prompt
"libubsan shared library base directory"
216 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libubsan
217 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
218 default
"/" if NATIVE_TOOLCHAIN
220 config LIBUBSAN_FILE_SPEC
222 prompt
"libubsan shared library files (use wildcards)"
223 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libubsan
224 default
"./lib/libubsan.so.*"
230 define Package
/libc
/Default
232 CATEGORY
:=Base system
233 VERSION
:=$(LIBC_VERSION
)-$(PKG_RELEASE
)
240 $(call Package
/libc
/Default
)
242 PROVIDES
:=libpthread librt
245 define Package
/libc
/config
247 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libc
251 prompt
"libc shared library base directory"
252 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libc
253 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
254 default
"/" if NATIVE_TOOLCHAIN
256 config LIBC_FILE_SPEC
258 prompt
"libc shared library files (use wildcards)"
259 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libc
260 default
"./lib/ld{*.so*,-linux*.so.*} ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,pthread,resolv,rt,util}{-*.so,.so.*,.so}"
266 define Package
/libthread-db
267 $(call Package
/libc
/Default
)
269 TITLE
:=POSIX thread library debugging support
272 define Package
/libthread-db
/config
274 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libthread-db
276 config LIBTHREAD_DB_ROOT_DIR
278 prompt
"POSIX thread debugging shared library base directory"
279 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libthread-db
280 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
281 default
"/" if NATIVE_TOOLCHAIN
283 config LIBTHREAD_DB_FILE_SPEC
285 prompt
"POSIX thread debugging shared library files (use wildcards)"
286 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libthread-db
287 default
"./lib/libthread_db{-*.so,.so.*}"
292 define Package
/libgfortran
293 $(call Package
/gcc
/Default
)
294 TITLE
:=GFortran support library
295 DEPENDS
+=@INSTALL_GFORTRAN
298 define Package
/libgfortran
/config
300 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libgfortran
302 config LIBGFORTRAN_ROOT_DIR
304 prompt
"libgfortran shared library base directory"
305 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libgfortran
306 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
307 default
"/" if NATIVE_TOOLCHAIN
309 config LIBGFORTRAN_FILE_SPEC
311 prompt
"libgfortran shared library files (use wildcards)"
312 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libgfortran
313 default
"./usr/lib/libgfortran.so.*"
318 define Package
/libgomp
319 $(call Package
/gcc
/Default
)
320 TITLE
:=OpenMP support library
323 define Package
/libgomp
/config
325 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libgomp
327 config LIBGOMP_ROOT_DIR
329 prompt
"libgomp shared library base directory"
330 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libgomp
331 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
332 default
"/" if NATIVE_TOOLCHAIN
334 config LIBGOMP_FILE_SPEC
336 prompt
"libgomp shared library files (use wildcards)"
337 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libgomp
338 default
"./lib/libgomp.so*"
345 $(call Package
/libc
/Default
)
349 TITLE
:=LDD trace utility
352 define Package
/ldd
/config
354 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_ldd
358 prompt
"ldd trace utility base directory"
359 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_ldd
360 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
361 default
"/" if NATIVE_TOOLCHAIN
365 prompt
"ldd trace utility file"
366 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_ldd
367 default
"./usr/bin/ldd"
373 define Package
/ldconfig
374 $(call Package
/libc
/Default
)
378 TITLE
:=Shared library path configuration
381 define Package
/ldconfig
/config
383 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_ldconfig
385 config LDCONFIG_ROOT_DIR
387 prompt
"ldconfig base directory"
388 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_ldconfig
389 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
390 default
"/" if NATIVE_TOOLCHAIN
392 config LDCONFIG_FILE_SPEC
394 prompt
"ldconfig file"
395 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_ldconfig
396 default
"./sbin/ldconfig"
402 mkdir
-p
$(PKG_BUILD_DIR
)
408 LIBGCC_A
=$(lastword
$(wildcard $(TOOLCHAIN_DIR
)/lib
/gcc
/*/*/libgcc_pic.a
))
409 LIBGCC_MAP
=$(lastword
$(wildcard $(TOOLCHAIN_DIR
)/lib
/gcc
/*/*/libgcc.map
))
410 LIBGCC_SO
=$(lastword
$(wildcard $(TOOLCHAIN_DIR
)/lib
/libgcc_s.so.
*))
412 ifneq ($(LIBGCC_SO
),)
413 define Build
/Compile
/libgcc
414 $(CP
) $(LIBGCC_SO
) $(PKG_BUILD_DIR
)/
418 define Build
/Compile
/Default
419 $(call Build
/Compile
/libgcc
)
420 $(call Build
/Compile
/$(LIBC
))
422 Build
/Compile
= $(Build
/Compile
/Default
)
424 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN
),)
426 define Package
/libgcc
/install
427 $(INSTALL_DIR
) $(1)/lib
428 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libgcc_s.so.
* $(1)/lib
/
431 define Package
/libatomic
/install
432 $(INSTALL_DIR
) $(1)/lib
433 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libatomic.so.
* $(1)/lib
/
436 define Package
/libgfortran
/install
437 $(INSTALL_DIR
) $(1)/usr
/lib
438 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libgfortran.so.
* $(1)/usr
/lib
/
441 define Package
/libstdcpp
/install
442 $(INSTALL_DIR
) $(1)/usr
/lib
443 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libstdc
++.so.
* $(1)/usr
/lib
/
444 rm -rf
$(1)/usr
/lib
/*-gdb.py
447 define Package
/libasan
/install
448 $(INSTALL_DIR
) $(1)/lib
449 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libasan.so.
* $(1)/lib
/
452 define Package
/libtsan
/install
453 $(INSTALL_DIR
) $(1)/lib
454 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libtsan.so.
* $(1)/lib
/
457 define Package
/liblsan
/install
458 $(INSTALL_DIR
) $(1)/lib
459 $(CP
) $(TOOLCHAIN_DIR
)/lib
/liblsan.so.
* $(1)/lib
/
462 define Package
/libubsan
/install
463 $(INSTALL_DIR
) $(1)/lib
464 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libubsan.so.
* $(1)/lib
/
467 define Package
/glibc
/install
468 $(CP
) .
/glibc-files
/* $(1)/
469 rm -f
$(1)/etc
/localtime
470 $(LN
) /tmp
/localtime
$(1)/etc
/localtime
471 $(INSTALL_DIR
) $(1)/lib
473 $(TOOLCHAIN_DIR
)/lib
/ld*.so.
* \
475 for file in libanl libc libcidn libcrypt libdl libm libnsl libnss_dns libnss_files libpthread libresolv librt libutil
; do \
476 for file in
$(TOOLCHAIN_DIR
)/lib
/$$$$file.so.
*; do \
477 if
[ -e
"$$$$file" ]; then \
478 $(CP
) $$$$file $(1)/lib
/; \
484 LD_MUSL_NAME
= $(notdir $(firstword $(wildcard $(TOOLCHAIN_DIR
)/lib
/libc.so
*)))
486 define Package
/musl
/install
487 $(INSTALL_DIR
) $(1)/lib
$(1)/usr
/bin
489 $(TOOLCHAIN_DIR
)/lib
/ld-musl-
*.so
* \
492 $(TOOLCHAIN_DIR
)/lib
/libc.so
* \
494 $(LN
) ..
/..
/lib
/$(LD_MUSL_NAME
) $(1)/usr
/bin
/ldd
497 define Package
/libc
/install
498 $(call Package
/$(LIBC
)/install,$1)
501 define Package
/libc
/install_lib
502 $(CP
) $(filter-out %/libdl_pic.a
%/libpthread_pic.a
%/libresolv_pic.a
,$(wildcard $(TOOLCHAIN_DIR
)/lib
/lib
*.a
)) $(1)/lib
/
503 $(if
$(wildcard $(TOOLCHAIN_DIR
)/lib
/libc_so.a
),$(CP
) $(TOOLCHAIN_DIR
)/lib
/libc_so.a
$(1)/lib
/libc_pic.a
)
504 $(if
$(wildcard $(TOOLCHAIN_DIR
)/lib
/libpthread_so.a
),$(CP
) $(TOOLCHAIN_DIR
)/lib
/libpthread_so.a
$(1)/lib
/libpthread_pic.a
)
505 $(if
$(LIBGCC_MAP
), \
506 $(CP
) $(LIBGCC_A
) $(1)/lib
/libgcc_s_pic.a
; \
507 $(CP
) $(LIBGCC_MAP
) $(1)/lib
/libgcc_s_pic.map \
511 define Package
/libthread-db
/install
512 $(INSTALL_DIR
) $(1)/lib
514 $(TOOLCHAIN_DIR
)/lib
/libthread_db.so.
* $(1)/lib
517 define Package
/ldd
/install
518 $(INSTALL_DIR
) $(1)/usr
/bin
/
519 $(CP
) $(TOOLCHAIN_DIR
)/bin
/ldd
$(1)/usr
/bin
/
520 sed
-i
's,^#!.*,#!/bin/sh,' $(1)/usr
/bin
/ldd
523 define Package
/ldconfig
/install
524 $(INSTALL_DIR
) $(1)/sbin
/
525 $(CP
) $(TOOLCHAIN_DIR
)/sbin
/ldconfig
$(1)/sbin
/
530 define Package
/libgcc
/install
531 for file in
$(call qstrip
,$(CONFIG_LIBGCC_FILE_SPEC
)); do \
532 $(INSTALL_DIR
) $(1)/lib
; \
533 $(CP
) $(call qstrip
,$(CONFIG_LIBGCC_ROOT_DIR
))/$$$$file $(1)/lib
/ ; \
538 define Package
/libgfortran
/install
539 for file in
$(call qstrip
,$(CONFIG_LIBGFORTRAN_FILE_SPEC
)); do \
540 $(INSTALL_DIR
) $(1)/lib
; \
541 $(CP
) $(call qstrip
,$(CONFIG_LIBGFORTRAN_ROOT_DIR
))/$$$$file $(1)/lib
/ ; \
545 define Package
/libstdcpp
/install
546 for file in
$(call qstrip
,$(CONFIG_LIBSTDCPP_FILE_SPEC
)); do \
547 $(INSTALL_DIR
) $(1)/lib
; \
548 $(CP
) $(call qstrip
,$(CONFIG_LIBSTDCPP_ROOT_DIR
))/$$$$file $(1)/lib
/ ; \
553 define Package
/libasan
/install
554 for file in
$(call qstrip
,$(CONFIG_LIBASAN_FILE_SPEC
)); do \
555 $(INSTALL_DIR
) $(1)/lib
; \
556 $(CP
) $(call qstrip
,$(CONFIG_LIBASAN_ROOT_DIR
))/$$$$file $(1)/lib
/ ; \
561 define Package
/libtsan
/install
562 for file in
$(call qstrip
,$(CONFIG_LIBTSAN_FILE_SPEC
)); do \
563 $(INSTALL_DIR
) $(1)/lib
; \
564 $(CP
) $(call qstrip
,$(CONFIG_LIBTSAN_ROOT_DIR
))/$$$$file $(1)/lib
/ ; \
569 define Package
/liblsan
/install
570 for file in
$(call qstrip
,$(CONFIG_LIBLSAN_FILE_SPEC
)); do \
571 $(INSTALL_DIR
) $(1)/lib
; \
572 $(CP
) $(call qstrip
,$(CONFIG_LIBLSAN_ROOT_DIR
))/$$$$file $(1)/lib
/ ; \
577 define Package
/libubsan
/install
578 for file in
$(call qstrip
,$(CONFIG_LIBUBSAN_FILE_SPEC
)); do \
579 $(INSTALL_DIR
) $(1)/lib
; \
580 $(CP
) $(call qstrip
,$(CONFIG_LIBUBSAN_ROOT_DIR
))/$$$$file $(1)/lib
/ ; \
585 define Package
/glibc
/install
588 LD_MUSL_NAME
= $(notdir $(firstword $(wildcard $(TOOLCHAIN_ROOT_DIR
)/lib
/libc.so
*)))
590 define Package
/musl
/install
591 $(INSTALL_DIR
) $(1)/usr
/bin
592 $(LN
) ..
/..
/lib
/$(LD_MUSL_NAME
) $(1)/usr
/bin
/ldd
595 define Package
/libc
/install
596 for file in
$(call qstrip
,$(CONFIG_LIBC_FILE_SPEC
)); do \
597 $(INSTALL_DIR
) $(1)/lib
; \
598 $(CP
) $(call qstrip
,$(CONFIG_LIBC_ROOT_DIR
))/$$$$file $(1)/lib
/ ; \
601 $(call Package
/$(LIBC
)/install,$1)
604 define Package
/libthread-db
/install
605 for file in
$(call qstrip
,$(CONFIG_LIBTHREAD_DB_FILE_SPEC
)); do \
606 $(INSTALL_DIR
) $(1)/lib
; \
607 $(CP
) $(call qstrip
,$(CONFIG_LIBTHREAD_DB_ROOT_DIR
))/$$$$file $(1)/lib
/ ; \
612 define Package
/libatomic
/install
613 for file in
$(call qstrip
,$(CONFIG_LIBATOMIC_FILE_SPEC
)); do \
614 $(INSTALL_DIR
) $(1)/lib
; \
615 $(CP
) $(call qstrip
,$(CONFIG_LIBATOMIC_ROOT_DIR
))/$$$$file $(1)/lib
/ ; \
620 define Package
/libgomp
/install
621 for file in
$(call qstrip
,$(CONFIG_LIBGOMP_FILE_SPEC
)); do \
622 $(INSTALL_DIR
) $(1)/lib
; \
623 $(CP
) $(call qstrip
,$(CONFIG_LIBGOMP_ROOT_DIR
))/$$$$file $(1)/lib
/ ; \
628 define Package
/ldd
/install
629 for file in
$(call qstrip
,$(CONFIG_LDD_FILE_SPEC
)); do \
630 dir=`dirname $$$$file` ; \
631 $(INSTALL_DIR
) $(1)/$$$$dir ; \
632 $(CP
) $(call qstrip
,$(CONFIG_LDD_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
637 define Package
/ldconfig
/install
638 for file in
$(call qstrip
,$(CONFIG_LDCONFIG_FILE_SPEC
)); do \
639 dir=`dirname $$$$file` ; \
640 $(INSTALL_DIR
) $(1)/$$$$dir ; \
641 $(CP
) $(call qstrip
,$(CONFIG_LDCONFIG_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
648 $(eval
$(call BuildPackage
,libc
))
649 $(eval
$(call BuildPackage
,libgcc
))
650 $(eval
$(call BuildPackage
,libatomic
))
651 $(eval
$(call BuildPackage
,libstdcpp
))
652 $(eval
$(call BuildPackage
,libasan
))
653 $(eval
$(call BuildPackage
,libtsan
))
654 $(eval
$(call BuildPackage
,liblsan
))
655 $(eval
$(call BuildPackage
,libubsan
))
656 $(eval
$(call BuildPackage
,libthread-db
))
657 $(eval
$(call BuildPackage
,libgfortran
))
658 $(eval
$(call BuildPackage
,libgomp
))
659 $(eval
$(call BuildPackage
,ldd
))
660 $(eval
$(call BuildPackage
,ldconfig
))