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
31 DEPENDS+=@!(TARGET_avr32||TARGET_coldfire)
34 define Package/libgcc/config
36 depends EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
38 config LIBGCC_ROOT_DIR
40 prompt "libgcc shared library base directory"
41 depends EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
42 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
43 default "/" if NATIVE_TOOLCHAIN
45 config LIBGCC_FILE_SPEC
47 prompt "libgcc shared library files (use wildcards)"
48 depends EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
49 default "./lib/libgcc_s.so.*"
56 $(call Package/gcc/Default)
58 TITLE:=GCC support library
61 define Package/libssp/config
63 depends EXTERNAL_TOOLCHAIN && PACKAGE_libssp
65 config LIBSPP_ROOT_DIR
67 prompt "libssp shared library base directory"
68 depends EXTERNAL_TOOLCHAIN && PACKAGE_libssp
69 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
70 default "/" if NATIVE_TOOLCHAIN
72 config LIBSSP_FILE_SPEC
74 prompt "libssp shared library files (use wildcards)"
75 depends EXTERNAL_TOOLCHAIN && PACKAGE_libssp
76 default "./lib/libssp.so.*"
82 define Package/libstdcpp
83 $(call Package/gcc/Default)
85 TITLE:=GNU Standard C++ Library v3
86 DEPENDS+=@INSTALL_LIBSTDCPP
89 define Package/libstdcpp/config
91 depends EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
93 config LIBSTDCPP_ROOT_DIR
95 prompt "libstdcpp shared library base directory"
96 depends 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 EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
104 default "./lib/libstdc++.so.*"
110 define Package/libc/Default
112 CATEGORY:=Base system
113 VERSION:=$(LIBC_VERSION)-$(PKG_RELEASE)
114 ifneq ($(TARGET_avr32)$(TARGET_coldfire),)
118 PKG_FLAGS:=hold essential
123 $(call Package/libc/Default)
127 define Package/libc/config
129 depends EXTERNAL_TOOLCHAIN && PACKAGE_libc
133 prompt "libc shared library base directory"
134 depends EXTERNAL_TOOLCHAIN && PACKAGE_libc
135 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
136 default "/" if NATIVE_TOOLCHAIN
138 config LIBC_FILE_SPEC
140 prompt "libc shared library files (use wildcards)"
141 depends EXTERNAL_TOOLCHAIN && PACKAGE_libc
142 default "./lib/ld{-*.so,-linux*.so.*} ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
148 define Package/libpthread
149 $(call Package/libc/Default)
150 TITLE:=POSIX thread library
153 define Package/libpthread/config
155 depends EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
157 config LIBPTHREAD_ROOT_DIR
159 prompt "libpthread shared library base directory"
160 depends EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
161 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
162 default "/" if NATIVE_TOOLCHAIN
164 config LIBPTHREAD_FILE_SPEC
166 prompt "libpthread shared library files (use wildcards)"
167 depends EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
168 default "./lib/libpthread{-*.so,.so.*}"
175 $(call Package/libc/Default)
176 TITLE:=POSIX.1b RealTime extension library
180 define Package/librt/config
182 depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
184 config LIBRT_ROOT_DIR
186 prompt "librt shared library base directory"
187 depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
188 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
189 default "/" if NATIVE_TOOLCHAIN
191 config LIBRT_FILE_SPEC
193 prompt "librt shared library files (use wildcards)"
194 depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
195 default "./lib/librt{-*.so,.so.*}"
201 define Package/libgfortran
202 $(call Package/gcc/Default)
203 TITLE:=GFortran support library
204 DEPENDS+=@!(TARGET_avr32||TARGET_coldfire) @INSTALL_GFORTRAN
207 define Package/libgfortran/config
209 depends EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
211 config LIBGFORTRAN_ROOT_DIR
213 prompt "libgfortran shared library base directory"
214 depends EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
215 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
216 default "/" if NATIVE_TOOLCHAIN
218 config LIBGFORTRAN_FILE_SPEC
220 prompt "libgfortran shared library files (use wildcards)"
221 depends EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
222 default "./usr/lib/libgfortran.so.*"
228 $(call Package/libc/Default)
231 TITLE:=LDD trace utility
234 define Package/ldd/config
236 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
240 prompt "ldd trace utility base directory"
241 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
242 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
243 default "/" if NATIVE_TOOLCHAIN
247 prompt "ldd trace utility file"
248 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
249 default "./usr/bin/ldd"
255 define Package/ldconfig
256 $(call Package/libc/Default)
259 TITLE:=Shared library path configuration
262 define Package/ldconfig/config
264 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
266 config LDCONFIG_ROOT_DIR
268 prompt "ldconfig base directory"
269 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
270 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
271 default "/" if NATIVE_TOOLCHAIN
273 config LDCONFIG_FILE_SPEC
275 prompt "ldconfig file"
276 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
277 default "./sbin/ldconfig"
283 mkdir -p $(PKG_BUILD_DIR)
286 LIBGCC_A=$(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc_pic.a)
287 LIBGCC_MAP=$(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc.map)
288 LIBGCC_SO=$(wildcard $(TOOLCHAIN_DIR)/lib/libgcc_s.so.*)
289 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
290 ifneq ($(if $(CONFIG_USE_UCLIBC),$(CONFIG_GCC_VERSION_LINARO)),)
291 BUILD_LIBGCC:=$(if $(CONFIG_avr32)$(CONFIG_m68k)$(CONFIG_powerpc),,$(PKG_BUILD_DIR)/libgcc_s.so.*)
295 ifneq ($(BUILD_LIBGCC),)
296 define Build/Compile/uClibc
297 $(SCRIPT_DIR)/relink-lib.sh \
299 "$(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a)" \
300 "$(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a)" \
301 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libuClibc-*.so))" \
302 -Wl,-init,__uClibc_init -Wl,-soname=libc.so.0 \
304 $(SCRIPT_DIR)/relink-lib.sh \
306 "$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt-*.so)" \
307 "$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt_pic.a)" \
308 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt-*.so))" \
310 -Wl,-soname=libcrypt.so.0
311 $(SCRIPT_DIR)/relink-lib.sh \
313 "$(wildcard $(TOOLCHAIN_DIR)/lib/libm-*.so)" \
314 "$(wildcard $(TOOLCHAIN_DIR)/lib/libm_pic.a)" \
315 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libm-*.so))" \
317 -Wl,-soname=libm.so.0
318 $(SCRIPT_DIR)/relink-lib.sh \
320 "$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread-*.so)" \
321 "$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a)" \
322 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread-*.so))" \
323 -Wl,-z,nodelete,-z,initfirst,-init=__pthread_initialize_minimal_internal \
324 -ldl -lc $(BUILD_LIBGCC) \
325 -Wl,-soname=libpthread.so.0
327 define Build/Compile/libgcc
328 $(SCRIPT_DIR)/relink-lib.sh \
332 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(LIBGCC_SO))" \
333 -Wl,--version-script=$(LIBGCC_MAP) -Wl,-soname=libgcc_s.so.1
336 define Build/Compile/uClibc
338 $(TOOLCHAIN_DIR)/lib/libuClibc-*.so \
339 $(TOOLCHAIN_DIR)/lib/libcrypt-*.so \
340 $(TOOLCHAIN_DIR)/lib/libm-*.so \
341 $(TOOLCHAIN_DIR)/lib/libpthread-*.so \
344 ifneq ($(LIBGCC_SO),)
345 define Build/Compile/libgcc
346 $(CP) $(LIBGCC_SO) $(PKG_BUILD_DIR)/
351 define Build/Compile/Default
352 $(call Build/Compile/libgcc)
353 $(call Build/Compile/$(LIBC))
355 Build/Compile = $(Build/Compile/Default)
357 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
359 define Package/libgcc/install
360 $(INSTALL_DIR) $(1)/lib
361 $(CP) $(TOOLCHAIN_DIR)/lib/libgcc_s.so.* $(1)/lib/
364 define Package/libgfortran/install
365 $(INSTALL_DIR) $(1)/usr/lib
366 $(CP) $(TOOLCHAIN_DIR)/lib/libgfortran.so.* $(1)/usr/lib/
369 define Package/libssp/install
370 $(INSTALL_DIR) $(1)/lib
371 $(CP) $(TOOLCHAIN_DIR)/lib/libssp.so.* $(1)/lib/
374 define Package/libstdcpp/install
375 $(INSTALL_DIR) $(1)/usr/lib
376 $(CP) $(TOOLCHAIN_DIR)/lib/libstdc++.so.* $(1)/usr/lib/
379 use_libutil=$(if $(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP),libutil)
380 use_libnsl=$(if $(CONFIG_EGLIBC_OPTION_EGLIBC_NIS),libnsl)
381 use_nsswitch=$(if $(CONFIG_EGLIBC_OPTION_EGLIBC_NSSWITCH),libnss_dns libnss_files)
383 define Package/eglibc/install
384 $(CP) ./eglibc-files/* $(1)/
385 rm -f $(1)/etc/localtime
386 ln -sf /tmp/localtime $(1)/etc/localtime
387 $(INSTALL_DIR) $(1)/lib
389 $(TOOLCHAIN_DIR)/lib/ld*.so.* \
390 $(TOOLCHAIN_DIR)/lib/ld-$(LIBC_SO_VERSION).so \
392 for file in libanl libc libcidn libcrypt libdl libm $(use_libnsl) $(use_nsswitch) libresolv $(use_libutil); do \
393 for file in $(TOOLCHAIN_DIR)/lib/$$$$file.so.* $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so; do \
394 if [ -e "$$$$file" ]; then \
395 $(CP) $$$$file $(1)/lib/; \
401 define Package/uClibc/install
402 $(INSTALL_DIR) $(1)/lib
404 $(TOOLCHAIN_DIR)/lib/ld*-uClibc.so.* \
405 $(TOOLCHAIN_DIR)/lib/ld*-uClibc-$(LIBC_SO_VERSION).so \
408 $(TOOLCHAIN_DIR)/lib/libc.so.* \
409 $(TOOLCHAIN_DIR)/lib/libuClibc-$(LIBC_SO_VERSION).so \
411 for file in libcrypt libdl libm libutil; do \
413 $(TOOLCHAIN_DIR)/lib/$$$$file.so.* \
414 $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so \
419 $(PKG_BUILD_DIR)/libuClibc-* \
420 $(PKG_BUILD_DIR)/libm-* \
421 $(PKG_BUILD_DIR)/libcrypt-* \
425 define Package/libc/install
426 $(call Package/$(LIBC)/install,$1)
429 define Package/libc/install_lib
430 $(CP) $(filter-out %/libdl_pic.a %/libpthread_pic.a %/libresolv_pic.a,$(wildcard $(TOOLCHAIN_DIR)/lib/lib*.a)) $(1)/lib/
431 $(if $(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libc_so.a $(1)/lib/libc_pic.a)
432 $(if $(LIBGCC_MAP), \
433 $(CP) $(LIBGCC_A) $(1)/lib/libgcc_s_pic.a; \
434 $(CP) $(LIBGCC_MAP) $(1)/lib/libgcc_s_pic.map \
438 define Package/libpthread/install
439 $(INSTALL_DIR) $(1)/lib
441 $(TOOLCHAIN_DIR)/lib/libpthread.so.* \
442 $(if $(BUILD_LIBGCC),\
443 $(PKG_BUILD_DIR)/libpthread-$(LIBC_SO_VERSION).so, \
444 $(TOOLCHAIN_DIR)/lib/libpthread-$(LIBC_SO_VERSION).so \
449 define Package/libpthread/install_lib
450 $(if $(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libpthread_so.a $(1)/lib/libpthread_pic.a)
453 define Package/librt/install
454 $(INSTALL_DIR) $(1)/lib
456 $(TOOLCHAIN_DIR)/lib/librt.so.* \
457 $(TOOLCHAIN_DIR)/lib/librt-$(LIBC_SO_VERSION).so \
461 define Package/ldd/install
462 $(INSTALL_DIR) $(1)/usr/bin/
463 $(CP) $(TOOLCHAIN_DIR)/bin/ldd $(1)/usr/bin/
466 define Package/ldconfig/install
467 $(INSTALL_DIR) $(1)/sbin/
468 $(CP) $(TOOLCHAIN_DIR)/sbin/ldconfig $(1)/sbin/
473 define Package/libgcc/install
474 for file in $(call qstrip,$(CONFIG_LIBGCC_FILE_SPEC)); do \
475 dir=`dirname $$$$file` ; \
476 $(INSTALL_DIR) $(1)/$$$$dir ; \
477 $(CP) $(call qstrip,$(CONFIG_LIBGCC_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
482 define Package/libgfortran/install
483 for file in $(call qstrip,$(CONFIG_LIBGFORTRAN_FILE_SPEC)); do \
484 dir=`dirname $$$$file` ; \
485 $(INSTALL_DIR) $(1)/$$$$dir ; \
486 $(CP) $(call qstrip,$(CONFIG_LIBGFORTRAN_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
490 define Package/libssp/install
491 for file in $(call qstrip,$(CONFIG_LIBSSP_FILE_SPEC)); do \
492 dir=`dirname $$$$file` ; \
493 $(INSTALL_DIR) $(1)/$$$$dir ; \
494 $(CP) $(call qstrip,$(CONFIG_LIBSSP_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
499 define Package/libstdcpp/install
500 for file in $(call qstrip,$(CONFIG_LIBSTDCPP_FILE_SPEC)); do \
501 dir=`dirname $$$$file` ; \
502 $(INSTALL_DIR) $(1)/$$$$dir ; \
503 $(CP) $(call qstrip,$(CONFIG_LIBSTDCPP_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
508 define Package/libc/install
509 for file in $(call qstrip,$(CONFIG_LIBC_FILE_SPEC)); do \
510 dir=`dirname $$$$file` ; \
511 $(INSTALL_DIR) $(1)/$$$$dir ; \
512 $(CP) $(call qstrip,$(CONFIG_LIBC_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
517 define Package/libpthread/install
518 for file in $(call qstrip,$(CONFIG_LIBPTHREAD_FILE_SPEC)); do \
519 dir=`dirname $$$$file` ; \
520 $(INSTALL_DIR) $(1)/$$$$dir ; \
521 $(CP) $(call qstrip,$(CONFIG_LIBPTHREAD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
526 define Package/librt/install
527 for file in $(call qstrip,$(CONFIG_LIBRT_FILE_SPEC)); do \
528 dir=`dirname $$$$file` ; \
529 $(INSTALL_DIR) $(1)/$$$$dir ; \
530 $(CP) $(call qstrip,$(CONFIG_LIBRT_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
535 define Package/ldd/install
536 for file in $(call qstrip,$(CONFIG_LDD_FILE_SPEC)); do \
537 dir=`dirname $$$$file` ; \
538 $(INSTALL_DIR) $(1)/$$$$dir ; \
539 $(CP) $(call qstrip,$(CONFIG_LDD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
544 define Package/ldconfig/install
545 for file in $(call qstrip,$(CONFIG_LDCONFIG_FILE_SPEC)); do \
546 dir=`dirname $$$$file` ; \
547 $(INSTALL_DIR) $(1)/$$$$dir ; \
548 $(CP) $(call qstrip,$(CONFIG_LDCONFIG_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
555 $(eval $(call BuildPackage,libc))
556 $(eval $(call BuildPackage,libgcc))
557 $(eval $(call BuildPackage,libssp))
558 $(eval $(call BuildPackage,libstdcpp))
559 $(eval $(call BuildPackage,libpthread))
560 $(eval $(call BuildPackage,librt))
561 $(eval $(call BuildPackage,libgfortran))
562 $(eval $(call BuildPackage,ldd))
563 $(eval $(call BuildPackage,ldconfig))