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)
176 TITLE:=POSIX thread library debugging support
180 $(call Package/libc/Default)
181 TITLE:=POSIX.1b RealTime extension library
185 define Package/librt/config
187 depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
189 config LIBRT_ROOT_DIR
191 prompt "librt shared library base directory"
192 depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
193 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
194 default "/" if NATIVE_TOOLCHAIN
196 config LIBRT_FILE_SPEC
198 prompt "librt shared library files (use wildcards)"
199 depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
200 default "./lib/librt{-*.so,.so.*}"
206 define Package/libgfortran
207 $(call Package/gcc/Default)
208 TITLE:=GFortran support library
209 DEPENDS+=@INSTALL_GFORTRAN
212 define Package/libgfortran/config
214 depends EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
216 config LIBGFORTRAN_ROOT_DIR
218 prompt "libgfortran shared library base directory"
219 depends EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
220 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
221 default "/" if NATIVE_TOOLCHAIN
223 config LIBGFORTRAN_FILE_SPEC
225 prompt "libgfortran shared library files (use wildcards)"
226 depends EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
227 default "./usr/lib/libgfortran.so.*"
233 $(call Package/libc/Default)
237 TITLE:=LDD trace utility
240 define Package/ldd/config
242 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
246 prompt "ldd trace utility base directory"
247 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
248 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
249 default "/" if NATIVE_TOOLCHAIN
253 prompt "ldd trace utility file"
254 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldd
255 default "./usr/bin/ldd"
261 define Package/ldconfig
262 $(call Package/libc/Default)
266 TITLE:=Shared library path configuration
269 define Package/ldconfig/config
271 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
273 config LDCONFIG_ROOT_DIR
275 prompt "ldconfig base directory"
276 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
277 default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN
278 default "/" if NATIVE_TOOLCHAIN
280 config LDCONFIG_FILE_SPEC
282 prompt "ldconfig file"
283 depends EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
284 default "./sbin/ldconfig"
290 mkdir -p $(PKG_BUILD_DIR)
293 LIBGCC_A=$(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc_pic.a)
294 LIBGCC_MAP=$(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc.map)
295 LIBGCC_SO=$(wildcard $(TOOLCHAIN_DIR)/lib/libgcc_s.so.*)
296 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
297 ifneq ($(if $(CONFIG_USE_UCLIBC),$(CONFIG_GCC_VERSION_LINARO)),)
298 BUILD_LIBGCC:=$(if $(CONFIG_avr32)$(CONFIG_m68k)$(CONFIG_powerpc),,$(PKG_BUILD_DIR)/libgcc_s.so.*)
302 ifneq ($(BUILD_LIBGCC),)
303 define Build/Compile/uClibc
304 $(SCRIPT_DIR)/relink-lib.sh \
306 "$(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a)" \
307 "$(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a)" \
308 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libuClibc-*.so))" \
309 -Wl,-init,__uClibc_init -Wl,-soname=libc.so.0 \
311 $(SCRIPT_DIR)/relink-lib.sh \
313 "$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt-*.so)" \
314 "$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt_pic.a)" \
315 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt-*.so))" \
317 -Wl,-soname=libcrypt.so.0
318 $(SCRIPT_DIR)/relink-lib.sh \
320 "$(wildcard $(TOOLCHAIN_DIR)/lib/libm-*.so)" \
321 "$(wildcard $(TOOLCHAIN_DIR)/lib/libm_pic.a)" \
322 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libm-*.so))" \
324 -Wl,-soname=libm.so.0
325 $(SCRIPT_DIR)/relink-lib.sh \
327 "$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread-*.so)" \
328 "$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a)" \
329 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread-*.so))" \
330 -Wl,-z,nodelete,-z,initfirst,-init=__pthread_initialize_minimal_internal \
331 -ldl -lc $(BUILD_LIBGCC) \
332 -Wl,-soname=libpthread.so.0
334 define Build/Compile/libgcc
335 $(SCRIPT_DIR)/relink-lib.sh \
339 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(LIBGCC_SO))" \
340 -Wl,--version-script=$(LIBGCC_MAP) -Wl,-soname=libgcc_s.so.1
343 define Build/Compile/uClibc
345 $(TOOLCHAIN_DIR)/lib/libuClibc-*.so \
346 $(TOOLCHAIN_DIR)/lib/libcrypt-*.so \
347 $(TOOLCHAIN_DIR)/lib/libm-*.so \
348 $(TOOLCHAIN_DIR)/lib/libpthread-*.so \
351 ifneq ($(LIBGCC_SO),)
352 define Build/Compile/libgcc
353 $(CP) $(LIBGCC_SO) $(PKG_BUILD_DIR)/
358 define Build/Compile/Default
359 $(call Build/Compile/libgcc)
360 $(call Build/Compile/$(LIBC))
362 Build/Compile = $(Build/Compile/Default)
364 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
366 define Package/libgcc/install
367 $(INSTALL_DIR) $(1)/lib
368 $(if $(CONFIG_TARGET_avr32)$(CONFIG_TARGET_coldfire),,$(CP) $(TOOLCHAIN_DIR)/lib/libgcc_s.so.* $(1)/lib/)
371 define Package/libgfortran/install
372 $(INSTALL_DIR) $(1)/usr/lib
373 $(if $(CONFIG_TARGET_avr32)$(CONFIG_TARGET_coldfire),,$(CP) $(TOOLCHAIN_DIR)/lib/libgfortran.so.* $(1)/usr/lib/)
376 define Package/libssp/install
377 $(INSTALL_DIR) $(1)/lib
378 $(CP) $(TOOLCHAIN_DIR)/lib/libssp.so.* $(1)/lib/
381 define Package/libstdcpp/install
382 $(INSTALL_DIR) $(1)/usr/lib
383 $(CP) $(TOOLCHAIN_DIR)/lib/libstdc++.so.* $(1)/usr/lib/
386 use_libutil=$(if $(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP),libutil)
387 use_libnsl=$(if $(CONFIG_EGLIBC_OPTION_EGLIBC_NIS),libnsl)
388 use_nsswitch=$(if $(CONFIG_EGLIBC_OPTION_EGLIBC_NSSWITCH),libnss_dns libnss_files)
390 define Package/eglibc/install
391 $(CP) ./eglibc-files/* $(1)/
392 rm -f $(1)/etc/localtime
393 ln -sf /tmp/localtime $(1)/etc/localtime
394 $(INSTALL_DIR) $(1)/lib
396 $(TOOLCHAIN_DIR)/lib/ld*.so.* \
397 $(TOOLCHAIN_DIR)/lib/ld-$(LIBC_SO_VERSION).so \
399 for file in libanl libc libcidn libcrypt libdl libm $(use_libnsl) $(use_nsswitch) libresolv $(use_libutil); do \
400 for file in $(TOOLCHAIN_DIR)/lib/$$$$file.so.* $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so; do \
401 if [ -e "$$$$file" ]; then \
402 $(CP) $$$$file $(1)/lib/; \
408 define Package/uClibc/install
409 $(INSTALL_DIR) $(1)/lib
411 $(TOOLCHAIN_DIR)/lib/ld*-uClibc.so.* \
412 $(TOOLCHAIN_DIR)/lib/ld*-uClibc-$(LIBC_SO_VERSION).so \
415 $(TOOLCHAIN_DIR)/lib/libc.so.* \
416 $(TOOLCHAIN_DIR)/lib/libuClibc-$(LIBC_SO_VERSION).so \
418 for file in libcrypt libdl libm libutil; do \
420 $(TOOLCHAIN_DIR)/lib/$$$$file.so.* \
421 $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so \
426 $(PKG_BUILD_DIR)/libuClibc-* \
427 $(PKG_BUILD_DIR)/libm-* \
428 $(PKG_BUILD_DIR)/libcrypt-* \
432 define Package/musl/install
433 $(INSTALL_DIR) $(1)/lib
435 $(TOOLCHAIN_DIR)/lib/ld-musl-*.so* \
438 $(TOOLCHAIN_DIR)/lib/libc.so* \
442 define Package/libc/install
443 $(call Package/$(LIBC)/install,$1)
446 define Package/libc/install_lib
447 $(CP) $(filter-out %/libdl_pic.a %/libpthread_pic.a %/libresolv_pic.a,$(wildcard $(TOOLCHAIN_DIR)/lib/lib*.a)) $(1)/lib/
448 $(if $(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libc_so.a $(1)/lib/libc_pic.a)
449 $(if $(LIBGCC_MAP), \
450 $(CP) $(LIBGCC_A) $(1)/lib/libgcc_s_pic.a; \
451 $(CP) $(LIBGCC_MAP) $(1)/lib/libgcc_s_pic.map \
455 define Package/libpthread/install
456 $(INSTALL_DIR) $(1)/lib
457 ifneq ($(CONFIG_USE_MUSL),y)
459 $(TOOLCHAIN_DIR)/lib/libpthread.so.* \
460 $(if $(BUILD_LIBGCC),\
461 $(PKG_BUILD_DIR)/libpthread-$(LIBC_SO_VERSION).so, \
462 $(TOOLCHAIN_DIR)/lib/libpthread-$(LIBC_SO_VERSION).so \
468 define Package/libthread-db/install
469 $(INSTALL_DIR) $(1)/lib
471 $(TOOLCHAIN_DIR)/lib/libthread_db.so.* $(1)/lib
472 ifeq ($(USE_UCLIBC),y)
474 $(TOOLCHAIN_DIR)/lib/libthread_db-$(LIBC_SO_VERSION).so \
479 define Package/libpthread/install_lib
480 $(if $(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libpthread_so.a $(1)/lib/libpthread_pic.a)
483 define Package/librt/install
484 $(INSTALL_DIR) $(1)/lib
485 ifneq ($(CONFIG_USE_MUSL),y)
487 $(TOOLCHAIN_DIR)/lib/librt.so.* \
488 $(TOOLCHAIN_DIR)/lib/librt-$(LIBC_SO_VERSION).so \
493 define Package/ldd/install
494 $(INSTALL_DIR) $(1)/usr/bin/
495 $(CP) $(TOOLCHAIN_DIR)/bin/ldd $(1)/usr/bin/
498 define Package/ldconfig/install
499 $(INSTALL_DIR) $(1)/sbin/
500 $(CP) $(TOOLCHAIN_DIR)/sbin/ldconfig $(1)/sbin/
505 define Package/libgcc/install
506 for file in $(call qstrip,$(CONFIG_LIBGCC_FILE_SPEC)); do \
507 dir=`dirname $$$$file` ; \
508 $(INSTALL_DIR) $(1)/$$$$dir ; \
509 $(CP) $(call qstrip,$(CONFIG_LIBGCC_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
514 define Package/libgfortran/install
515 for file in $(call qstrip,$(CONFIG_LIBGFORTRAN_FILE_SPEC)); do \
516 dir=`dirname $$$$file` ; \
517 $(INSTALL_DIR) $(1)/$$$$dir ; \
518 $(CP) $(call qstrip,$(CONFIG_LIBGFORTRAN_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
522 define Package/libssp/install
523 for file in $(call qstrip,$(CONFIG_LIBSSP_FILE_SPEC)); do \
524 dir=`dirname $$$$file` ; \
525 $(INSTALL_DIR) $(1)/$$$$dir ; \
526 $(CP) $(call qstrip,$(CONFIG_LIBSSP_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
531 define Package/libstdcpp/install
532 for file in $(call qstrip,$(CONFIG_LIBSTDCPP_FILE_SPEC)); do \
533 dir=`dirname $$$$file` ; \
534 $(INSTALL_DIR) $(1)/$$$$dir ; \
535 $(CP) $(call qstrip,$(CONFIG_LIBSTDCPP_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
540 define Package/libc/install
541 for file in $(call qstrip,$(CONFIG_LIBC_FILE_SPEC)); do \
542 dir=`dirname $$$$file` ; \
543 $(INSTALL_DIR) $(1)/$$$$dir ; \
544 $(CP) $(call qstrip,$(CONFIG_LIBC_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
549 define Package/libpthread/install
550 for file in $(call qstrip,$(CONFIG_LIBPTHREAD_FILE_SPEC)); do \
551 dir=`dirname $$$$file` ; \
552 $(INSTALL_DIR) $(1)/$$$$dir ; \
553 $(CP) $(call qstrip,$(CONFIG_LIBPTHREAD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
558 define Package/librt/install
559 for file in $(call qstrip,$(CONFIG_LIBRT_FILE_SPEC)); do \
560 dir=`dirname $$$$file` ; \
561 $(INSTALL_DIR) $(1)/$$$$dir ; \
562 $(CP) $(call qstrip,$(CONFIG_LIBRT_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
567 define Package/ldd/install
568 for file in $(call qstrip,$(CONFIG_LDD_FILE_SPEC)); do \
569 dir=`dirname $$$$file` ; \
570 $(INSTALL_DIR) $(1)/$$$$dir ; \
571 $(CP) $(call qstrip,$(CONFIG_LDD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
576 define Package/ldconfig/install
577 for file in $(call qstrip,$(CONFIG_LDCONFIG_FILE_SPEC)); do \
578 dir=`dirname $$$$file` ; \
579 $(INSTALL_DIR) $(1)/$$$$dir ; \
580 $(CP) $(call qstrip,$(CONFIG_LDCONFIG_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
587 $(eval $(call BuildPackage,libc))
588 $(eval $(call BuildPackage,libgcc))
589 $(eval $(call BuildPackage,libssp))
590 $(eval $(call BuildPackage,libstdcpp))
591 $(eval $(call BuildPackage,libpthread))
592 $(eval $(call BuildPackage,libthread-db))
593 $(eval $(call BuildPackage,librt))
594 $(eval $(call BuildPackage,libgfortran))
595 $(eval $(call BuildPackage,ldd))
596 $(eval $(call BuildPackage,ldconfig))