source: trunk/toolchain/make/toolchain-common.in @ 6384

Letzte Änderung dieser Datei seit 6384 war 6384, erstellt von er13 vor 8 Jahren

toolchain:

  • exclude kernel-headers from the download-toolchain
  • install the right ones at the build-time
  • refs #842, refs #348
Dateigröße: 3.5 KB
Zeile 
1TOOLCHAIN_HOSTCC:=gcc
2TOOLCHAIN_HOST_CFLAGS:=
3ifeq ($(strip $(FREETZ_TOOLCHAIN_MINIMIZE_REQUIRED_GLIBC_VERSION)),y)
4
5# avoids dependency on __isoc99_sscanf@@GLIBC_2.7 (added in GLIBC 2.7)
6TOOLCHAIN_HOST_CFLAGS+=-D_GNU_SOURCE
7
8# avoids dependency on __stack_chk_fail@@GLIBC_2.4 (added in GLIBC 2.4)
9TOOLCHAIN_HOST_CFLAGS+=-fno-stack-protector
10
11endif
12
13ifeq ($(strip $(FREETZ_BUILD_32BIT_TOOLCHAIN)),y)
14TOOLCHAIN_HOST_CFLAGS+=-m32
15endif
16
17BINUTILS_BINARIES_BIN := addr2line ar as c++filt elfedit gprof ld nm objcopy objdump ranlib readelf size strings strip
18GCC_BINARIES_BIN := gcc g++ cc c++ cpp gccbug gcov
19GCC_BINARIES_LIBEXEC := cc1 cc1plus collect2 install-tools/fixincl
20
21# $1 - toolchain base dir
22# $2 - binaries
23# $3 - target name
24define TOOLCHAIN_BINARIES_LIST
25    $(addprefix $(1),$(foreach p,/bin/ /bin/$(3)- /$(3)/bin/,$(foreach b,$(2),$(p)$(b))))
26endef
27
28# $1 - toolchain base dir
29# $2 - binaries
30# $3 - target name
31# $4 - strip command to be used
32define STRIP_TOOLCHAIN_BINARIES
33    -$(4) $(call TOOLCHAIN_BINARIES_LIST,$(1),$(2),$(3)) >/dev/null 2>&1
34endef
35
36# $1 - toolchain base dir
37# $2 - gcc version
38# $3 - target name
39# $4 - strip command to be used
40define STRIP_GCC_LIBEXEC_BINARIES
41    -$(4) $(addprefix $(1)/libexec/gcc/$(3)/$(2)/,$(GCC_BINARIES_LIBEXEC)) >/dev/null 2>&1
42endef
43
44# $1 - toolchain base dir
45# $2 - target name
46define GCC_ENSURE_CC_CXX
47    # make sure we have '*cc' && '*c++' / replace identical files and hardlinks with symlinks
48    for d in "$(1)/bin" "$(1)/$(2)/bin"; do \
49        for p in "" $(2)-; do \
50            pp="$${d}/$${p}"; \
51            if [ -f "$${pp}gcc" ]; then \
52                ln -snf $${p}gcc $${pp}cc; \
53            fi; \
54            if [ -f "$${pp}g++" ]; then \
55                ln -snf $${p}g++ $${pp}c++; \
56            fi; \
57        done; \
58    done;
59endef
60
61# $1 - toolchain base dir
62# $2 - gcc version
63# $3 - target name
64# $4 - strip command to be used
65define GCC_INSTALL_COMMON
66    $(RM) $(1)/bin/*-$(2) # remove unnecessary *-$(GCC_VERSION) files
67    $(call STRIP_TOOLCHAIN_BINARIES,$(1),$(GCC_BINARIES_BIN),$(3),$(4))
68    $(call STRIP_GCC_LIBEXEC_BINARIES,$(1),$(2),$(3),$(4))
69    $(call GCC_ENSURE_CC_CXX,$(1),$(3))
70endef
71
72# $1 - toolchain base dir
73# $2 - binaries
74# $3 - real target name
75# $4 - target name
76define CREATE_TARGET_NAME_SYMLINKS
77    for app in $(2); do \
78        if [ -e $(1)/bin/$(3)-$${app} ]; then \
79            ln -snf $(3)-$${app} $(1)/bin/$(4)-$${app}; \
80        fi; \
81    done;
82endef
83
84define updir
85$(patsubst %/,%,$(dir $(patsubst %/,%,$(strip $(1)))))
86endef
87
88
89TOOLCHAIN_EXCLUDE_FILES := *uClibc++* *g++-uc libtool* aclocal lib32
90# Union of versions 2.6.13, 2.6.19, and 2.6.28
91KERNEL_HEADERS_SUBDIRS := asm asm-generic drm linux mtd rdma scsi sound video
92
93# $1 - toolchain base dir
94# $2 - tarball name suffix (TARGET_ARCH? / toolchain version)
95define TOOLCHAIN_CREATE_TARBALL
96    droot="$(call updir,$(call updir,$(1)))"; \
97    dname="$(notdir $(call updir,$(1)))"; \
98    tname="$${dname}$(if $(strip $(2)),-$(strip $(2)))"; \
99    $(RM) $(DL_DIR)/$${tname}.tar.lzma; \
100    $(TOOLS_DIR)/tar -C $${droot} -c $${dname} $(foreach f,$(TOOLCHAIN_EXCLUDE_FILES) $(addprefix include/,$(KERNEL_HEADERS_SUBDIRS)),--exclude $(f)) | \
101    $(TOOLS_DIR)/lzma e -si $(DL_DIR)/$${tname}.tar.lzma -d25;
102endef
103
104# $1 - source dir
105# $2 - target dir
106# $3 - subdirs to be copied (optional, if omitted all subdirs are copied)
107define COPY_KERNEL_HEADERS
108    if ! diff -q $(strip $(1))/include/linux/version.h $(strip $(2))/include/linux/version.h >/dev/null 2>&1 ; then \
109        $(RM) -r $(addprefix $(strip $(2))/include/,$(KERNEL_HEADERS_SUBDIRS)); \
110        mkdir -p $(strip $(2))/include/; \
111        cp -pLR $(strip $(1))/include/$(if $(strip $(3)),$(strip $(3)),*) $(strip $(2))/include/; \
112    fi;
113endef
Hinweis: Hilfe zum Repository-Browser finden Sie in TracBrowser.