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@openwrt.org
>
13 PKG_LICENSE
:=GPL-3.0
-with-GCC-exception
15 include $(INCLUDE_DIR
)/package.mk
18 LIBGCC_VERSION
:=$(GCC_VERSION
)
20 LIBC_VERSION
:=<LIBC_VERSION
>
21 LIBGCC_VERSION
:=<LIBGCC_VERSION
>
24 define Package
/gcc
/Default
27 URL
:=http
://gcc.gnu.org
/
28 VERSION
:=$(LIBGCC_VERSION
)-$(PKG_RELEASE
)
32 $(call Package
/gcc
/Default
)
33 TITLE
:=GCC support library
36 define Package
/libgcc
/config
38 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libgcc
40 config LIBGCC_ROOT_DIR
42 prompt
"libgcc shared library base directory"
43 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libgcc
44 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
45 default
"/" if NATIVE_TOOLCHAIN
47 config LIBGCC_FILE_SPEC
49 prompt
"libgcc shared library files (use wildcards)"
50 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libgcc
51 default
"./lib/libgcc_s.so.*"
56 define Package
/libatomic
57 $(call Package
/gcc
/Default
)
59 TITLE
:=Atomic support library
62 define Package
/libatomic
/config
64 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libatomic
66 config LIBATOMIC_ROOT_DIR
68 prompt
"libatomic shared library base directory"
69 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libatomic
70 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
71 default
"/" if NATIVE_TOOLCHAIN
73 config LIBATOMIC_FILE_SPEC
75 prompt
"libatomic shared library files (use wildcards)"
76 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libatomic
77 default
"./lib/libatomic.so.*"
83 $(call Package
/gcc
/Default
)
85 TITLE
:=GCC support library
88 define Package
/libssp
/config
90 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libssp
92 config LIBSSP_ROOT_DIR
94 prompt
"libssp shared library base directory"
95 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libssp
96 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
97 default
"/" if NATIVE_TOOLCHAIN
99 config LIBSSP_FILE_SPEC
101 prompt
"libssp shared library files (use wildcards)"
102 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libssp
103 default
"./lib/libssp.so.*"
109 define Package
/libstdcpp
110 $(call Package
/gcc
/Default
)
112 TITLE
:=GNU Standard C
++ Library v3
115 define Package
/libstdcpp
/config
117 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libstdcpp
119 config LIBSTDCPP_ROOT_DIR
121 prompt
"libstdcpp shared library base directory"
122 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libstdcpp
123 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
124 default
"/" if NATIVE_TOOLCHAIN
126 config LIBSTDCPP_FILE_SPEC
128 prompt
"libstdc++ shared library files (use wildcards)"
129 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libstdcpp
130 default
"./lib/libstdc++.so.*"
136 define Package
/libc
/Default
138 CATEGORY
:=Base system
139 VERSION
:=$(LIBC_VERSION
)-$(PKG_RELEASE
)
142 PKG_FLAGS
:=hold essential
147 $(call Package
/libc
/Default
)
151 define Package
/libc
/config
153 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libc
157 prompt
"libc shared library base directory"
158 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libc
159 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
160 default
"/" if NATIVE_TOOLCHAIN
162 config LIBC_FILE_SPEC
164 prompt
"libc shared library files (use wildcards)"
165 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libc
166 default
"./lib/ld{-*.so,-linux*.so.*} ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
172 define Package
/libpthread
173 $(call Package
/libc
/Default
)
174 TITLE
:=POSIX thread library
177 define Package
/libpthread
/config
179 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libpthread
181 config LIBPTHREAD_ROOT_DIR
183 prompt
"libpthread shared library base directory"
184 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libpthread
185 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
186 default
"/" if NATIVE_TOOLCHAIN
188 config LIBPTHREAD_FILE_SPEC
190 prompt
"libpthread shared library files (use wildcards)"
191 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libpthread
192 default
"./lib/libpthread{-*.so,.so.*}"
198 define Package
/libthread-db
199 $(call Package
/libc
/Default
)
201 TITLE
:=POSIX thread library debugging support
205 $(call Package
/libc
/Default
)
206 TITLE
:=POSIX
.1b RealTime extension library
210 define Package
/librt
/config
212 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_librt
214 config LIBRT_ROOT_DIR
216 prompt
"librt shared library base directory"
217 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_librt
218 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
219 default
"/" if NATIVE_TOOLCHAIN
221 config LIBRT_FILE_SPEC
223 prompt
"librt shared library files (use wildcards)"
224 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_librt
225 default
"./lib/librt{-*.so,.so.*}"
231 define Package
/libgfortran
232 $(call Package
/gcc
/Default
)
233 TITLE
:=GFortran support library
234 DEPENDS
+=@INSTALL_GFORTRAN
237 define Package
/libgfortran
/config
239 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libgfortran
241 config LIBGFORTRAN_ROOT_DIR
243 prompt
"libgfortran shared library base directory"
244 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libgfortran
245 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
246 default
"/" if NATIVE_TOOLCHAIN
248 config LIBGFORTRAN_FILE_SPEC
250 prompt
"libgfortran shared library files (use wildcards)"
251 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libgfortran
252 default
"./usr/lib/libgfortran.so.*"
258 $(call Package
/libc
/Default
)
262 TITLE
:=LDD trace utility
265 define Package
/ldd
/config
267 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_ldd
271 prompt
"ldd trace utility base directory"
272 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_ldd
273 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
274 default
"/" if NATIVE_TOOLCHAIN
278 prompt
"ldd trace utility file"
279 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_ldd
280 default
"./usr/bin/ldd"
286 define Package
/ldconfig
287 $(call Package
/libc
/Default
)
291 TITLE
:=Shared library path configuration
294 define Package
/ldconfig
/config
296 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_ldconfig
298 config LDCONFIG_ROOT_DIR
300 prompt
"ldconfig base directory"
301 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_ldconfig
302 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
303 default
"/" if NATIVE_TOOLCHAIN
305 config LDCONFIG_FILE_SPEC
307 prompt
"ldconfig file"
308 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_ldconfig
309 default
"./sbin/ldconfig"
315 mkdir
-p
$(PKG_BUILD_DIR
)
318 LIBGCC_A
=$(lastword
$(wildcard $(TOOLCHAIN_DIR
)/lib
/gcc
/*/*/libgcc_pic.a
))
319 LIBGCC_MAP
=$(lastword
$(wildcard $(TOOLCHAIN_DIR
)/lib
/gcc
/*/*/libgcc.map
))
320 LIBGCC_SO
=$(lastword
$(wildcard $(TOOLCHAIN_DIR
)/lib
/libgcc_s.so.
*))
322 define Build
/Compile
/uClibc
324 $(TOOLCHAIN_DIR
)/lib
/libuClibc-
*.so \
325 $(TOOLCHAIN_DIR
)/lib
/libcrypt-
*.so \
326 $(TOOLCHAIN_DIR
)/lib
/libm-
*.so \
327 $(TOOLCHAIN_DIR
)/lib
/libpthread-
*.so \
330 ifneq ($(LIBGCC_SO
),)
331 define Build
/Compile
/libgcc
332 $(CP
) $(LIBGCC_SO
) $(PKG_BUILD_DIR
)/
336 define Build
/Compile
/Default
337 $(call Build
/Compile
/libgcc
)
338 $(call Build
/Compile
/$(LIBC
))
340 Build
/Compile
= $(Build
/Compile
/Default
)
342 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN
),)
344 define Package
/libgcc
/install
345 $(INSTALL_DIR
) $(1)/lib
346 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libgcc_s.so.
* $(1)/lib
/
349 define Package
/libatomic
/install
350 $(INSTALL_DIR
) $(1)/lib
351 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libatomic.so.
* $(1)/lib
/
354 define Package
/libgfortran
/install
355 $(INSTALL_DIR
) $(1)/usr
/lib
356 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libgfortran.so.
* $(1)/usr
/lib
/
359 define Package
/libssp
/install
360 $(INSTALL_DIR
) $(1)/lib
361 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libssp.so.
* $(1)/lib
/
364 define Package
/libstdcpp
/install
365 $(INSTALL_DIR
) $(1)/usr
/lib
366 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libstdc
++.so.
* $(1)/usr
/lib
/
369 use_libutil
=$(if
$(CONFIG_GLIBC_USE_VERSION_2_21
)$(CONFIG_GLIBC_USE_VERSION_2_22
)$(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP
),libutil
)
370 use_libnsl
=$(if
$(CONFIG_GLIBC_USE_VERSION_2_21
)$(CONFIG_GLIBC_USE_VERSION_2_22
)$(CONFIG_EGLIBC_OPTION_EGLIBC_NIS
),libnsl
)
371 use_nsswitch
=$(if
$(CONFIG_GLIBC_USE_VERSION_2_21
)$(CONFIG_GLIBC_USE_VERSION_2_22
)$(CONFIG_EGLIBC_OPTION_EGLIBC_NSSWITCH
),libnss_dns libnss_files
)
373 define Package
/glibc
/install
374 $(CP
) .
/glibc-files
/* $(1)/
375 rm -f
$(1)/etc
/localtime
376 $(LN
) /tmp
/localtime
$(1)/etc
/localtime
377 $(INSTALL_DIR
) $(1)/lib
379 $(TOOLCHAIN_DIR
)/lib
/ld*.so.
* \
380 $(TOOLCHAIN_DIR
)/lib
/ld-
$(LIBC_SO_VERSION
).so \
382 for file in libanl libc libcidn libcrypt libdl libm
$(use_libnsl
) $(use_nsswitch
) libresolv
$(use_libutil
); do \
383 for file in
$(TOOLCHAIN_DIR
)/lib
/$$$$file.so.
* $(TOOLCHAIN_DIR
)/lib
/$$$$file-$(LIBC_SO_VERSION
).so
; do \
384 if
[ -e
"$$$$file" ]; then \
385 $(CP
) $$$$file $(1)/lib
/; \
391 define Package
/uClibc
/install
392 $(INSTALL_DIR
) $(1)/lib
394 $(TOOLCHAIN_DIR
)/lib
/ld*-uClibc.so.
* \
395 $(TOOLCHAIN_DIR
)/lib
/ld*-uClibc-
$(LIBC_SO_VERSION
).so \
398 $(TOOLCHAIN_DIR
)/lib
/libc.so.
* \
399 $(TOOLCHAIN_DIR
)/lib
/libuClibc-
$(LIBC_SO_VERSION
).so \
401 for file in libcrypt libdl libm libutil
; do \
403 $(TOOLCHAIN_DIR
)/lib
/$$$$file.so.
* \
404 $(TOOLCHAIN_DIR
)/lib
/$$$$file-$(LIBC_SO_VERSION
).so \
409 $(PKG_BUILD_DIR
)/libuClibc-
* \
410 $(PKG_BUILD_DIR
)/libm-
* \
411 $(PKG_BUILD_DIR
)/libcrypt-
* \
415 LD_MUSL_NAME
= $(notdir $(firstword $(wildcard $(TOOLCHAIN_DIR
)/lib
/libc.so
*)))
417 define Package
/musl
/install
418 $(INSTALL_DIR
) $(1)/lib
$(1)/usr
/bin
420 $(TOOLCHAIN_DIR
)/lib
/ld-musl-
*.so
* \
423 $(TOOLCHAIN_DIR
)/lib
/libc.so
* \
425 $(LN
) ..
/..
/lib
/$(LD_MUSL_NAME
) $(1)/usr
/bin
/ldd
428 define Package
/libc
/install
429 $(call Package
/$(LIBC
)/install,$1)
432 define Package
/libc
/install_lib
433 $(CP
) $(filter-out %/libdl_pic.a
%/libpthread_pic.a
%/libresolv_pic.a
,$(wildcard $(TOOLCHAIN_DIR
)/lib
/lib
*.a
)) $(1)/lib
/
434 $(if
$(wildcard $(TOOLCHAIN_DIR
)/lib
/libc_so.a
),$(CP
) $(TOOLCHAIN_DIR
)/lib
/libc_so.a
$(1)/lib
/libc_pic.a
)
435 $(if
$(LIBGCC_MAP
), \
436 $(CP
) $(LIBGCC_A
) $(1)/lib
/libgcc_s_pic.a
; \
437 $(CP
) $(LIBGCC_MAP
) $(1)/lib
/libgcc_s_pic.map \
441 define Package
/libpthread
/install
442 $(INSTALL_DIR
) $(1)/lib
443 ifneq ($(CONFIG_USE_MUSL
),y
)
445 $(TOOLCHAIN_DIR
)/lib
/libpthread.so.
* \
446 $(TOOLCHAIN_DIR
)/lib
/libpthread-
$(LIBC_SO_VERSION
).so \
451 define Package
/libthread-db
/install
452 $(INSTALL_DIR
) $(1)/lib
454 $(TOOLCHAIN_DIR
)/lib
/libthread_db.so.
* $(1)/lib
455 ifeq ($(CONFIG_USE_UCLIBC
),y
)
457 $(TOOLCHAIN_DIR
)/lib
/libthread_db-
$(LIBC_SO_VERSION
).so \
462 define Package
/libpthread
/install_lib
463 $(if
$(wildcard $(TOOLCHAIN_DIR
)/lib
/libpthread_so.a
),$(CP
) $(TOOLCHAIN_DIR
)/lib
/libpthread_so.a
$(1)/lib
/libpthread_pic.a
)
466 define Package
/librt
/install
467 $(INSTALL_DIR
) $(1)/lib
468 ifneq ($(CONFIG_USE_MUSL
),y
)
470 $(TOOLCHAIN_DIR
)/lib
/librt.so.
* \
471 $(TOOLCHAIN_DIR
)/lib
/librt-
$(LIBC_SO_VERSION
).so \
476 define Package
/ldd
/install
477 $(INSTALL_DIR
) $(1)/usr
/bin
/
478 $(CP
) $(TOOLCHAIN_DIR
)/bin
/ldd
$(1)/usr
/bin
/
481 define Package
/ldconfig
/install
482 $(INSTALL_DIR
) $(1)/sbin
/
483 $(CP
) $(TOOLCHAIN_DIR
)/sbin
/ldconfig
$(1)/sbin
/
488 define Package
/libgcc
/install
489 for file in
$(call qstrip
,$(CONFIG_LIBGCC_FILE_SPEC
)); do \
490 dir=`dirname $$$$file` ; \
491 $(INSTALL_DIR
) $(1)/$$$$dir ; \
492 $(CP
) $(call qstrip
,$(CONFIG_LIBGCC_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
497 define Package
/libgfortran
/install
498 for file in
$(call qstrip
,$(CONFIG_LIBGFORTRAN_FILE_SPEC
)); do \
499 dir=`dirname $$$$file` ; \
500 $(INSTALL_DIR
) $(1)/$$$$dir ; \
501 $(CP
) $(call qstrip
,$(CONFIG_LIBGFORTRAN_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
505 define Package
/libssp
/install
506 for file in
$(call qstrip
,$(CONFIG_LIBSSP_FILE_SPEC
)); do \
507 dir=`dirname $$$$file` ; \
508 $(INSTALL_DIR
) $(1)/$$$$dir ; \
509 $(CP
) $(call qstrip
,$(CONFIG_LIBSSP_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
514 define Package
/libstdcpp
/install
515 for file in
$(call qstrip
,$(CONFIG_LIBSTDCPP_FILE_SPEC
)); do \
516 dir=`dirname $$$$file` ; \
517 $(INSTALL_DIR
) $(1)/$$$$dir ; \
518 $(CP
) $(call qstrip
,$(CONFIG_LIBSTDCPP_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
523 define Package
/libc
/install
524 for file in
$(call qstrip
,$(CONFIG_LIBC_FILE_SPEC
)); do \
525 dir=`dirname $$$$file` ; \
526 $(INSTALL_DIR
) $(1)/$$$$dir ; \
527 $(CP
) $(call qstrip
,$(CONFIG_LIBC_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
532 define Package
/libpthread
/install
533 for file in
$(call qstrip
,$(CONFIG_LIBPTHREAD_FILE_SPEC
)); do \
534 dir=`dirname $$$$file` ; \
535 $(INSTALL_DIR
) $(1)/$$$$dir ; \
536 $(CP
) $(call qstrip
,$(CONFIG_LIBPTHREAD_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
541 define Package
/librt
/install
542 for file in
$(call qstrip
,$(CONFIG_LIBRT_FILE_SPEC
)); do \
543 dir=`dirname $$$$file` ; \
544 $(INSTALL_DIR
) $(1)/$$$$dir ; \
545 $(CP
) $(call qstrip
,$(CONFIG_LIBRT_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
550 define Package
/libatomic
/install
551 for file in
$(call qstrip
,$(CONFIG_LIBATOMIC_FILE_SPEC
)); do \
552 dir=`dirname $$$$file` ; \
553 $(INSTALL_DIR
) $(1)/$$$$dir ; \
554 $(CP
) $(call qstrip
,$(CONFIG_LIBATOMIC_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
559 define Package
/ldd
/install
560 for file in
$(call qstrip
,$(CONFIG_LDD_FILE_SPEC
)); do \
561 dir=`dirname $$$$file` ; \
562 $(INSTALL_DIR
) $(1)/$$$$dir ; \
563 $(CP
) $(call qstrip
,$(CONFIG_LDD_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
568 define Package
/ldconfig
/install
569 for file in
$(call qstrip
,$(CONFIG_LDCONFIG_FILE_SPEC
)); do \
570 dir=`dirname $$$$file` ; \
571 $(INSTALL_DIR
) $(1)/$$$$dir ; \
572 $(CP
) $(call qstrip
,$(CONFIG_LDCONFIG_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
579 $(eval
$(call BuildPackage
,libc
))
580 $(eval
$(call BuildPackage
,libgcc
))
581 $(eval
$(call BuildPackage
,libatomic
))
582 $(eval
$(call BuildPackage
,libssp
))
583 $(eval
$(call BuildPackage
,libstdcpp
))
584 $(eval
$(call BuildPackage
,libpthread
))
585 $(eval
$(call BuildPackage
,libthread-db
))
586 $(eval
$(call BuildPackage
,librt
))
587 $(eval
$(call BuildPackage
,libgfortran
))
588 $(eval
$(call BuildPackage
,ldd
))
589 $(eval
$(call BuildPackage
,ldconfig
))