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.*}"
174 $(call Package/libc/Default)
175 TITLE:=POSIX.1b RealTime extension library
179 define Package/librt/config
181 depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
183 config LIBRT_ROOT_DIR
185 prompt "librt shared library base directory"
186 depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
187 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
188 default "/" if NATIVE_TOOLCHAIN
190 config LIBRT_FILE_SPEC
192 prompt "librt shared library files (use wildcards)"
193 depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
194 default "./lib/librt{-*.so,.so.*}"
200 define Package/libgfortran
201 $(call Package/gcc/Default)
202 TITLE:=GFortran support library
203 DEPENDS+=@INSTALL_GFORTRAN
206 define Package/libgfortran/config
208 depends EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
210 config LIBGFORTRAN_ROOT_DIR
212 prompt "libgfortran shared library base directory"
213 depends EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
214 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
215 default "/" if NATIVE_TOOLCHAIN
217 config LIBGFORTRAN_FILE_SPEC
219 prompt "libgfortran shared library files (use wildcards)"
220 depends EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
221 default "./usr/lib/libgfortran.so.*"
227 $(call Package/libc/Default)
230 TITLE:=LDD trace utility
233 define Package/ldd/config
235 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
239 prompt "ldd trace utility base directory"
240 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
241 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
242 default "/" if NATIVE_TOOLCHAIN
246 prompt "ldd trace utility file"
247 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
248 default "./usr/bin/ldd"
254 define Package/ldconfig
255 $(call Package/libc/Default)
258 TITLE:=Shared library path configuration
261 define Package/ldconfig/config
263 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
265 config LDCONFIG_ROOT_DIR
267 prompt "ldconfig base directory"
268 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
269 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
270 default "/" if NATIVE_TOOLCHAIN
272 config LDCONFIG_FILE_SPEC
274 prompt "ldconfig file"
275 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
276 default "./sbin/ldconfig"
282 mkdir -p $(PKG_BUILD_DIR)
285 LIBGCC_A=$(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc_pic.a)
286 LIBGCC_MAP=$(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc.map)
287 LIBGCC_SO=$(wildcard $(TOOLCHAIN_DIR)/lib/libgcc_s.so.*)
288 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
289 ifneq ($(if $(CONFIG_USE_UCLIBC),$(CONFIG_GCC_VERSION_LINARO)),)
290 BUILD_LIBGCC:=$(if $(CONFIG_avr32)$(CONFIG_m68k)$(CONFIG_powerpc),,$(PKG_BUILD_DIR)/libgcc_s.so.*)
294 ifneq ($(BUILD_LIBGCC),)
295 define Build/Compile/uClibc
296 $(SCRIPT_DIR)/relink-lib.sh \
298 "$(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a)" \
299 "$(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a)" \
300 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libuClibc-*.so))" \
301 -Wl,-init,__uClibc_init -Wl,-soname=libc.so.0 \
303 $(SCRIPT_DIR)/relink-lib.sh \
305 "$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt-*.so)" \
306 "$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt_pic.a)" \
307 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt-*.so))" \
309 -Wl,-soname=libcrypt.so.0
310 $(SCRIPT_DIR)/relink-lib.sh \
312 "$(wildcard $(TOOLCHAIN_DIR)/lib/libm-*.so)" \
313 "$(wildcard $(TOOLCHAIN_DIR)/lib/libm_pic.a)" \
314 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libm-*.so))" \
316 -Wl,-soname=libm.so.0
317 $(SCRIPT_DIR)/relink-lib.sh \
319 "$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread-*.so)" \
320 "$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a)" \
321 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread-*.so))" \
322 -Wl,-z,nodelete,-z,initfirst,-init=__pthread_initialize_minimal_internal \
323 -ldl -lc $(BUILD_LIBGCC) \
324 -Wl,-soname=libpthread.so.0
326 define Build/Compile/libgcc
327 $(SCRIPT_DIR)/relink-lib.sh \
331 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(LIBGCC_SO))" \
332 -Wl,--version-script=$(LIBGCC_MAP) -Wl,-soname=libgcc_s.so.1
335 define Build/Compile/uClibc
337 $(TOOLCHAIN_DIR)/lib/libuClibc-*.so \
338 $(TOOLCHAIN_DIR)/lib/libcrypt-*.so \
339 $(TOOLCHAIN_DIR)/lib/libm-*.so \
340 $(TOOLCHAIN_DIR)/lib/libpthread-*.so \
343 ifneq ($(LIBGCC_SO),)
344 define Build/Compile/libgcc
345 $(CP) $(LIBGCC_SO) $(PKG_BUILD_DIR)/
350 define Build/Compile/Default
351 $(call Build/Compile/libgcc)
352 $(call Build/Compile/$(LIBC))
354 Build/Compile = $(Build/Compile/Default)
356 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
358 define Package/libgcc/install
359 $(INSTALL_DIR) $(1)/lib
360 $(if $(CONFIG_TARGET_avr32)$(CONFIG_TARGET_coldfire),,$(CP) $(TOOLCHAIN_DIR)/lib/libgcc_s.so.* $(1)/lib/)
363 define Package/libgfortran/install
364 $(INSTALL_DIR) $(1)/usr/lib
365 $(if $(CONFIG_TARGET_avr32)$(CONFIG_TARGET_coldfire),,$(CP) $(TOOLCHAIN_DIR)/lib/libgfortran.so.* $(1)/usr/lib/)
368 define Package/libssp/install
369 $(INSTALL_DIR) $(1)/lib
370 $(CP) $(TOOLCHAIN_DIR)/lib/libssp.so.* $(1)/lib/
373 define Package/libstdcpp/install
374 $(INSTALL_DIR) $(1)/usr/lib
375 $(CP) $(TOOLCHAIN_DIR)/lib/libstdc++.so.* $(1)/usr/lib/
378 use_libutil=$(if $(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP),libutil)
379 use_libnsl=$(if $(CONFIG_EGLIBC_OPTION_EGLIBC_NIS),libnsl)
380 use_nsswitch=$(if $(CONFIG_EGLIBC_OPTION_EGLIBC_NSSWITCH),libnss_dns libnss_files)
382 define Package/eglibc/install
383 $(CP) ./eglibc-files/* $(1)/
384 rm -f $(1)/etc/localtime
385 ln -sf /tmp/localtime $(1)/etc/localtime
386 $(INSTALL_DIR) $(1)/lib
388 $(TOOLCHAIN_DIR)/lib/ld*.so.* \
389 $(TOOLCHAIN_DIR)/lib/ld-$(LIBC_SO_VERSION).so \
391 for file in libanl libc libcidn libcrypt libdl libm $(use_libnsl) $(use_nsswitch) libresolv $(use_libutil); do \
392 for file in $(TOOLCHAIN_DIR)/lib/$$$$file.so.* $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so; do \
393 if [ -e "$$$$file" ]; then \
394 $(CP) $$$$file $(1)/lib/; \
400 define Package/uClibc/install
401 $(INSTALL_DIR) $(1)/lib
403 $(TOOLCHAIN_DIR)/lib/ld*-uClibc.so.* \
404 $(TOOLCHAIN_DIR)/lib/ld*-uClibc-$(LIBC_SO_VERSION).so \
407 $(TOOLCHAIN_DIR)/lib/libc.so.* \
408 $(TOOLCHAIN_DIR)/lib/libuClibc-$(LIBC_SO_VERSION).so \
410 for file in libcrypt libdl libm libutil; do \
412 $(TOOLCHAIN_DIR)/lib/$$$$file.so.* \
413 $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so \
418 $(PKG_BUILD_DIR)/libuClibc-* \
419 $(PKG_BUILD_DIR)/libm-* \
420 $(PKG_BUILD_DIR)/libcrypt-* \
424 define Package/libc/install
425 $(call Package/$(LIBC)/install,$1)
428 define Package/libc/install_lib
429 $(CP) $(filter-out %/libdl_pic.a %/libpthread_pic.a %/libresolv_pic.a,$(wildcard $(TOOLCHAIN_DIR)/lib/lib*.a)) $(1)/lib/
430 $(if $(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libc_so.a $(1)/lib/libc_pic.a)
431 $(if $(LIBGCC_MAP), \
432 $(CP) $(LIBGCC_A) $(1)/lib/libgcc_s_pic.a; \
433 $(CP) $(LIBGCC_MAP) $(1)/lib/libgcc_s_pic.map \
437 define Package/libpthread/install
438 $(INSTALL_DIR) $(1)/lib
440 $(TOOLCHAIN_DIR)/lib/libpthread.so.* \
441 $(if $(BUILD_LIBGCC),\
442 $(PKG_BUILD_DIR)/libpthread-$(LIBC_SO_VERSION).so, \
443 $(TOOLCHAIN_DIR)/lib/libpthread-$(LIBC_SO_VERSION).so \
448 define Package/libpthread/install_lib
449 $(if $(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libpthread_so.a $(1)/lib/libpthread_pic.a)
452 define Package/librt/install
453 $(INSTALL_DIR) $(1)/lib
455 $(TOOLCHAIN_DIR)/lib/librt.so.* \
456 $(TOOLCHAIN_DIR)/lib/librt-$(LIBC_SO_VERSION).so \
460 define Package/ldd/install
461 $(INSTALL_DIR) $(1)/usr/bin/
462 $(CP) $(TOOLCHAIN_DIR)/bin/ldd $(1)/usr/bin/
465 define Package/ldconfig/install
466 $(INSTALL_DIR) $(1)/sbin/
467 $(CP) $(TOOLCHAIN_DIR)/sbin/ldconfig $(1)/sbin/
472 define Package/libgcc/install
473 for file in $(call qstrip,$(CONFIG_LIBGCC_FILE_SPEC)); do \
474 dir=`dirname $$$$file` ; \
475 $(INSTALL_DIR) $(1)/$$$$dir ; \
476 $(CP) $(call qstrip,$(CONFIG_LIBGCC_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
481 define Package/libgfortran/install
482 for file in $(call qstrip,$(CONFIG_LIBGFORTRAN_FILE_SPEC)); do \
483 dir=`dirname $$$$file` ; \
484 $(INSTALL_DIR) $(1)/$$$$dir ; \
485 $(CP) $(call qstrip,$(CONFIG_LIBGFORTRAN_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
489 define Package/libssp/install
490 for file in $(call qstrip,$(CONFIG_LIBSSP_FILE_SPEC)); do \
491 dir=`dirname $$$$file` ; \
492 $(INSTALL_DIR) $(1)/$$$$dir ; \
493 $(CP) $(call qstrip,$(CONFIG_LIBSSP_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
498 define Package/libstdcpp/install
499 for file in $(call qstrip,$(CONFIG_LIBSTDCPP_FILE_SPEC)); do \
500 dir=`dirname $$$$file` ; \
501 $(INSTALL_DIR) $(1)/$$$$dir ; \
502 $(CP) $(call qstrip,$(CONFIG_LIBSTDCPP_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
507 define Package/libc/install
508 for file in $(call qstrip,$(CONFIG_LIBC_FILE_SPEC)); do \
509 dir=`dirname $$$$file` ; \
510 $(INSTALL_DIR) $(1)/$$$$dir ; \
511 $(CP) $(call qstrip,$(CONFIG_LIBC_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
516 define Package/libpthread/install
517 for file in $(call qstrip,$(CONFIG_LIBPTHREAD_FILE_SPEC)); do \
518 dir=`dirname $$$$file` ; \
519 $(INSTALL_DIR) $(1)/$$$$dir ; \
520 $(CP) $(call qstrip,$(CONFIG_LIBPTHREAD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
525 define Package/librt/install
526 for file in $(call qstrip,$(CONFIG_LIBRT_FILE_SPEC)); do \
527 dir=`dirname $$$$file` ; \
528 $(INSTALL_DIR) $(1)/$$$$dir ; \
529 $(CP) $(call qstrip,$(CONFIG_LIBRT_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
534 define Package/ldd/install
535 for file in $(call qstrip,$(CONFIG_LDD_FILE_SPEC)); do \
536 dir=`dirname $$$$file` ; \
537 $(INSTALL_DIR) $(1)/$$$$dir ; \
538 $(CP) $(call qstrip,$(CONFIG_LDD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
543 define Package/ldconfig/install
544 for file in $(call qstrip,$(CONFIG_LDCONFIG_FILE_SPEC)); do \
545 dir=`dirname $$$$file` ; \
546 $(INSTALL_DIR) $(1)/$$$$dir ; \
547 $(CP) $(call qstrip,$(CONFIG_LDCONFIG_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
554 $(eval $(call BuildPackage,libc))
555 $(eval $(call BuildPackage,libgcc))
556 $(eval $(call BuildPackage,libssp))
557 $(eval $(call BuildPackage,libstdcpp))
558 $(eval $(call BuildPackage,libpthread))
559 $(eval $(call BuildPackage,librt))
560 $(eval $(call BuildPackage,libgfortran))
561 $(eval $(call BuildPackage,ldd))
562 $(eval $(call BuildPackage,ldconfig))