| 1 | # $FreeWRT$
|
|---|
| 2 |
|
|---|
| 3 | include $(TOPDIR)/rules.mk
|
|---|
| 4 | include ../rules.mk
|
|---|
| 5 |
|
|---|
| 6 | WRKDIR?= ${WRKDIR_BASE}/w-gcc-${GCC_VERSION}-2
|
|---|
| 7 |
|
|---|
| 8 | GCC_VERSION:= 3.4.4
|
|---|
| 9 | MASTER_SITES:= ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-$(GCC_VERSION)/ \
|
|---|
| 10 | http://mirrors.rcn.net/pub/sourceware/gcc/releases/gcc-$(GCC_VERSION)/
|
|---|
| 11 | PKG_MD5SUM:= b594ff4ea4fbef4ba9220887de713dfe
|
|---|
| 12 | SOURCE:= gcc-$(GCC_VERSION).tar.bz2
|
|---|
| 13 | GCC_DIR:= $(WRKDIR)/gcc-$(GCC_VERSION)
|
|---|
| 14 |
|
|---|
| 15 | TARGET_LANGUAGES:= c,c++
|
|---|
| 16 |
|
|---|
| 17 | GCC_BUILD_DIR1:= $(WRKDIR)/gcc-$(GCC_VERSION)-initial
|
|---|
| 18 |
|
|---|
| 19 | GCC_CONFOPTS= --prefix=$(STAGING_TOOLS) \
|
|---|
| 20 | --build=$(GNU_HOST_NAME) \
|
|---|
| 21 | --host=$(GNU_HOST_NAME) \
|
|---|
| 22 | --target=$(REAL_GNU_TARGET_NAME) \
|
|---|
| 23 | --disable-__cxa_atexit \
|
|---|
| 24 | --enable-sjlj-exceptions \
|
|---|
| 25 | --enable-target-optspace \
|
|---|
| 26 | --with-gnu-ld \
|
|---|
| 27 | --disable-nls \
|
|---|
| 28 | --disable-dependency-tracking \
|
|---|
| 29 | --disable-libtool-lock
|
|---|
| 30 |
|
|---|
| 31 | include ${TOPDIR}/mk/fetch.mk
|
|---|
| 32 | include ${TOPDIR}/mk/targets.mk
|
|---|
| 33 |
|
|---|
| 34 | $(GCC_DIR)/.unpacked: ${_CHECKSUM_COOKIE}
|
|---|
| 35 | ${EXTRACT_CMD}
|
|---|
| 36 | touch $@
|
|---|
| 37 |
|
|---|
| 38 | $(GCC_DIR)/.patched: $(GCC_DIR)/.unpacked
|
|---|
| 39 | # Apply any files named gcc-*.patch from the source directory to gcc
|
|---|
| 40 | ${MBSH} $(SCRIPT_DIR)/patch-kernel.sh $(GCC_DIR) ./$(GCC_VERSION) \*.patch
|
|---|
| 41 | typeset -i REV; \
|
|---|
| 42 | if fgrep xml .svn/entries >/dev/null 2>&1; then \
|
|---|
| 43 | let REV="$$(sed -n '/revision=/s/^.*"\([0-9]*\)".*$$/\1/p' \
|
|---|
| 44 | .svn/entries)"; \
|
|---|
| 45 | else \
|
|---|
| 46 | let REV="$$(head -n 4 .svn/entries | tail -1)"; \
|
|---|
| 47 | fi; ${SED} 's,\(version_string.. = "[0-9\.]*\).*\(";\),\1 (FreeWRT rev. '"$$REV"')\2,' ${GCC_DIR}/gcc/version.c
|
|---|
| 48 | $(SED) 's,\(bug_report_url.. = "\).*\(";\),\1<URL:http://www.freewrt.org/development/freewrt>\2,' $(GCC_DIR)/gcc/version.c
|
|---|
| 49 | touch $@
|
|---|
| 50 |
|
|---|
| 51 | $(GCC_BUILD_DIR1)/.configured: $(GCC_DIR)/.patched
|
|---|
| 52 | mkdir -p $(GCC_BUILD_DIR1)
|
|---|
| 53 | (cd $(GCC_BUILD_DIR1); rm -f config.cache; PATH=$(TARGET_PATH) \
|
|---|
| 54 | $(GCC_DIR)/configure \
|
|---|
| 55 | ${GCC_CONFOPTS} \
|
|---|
| 56 | --enable-languages=c \
|
|---|
| 57 | --disable-shared \
|
|---|
| 58 | --with-sysroot=$(TOOLCHAIN_BUILD_DIR)/uClibc_dev/ \
|
|---|
| 59 | );
|
|---|
| 60 | touch $@
|
|---|
| 61 |
|
|---|
| 62 | $(GCC_BUILD_DIR1)/.compiled: $(GCC_BUILD_DIR1)/.configured
|
|---|
| 63 | PATH=$(TARGET_PATH) $(MAKE) -C $(GCC_BUILD_DIR1) all-gcc
|
|---|
| 64 | touch $@
|
|---|
| 65 |
|
|---|
| 66 | $(STAGING_TOOLS)/bin/$(REAL_GNU_TARGET_NAME)-gcc: $(GCC_BUILD_DIR1)/.compiled
|
|---|
| 67 | PATH=$(TARGET_PATH) $(MAKE) -C $(GCC_BUILD_DIR1) install-gcc
|
|---|
| 68 |
|
|---|
| 69 | GCC_BUILD_DIR2:=$(WRKDIR)/gcc-$(GCC_VERSION)-final
|
|---|
| 70 | $(GCC_BUILD_DIR2)/.configured: $(GCC_DIR)/.patched $(STAGING_DIR)/lib/libc.a
|
|---|
| 71 | mkdir -p $(GCC_BUILD_DIR2) ${STAGING_TOOLS}/$(REAL_GNU_TARGET_NAME)
|
|---|
| 72 | # Important! Required for limits.h to be fixed.
|
|---|
| 73 | rm -rf $(STAGING_TOOLS)/$(REAL_GNU_TARGET_NAME)/sys-include
|
|---|
| 74 | ln -sf ${STAGING_DIR}/include $(STAGING_TOOLS)/$(REAL_GNU_TARGET_NAME)/sys-include
|
|---|
| 75 | rm -rf ${STAGING_TOOLS}/$(REAL_GNU_TARGET_NAME)/lib
|
|---|
| 76 | ln -sf ${STAGING_DIR}/lib $(STAGING_TOOLS)/$(REAL_GNU_TARGET_NAME)/lib
|
|---|
| 77 | (cd $(GCC_BUILD_DIR2); rm -f config.cache; PATH=$(TARGET_PATH) \
|
|---|
| 78 | $(GCC_DIR)/configure \
|
|---|
| 79 | ${GCC_CONFOPTS} \
|
|---|
| 80 | --enable-languages=$(TARGET_LANGUAGES) \
|
|---|
| 81 | --enable-shared \
|
|---|
| 82 | --with-sysroot=${STAGING_DIR} \
|
|---|
| 83 | );
|
|---|
| 84 | touch $@
|
|---|
| 85 |
|
|---|
| 86 | $(GCC_BUILD_DIR2)/.compiled: $(GCC_BUILD_DIR2)/.configured
|
|---|
| 87 | PATH=$(TARGET_PATH) $(MAKE) -C $(GCC_BUILD_DIR2) all
|
|---|
| 88 | touch $@
|
|---|
| 89 |
|
|---|
| 90 | ${STAGING_TOOLS}/gcc_installed: $(GCC_BUILD_DIR2)/.compiled
|
|---|
| 91 | PATH=$(TARGET_PATH) $(MAKE) -C $(GCC_BUILD_DIR2) install
|
|---|
| 92 | echo $(GCC_VERSION) > $(STAGING_TOOLS)/gcc_version
|
|---|
| 93 | # Set up the symlinks to enable lying about target name.
|
|---|
| 94 | set -e; \
|
|---|
| 95 | (cd $(STAGING_TOOLS); \
|
|---|
| 96 | ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
|
|---|
| 97 | cd bin; \
|
|---|
| 98 | for app in $(REAL_GNU_TARGET_NAME)-* ; do \
|
|---|
| 99 | ln -sf $${app} \
|
|---|
| 100 | $(GNU_TARGET_NAME)$${app##$(REAL_GNU_TARGET_NAME)}; \
|
|---|
| 101 | done; \
|
|---|
| 102 | )
|
|---|
| 103 | # We do another ugly hack here because the standard behaviour is
|
|---|
| 104 | # to include a reference to libgcc.so.1 in all binaries. For flash space
|
|---|
| 105 | # saving, we change the specs file to link in a static libgcc here.
|
|---|
| 106 | ifeq ($(CPU_ARCH),mipsel)
|
|---|
| 107 | if [ -f $(STAGING_TOOLS)/lib/gcc/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs ] ; then \
|
|---|
| 108 | patch -d $(STAGING_TOOLS)/lib/gcc/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/ -p0 < ./$(GCC_VERSION)/static-libgcc.patch.conditional ; \
|
|---|
| 109 | fi
|
|---|
| 110 | endif
|
|---|
| 111 | touch $@
|
|---|
| 112 |
|
|---|
| 113 | source: ${_CHECKSUM_COOKIE}
|
|---|
| 114 | prepare: $(STAGING_TOOLS)/bin/$(REAL_GNU_TARGET_NAME)-gcc
|
|---|
| 115 | compile: ${STAGING_TOOLS}/gcc_installed
|
|---|
| 116 | install:
|
|---|
| 117 | clean: gcc-clean
|
|---|
| 118 | rm -rf $(GCC_DIR) $(GCC_BUILD_DIR1) $(GCC_BUILD_DIR2)
|
|---|
| 119 | rm -f $(STAGING_TOOLS)/bin/$(REAL_GNU_TARGET_NAME)-{,g}c* \
|
|---|
| 120 | ${STAGING_TOOLS}/gcc_installed
|
|---|