handle ssp support for glibc/eglibc/gcc
[openadk.git] / toolchain / gcc / Makefile
blob190cdf689265bb7e67f3049d0e43c27e5e854780
1 # This file is part of the OpenADK project. OpenADK is copyrighted
2 # material, please see the LICENCE file in the top-level directory.
4 include $(TOPDIR)/rules.mk
5 include ../rules.mk
7 TARGET_CFLAGS:= $(filter-out -fstack-protector,$(TARGET_CFLAGS))
9 include Makefile.inc
11 GCC_CONFOPTS= --prefix=$(STAGING_HOST_DIR) \
12 --build=$(GNU_HOST_NAME) \
13 --host=$(GNU_HOST_NAME) \
14 --target=$(REAL_GNU_TARGET_NAME) \
15 --with-gmp=$(STAGING_HOST_DIR) \
16 --with-mpfr=$(STAGING_HOST_DIR) \
17 --with-libelf=$(STAGING_HOST_DIR) \
18 --disable-__cxa_atexit \
19 --with-gnu-ld \
20 --disable-libmudflap \
21 --disable-libgomp \
22 --disable-biarch \
23 --disable-decimal-float \
24 --disable-multilib \
25 --disable-sjlj-exceptions \
26 --disable-libstdcxx-pch \
27 --disable-ppl-version-check \
28 --disable-cloog-version-check \
29 --without-ppl \
30 --without-cloog \
31 --disable-nls
33 ifeq ($(ADK_TOOLCHAIN_GCC_SSP),y)
34 GCC_CONFOPTS+= --enable-libssp
35 else
36 GCC_CONFOPTS+= --disable-libssp
37 endif
39 ifeq ($(ADK_TOOLCHAIN_GCC_LTO),y)
40 GCC_CONFOPTS+= --enable-lto
41 else
42 GCC_CONFOPTS+= --disable-lto
43 endif
45 ifeq ($(ARCH),cris)
46 GCC_CONFOPTS+= --disable-tls
47 else
48 GCC_CONFOPTS+= --enable-tls
49 endif
51 ifeq ($(ARCH),powerpc)
52 GCC_CONFOPTS+= --disable-target-optspace
53 else
54 GCC_CONFOPTS+= --enable-target-optspace
55 endif
57 ifeq ($(ADK_TARGET_NO_FPU),y)
58 GCC_CONFOPTS+= --with-float=soft
59 endif
61 ifeq ($(ADK_LINUX_MIPS64),y)
62 GCC_CONFOPTS+= --with-abi=64
63 endif
65 ifeq ($(ADK_LINUX_MIPS64EL),y)
66 GCC_CONFOPTS+= --with-abi=64
67 endif
69 ifeq (${ADK_MAKE_PARALLEL},y)
70 GCC_MAKEOPTS+= -j${ADK_MAKE_JOBS}
71 endif
73 LANGUAGES:=c
74 ifeq ($(ADK_TOOLCHAIN_GCC_CXX),y)
75 LANGUAGES:=${LANGUAGES},c++
76 endif
77 ifeq ($(ADK_TOOLCHAIN_GCC_JAVA),y)
78 LANGUAGES:=${LANGUAGES},java
79 endif
80 ifeq ($(ADK_TOOLCHAIN_GCC_ADA),y)
81 LANGUAGES:=${LANGUAGES},ada
82 endif
84 include ${TOPDIR}/mk/buildhlp.mk
86 GCC_BUILD_DIR_MINIMAL:= $(WRKBUILD)-minimal
87 GCC_BUILD_DIR_INITIAL:= $(WRKBUILD)-initial
88 GCC_BUILD_DIR_FINAL:= $(WRKBUILD)-final
90 $(GCC_BUILD_DIR_MINIMAL)/.configured:
91 mkdir -p $(GCC_BUILD_DIR_MINIMAL)
92 # these symlinks are very important, do not remove
93 rm -rf $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
94 ln -sf ${STAGING_TARGET_DIR}/include $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
95 rm -rf ${STAGING_HOST_DIR}/$(REAL_GNU_TARGET_NAME)/lib
96 ln -sf ${STAGING_TARGET_DIR}/lib $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/lib
97 (cd $(GCC_BUILD_DIR_MINIMAL); \
98 PATH='$(TARGET_PATH)' \
99 $(WRKBUILD)/configure \
100 ${GCC_CONFOPTS} \
101 --enable-languages=c \
102 --disable-shared \
103 --with-newlib \
104 --without-headers \
106 touch $@
108 $(GCC_BUILD_DIR_MINIMAL)/.compiled: $(GCC_BUILD_DIR_MINIMAL)/.configured
109 PATH='$(TARGET_PATH)' \
110 $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_MINIMAL) all-gcc
111 touch $@
113 $(WRKBUILD)/.headers: $(GCC_BUILD_DIR_MINIMAL)/.compiled
114 PATH='$(TARGET_PATH)' \
115 $(MAKE) -C $(GCC_BUILD_DIR_MINIMAL) install-gcc
116 touch $@
118 $(GCC_BUILD_DIR_INITIAL)/.configured:
119 mkdir -p $(GCC_BUILD_DIR_INITIAL)
120 (cd $(GCC_BUILD_DIR_INITIAL); \
121 PATH='$(TARGET_PATH)' \
122 $(WRKBUILD)/configure \
123 ${GCC_CONFOPTS} \
124 --enable-languages=c \
125 --disable-shared \
126 --disable-threads \
127 --with-newlib \
128 --with-sysroot=$(STAGING_TARGET_DIR) \
130 touch $@
133 $(GCC_BUILD_DIR_INITIAL)/.compiled: $(GCC_BUILD_DIR_INITIAL)/.configured
134 PATH='$(TARGET_PATH)' \
135 $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_INITIAL) all-gcc all-target-libgcc
136 touch $@
138 $(WRKBUILD)/.configured: $(GCC_BUILD_DIR_INITIAL)/.compiled
139 PATH='$(TARGET_PATH)' \
140 $(MAKE) -C $(GCC_BUILD_DIR_INITIAL) install-gcc install-target-libgcc
141 touch $@
143 $(GCC_BUILD_DIR_FINAL)/.configured:
144 mkdir -p $(GCC_BUILD_DIR_FINAL)
145 (cd $(GCC_BUILD_DIR_FINAL); \
146 PATH='$(TARGET_PATH)' \
147 $(WRKBUILD)/configure \
148 ${GCC_CONFOPTS} \
149 --enable-languages=$(LANGUAGES) \
150 --with-sysroot='$${prefix}/${STAGING_HOST2TARGET}' \
151 --with-slibdir=$(STAGING_TARGET_DIR)/lib \
152 --enable-shared \
154 touch $@
156 $(WRKBUILD)/.compiled: $(GCC_BUILD_DIR_FINAL)/.configured
157 PATH='$(TARGET_PATH)' \
158 $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_FINAL) all
159 touch $@
161 $(WRKBUILD)/.installed: $(WRKBUILD)/.compiled
162 PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_FINAL) install
163 # Set up the symlinks to enable lying about target name.
164 set -e; \
165 (cd $(STAGING_HOST_DIR); \
166 ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
167 cd bin; \
168 for app in $(REAL_GNU_TARGET_NAME)-* ; do \
169 ln -sf $${app} \
170 $(GNU_TARGET_NAME)$${app##$(REAL_GNU_TARGET_NAME)}; \
171 done; \
173 touch $@
175 include ${TOPDIR}/mk/toolchain.mk