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