5e7116f3871f8de5ebedf3971ea42d01d15ac23f
[openwrt.git] / package / libs / toolchain / Makefile
1 #
2 # Copyright (C) 2007-2012 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9 PKG_NAME:=toolchain
10 PKG_RELEASE:=1
11
12 PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
13
14 include $(INCLUDE_DIR)/package.mk
15
16 ifneq ($(DUMP),1)
17   LIBGCC_VERSION:=$(GCC_VERSION)
18 else
19   LIBC_VERSION:=<LIBC_VERSION>
20   LIBGCC_VERSION:=<LIBGCC_VERSION>
21 endif
22
23 define Package/gcc/Default
24   SECTION:=libs
25   CATEGORY:=Base system
26   URL:=http://gcc.gnu.org/
27   VERSION:=$(LIBGCC_VERSION)-$(PKG_RELEASE)
28 endef
29
30 define Package/libgcc
31 $(call Package/gcc/Default)
32   TITLE:=GCC support library
33 endef
34
35 define Package/libgcc/config
36         menu "Configuration"
37                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
38
39         config LIBGCC_ROOT_DIR
40                 string
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
45
46         config LIBGCC_FILE_SPEC
47                 string
48                 prompt "libgcc shared library files (use wildcards)"
49                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
50                 default "./lib/libgcc_s.so.*"
51
52         endmenu
53 endef
54
55 define Package/libatomic
56 $(call Package/gcc/Default)
57   DEPENDS:=+libgcc
58   TITLE:=Atomic support library
59 endef
60
61 define Package/libatomic/config
62         menu "Configuration"
63                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libatomic
64
65         config LIBATOMIC_ROOT_DIR
66                 string
67                 prompt "libatomic shared library base directory"
68                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libatomic
69                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
70                 default "/"  if NATIVE_TOOLCHAIN
71
72         config LIBATOMIC_FILE_SPEC
73                 string
74                 prompt "libatomic shared library files (use wildcards)"
75                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libatomic
76                 default "./lib/libatomic.so.*"
77
78         endmenu
79 endef
80
81 define Package/libssp
82 $(call Package/gcc/Default)
83   DEPENDS+=@SSP_SUPPORT
84   TITLE:=GCC support library
85 endef
86
87 define Package/libssp/config
88         menu "Configuration"
89                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libssp
90
91         config LIBSSP_ROOT_DIR
92                 string
93                 prompt "libssp shared library base directory"
94                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libssp
95                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
96                 default "/"  if NATIVE_TOOLCHAIN
97
98         config LIBSSP_FILE_SPEC
99                 string
100                 prompt "libssp shared library files (use wildcards)"
101                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libssp
102                 default "./lib/libssp.so.*"
103
104         endmenu
105 endef
106
107
108 define Package/libstdcpp
109 $(call Package/gcc/Default)
110   NAME:=libstdc++
111   TITLE:=GNU Standard C++ Library v3
112 endef
113
114 define Package/libstdcpp/config
115         menu "Configuration"
116         depends on EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
117
118         config LIBSTDCPP_ROOT_DIR
119                 string
120                 prompt "libstdcpp shared library base directory"
121                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
122                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
123                 default "/"  if NATIVE_TOOLCHAIN
124
125         config LIBSTDCPP_FILE_SPEC
126                 string
127                 prompt "libstdc++ shared library files (use wildcards)"
128                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
129                 default "./lib/libstdc++.so.*"
130
131         endmenu
132 endef
133
134
135 define Package/libc/Default
136   SECTION:=libs
137   CATEGORY:=Base system
138   VERSION:=$(LIBC_VERSION)-$(PKG_RELEASE)
139   DEPENDS:=+libgcc
140   URL:=$(LIBC_URL)
141   PKG_FLAGS:=hold essential
142 endef
143
144
145 define Package/libc
146 $(call Package/libc/Default)
147   TITLE:=C library
148 endef
149
150 define Package/libc/config
151         menu "Configuration"
152         depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc
153
154         config LIBC_ROOT_DIR
155                 string
156                 prompt "libc shared library base directory"
157                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc
158                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
159                 default "/"  if NATIVE_TOOLCHAIN
160
161         config LIBC_FILE_SPEC
162                 string
163                 prompt "libc shared library files (use wildcards)"
164                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc
165                 default "./lib/ld{-*.so,-linux*.so.*} ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
166
167         endmenu
168 endef
169
170
171 define Package/libpthread
172 $(call Package/libc/Default)
173   TITLE:=POSIX thread library
174 endef
175
176 define Package/libpthread/config
177         menu "Configuration"
178         depends on EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
179
180         config LIBPTHREAD_ROOT_DIR
181                 string
182                 prompt "libpthread shared library base directory"
183                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
184                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
185                 default "/"  if NATIVE_TOOLCHAIN
186
187         config LIBPTHREAD_FILE_SPEC
188                 string
189                 prompt "libpthread shared library files (use wildcards)"
190                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
191                 default "./lib/libpthread{-*.so,.so.*}"
192
193         endmenu
194 endef
195
196
197 define Package/libthread-db
198 $(call Package/libc/Default)
199   DEPENDS:=@!USE_MUSL
200   TITLE:=POSIX thread library debugging support
201 endef
202
203 define Package/librt
204 $(call Package/libc/Default)
205   TITLE:=POSIX.1b RealTime extension library
206   DEPENDS:=+libpthread
207 endef
208
209 define Package/librt/config
210         menu "Configuration"
211         depends on EXTERNAL_TOOLCHAIN && PACKAGE_librt
212
213         config LIBRT_ROOT_DIR
214                 string
215                 prompt "librt shared library base directory"
216                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_librt
217                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
218                 default "/"  if NATIVE_TOOLCHAIN
219
220         config LIBRT_FILE_SPEC
221                 string
222                 prompt "librt shared library files (use wildcards)"
223                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_librt
224                 default "./lib/librt{-*.so,.so.*}"
225
226         endmenu
227 endef
228
229
230 define Package/libgfortran
231 $(call Package/gcc/Default)
232   TITLE:=GFortran support library
233   DEPENDS+=@INSTALL_GFORTRAN
234 endef
235
236 define Package/libgfortran/config
237         menu "Configuration"
238                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
239
240         config LIBGFORTRAN_ROOT_DIR
241                 string
242                 prompt "libgfortran shared library base directory"
243                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
244                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
245                 default "/"  if NATIVE_TOOLCHAIN
246
247         config LIBGFORTRAN_FILE_SPEC
248                 string
249                 prompt "libgfortran shared library files (use wildcards)"
250                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
251                 default "./usr/lib/libgfortran.so.*"
252
253         endmenu
254 endef
255
256 define Package/ldd
257 $(call Package/libc/Default)
258   DEPENDS:=@!USE_MUSL
259   SECTION:=utils
260   CATEGORY:=Utilities
261   TITLE:=LDD trace utility
262 endef
263
264 define Package/ldd/config
265         menu "Configuration"
266                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldd
267
268         config LDD_ROOT_DIR
269                 string
270                 prompt "ldd trace utility base directory"
271                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldd
272                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
273                 default "/"  if NATIVE_TOOLCHAIN
274
275         config LDD_FILE_SPEC
276                 string
277                 prompt "ldd trace utility file"
278                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldd
279                 default "./usr/bin/ldd"
280
281         endmenu
282 endef
283
284
285 define Package/ldconfig
286 $(call Package/libc/Default)
287   DEPENDS:=@!USE_MUSL
288   SECTION:=utils
289   CATEGORY:=Utilities
290   TITLE:=Shared library path configuration
291 endef
292
293 define Package/ldconfig/config
294         menu "Configuration"
295                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
296
297         config LDCONFIG_ROOT_DIR
298                 string
299                 prompt "ldconfig base directory"
300                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
301                 default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
302                 default "/"  if NATIVE_TOOLCHAIN
303
304         config LDCONFIG_FILE_SPEC
305                 string
306                 prompt "ldconfig file"
307                 depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
308                 default "./sbin/ldconfig"
309
310         endmenu
311 endef
312
313 define Build/Prepare
314         mkdir -p $(PKG_BUILD_DIR)
315 endef
316
317 LIBGCC_A=$(lastword $(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc_pic.a))
318 LIBGCC_MAP=$(lastword $(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc.map))
319 LIBGCC_SO=$(lastword $(wildcard $(TOOLCHAIN_DIR)/lib/libgcc_s.so.*))
320 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
321   ifneq ($(if $(CONFIG_USE_UCLIBC),$(CONFIG_GCC_VERSION_LINARO)),)
322     BUILD_LIBGCC:=$(if $(CONFIG_avr32)$(CONFIG_m68k)$(CONFIG_powerpc),,$(PKG_BUILD_DIR)/libgcc_s.so.*)
323   endif
324 endif
325
326 ifneq ($(BUILD_LIBGCC),)
327   define Build/Compile/uClibc
328         $(SCRIPT_DIR)/relink-lib.sh \
329                 "$(TARGET_CROSS)" \
330                 "$(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a)" \
331                 "$(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a)" \
332                 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libuClibc-*.so))" \
333                 -Wl,-init,__uClibc_init -Wl,-soname=libc.so.0 \
334                 $(BUILD_LIBGCC)
335         $(SCRIPT_DIR)/relink-lib.sh \
336                 "$(TARGET_CROSS)" \
337                 "$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt-*.so)" \
338                 "$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt_pic.a)" \
339                 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libcrypt-*.so))" \
340                 $(BUILD_LIBGCC) \
341                 -Wl,-soname=libcrypt.so.0
342         $(SCRIPT_DIR)/relink-lib.sh \
343                 "$(TARGET_CROSS)" \
344                 "$(wildcard $(TOOLCHAIN_DIR)/lib/libatomic.so)" \
345                 "$(wildcard $(TOOLCHAIN_DIR)/lib/libatomic.a)" \
346                 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libatomic*.so))" \
347                 $(BUILD_LIBGCC) \
348                 -Wl,-soname=libatomic.so.0
349         $(SCRIPT_DIR)/relink-lib.sh \
350                 "$(TARGET_CROSS)" \
351                 "$(wildcard $(TOOLCHAIN_DIR)/lib/libm-*.so)" \
352                 "$(wildcard $(TOOLCHAIN_DIR)/lib/libm_pic.a)" \
353                 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libm-*.so))" \
354                 $(BUILD_LIBGCC) \
355                 -Wl,-soname=libm.so.0
356         $(SCRIPT_DIR)/relink-lib.sh \
357                 "$(TARGET_CROSS)" \
358                 "$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread-*.so)" \
359                 "$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a)" \
360                 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(wildcard $(TOOLCHAIN_DIR)/lib/libpthread-*.so))" \
361                 -Wl,-z,nodelete,-z,initfirst,-init=__pthread_initialize_minimal_internal \
362                 -ldl -lc $(BUILD_LIBGCC) \
363                 -Wl,-soname=libpthread.so.0
364   endef
365   define Build/Compile/libgcc
366         $(SCRIPT_DIR)/relink-lib.sh \
367                 "$(TARGET_CROSS)" \
368                 "$(LIBGCC_SO)" \
369                 "$(LIBGCC_A)" \
370                 "$(patsubst $(TOOLCHAIN_DIR)/lib/%,$(PKG_BUILD_DIR)/%,$(LIBGCC_SO))" \
371                 -Wl,--version-script=$(LIBGCC_MAP) -Wl,-soname=libgcc_s.so.1
372   endef
373 else
374   define Build/Compile/uClibc
375         $(CP) \
376                 $(TOOLCHAIN_DIR)/lib/libuClibc-*.so \
377                 $(TOOLCHAIN_DIR)/lib/libcrypt-*.so \
378                 $(TOOLCHAIN_DIR)/lib/libm-*.so \
379                 $(TOOLCHAIN_DIR)/lib/libpthread-*.so \
380                 $(PKG_BUILD_DIR)/
381   endef
382   ifneq ($(LIBGCC_SO),)
383     define Build/Compile/libgcc
384         $(CP) $(LIBGCC_SO) $(PKG_BUILD_DIR)/
385     endef
386   endif
387 endif
388
389 define Build/Compile/Default
390         $(call Build/Compile/libgcc)
391         $(call Build/Compile/$(LIBC))
392 endef
393 Build/Compile = $(Build/Compile/Default)
394
395 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
396
397   define Package/libgcc/install
398         $(INSTALL_DIR) $(1)/lib
399         $(if $(CONFIG_TARGET_avr32)$(CONFIG_TARGET_coldfire),,$(CP) $(TOOLCHAIN_DIR)/lib/libgcc_s.so.* $(1)/lib/)
400   endef
401
402   define Package/libatomic/install
403         $(INSTALL_DIR) $(1)/lib
404         $(if $(CONFIG_TARGET_avr32)$(CONFIG_TARGET_coldfire),,$(CP) $(TOOLCHAIN_DIR)/lib/libatomic.so.* $(1)/lib/)
405   endef
406
407   define Package/libgfortran/install
408         $(INSTALL_DIR) $(1)/usr/lib
409         $(if $(CONFIG_TARGET_avr32)$(CONFIG_TARGET_coldfire),,$(CP) $(TOOLCHAIN_DIR)/lib/libgfortran.so.* $(1)/usr/lib/)
410   endef
411
412   define Package/libssp/install
413         $(INSTALL_DIR) $(1)/lib
414         $(CP) $(TOOLCHAIN_DIR)/lib/libssp.so.* $(1)/lib/
415   endef
416
417   define Package/libstdcpp/install
418         $(INSTALL_DIR) $(1)/usr/lib
419         $(CP) $(TOOLCHAIN_DIR)/lib/libstdc++.so.* $(1)/usr/lib/
420   endef
421
422   use_libutil=$(if $(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP),libutil)
423   use_libnsl=$(if $(CONFIG_EGLIBC_OPTION_EGLIBC_NIS),libnsl)
424   use_nsswitch=$(if $(CONFIG_EGLIBC_OPTION_EGLIBC_NSSWITCH),libnss_dns libnss_files)
425
426   define Package/eglibc/install
427         $(CP) ./eglibc-files/* $(1)/
428         rm -f $(1)/etc/localtime
429         ln -sf /tmp/localtime $(1)/etc/localtime
430         $(INSTALL_DIR) $(1)/lib
431         $(CP) \
432                 $(TOOLCHAIN_DIR)/lib/ld*.so.* \
433                 $(TOOLCHAIN_DIR)/lib/ld-$(LIBC_SO_VERSION).so \
434                 $(1)/lib/
435         for file in libanl libc libcidn libcrypt libdl libm $(use_libnsl) $(use_nsswitch) libresolv $(use_libutil); do \
436                 for file in $(TOOLCHAIN_DIR)/lib/$$$$file.so.* $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so; do \
437                         if [ -e "$$$$file" ]; then \
438                                 $(CP) $$$$file $(1)/lib/; \
439                         fi; \
440                 done; \
441         done
442   endef
443
444   define Package/uClibc/install
445         $(INSTALL_DIR) $(1)/lib
446         $(CP) \
447                 $(TOOLCHAIN_DIR)/lib/ld*-uClibc.so.* \
448                 $(TOOLCHAIN_DIR)/lib/ld*-uClibc-$(LIBC_SO_VERSION).so \
449                 $(1)/lib/
450         $(CP) \
451                 $(TOOLCHAIN_DIR)/lib/libc.so.* \
452                 $(TOOLCHAIN_DIR)/lib/libuClibc-$(LIBC_SO_VERSION).so \
453                 $(1)/lib/
454         for file in libatomic libcrypt libdl libm libutil; do \
455                 $(CP) \
456                         $(TOOLCHAIN_DIR)/lib/$$$$file.so.* \
457                         $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so \
458                         $(1)/lib/; \
459         done
460
461         $(CP) \
462                 $(PKG_BUILD_DIR)/libuClibc-* \
463                 $(PKG_BUILD_DIR)/libm-* \
464                 $(PKG_BUILD_DIR)/libcrypt-* \
465                 $(1)/lib/
466   endef
467
468   LD_MUSL_NAME = $(notdir $(firstword $(wildcard $(TOOLCHAIN_DIR)/lib/ld-musl-*.so*)))
469
470   define Package/musl/install
471         $(INSTALL_DIR) $(1)/lib $(1)/usr/bin
472         $(CP) \
473                 $(TOOLCHAIN_DIR)/lib/ld-musl-*.so* \
474                 $(1)/lib/
475         $(CP) \
476                 $(TOOLCHAIN_DIR)/lib/libc.so* \
477                 $(1)/lib/
478         ln -s ../../lib/$(LD_MUSL_NAME) $(1)/usr/bin/ldd
479   endef
480
481   define Package/libc/install
482     $(call Package/$(LIBC)/install,$1)
483   endef
484
485   define Package/libc/install_lib
486         $(CP) $(filter-out %/libdl_pic.a %/libpthread_pic.a %/libresolv_pic.a,$(wildcard $(TOOLCHAIN_DIR)/lib/lib*.a)) $(1)/lib/
487         $(if $(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libc_so.a $(1)/lib/libc_pic.a)
488         $(if $(LIBGCC_MAP), \
489                 $(CP) $(LIBGCC_A) $(1)/lib/libgcc_s_pic.a; \
490                 $(CP) $(LIBGCC_MAP) $(1)/lib/libgcc_s_pic.map \
491         )
492   endef
493
494   define Package/libpthread/install
495         $(INSTALL_DIR) $(1)/lib
496   ifneq ($(CONFIG_USE_MUSL),y)
497         $(CP) \
498                 $(TOOLCHAIN_DIR)/lib/libpthread.so.* \
499                 $(if $(BUILD_LIBGCC),\
500                         $(PKG_BUILD_DIR)/libpthread-$(LIBC_SO_VERSION).so, \
501                         $(TOOLCHAIN_DIR)/lib/libpthread-$(LIBC_SO_VERSION).so \
502                 ) \
503                 $(1)/lib/
504   endif
505   endef
506
507   define Package/libthread-db/install
508         $(INSTALL_DIR) $(1)/lib
509         $(CP) \
510                 $(TOOLCHAIN_DIR)/lib/libthread_db.so.* $(1)/lib
511   ifeq ($(CONFIG_USE_UCLIBC),y)
512         $(CP) \
513                 $(TOOLCHAIN_DIR)/lib/libthread_db-$(LIBC_SO_VERSION).so \
514                 $(1)/lib/
515   endif
516   endef
517
518   define Package/libpthread/install_lib
519         $(if $(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libpthread_so.a $(1)/lib/libpthread_pic.a)
520   endef
521
522   define Package/librt/install
523         $(INSTALL_DIR) $(1)/lib
524   ifneq ($(CONFIG_USE_MUSL),y)
525         $(CP) \
526                 $(TOOLCHAIN_DIR)/lib/librt.so.* \
527                 $(TOOLCHAIN_DIR)/lib/librt-$(LIBC_SO_VERSION).so \
528                 $(1)/lib/
529   endif
530   endef
531
532   define Package/ldd/install
533         $(INSTALL_DIR) $(1)/usr/bin/
534         $(CP) $(TOOLCHAIN_DIR)/bin/ldd $(1)/usr/bin/
535   endef
536
537   define Package/ldconfig/install
538         $(INSTALL_DIR) $(1)/sbin/
539         $(CP) $(TOOLCHAIN_DIR)/sbin/ldconfig $(1)/sbin/
540   endef
541
542 else
543
544   define Package/libgcc/install
545         for file in $(call qstrip,$(CONFIG_LIBGCC_FILE_SPEC)); do \
546                 dir=`dirname $$$$file` ; \
547                 $(INSTALL_DIR) $(1)/$$$$dir ; \
548                 $(CP) $(call qstrip,$(CONFIG_LIBGCC_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
549         done ; \
550         exit 0
551   endef
552
553   define Package/libgfortran/install
554         for file in $(call qstrip,$(CONFIG_LIBGFORTRAN_FILE_SPEC)); do \
555                 dir=`dirname $$$$file` ; \
556                 $(INSTALL_DIR) $(1)/$$$$dir ; \
557                 $(CP) $(call qstrip,$(CONFIG_LIBGFORTRAN_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
558         done
559   endef
560
561   define Package/libssp/install
562         for file in $(call qstrip,$(CONFIG_LIBSSP_FILE_SPEC)); do \
563                 dir=`dirname $$$$file` ; \
564                 $(INSTALL_DIR) $(1)/$$$$dir ; \
565                 $(CP) $(call qstrip,$(CONFIG_LIBSSP_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
566         done ; \
567         exit 0
568   endef
569
570   define Package/libstdcpp/install
571         for file in $(call qstrip,$(CONFIG_LIBSTDCPP_FILE_SPEC)); do \
572                 dir=`dirname $$$$file` ; \
573                 $(INSTALL_DIR) $(1)/$$$$dir ; \
574                 $(CP) $(call qstrip,$(CONFIG_LIBSTDCPP_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
575         done ; \
576         exit 0
577   endef
578
579   define Package/libc/install
580         for file in $(call qstrip,$(CONFIG_LIBC_FILE_SPEC)); do \
581                 dir=`dirname $$$$file` ; \
582                 $(INSTALL_DIR) $(1)/$$$$dir ; \
583                 $(CP) $(call qstrip,$(CONFIG_LIBC_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
584         done ; \
585         exit 0
586   endef
587
588   define Package/libpthread/install
589         for file in $(call qstrip,$(CONFIG_LIBPTHREAD_FILE_SPEC)); do \
590                 dir=`dirname $$$$file` ; \
591                 $(INSTALL_DIR) $(1)/$$$$dir ; \
592                 $(CP) $(call qstrip,$(CONFIG_LIBPTHREAD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
593         done ; \
594         exit 0
595   endef
596
597   define Package/librt/install
598         for file in $(call qstrip,$(CONFIG_LIBRT_FILE_SPEC)); do \
599                 dir=`dirname $$$$file` ; \
600                 $(INSTALL_DIR) $(1)/$$$$dir ; \
601                 $(CP) $(call qstrip,$(CONFIG_LIBRT_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
602         done ; \
603         exit 0
604   endef
605
606   define Package/ldd/install
607         for file in $(call qstrip,$(CONFIG_LDD_FILE_SPEC)); do \
608                 dir=`dirname $$$$file` ; \
609                 $(INSTALL_DIR) $(1)/$$$$dir ; \
610                 $(CP) $(call qstrip,$(CONFIG_LDD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
611         done ; \
612         exit 0
613   endef
614
615   define Package/ldconfig/install
616         for file in $(call qstrip,$(CONFIG_LDCONFIG_FILE_SPEC)); do \
617                 dir=`dirname $$$$file` ; \
618                 $(INSTALL_DIR) $(1)/$$$$dir ; \
619                 $(CP) $(call qstrip,$(CONFIG_LDCONFIG_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
620         done ; \
621         exit 0
622   endef
623
624 endif
625
626 $(eval $(call BuildPackage,libc))
627 $(eval $(call BuildPackage,libgcc))
628 $(eval $(call BuildPackage,libatomic))
629 $(eval $(call BuildPackage,libssp))
630 $(eval $(call BuildPackage,libstdcpp))
631 $(eval $(call BuildPackage,libpthread))
632 $(eval $(call BuildPackage,libthread-db))
633 $(eval $(call BuildPackage,librt))
634 $(eval $(call BuildPackage,libgfortran))
635 $(eval $(call BuildPackage,ldd))
636 $(eval $(call BuildPackage,ldconfig))