2 # Copyright (C) 2007-2012 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
>
14 include $(INCLUDE_DIR
)/package.mk
17 LIBGCC_VERSION
:=$(GCC_VERSION
)
19 LIBC_VERSION
:=<LIBC_VERSION
>
20 LIBGCC_VERSION
:=<LIBGCC_VERSION
>
23 define Package
/gcc
/Default
26 URL
:=http
://gcc.gnu.org
/
27 VERSION
:=$(LIBGCC_VERSION
)-$(PKG_RELEASE
)
31 $(call Package
/gcc
/Default
)
32 TITLE
:=GCC support library
35 define Package
/libgcc
/config
37 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libgcc
39 config LIBGCC_ROOT_DIR
41 prompt
"libgcc shared library base directory"
42 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libgcc
43 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
44 default
"/" if NATIVE_TOOLCHAIN
46 config LIBGCC_FILE_SPEC
48 prompt
"libgcc shared library files (use wildcards)"
49 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libgcc
50 default
"./lib/libgcc_s.so.*"
57 $(call Package
/gcc
/Default
)
59 TITLE
:=GCC support library
62 define Package
/libssp
/config
64 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libssp
66 config LIBSSP_ROOT_DIR
68 prompt
"libssp shared library base directory"
69 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libssp
70 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
71 default
"/" if NATIVE_TOOLCHAIN
73 config LIBSSP_FILE_SPEC
75 prompt
"libssp shared library files (use wildcards)"
76 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libssp
77 default
"./lib/libssp.so.*"
83 define Package
/libstdcpp
84 $(call Package
/gcc
/Default
)
86 TITLE
:=GNU Standard C
++ Library v3
89 define Package
/libstdcpp
/config
91 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libstdcpp
93 config LIBSTDCPP_ROOT_DIR
95 prompt
"libstdcpp shared library base directory"
96 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libstdcpp
97 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
98 default
"/" if NATIVE_TOOLCHAIN
100 config LIBSTDCPP_FILE_SPEC
102 prompt
"libstdc++ shared library files (use wildcards)"
103 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libstdcpp
104 default
"./lib/libstdc++.so.*"
110 define Package
/libc
/Default
112 CATEGORY
:=Base system
113 VERSION
:=$(LIBC_VERSION
)-$(PKG_RELEASE
)
116 PKG_FLAGS
:=hold essential
121 $(call Package
/libc
/Default
)
125 define Package
/libc
/config
127 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libc
131 prompt
"libc shared library base directory"
132 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libc
133 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
134 default
"/" if NATIVE_TOOLCHAIN
136 config LIBC_FILE_SPEC
138 prompt
"libc shared library files (use wildcards)"
139 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libc
140 default
"./lib/ld{-*.so,-linux*.so.*} ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
146 define Package
/libpthread
147 $(call Package
/libc
/Default
)
148 TITLE
:=POSIX thread library
151 define Package
/libpthread
/config
153 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libpthread
155 config LIBPTHREAD_ROOT_DIR
157 prompt
"libpthread shared library base directory"
158 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libpthread
159 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
160 default
"/" if NATIVE_TOOLCHAIN
162 config LIBPTHREAD_FILE_SPEC
164 prompt
"libpthread shared library files (use wildcards)"
165 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libpthread
166 default
"./lib/libpthread{-*.so,.so.*}"
172 define Package
/libthread-db
173 $(call Package
/libc
/Default
)
175 TITLE
:=POSIX thread library debugging support
179 $(call Package
/libc
/Default
)
180 TITLE
:=POSIX
.1b RealTime extension library
184 define Package
/librt
/config
186 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_librt
188 config LIBRT_ROOT_DIR
190 prompt
"librt shared library base directory"
191 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_librt
192 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
193 default
"/" if NATIVE_TOOLCHAIN
195 config LIBRT_FILE_SPEC
197 prompt
"librt shared library files (use wildcards)"
198 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_librt
199 default
"./lib/librt{-*.so,.so.*}"
205 define Package
/libgfortran
206 $(call Package
/gcc
/Default
)
207 TITLE
:=GFortran support library
208 DEPENDS
+=@INSTALL_GFORTRAN
211 define Package
/libgfortran
/config
213 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libgfortran
215 config LIBGFORTRAN_ROOT_DIR
217 prompt
"libgfortran shared library base directory"
218 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libgfortran
219 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
220 default
"/" if NATIVE_TOOLCHAIN
222 config LIBGFORTRAN_FILE_SPEC
224 prompt
"libgfortran shared library files (use wildcards)"
225 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_libgfortran
226 default
"./usr/lib/libgfortran.so.*"
232 $(call Package
/libc
/Default
)
236 TITLE
:=LDD trace utility
239 define Package
/ldd
/config
241 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_ldd
245 prompt
"ldd trace utility base directory"
246 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_ldd
247 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
248 default
"/" if NATIVE_TOOLCHAIN
252 prompt
"ldd trace utility file"
253 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_ldd
254 default
"./usr/bin/ldd"
260 define Package
/ldconfig
261 $(call Package
/libc
/Default
)
265 TITLE
:=Shared library path configuration
268 define Package
/ldconfig
/config
270 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_ldconfig
272 config LDCONFIG_ROOT_DIR
274 prompt
"ldconfig base directory"
275 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_ldconfig
276 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
277 default
"/" if NATIVE_TOOLCHAIN
279 config LDCONFIG_FILE_SPEC
281 prompt
"ldconfig file"
282 depends on EXTERNAL_TOOLCHAIN
&& PACKAGE_ldconfig
283 default
"./sbin/ldconfig"
289 mkdir
-p
$(PKG_BUILD_DIR
)
292 LIBGCC_A
=$(wildcard $(TOOLCHAIN_DIR
)/lib
/gcc
/*/*/libgcc_pic.a
)
293 LIBGCC_MAP
=$(wildcard $(TOOLCHAIN_DIR
)/lib
/gcc
/*/*/libgcc.map
)
294 LIBGCC_SO
=$(wildcard $(TOOLCHAIN_DIR
)/lib
/libgcc_s.so.
*)
295 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN
),)
296 ifneq ($(if
$(CONFIG_USE_UCLIBC
),$(CONFIG_GCC_VERSION_LINARO
)),)
297 BUILD_LIBGCC
:=$(if
$(CONFIG_avr32
)$(CONFIG_m68k
)$(CONFIG_powerpc
),,$(PKG_BUILD_DIR
)/libgcc_s.so.
*)
301 ifneq ($(BUILD_LIBGCC
),)
302 define Build
/Compile
/uClibc
303 $(SCRIPT_DIR
)/relink-lib.sh \
305 "$(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a)" \
306 "$(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a)" \
307 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libuClibc-*.so))" \
308 -Wl
,-init
,__uClibc_init
-Wl
,-soname
=libc.so
.0 \
310 $(SCRIPT_DIR
)/relink-lib.sh \
312 "$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt-*.so)" \
313 "$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt_pic.a)" \
314 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt-*.so))" \
316 -Wl
,-soname
=libcrypt.so
.0
317 $(SCRIPT_DIR
)/relink-lib.sh \
319 "$(wildcard $(TOOLCHAIN_DIR)/lib/libm-*.so)" \
320 "$(wildcard $(TOOLCHAIN_DIR)/lib/libm_pic.a)" \
321 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libm-*.so))" \
323 -Wl
,-soname
=libm.so
.0
324 $(SCRIPT_DIR
)/relink-lib.sh \
326 "$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread-*.so)" \
327 "$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a)" \
328 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread-*.so))" \
329 -Wl
,-z
,nodelete
,-z
,initfirst
,-init
=__pthread_initialize_minimal_internal \
330 -ldl
-lc
$(BUILD_LIBGCC
) \
331 -Wl
,-soname
=libpthread.so
.0
333 define Build
/Compile
/libgcc
334 $(SCRIPT_DIR
)/relink-lib.sh \
338 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(LIBGCC_SO))" \
339 -Wl
,--version-script
=$(LIBGCC_MAP
) -Wl
,-soname
=libgcc_s.so
.1
342 define Build
/Compile
/uClibc
344 $(TOOLCHAIN_DIR
)/lib
/libuClibc-
*.so \
345 $(TOOLCHAIN_DIR
)/lib
/libcrypt-
*.so \
346 $(TOOLCHAIN_DIR
)/lib
/libm-
*.so \
347 $(TOOLCHAIN_DIR
)/lib
/libpthread-
*.so \
350 ifneq ($(LIBGCC_SO
),)
351 define Build
/Compile
/libgcc
352 $(CP
) $(LIBGCC_SO
) $(PKG_BUILD_DIR
)/
357 define Build
/Compile
/Default
358 $(call Build
/Compile
/libgcc
)
359 $(call Build
/Compile
/$(LIBC
))
361 Build
/Compile
= $(Build
/Compile
/Default
)
363 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN
),)
365 define Package
/libgcc
/install
366 $(INSTALL_DIR
) $(1)/lib
367 $(if
$(CONFIG_TARGET_avr32
)$(CONFIG_TARGET_coldfire
),,$(CP
) $(TOOLCHAIN_DIR
)/lib
/libgcc_s.so.
* $(1)/lib
/)
370 define Package
/libgfortran
/install
371 $(INSTALL_DIR
) $(1)/usr
/lib
372 $(if
$(CONFIG_TARGET_avr32
)$(CONFIG_TARGET_coldfire
),,$(CP
) $(TOOLCHAIN_DIR
)/lib
/libgfortran.so.
* $(1)/usr
/lib
/)
375 define Package
/libssp
/install
376 $(INSTALL_DIR
) $(1)/lib
377 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libssp.so.
* $(1)/lib
/
380 define Package
/libstdcpp
/install
381 $(INSTALL_DIR
) $(1)/usr
/lib
382 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libstdc
++.so.
* $(1)/usr
/lib
/
385 use_libutil
=$(if
$(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP
),libutil
)
386 use_libnsl
=$(if
$(CONFIG_EGLIBC_OPTION_EGLIBC_NIS
),libnsl
)
387 use_nsswitch
=$(if
$(CONFIG_EGLIBC_OPTION_EGLIBC_NSSWITCH
),libnss_dns libnss_files
)
389 define Package
/eglibc
/install
390 $(CP
) .
/eglibc-files
/* $(1)/
391 rm -f
$(1)/etc
/localtime
392 ln
-sf
/tmp
/localtime
$(1)/etc
/localtime
393 $(INSTALL_DIR
) $(1)/lib
395 $(TOOLCHAIN_DIR
)/lib
/ld*.so.
* \
396 $(TOOLCHAIN_DIR
)/lib
/ld-
$(LIBC_SO_VERSION
).so \
398 for file in libanl libc libcidn libcrypt libdl libm
$(use_libnsl
) $(use_nsswitch
) libresolv
$(use_libutil
); do \
399 for file in
$(TOOLCHAIN_DIR
)/lib
/$$$$file.so.
* $(TOOLCHAIN_DIR
)/lib
/$$$$file-$(LIBC_SO_VERSION
).so
; do \
400 if
[ -e
"$$$$file" ]; then \
401 $(CP
) $$$$file $(1)/lib
/; \
407 define Package
/uClibc
/install
408 $(INSTALL_DIR
) $(1)/lib
410 $(TOOLCHAIN_DIR
)/lib
/ld*-uClibc.so.
* \
411 $(TOOLCHAIN_DIR
)/lib
/ld*-uClibc-
$(LIBC_SO_VERSION
).so \
414 $(TOOLCHAIN_DIR
)/lib
/libc.so.
* \
415 $(TOOLCHAIN_DIR
)/lib
/libuClibc-
$(LIBC_SO_VERSION
).so \
417 for file in libcrypt libdl libm libutil
; do \
419 $(TOOLCHAIN_DIR
)/lib
/$$$$file.so.
* \
420 $(TOOLCHAIN_DIR
)/lib
/$$$$file-$(LIBC_SO_VERSION
).so \
425 $(PKG_BUILD_DIR
)/libuClibc-
* \
426 $(PKG_BUILD_DIR
)/libm-
* \
427 $(PKG_BUILD_DIR
)/libcrypt-
* \
431 LD_MUSL_NAME
= $(notdir $(firstword $(wildcard $(TOOLCHAIN_DIR
)/lib
/ld-musl-
*.so
*)))
433 define Package
/musl
/install
434 $(INSTALL_DIR
) $(1)/lib
436 $(TOOLCHAIN_DIR
)/lib
/ld-musl-
*.so
* \
439 $(TOOLCHAIN_DIR
)/lib
/libc.so
* \
441 $(if
$(findstring -sf.so
,$(LD_MUSL_NAME
)),ln
-s
$(LD_MUSL_NAME
) $(1)/lib
/$(subst -sf.so
,.so
,$(LD_MUSL_NAME
)))
444 define Package
/libc
/install
445 $(call Package
/$(LIBC
)/install,$1)
448 define Package
/libc
/install_lib
449 $(CP
) $(filter-out %/libdl_pic.a
%/libpthread_pic.a
%/libresolv_pic.a
,$(wildcard $(TOOLCHAIN_DIR
)/lib
/lib
*.a
)) $(1)/lib
/
450 $(if
$(wildcard $(TOOLCHAIN_DIR
)/lib
/libc_so.a
),$(CP
) $(TOOLCHAIN_DIR
)/lib
/libc_so.a
$(1)/lib
/libc_pic.a
)
451 $(if
$(LIBGCC_MAP
), \
452 $(CP
) $(LIBGCC_A
) $(1)/lib
/libgcc_s_pic.a
; \
453 $(CP
) $(LIBGCC_MAP
) $(1)/lib
/libgcc_s_pic.map \
457 define Package
/libpthread
/install
458 $(INSTALL_DIR
) $(1)/lib
459 ifneq ($(CONFIG_USE_MUSL
),y
)
461 $(TOOLCHAIN_DIR
)/lib
/libpthread.so.
* \
462 $(if
$(BUILD_LIBGCC
),\
463 $(PKG_BUILD_DIR
)/libpthread-
$(LIBC_SO_VERSION
).so
, \
464 $(TOOLCHAIN_DIR
)/lib
/libpthread-
$(LIBC_SO_VERSION
).so \
470 define Package
/libthread-db
/install
471 $(INSTALL_DIR
) $(1)/lib
473 $(TOOLCHAIN_DIR
)/lib
/libthread_db.so.
* $(1)/lib
474 ifeq ($(USE_UCLIBC
),y
)
476 $(TOOLCHAIN_DIR
)/lib
/libthread_db-
$(LIBC_SO_VERSION
).so \
481 define Package
/libpthread
/install_lib
482 $(if
$(wildcard $(TOOLCHAIN_DIR
)/lib
/libpthread_so.a
),$(CP
) $(TOOLCHAIN_DIR
)/lib
/libpthread_so.a
$(1)/lib
/libpthread_pic.a
)
485 define Package
/librt
/install
486 $(INSTALL_DIR
) $(1)/lib
487 ifneq ($(CONFIG_USE_MUSL
),y
)
489 $(TOOLCHAIN_DIR
)/lib
/librt.so.
* \
490 $(TOOLCHAIN_DIR
)/lib
/librt-
$(LIBC_SO_VERSION
).so \
495 define Package
/ldd
/install
496 $(INSTALL_DIR
) $(1)/usr
/bin
/
497 $(CP
) $(TOOLCHAIN_DIR
)/bin
/ldd
$(1)/usr
/bin
/
500 define Package
/ldconfig
/install
501 $(INSTALL_DIR
) $(1)/sbin
/
502 $(CP
) $(TOOLCHAIN_DIR
)/sbin
/ldconfig
$(1)/sbin
/
507 define Package
/libgcc
/install
508 for file in
$(call qstrip
,$(CONFIG_LIBGCC_FILE_SPEC
)); do \
509 dir=`dirname $$$$file` ; \
510 $(INSTALL_DIR
) $(1)/$$$$dir ; \
511 $(CP
) $(call qstrip
,$(CONFIG_LIBGCC_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
516 define Package
/libgfortran
/install
517 for file in
$(call qstrip
,$(CONFIG_LIBGFORTRAN_FILE_SPEC
)); do \
518 dir=`dirname $$$$file` ; \
519 $(INSTALL_DIR
) $(1)/$$$$dir ; \
520 $(CP
) $(call qstrip
,$(CONFIG_LIBGFORTRAN_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
524 define Package
/libssp
/install
525 for file in
$(call qstrip
,$(CONFIG_LIBSSP_FILE_SPEC
)); do \
526 dir=`dirname $$$$file` ; \
527 $(INSTALL_DIR
) $(1)/$$$$dir ; \
528 $(CP
) $(call qstrip
,$(CONFIG_LIBSSP_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
533 define Package
/libstdcpp
/install
534 for file in
$(call qstrip
,$(CONFIG_LIBSTDCPP_FILE_SPEC
)); do \
535 dir=`dirname $$$$file` ; \
536 $(INSTALL_DIR
) $(1)/$$$$dir ; \
537 $(CP
) $(call qstrip
,$(CONFIG_LIBSTDCPP_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
542 define Package
/libc
/install
543 for file in
$(call qstrip
,$(CONFIG_LIBC_FILE_SPEC
)); do \
544 dir=`dirname $$$$file` ; \
545 $(INSTALL_DIR
) $(1)/$$$$dir ; \
546 $(CP
) $(call qstrip
,$(CONFIG_LIBC_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
551 define Package
/libpthread
/install
552 for file in
$(call qstrip
,$(CONFIG_LIBPTHREAD_FILE_SPEC
)); do \
553 dir=`dirname $$$$file` ; \
554 $(INSTALL_DIR
) $(1)/$$$$dir ; \
555 $(CP
) $(call qstrip
,$(CONFIG_LIBPTHREAD_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
560 define Package
/librt
/install
561 for file in
$(call qstrip
,$(CONFIG_LIBRT_FILE_SPEC
)); do \
562 dir=`dirname $$$$file` ; \
563 $(INSTALL_DIR
) $(1)/$$$$dir ; \
564 $(CP
) $(call qstrip
,$(CONFIG_LIBRT_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
569 define Package
/ldd
/install
570 for file in
$(call qstrip
,$(CONFIG_LDD_FILE_SPEC
)); do \
571 dir=`dirname $$$$file` ; \
572 $(INSTALL_DIR
) $(1)/$$$$dir ; \
573 $(CP
) $(call qstrip
,$(CONFIG_LDD_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
578 define Package
/ldconfig
/install
579 for file in
$(call qstrip
,$(CONFIG_LDCONFIG_FILE_SPEC
)); do \
580 dir=`dirname $$$$file` ; \
581 $(INSTALL_DIR
) $(1)/$$$$dir ; \
582 $(CP
) $(call qstrip
,$(CONFIG_LDCONFIG_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
589 $(eval
$(call BuildPackage
,libc
))
590 $(eval
$(call BuildPackage
,libgcc
))
591 $(eval
$(call BuildPackage
,libssp
))
592 $(eval
$(call BuildPackage
,libstdcpp
))
593 $(eval
$(call BuildPackage
,libpthread
))
594 $(eval
$(call BuildPackage
,libthread-db
))
595 $(eval
$(call BuildPackage
,librt
))
596 $(eval
$(call BuildPackage
,libgfortran
))
597 $(eval
$(call BuildPackage
,ldd
))
598 $(eval
$(call BuildPackage
,ldconfig
))