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