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 EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
39 config LIBGCC_ROOT_DIR
41 prompt "libgcc shared library base directory"
42 depends 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 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 EXTERNAL_TOOLCHAIN && PACKAGE_libssp
66 config LIBSSP_ROOT_DIR
68 prompt "libssp shared library base directory"
69 depends 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 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
87 DEPENDS+=@INSTALL_LIBSTDCPP
90 define Package/libstdcpp/config
92 depends EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
94 config LIBSTDCPP_ROOT_DIR
96 prompt "libstdcpp shared library base directory"
97 depends EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
98 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
99 default "/" if NATIVE_TOOLCHAIN
101 config LIBSTDCPP_FILE_SPEC
103 prompt "libstdc++ shared library files (use wildcards)"
104 depends EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
105 default "./lib/libstdc++.so.*"
111 define Package/libc/Default
113 CATEGORY:=Base system
114 VERSION:=$(LIBC_VERSION)-$(PKG_RELEASE)
117 PKG_FLAGS:=hold essential
122 $(call Package/libc/Default)
126 define Package/libc/config
128 depends EXTERNAL_TOOLCHAIN && PACKAGE_libc
132 prompt "libc shared library base directory"
133 depends EXTERNAL_TOOLCHAIN && PACKAGE_libc
134 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
135 default "/" if NATIVE_TOOLCHAIN
137 config LIBC_FILE_SPEC
139 prompt "libc shared library files (use wildcards)"
140 depends EXTERNAL_TOOLCHAIN && PACKAGE_libc
141 default "./lib/ld{-*.so,-linux*.so.*} ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
147 define Package/libpthread
148 $(call Package/libc/Default)
149 TITLE:=POSIX thread library
152 define Package/libpthread/config
154 depends EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
156 config LIBPTHREAD_ROOT_DIR
158 prompt "libpthread shared library base directory"
159 depends EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
160 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
161 default "/" if NATIVE_TOOLCHAIN
163 config LIBPTHREAD_FILE_SPEC
165 prompt "libpthread shared library files (use wildcards)"
166 depends EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
167 default "./lib/libpthread{-*.so,.so.*}"
173 define Package/libthread-db
174 $(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 EXTERNAL_TOOLCHAIN && PACKAGE_librt
188 config LIBRT_ROOT_DIR
190 prompt "librt shared library base directory"
191 depends 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 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 EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
215 config LIBGFORTRAN_ROOT_DIR
217 prompt "libgfortran shared library base directory"
218 depends 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 EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
226 default "./usr/lib/libgfortran.so.*"
232 $(call Package/libc/Default)
235 TITLE:=LDD trace utility
238 define Package/ldd/config
240 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
244 prompt "ldd trace utility base directory"
245 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
246 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
247 default "/" if NATIVE_TOOLCHAIN
251 prompt "ldd trace utility file"
252 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
253 default "./usr/bin/ldd"
259 define Package/ldconfig
260 $(call Package/libc/Default)
263 TITLE:=Shared library path configuration
266 define Package/ldconfig/config
268 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
270 config LDCONFIG_ROOT_DIR
272 prompt "ldconfig base directory"
273 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
274 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
275 default "/" if NATIVE_TOOLCHAIN
277 config LDCONFIG_FILE_SPEC
279 prompt "ldconfig file"
280 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
281 default "./sbin/ldconfig"
287 mkdir -p $(PKG_BUILD_DIR)
290 LIBGCC_A=$(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc_pic.a)
291 LIBGCC_MAP=$(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc.map)
292 LIBGCC_SO=$(wildcard $(TOOLCHAIN_DIR)/lib/libgcc_s.so.*)
293 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
294 ifneq ($(if $(CONFIG_USE_UCLIBC),$(CONFIG_GCC_VERSION_LINARO)),)
295 BUILD_LIBGCC:=$(if $(CONFIG_avr32)$(CONFIG_m68k)$(CONFIG_powerpc),,$(PKG_BUILD_DIR)/libgcc_s.so.*)
299 ifneq ($(BUILD_LIBGCC),)
300 define Build/Compile/uClibc
301 $(SCRIPT_DIR)/relink-lib.sh \
303 "$(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a)" \
304 "$(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a)" \
305 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libuClibc-*.so))" \
306 -Wl,-init,__uClibc_init -Wl,-soname=libc.so.0 \
308 $(SCRIPT_DIR)/relink-lib.sh \
310 "$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt-*.so)" \
311 "$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt_pic.a)" \
312 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt-*.so))" \
314 -Wl,-soname=libcrypt.so.0
315 $(SCRIPT_DIR)/relink-lib.sh \
317 "$(wildcard $(TOOLCHAIN_DIR)/lib/libm-*.so)" \
318 "$(wildcard $(TOOLCHAIN_DIR)/lib/libm_pic.a)" \
319 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libm-*.so))" \
321 -Wl,-soname=libm.so.0
322 $(SCRIPT_DIR)/relink-lib.sh \
324 "$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread-*.so)" \
325 "$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a)" \
326 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread-*.so))" \
327 -Wl,-z,nodelete,-z,initfirst,-init=__pthread_initialize_minimal_internal \
328 -ldl -lc $(BUILD_LIBGCC) \
329 -Wl,-soname=libpthread.so.0
331 define Build/Compile/libgcc
332 $(SCRIPT_DIR)/relink-lib.sh \
336 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(LIBGCC_SO))" \
337 -Wl,--version-script=$(LIBGCC_MAP) -Wl,-soname=libgcc_s.so.1
340 define Build/Compile/uClibc
342 $(TOOLCHAIN_DIR)/lib/libuClibc-*.so \
343 $(TOOLCHAIN_DIR)/lib/libcrypt-*.so \
344 $(TOOLCHAIN_DIR)/lib/libm-*.so \
345 $(TOOLCHAIN_DIR)/lib/libpthread-*.so \
348 ifneq ($(LIBGCC_SO),)
349 define Build/Compile/libgcc
350 $(CP) $(LIBGCC_SO) $(PKG_BUILD_DIR)/
355 define Build/Compile/Default
356 $(call Build/Compile/libgcc)
357 $(call Build/Compile/$(LIBC))
359 Build/Compile = $(Build/Compile/Default)
361 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
363 define Package/libgcc/install
364 $(INSTALL_DIR) $(1)/lib
365 $(if $(CONFIG_TARGET_avr32)$(CONFIG_TARGET_coldfire),,$(CP) $(TOOLCHAIN_DIR)/lib/libgcc_s.so.* $(1)/lib/)
368 define Package/libgfortran/install
369 $(INSTALL_DIR) $(1)/usr/lib
370 $(if $(CONFIG_TARGET_avr32)$(CONFIG_TARGET_coldfire),,$(CP) $(TOOLCHAIN_DIR)/lib/libgfortran.so.* $(1)/usr/lib/)
373 define Package/libssp/install
374 $(INSTALL_DIR) $(1)/lib
375 $(CP) $(TOOLCHAIN_DIR)/lib/libssp.so.* $(1)/lib/
378 define Package/libstdcpp/install
379 $(INSTALL_DIR) $(1)/usr/lib
380 $(CP) $(TOOLCHAIN_DIR)/lib/libstdc++.so.* $(1)/usr/lib/
383 use_libutil=$(if $(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP),libutil)
384 use_libnsl=$(if $(CONFIG_EGLIBC_OPTION_EGLIBC_NIS),libnsl)
385 use_nsswitch=$(if $(CONFIG_EGLIBC_OPTION_EGLIBC_NSSWITCH),libnss_dns libnss_files)
387 define Package/eglibc/install
388 $(CP) ./eglibc-files/* $(1)/
389 rm -f $(1)/etc/localtime
390 ln -sf /tmp/localtime $(1)/etc/localtime
391 $(INSTALL_DIR) $(1)/lib
393 $(TOOLCHAIN_DIR)/lib/ld*.so.* \
394 $(TOOLCHAIN_DIR)/lib/ld-$(LIBC_SO_VERSION).so \
396 for file in libanl libc libcidn libcrypt libdl libm $(use_libnsl) $(use_nsswitch) libresolv $(use_libutil); do \
397 for file in $(TOOLCHAIN_DIR)/lib/$$$$file.so.* $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so; do \
398 if [ -e "$$$$file" ]; then \
399 $(CP) $$$$file $(1)/lib/; \
405 define Package/uClibc/install
406 $(INSTALL_DIR) $(1)/lib
408 $(TOOLCHAIN_DIR)/lib/ld*-uClibc.so.* \
409 $(TOOLCHAIN_DIR)/lib/ld*-uClibc-$(LIBC_SO_VERSION).so \
412 $(TOOLCHAIN_DIR)/lib/libc.so.* \
413 $(TOOLCHAIN_DIR)/lib/libuClibc-$(LIBC_SO_VERSION).so \
415 for file in libcrypt libdl libm libutil; do \
417 $(TOOLCHAIN_DIR)/lib/$$$$file.so.* \
418 $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so \
423 $(PKG_BUILD_DIR)/libuClibc-* \
424 $(PKG_BUILD_DIR)/libm-* \
425 $(PKG_BUILD_DIR)/libcrypt-* \
429 define Package/libc/install
430 $(call Package/$(LIBC)/install,$1)
433 define Package/libc/install_lib
434 $(CP) $(filter-out %/libdl_pic.a %/libpthread_pic.a %/libresolv_pic.a,$(wildcard $(TOOLCHAIN_DIR)/lib/lib*.a)) $(1)/lib/
435 $(if $(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libc_so.a $(1)/lib/libc_pic.a)
436 $(if $(LIBGCC_MAP), \
437 $(CP) $(LIBGCC_A) $(1)/lib/libgcc_s_pic.a; \
438 $(CP) $(LIBGCC_MAP) $(1)/lib/libgcc_s_pic.map \
442 define Package/libpthread/install
443 $(INSTALL_DIR) $(1)/lib
445 $(TOOLCHAIN_DIR)/lib/libpthread.so.* \
446 $(if $(BUILD_LIBGCC),\
447 $(PKG_BUILD_DIR)/libpthread-$(LIBC_SO_VERSION).so, \
448 $(TOOLCHAIN_DIR)/lib/libpthread-$(LIBC_SO_VERSION).so \
453 define Package/libthread-db/install
454 $(INSTALL_DIR) $(1)/lib
456 $(TOOLCHAIN_DIR)/lib/libthread_db.so.* $(1)/lib
457 ifeq ($(USE_UCLIBC),y)
459 $(TOOLCHAIN_DIR)/lib/libthread_db-$(LIBC_SO_VERSION).so \
464 define Package/libpthread/install_lib
465 $(if $(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libpthread_so.a $(1)/lib/libpthread_pic.a)
468 define Package/librt/install
469 $(INSTALL_DIR) $(1)/lib
471 $(TOOLCHAIN_DIR)/lib/librt.so.* \
472 $(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/ldd/install
551 for file in $(call qstrip,$(CONFIG_LDD_FILE_SPEC)); do \
552 dir=`dirname $$$$file` ; \
553 $(INSTALL_DIR) $(1)/$$$$dir ; \
554 $(CP) $(call qstrip,$(CONFIG_LDD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
559 define Package/ldconfig/install
560 for file in $(call qstrip,$(CONFIG_LDCONFIG_FILE_SPEC)); do \
561 dir=`dirname $$$$file` ; \
562 $(INSTALL_DIR) $(1)/$$$$dir ; \
563 $(CP) $(call qstrip,$(CONFIG_LDCONFIG_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
570 $(eval $(call BuildPackage,libc))
571 $(eval $(call BuildPackage,libgcc))
572 $(eval $(call BuildPackage,libssp))
573 $(eval $(call BuildPackage,libstdcpp))
574 $(eval $(call BuildPackage,libpthread))
575 $(eval $(call BuildPackage,libthread-db))
576 $(eval $(call BuildPackage,librt))
577 $(eval $(call BuildPackage,libgfortran))
578 $(eval $(call BuildPackage,ldd))
579 $(eval $(call BuildPackage,ldconfig))