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 define Package/musl/install
432 $(INSTALL_DIR) $(1)/lib
434 $(TOOLCHAIN_DIR)/lib/ld-musl-*.so* \
437 $(TOOLCHAIN_DIR)/lib/libc.so* \
441 define Package/libc/install
442 $(call Package/$(LIBC)/install,$1)
445 define Package/libc/install_lib
446 $(CP) $(filter-out %/libdl_pic.a %/libpthread_pic.a %/libresolv_pic.a,$(wildcard $(TOOLCHAIN_DIR)/lib/lib*.a)) $(1)/lib/
447 $(if $(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libc_so.a $(1)/lib/libc_pic.a)
448 $(if $(LIBGCC_MAP), \
449 $(CP) $(LIBGCC_A) $(1)/lib/libgcc_s_pic.a; \
450 $(CP) $(LIBGCC_MAP) $(1)/lib/libgcc_s_pic.map \
454 define Package/libpthread/install
455 $(INSTALL_DIR) $(1)/lib
456 ifneq ($(CONFIG_USE_MUSL),y)
458 $(TOOLCHAIN_DIR)/lib/libpthread.so.* \
459 $(if $(BUILD_LIBGCC),\
460 $(PKG_BUILD_DIR)/libpthread-$(LIBC_SO_VERSION).so, \
461 $(TOOLCHAIN_DIR)/lib/libpthread-$(LIBC_SO_VERSION).so \
467 define Package/libthread-db/install
468 $(INSTALL_DIR) $(1)/lib
470 $(TOOLCHAIN_DIR)/lib/libthread_db.so.* $(1)/lib
471 ifeq ($(USE_UCLIBC),y)
473 $(TOOLCHAIN_DIR)/lib/libthread_db-$(LIBC_SO_VERSION).so \
478 define Package/libpthread/install_lib
479 $(if $(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libpthread_so.a $(1)/lib/libpthread_pic.a)
482 define Package/librt/install
483 $(INSTALL_DIR) $(1)/lib
484 ifneq ($(CONFIG_USE_MUSL),y)
486 $(TOOLCHAIN_DIR)/lib/librt.so.* \
487 $(TOOLCHAIN_DIR)/lib/librt-$(LIBC_SO_VERSION).so \
492 define Package/ldd/install
493 $(INSTALL_DIR) $(1)/usr/bin/
494 $(CP) $(TOOLCHAIN_DIR)/bin/ldd $(1)/usr/bin/
497 define Package/ldconfig/install
498 $(INSTALL_DIR) $(1)/sbin/
499 $(CP) $(TOOLCHAIN_DIR)/sbin/ldconfig $(1)/sbin/
504 define Package/libgcc/install
505 for file in $(call qstrip,$(CONFIG_LIBGCC_FILE_SPEC)); do \
506 dir=`dirname $$$$file` ; \
507 $(INSTALL_DIR) $(1)/$$$$dir ; \
508 $(CP) $(call qstrip,$(CONFIG_LIBGCC_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
513 define Package/libgfortran/install
514 for file in $(call qstrip,$(CONFIG_LIBGFORTRAN_FILE_SPEC)); do \
515 dir=`dirname $$$$file` ; \
516 $(INSTALL_DIR) $(1)/$$$$dir ; \
517 $(CP) $(call qstrip,$(CONFIG_LIBGFORTRAN_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
521 define Package/libssp/install
522 for file in $(call qstrip,$(CONFIG_LIBSSP_FILE_SPEC)); do \
523 dir=`dirname $$$$file` ; \
524 $(INSTALL_DIR) $(1)/$$$$dir ; \
525 $(CP) $(call qstrip,$(CONFIG_LIBSSP_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
530 define Package/libstdcpp/install
531 for file in $(call qstrip,$(CONFIG_LIBSTDCPP_FILE_SPEC)); do \
532 dir=`dirname $$$$file` ; \
533 $(INSTALL_DIR) $(1)/$$$$dir ; \
534 $(CP) $(call qstrip,$(CONFIG_LIBSTDCPP_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
539 define Package/libc/install
540 for file in $(call qstrip,$(CONFIG_LIBC_FILE_SPEC)); do \
541 dir=`dirname $$$$file` ; \
542 $(INSTALL_DIR) $(1)/$$$$dir ; \
543 $(CP) $(call qstrip,$(CONFIG_LIBC_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
548 define Package/libpthread/install
549 for file in $(call qstrip,$(CONFIG_LIBPTHREAD_FILE_SPEC)); do \
550 dir=`dirname $$$$file` ; \
551 $(INSTALL_DIR) $(1)/$$$$dir ; \
552 $(CP) $(call qstrip,$(CONFIG_LIBPTHREAD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
557 define Package/librt/install
558 for file in $(call qstrip,$(CONFIG_LIBRT_FILE_SPEC)); do \
559 dir=`dirname $$$$file` ; \
560 $(INSTALL_DIR) $(1)/$$$$dir ; \
561 $(CP) $(call qstrip,$(CONFIG_LIBRT_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
566 define Package/ldd/install
567 for file in $(call qstrip,$(CONFIG_LDD_FILE_SPEC)); do \
568 dir=`dirname $$$$file` ; \
569 $(INSTALL_DIR) $(1)/$$$$dir ; \
570 $(CP) $(call qstrip,$(CONFIG_LDD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
575 define Package/ldconfig/install
576 for file in $(call qstrip,$(CONFIG_LDCONFIG_FILE_SPEC)); do \
577 dir=`dirname $$$$file` ; \
578 $(INSTALL_DIR) $(1)/$$$$dir ; \
579 $(CP) $(call qstrip,$(CONFIG_LDCONFIG_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
586 $(eval $(call BuildPackage,libc))
587 $(eval $(call BuildPackage,libgcc))
588 $(eval $(call BuildPackage,libssp))
589 $(eval $(call BuildPackage,libstdcpp))
590 $(eval $(call BuildPackage,libpthread))
591 $(eval $(call BuildPackage,libthread-db))
592 $(eval $(call BuildPackage,librt))
593 $(eval $(call BuildPackage,libgfortran))
594 $(eval $(call BuildPackage,ldd))
595 $(eval $(call BuildPackage,ldconfig))