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 include $(INCLUDE_DIR
)/package.mk
15 LIBGCC_VERSION
:=$(GCC_VERSION
)
17 LIBC_VERSION
:=<LIBC_VERSION
>
18 LIBGCC_VERSION
:=<LIBGCC_VERSION
>
21 define Package
/gcc
/Default
24 URL
:=http
://gcc.gnu.org
/
25 VERSION
:=$(LIBGCC_VERSION
)-$(PKG_RELEASE
)
29 $(call Package
/gcc
/Default
)
30 TITLE
:=GCC support library
33 define Package
/libgcc
/config
35 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libgcc
37 config LIBGCC_ROOT_DIR
39 prompt
"libgcc shared library base directory"
40 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libgcc
41 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
42 default
"/" if NATIVE_TOOLCHAIN
44 config LIBGCC_FILE_SPEC
46 prompt
"libgcc shared library files (use wildcards)"
47 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libgcc
48 default
"./lib/libgcc_s.so.*"
55 $(call Package
/gcc
/Default
)
57 TITLE
:=GCC support library
60 define Package
/libssp
/config
62 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libssp
64 config LIBSSP_ROOT_DIR
66 prompt
"libssp shared library base directory"
67 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libssp
68 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
69 default
"/" if NATIVE_TOOLCHAIN
71 config LIBSSP_FILE_SPEC
73 prompt
"libssp shared library files (use wildcards)"
74 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libssp
75 default
"./lib/libssp.so.*"
81 define Package
/libstdcpp
82 $(call Package
/gcc
/Default
)
84 TITLE
:=GNU Standard C
++ Library v3
85 DEPENDS
+=@INSTALL_LIBSTDCPP
88 define Package
/libstdcpp
/config
90 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libstdcpp
92 config LIBSTDCPP_ROOT_DIR
94 prompt
"libstdcpp shared library base directory"
95 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libstdcpp
96 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
97 default
"/" if NATIVE_TOOLCHAIN
99 config LIBSTDCPP_FILE_SPEC
101 prompt
"libstdc++ shared library files (use wildcards)"
102 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libstdcpp
103 default
"./lib/libstdc++.so.*"
109 define Package
/libc
/Default
111 CATEGORY
:=Base system
112 VERSION
:=$(LIBC_VERSION
)-$(PKG_RELEASE
)
115 PKG_FLAGS
:=hold essential
120 $(call Package
/libc
/Default
)
124 define Package
/libc
/config
126 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libc
130 prompt
"libc shared library base directory"
131 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libc
132 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
133 default
"/" if NATIVE_TOOLCHAIN
135 config LIBC_FILE_SPEC
137 prompt
"libc shared library files (use wildcards)"
138 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libc
139 default
"./lib/ld{-*.so,-linux*.so.*} ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
145 define Package
/libpthread
146 $(call Package
/libc
/Default
)
147 TITLE
:=POSIX thread library
150 define Package
/libpthread
/config
152 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libpthread
154 config LIBPTHREAD_ROOT_DIR
156 prompt
"libpthread shared library base directory"
157 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libpthread
158 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
159 default
"/" if NATIVE_TOOLCHAIN
161 config LIBPTHREAD_FILE_SPEC
163 prompt
"libpthread shared library files (use wildcards)"
164 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libpthread
165 default
"./lib/libpthread{-*.so,.so.*}"
172 $(call Package
/libc
/Default
)
173 TITLE
:=POSIX
.1b RealTime extension library
177 define Package
/librt
/config
179 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_librt
181 config LIBRT_ROOT_DIR
183 prompt
"librt shared library base directory"
184 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_librt
185 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
186 default
"/" if NATIVE_TOOLCHAIN
188 config LIBRT_FILE_SPEC
190 prompt
"librt shared library files (use wildcards)"
191 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_librt
192 default
"./lib/librt{-*.so,.so.*}"
198 define Package
/libgfortran
199 $(call Package
/gcc
/Default
)
200 TITLE
:=GFortran support library
201 DEPENDS
+=@INSTALL_GFORTRAN
204 define Package
/libgfortran
/config
206 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libgfortran
208 config LIBGFORTRAN_ROOT_DIR
210 prompt
"libgfortran shared library base directory"
211 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libgfortran
212 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
213 default
"/" if NATIVE_TOOLCHAIN
215 config LIBGFORTRAN_FILE_SPEC
217 prompt
"libgfortran shared library files (use wildcards)"
218 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_libgfortran
219 default
"./usr/lib/libgfortran.so.*"
225 $(call Package
/libc
/Default
)
228 TITLE
:=LDD trace utility
231 define Package
/ldd
/config
233 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldd
237 prompt
"ldd trace utility base directory"
238 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldd
239 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
240 default
"/" if NATIVE_TOOLCHAIN
244 prompt
"ldd trace utility file"
245 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldd
246 default
"./usr/bin/ldd"
252 define Package
/ldconfig
253 $(call Package
/libc
/Default
)
256 TITLE
:=Shared library path configuration
259 define Package
/ldconfig
/config
261 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldconfig
263 config LDCONFIG_ROOT_DIR
265 prompt
"ldconfig base directory"
266 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldconfig
267 default TOOLCHAIN_ROOT if
!NATIVE_TOOLCHAIN
268 default
"/" if NATIVE_TOOLCHAIN
270 config LDCONFIG_FILE_SPEC
272 prompt
"ldconfig file"
273 depends EXTERNAL_TOOLCHAIN
&& PACKAGE_ldconfig
274 default
"./sbin/ldconfig"
280 mkdir
-p
$(PKG_BUILD_DIR
)
283 LIBGCC_A
=$(wildcard $(TOOLCHAIN_DIR
)/lib
/gcc
/*/*/libgcc_pic.a
)
284 LIBGCC_MAP
=$(wildcard $(TOOLCHAIN_DIR
)/lib
/gcc
/*/*/libgcc.map
)
285 LIBGCC_SO
=$(wildcard $(TOOLCHAIN_DIR
)/lib
/libgcc_s.so.
*)
286 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN
),)
287 ifneq ($(if
$(CONFIG_USE_UCLIBC
),$(CONFIG_GCC_VERSION_LINARO
)),)
288 BUILD_LIBGCC
:=$(if
$(CONFIG_avr32
)$(CONFIG_m68k
)$(CONFIG_powerpc
),,$(PKG_BUILD_DIR
)/libgcc_s.so.
*)
292 ifneq ($(BUILD_LIBGCC
),)
293 define Build
/Compile
/uClibc
294 $(SCRIPT_DIR
)/relink-lib.sh \
296 "$(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a)" \
297 "$(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a)" \
298 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libuClibc-*.so))" \
299 -Wl
,-init
,__uClibc_init
-Wl
,-soname
=libc.so
.0 \
301 $(SCRIPT_DIR
)/relink-lib.sh \
303 "$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt-*.so)" \
304 "$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt_pic.a)" \
305 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt-*.so))" \
307 -Wl
,-soname
=libcrypt.so
.0
308 $(SCRIPT_DIR
)/relink-lib.sh \
310 "$(wildcard $(TOOLCHAIN_DIR)/lib/libm-*.so)" \
311 "$(wildcard $(TOOLCHAIN_DIR)/lib/libm_pic.a)" \
312 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libm-*.so))" \
314 -Wl
,-soname
=libm.so
.0
315 $(SCRIPT_DIR
)/relink-lib.sh \
317 "$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread-*.so)" \
318 "$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a)" \
319 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread-*.so))" \
320 -Wl
,-z
,nodelete
,-z
,initfirst
,-init
=__pthread_initialize_minimal_internal \
321 -ldl
-lc
$(BUILD_LIBGCC
) \
322 -Wl
,-soname
=libpthread.so
.0
324 define Build
/Compile
/libgcc
325 $(SCRIPT_DIR
)/relink-lib.sh \
329 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(LIBGCC_SO))" \
330 -Wl
,--version-script
=$(LIBGCC_MAP
) -Wl
,-soname
=libgcc_s.so
.1
333 define Build
/Compile
/uClibc
335 $(TOOLCHAIN_DIR
)/lib
/libuClibc-
*.so \
336 $(TOOLCHAIN_DIR
)/lib
/libcrypt-
*.so \
337 $(TOOLCHAIN_DIR
)/lib
/libm-
*.so \
338 $(TOOLCHAIN_DIR
)/lib
/libpthread-
*.so \
341 ifneq ($(LIBGCC_SO
),)
342 define Build
/Compile
/libgcc
343 $(CP
) $(LIBGCC_SO
) $(PKG_BUILD_DIR
)/
348 define Build
/Compile
/Default
349 $(call Build
/Compile
/libgcc
)
350 $(call Build
/Compile
/$(LIBC
))
352 Build
/Compile
= $(Build
/Compile
/Default
)
354 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN
),)
356 define Package
/libgcc
/install
357 $(INSTALL_DIR
) $(1)/lib
358 $(if
$(TARGET_avr32
)$(TARGET_coldfire
),,$(CP
) $(TOOLCHAIN_DIR
)/lib
/libgcc_s.so.
* $(1)/lib
/)
361 define Package
/libgfortran
/install
362 $(INSTALL_DIR
) $(1)/usr
/lib
363 $(if
$(TARGET_avr32
)$(TARGET_coldfire
),,$(CP
) $(TOOLCHAIN_DIR
)/lib
/libgfortran.so.
* $(1)/usr
/lib
/)
366 define Package
/libssp
/install
367 $(INSTALL_DIR
) $(1)/lib
368 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libssp.so.
* $(1)/lib
/
371 define Package
/libstdcpp
/install
372 $(INSTALL_DIR
) $(1)/usr
/lib
373 $(CP
) $(TOOLCHAIN_DIR
)/lib
/libstdc
++.so.
* $(1)/usr
/lib
/
376 use_libutil
=$(if
$(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP
),libutil
)
377 use_libnsl
=$(if
$(CONFIG_EGLIBC_OPTION_EGLIBC_NIS
),libnsl
)
378 use_nsswitch
=$(if
$(CONFIG_EGLIBC_OPTION_EGLIBC_NSSWITCH
),libnss_dns libnss_files
)
380 define Package
/eglibc
/install
381 $(CP
) .
/eglibc-files
/* $(1)/
382 rm -f
$(1)/etc
/localtime
383 ln
-sf
/tmp
/localtime
$(1)/etc
/localtime
384 $(INSTALL_DIR
) $(1)/lib
386 $(TOOLCHAIN_DIR
)/lib
/ld*.so.
* \
387 $(TOOLCHAIN_DIR
)/lib
/ld-
$(LIBC_SO_VERSION
).so \
389 for file in libanl libc libcidn libcrypt libdl libm
$(use_libnsl
) $(use_nsswitch
) libresolv
$(use_libutil
); do \
390 for file in
$(TOOLCHAIN_DIR
)/lib
/$$$$file.so.
* $(TOOLCHAIN_DIR
)/lib
/$$$$file-$(LIBC_SO_VERSION
).so
; do \
391 if
[ -e
"$$$$file" ]; then \
392 $(CP
) $$$$file $(1)/lib
/; \
398 define Package
/uClibc
/install
399 $(INSTALL_DIR
) $(1)/lib
401 $(TOOLCHAIN_DIR
)/lib
/ld*-uClibc.so.
* \
402 $(TOOLCHAIN_DIR
)/lib
/ld*-uClibc-
$(LIBC_SO_VERSION
).so \
405 $(TOOLCHAIN_DIR
)/lib
/libc.so.
* \
406 $(TOOLCHAIN_DIR
)/lib
/libuClibc-
$(LIBC_SO_VERSION
).so \
408 for file in libcrypt libdl libm libutil
; do \
410 $(TOOLCHAIN_DIR
)/lib
/$$$$file.so.
* \
411 $(TOOLCHAIN_DIR
)/lib
/$$$$file-$(LIBC_SO_VERSION
).so \
416 $(PKG_BUILD_DIR
)/libuClibc-
* \
417 $(PKG_BUILD_DIR
)/libm-
* \
418 $(PKG_BUILD_DIR
)/libcrypt-
* \
422 define Package
/libc
/install
423 $(call Package
/$(LIBC
)/install,$1)
426 define Package
/libc
/install_lib
427 $(CP
) $(filter-out %/libdl_pic.a
%/libpthread_pic.a
%/libresolv_pic.a
,$(wildcard $(TOOLCHAIN_DIR
)/lib
/lib
*.a
)) $(1)/lib
/
428 $(if
$(wildcard $(TOOLCHAIN_DIR
)/lib
/libc_so.a
),$(CP
) $(TOOLCHAIN_DIR
)/lib
/libc_so.a
$(1)/lib
/libc_pic.a
)
429 $(if
$(LIBGCC_MAP
), \
430 $(CP
) $(LIBGCC_A
) $(1)/lib
/libgcc_s_pic.a
; \
431 $(CP
) $(LIBGCC_MAP
) $(1)/lib
/libgcc_s_pic.map \
435 define Package
/libpthread
/install
436 $(INSTALL_DIR
) $(1)/lib
438 $(TOOLCHAIN_DIR
)/lib
/libpthread.so.
* \
439 $(if
$(BUILD_LIBGCC
),\
440 $(PKG_BUILD_DIR
)/libpthread-
$(LIBC_SO_VERSION
).so
, \
441 $(TOOLCHAIN_DIR
)/lib
/libpthread-
$(LIBC_SO_VERSION
).so \
446 define Package
/libpthread
/install_lib
447 $(if
$(wildcard $(TOOLCHAIN_DIR
)/lib
/libpthread_so.a
),$(CP
) $(TOOLCHAIN_DIR
)/lib
/libpthread_so.a
$(1)/lib
/libpthread_pic.a
)
450 define Package
/librt
/install
451 $(INSTALL_DIR
) $(1)/lib
453 $(TOOLCHAIN_DIR
)/lib
/librt.so.
* \
454 $(TOOLCHAIN_DIR
)/lib
/librt-
$(LIBC_SO_VERSION
).so \
458 define Package
/ldd
/install
459 $(INSTALL_DIR
) $(1)/usr
/bin
/
460 $(CP
) $(TOOLCHAIN_DIR
)/bin
/ldd
$(1)/usr
/bin
/
463 define Package
/ldconfig
/install
464 $(INSTALL_DIR
) $(1)/sbin
/
465 $(CP
) $(TOOLCHAIN_DIR
)/sbin
/ldconfig
$(1)/sbin
/
470 define Package
/libgcc
/install
471 for file in
$(call qstrip
,$(CONFIG_LIBGCC_FILE_SPEC
)); do \
472 dir=`dirname $$$$file` ; \
473 $(INSTALL_DIR
) $(1)/$$$$dir ; \
474 $(CP
) $(call qstrip
,$(CONFIG_LIBGCC_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
479 define Package
/libgfortran
/install
480 for file in
$(call qstrip
,$(CONFIG_LIBGFORTRAN_FILE_SPEC
)); do \
481 dir=`dirname $$$$file` ; \
482 $(INSTALL_DIR
) $(1)/$$$$dir ; \
483 $(CP
) $(call qstrip
,$(CONFIG_LIBGFORTRAN_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
487 define Package
/libssp
/install
488 for file in
$(call qstrip
,$(CONFIG_LIBSSP_FILE_SPEC
)); do \
489 dir=`dirname $$$$file` ; \
490 $(INSTALL_DIR
) $(1)/$$$$dir ; \
491 $(CP
) $(call qstrip
,$(CONFIG_LIBSSP_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
496 define Package
/libstdcpp
/install
497 for file in
$(call qstrip
,$(CONFIG_LIBSTDCPP_FILE_SPEC
)); do \
498 dir=`dirname $$$$file` ; \
499 $(INSTALL_DIR
) $(1)/$$$$dir ; \
500 $(CP
) $(call qstrip
,$(CONFIG_LIBSTDCPP_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
505 define Package
/libc
/install
506 for file in
$(call qstrip
,$(CONFIG_LIBC_FILE_SPEC
)); do \
507 dir=`dirname $$$$file` ; \
508 $(INSTALL_DIR
) $(1)/$$$$dir ; \
509 $(CP
) $(call qstrip
,$(CONFIG_LIBC_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
514 define Package
/libpthread
/install
515 for file in
$(call qstrip
,$(CONFIG_LIBPTHREAD_FILE_SPEC
)); do \
516 dir=`dirname $$$$file` ; \
517 $(INSTALL_DIR
) $(1)/$$$$dir ; \
518 $(CP
) $(call qstrip
,$(CONFIG_LIBPTHREAD_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
523 define Package
/librt
/install
524 for file in
$(call qstrip
,$(CONFIG_LIBRT_FILE_SPEC
)); do \
525 dir=`dirname $$$$file` ; \
526 $(INSTALL_DIR
) $(1)/$$$$dir ; \
527 $(CP
) $(call qstrip
,$(CONFIG_LIBRT_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
532 define Package
/ldd
/install
533 for file in
$(call qstrip
,$(CONFIG_LDD_FILE_SPEC
)); do \
534 dir=`dirname $$$$file` ; \
535 $(INSTALL_DIR
) $(1)/$$$$dir ; \
536 $(CP
) $(call qstrip
,$(CONFIG_LDD_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
541 define Package
/ldconfig
/install
542 for file in
$(call qstrip
,$(CONFIG_LDCONFIG_FILE_SPEC
)); do \
543 dir=`dirname $$$$file` ; \
544 $(INSTALL_DIR
) $(1)/$$$$dir ; \
545 $(CP
) $(call qstrip
,$(CONFIG_LDCONFIG_ROOT_DIR
))/$$$$file $(1)/$$$$dir/ ; \
552 $(eval
$(call BuildPackage
,libc
))
553 $(eval
$(call BuildPackage
,libgcc
))
554 $(eval
$(call BuildPackage
,libssp
))
555 $(eval
$(call BuildPackage
,libstdcpp
))
556 $(eval
$(call BuildPackage
,libpthread
))
557 $(eval
$(call BuildPackage
,librt
))
558 $(eval
$(call BuildPackage
,libgfortran
))
559 $(eval
$(call BuildPackage
,ldd
))
560 $(eval
$(call BuildPackage
,ldconfig
))