summaryrefslogtreecommitdiffhomepage
path: root/vars/gcc.vars
blob: 5391aeec82e2d720eb84914b1f428095f480a266 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#
# set -o errexit -o noglob are assumed.
# Order: stage1, runtime, libstdcpp_v3, full, native
# Order: stage1_x86_64_w64_mingw32, native_x86_64_w64_mingw32
#

pkgp_gcc_setup_env() {
	local __;
	export MAKE="make LIBTOOL=slibtool";
	export	cbb_ldflags_for_target=--sysroot="${PKG_PREFIX}"	\
		cbb_sysroot_for_libgcc="${PKG_PREFIX}"			\
		cbb_target="${PKG_TARGET}";
	case "${PKG_NAME}" in
	gcc_stage1)
		export	cbb_neutral_libiberty=no		\
			cbb_xgcc_for_specs="${PKG_BASE_DIR}/${PKG_BUILD_DIR}/gcc/xgcc"; ;;
	gcc_stage1_cross_x86_64_w64_mingw32)
		export	cbb_neutral_libiberty=no		\
			cbb_xgcc_for_specs="${PKG_BASE_DIR}/${PKG_BUILD_DIR}/gcc/xgcc"; ;;
	gcc_stage1_native_x86_64_w64_mingw32)
		export	cbb_neutral_libiberty=no		\
			cbb_xgcc_for_specs="${PKG_TARGET}-gcc"; ;;
	gcc_native)
		export	cbb_xgcc_for_specs="${PKG_TARGET}-gcc"	\
			sysroot_headers_suffix="${PKG_PREFIX}"; ;;
	esac;
	GCCTARGET_FLAGS="-DIN_TARGET_LIBRARY_BUILD --sysroot=${PKG_PREFIX} -midata";
	GCCFLAGS="${CFLAGS:+${CFLAGS} }--include $(readlink -f "${PKG_BASE_DIR}/cbb-gcc-${1}/libc/cbb-musl-pe.h")";
	for __ in CFLAGS CFLAGS_FOR_BUILD CPPFLAGS_FOR_BUILD CXXFLAGS CXXFLAGS_FOR_BUILD; do
		export "${__}=${GCCFLAGS}";
	done;
	for __ in CFLAGS_FOR_TARGET CPPFLAGS_FOR_TARGET CXXFLAGS_FOR_TARGET LIBCFLAGS_FOR_TARGET XGCC_FLAGS_FOR_TARGET; do
		export "${__}=${GCCTARGET_FLAGS}";
	done;
	for __ in cbb_cflags_for_stage1 cbb_cflags_for_stage2 cbb_cflags_for_stage3 cbb_cflags_for_stage4; do
		export "${__}=${CFLAGS_FOR_BUILD}" ;
	done;
	export CFLAGS CXXFLAGS CFLAGS_FOR_BUILD CPPFLAGS_FOR_BUILD CXXFLAGS_FOR_BUILD CFLAGS_FOR_TARGET XGCC_FLAGS_FOR_TARGET CPPFLAGS_FOR_TARGET CXXFLAGS_FOR_TARGET LIBCFLAGS_FOR_TARGET;
};

pkgp_gcc_configure() {
	build_fileop rm "${PKG_BASE_DIR}/${PKG_BUILD_DIR}";
	build_fileop mkdir "${PKG_BASE_DIR}/${PKG_BUILD_DIR}";
	build_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}";
	"../cbb-gcc-${PKG_GCC_VERSION}/configure" "${@}"\
		--disable-bootstrap			\
		--disable-libmudflap			\
		--disable-multilib			\
		--disable-nls				\
		--disable-obsolete			\
		--disable-symvers			\
		--enable-__cxa_atexit			\
		--enable-canonical-system-headers	\
		--enable-debug				\
		--enable-gnu-indirect-function		\
		--enable-gnu-unique-object		\
		--enable-initfini-array			\
		--enable-languages=c,c++,objc,lto	\
		--enable-libstdcxx-debug		\
		--enable-lto				\
		--enable-multiarch			\
		--enable-secureplt			\
		--enable-shared				\
		--enable-threads=posix			\
		--target="${PKG_TARGET}"		\
		--with-fpmath=sse;
	set_build_script_done "${PKG_NAME}" configure -build;
};

pkg_gcc_stage1_cross_x86_64_w64_mingw32_all() {
	pkg_gcc_stage1_all "${@}";
};

pkg_gcc_stage1_native_x86_64_w64_mingw32_all() {
	export AR="${TARGET}-ar";
	export CC="${TARGET}-gcc";
	export CXX="${TARGET}-g++";
	export RANLIB="${TARGET}-ranlib";
	pkg_gcc_stage1_all "${@}";
};

pkg_gcc_stage1_all() {
	local __ _restart_at="${1}";
	case "${PKG_NAME}" in
	gcc_stage1)
		PKG_GCC_VERSION="${PKG_GCC_STAGE1_VERSION}";
		set_build_dir "cbb-gcc-${PKG_GCC_VERSION}" cross;
		;;
	gcc_stage1_cross_x86_64_w64_mingw32)
		PKG_GCC_VERSION="${PKG_GCC_STAGE1_CROSS_X86_64_W64_MINGW32_VERSION}";
		set_build_dir "cbb-gcc-${PKG_GCC_VERSION}" cross;
		;;
	gcc_stage1_native_x86_64_w64_mingw32)
		PKG_GCC_VERSION="${PKG_GCC_STAGE1_NATIVE_X86_64_W64_MINGW32_VERSION}";
		set_build_dir "cbb-gcc-${PKG_GCC_VERSION}" native;
		;;
	esac;
	# GCC, stage1.
	if ! is_build_script_done "${PKG_NAME}" fetch "${_restart_at}"; then
		pkg_fetch_git "cbb-gcc-${PKG_GCC_VERSION}=${DEFAULT_GITROOT}/cbb/cbb-gcc-${PKG_GCC_VERSION}";
		set_build_script_done "${PKG_NAME}" fetch -patch;
	fi;
	if ! is_build_script_done "${PKG_NAME}" patch "${_restart_at}"; then
		if [ -e "${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}.local.patch" ]; then
			patch -b -d "${PKG_BASE_DIR}" -p0 < "${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}.local.patch";
		fi;
		set_build_script_done "${PKG_NAME}" patch -configure;
	fi;
	pkgp_gcc_setup_env "${PKG_GCC_VERSION}";
	if ! is_build_script_done "${PKG_NAME}" configure "${_restart_at}"; then
		build_fileop mkdir "${PKG_PREFIX}/include";
		[ \! -d "${PKG_PREFIX}/usr" ] &&			\
			build_fileop ln_symbolic . "${PKG_PREFIX}/usr";
		case "${PKG_NAME}" in
		gcc_stage1)
			pkgp_gcc_configure				\
				--disable-sjlj-exceptions		\
				--prefix="${PREFIX}"			\
				--with-sysroot="${PREFIX}/${PKG_TARGET}"; ;;
		gcc_stage1_cross_x86_64_w64_mingw32)
			pkgp_gcc_configure				\
				--enable-sjlj-exceptions		\
				--prefix="${PREFIX}"			\
				--with-sysroot="${PREFIX}/${PKG_TARGET}"\
				--without-headers; ;;
		gcc_stage1_native_x86_64_w64_mingw32)
			pkgp_gcc_configure				\
				--build=x86_64-unknown-linux-gnu	\
				--enable-sjlj-exceptions		\
				--host=x86_64-nt64-midipix		\
				--prefix=/				\
				--with-elf="${PKG_PREFIX}"		\
				--with-gmp="${PKG_PREFIX}"		\
				--with-mpc="${PKG_PREFIX}"		\
				--with-mpfr="${PKG_PREFIX}"		\
				--with-sysroot=				\
				--without-headers; ;;
		esac;
	else
		build_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}";
	fi;
	if ! is_build_script_done "${PKG_NAME}" build "${_restart_at}"; then
		make ${PKG_MAKEFLAGS_BUILD} all-gcc;
		set_build_script_done "${PKG_NAME}" build -install;
	fi;
	if ! is_build_script_done "${PKG_NAME}" install "${_restart_at}"; then
		case "${PKG_NAME}" in
		gcc_stage1)
			make ${PKG_MAKEFLAGS_BUILD} install-gcc; ;;
		gcc_stage1_cross_x86_64_w64_mingw32)
			make ${PKG_MAKEFLAGS_BUILD} install-gcc; ;;
		gcc_stage1_native_x86_64_w64_mingw32)
			make ${PKG_MAKEFLAGS_BUILD} "DESTDIR=${PKG_PREFIX}" install-gcc; ;;
		esac;
		__="$(uname -s)";
		if [ "${__#*CYGWIN*}" != "${__}" ]; then
			build_fileop ln_symbolic "${PREFIX}/libexec/gcc/${PKG_TARGET}/${PKG_GCC_VERSION}/liblto_plugin.dll.a"	\
				build_fileop ln_symbolic "${PREFIX}/libexec/gcc/${PKG_TARGET}/${PKG_GCC_VERSION}/liblto_plugin.so";
		fi;
		set_build_script_done "${PKG_NAME}" install finish;
	fi;
	exit 0;
};

pkg_gcc_runtime_all() {
	local _restart_at="${1}";
	export MAKE="make LIBTOOL=slibtool";
	set_build_dir "cbb-gcc-${PKG_GCC_RUNTIME_VERSION}" cross;
	build_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}";
	# GCC, compiler runtime.
	if ! is_build_script_done "${PKG_NAME}" build "${_restart_at}"; then
		make ${PKG_MAKEFLAGS_BUILD} all-target-libgcc;
		set_build_script_done "${PKG_NAME}" build -install;
	fi;
	if ! is_build_script_done "${PKG_NAME}" install "${_restart_at}"; then
		make ${PKG_MAKEFLAGS_BUILD} install-target-libgcc;
		set_build_script_done "${PKG_NAME}" install finish;
	fi;
	exit 0;
};

pkg_gcc_libstdcpp_v3_all() {
	local _restart_at="${1}";
	export MAKE="make LIBTOOL=slibtool";
	set_build_dir "cbb-gcc-${PKG_GCC_LIBSTDCPP_V3_VERSION}" cross;
	build_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}";
	# GCC, libstdc++-v3.
	if ! is_build_script_done "${PKG_NAME}" build "${_restart_at}"; then
		make ${PKG_MAKEFLAGS_BUILD} all-target-libstdc++-v3;
		set_build_script_done "${PKG_NAME}" build -install;
	fi;
	if ! is_build_script_done "${PKG_NAME}" install "${_restart_at}"; then
		make ${PKG_MAKEFLAGS_BUILD} install-target-libstdc++-v3;
		set_build_script_done "${PKG_NAME}" install finish;
	fi;
	exit 0;
};

pkg_gcc_full_all() {
	local _restart_at="${1}";
	export MAKE="make LIBTOOL=slibtool";
	set_build_dir "cbb-gcc-${PKG_GCC_FULL_VERSION}" cross;
	build_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}";
	# GCC, everything else.
	if ! is_build_script_done "${PKG_NAME}" build "${_restart_at}"; then
		make ${PKG_MAKEFLAGS_BUILD};
		set_build_script_done "${PKG_NAME}" build -install;
	fi;
	if ! is_build_script_done "${PKG_NAME}" install "${_restart_at}"; then
		make ${PKG_MAKEFLAGS_BUILD} install;
		set_build_script_done "${PKG_NAME}" install finish;
	fi;
	exit 0;
};

pkg_gcc_native_all() {
	local _restart_at="${1}" _configure_host;
	PKG_GCC_VERSION="${PKG_GCC_NATIVE_VERSION}";
	export MAKE="make LIBTOOL=slibtool";
	# GCC, native.
	set_build_dir "cbb-gcc-${PKG_GCC_VERSION}" native;
	pkgp_gcc_setup_env "${PKG_GCC_VERSION}";
	if ! is_build_script_done "${PKG_NAME}" configure "${_restart_at}"; then
		build_fileop mkdir "${PKG_PREFIX}/${PKG_TARGET}";
		if [ \! -d "${PKG_PREFIX}/${PKG_TARGET}/usr" ]; then
			build_fileop ln_symbolic . "${PKG_PREFIX}/${PKG_TARGET}/usr";
		fi;
		if [ "${ARCH}" = nt32 ]; then
			_configure_host="i686-nt32-midipix";
		else
			_configure_host="x86_64-nt64-midipix";
		fi;
		pkgp_gcc_configure				\
			--disable-sjlj-exceptions		\
			--host="${_configure_host}"		\
			--prefix=/				\
			--with-elf="${PKG_PREFIX}"		\
			--with-gmp="${PKG_PREFIX}"		\
			--with-mpc="${PKG_PREFIX}"		\
			--with-mpfr="${PKG_PREFIX}"		\
			--with-sysroot=;
	else
		build_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}";
	fi;
	if ! is_build_script_done "${PKG_NAME}" build "${_restart_at}"; then
		make ${PKG_MAKEFLAGS_BUILD} all-gcc;
		make ${PKG_MAKEFLAGS_BUILD} all-target-libgcc;
		make ${PKG_MAKEFLAGS_BUILD} all-target-libstdc++-v3;
		make ${PKG_MAKEFLAGS_BUILD} all;
		set_build_script_done "${PKG_NAME}" build -install;
	fi;
	if ! is_build_script_done "${PKG_NAME}" install "${_restart_at}"; then
		make ${PKG_MAKEFLAGS_BUILD} "DESTDIR=${PKG_PREFIX}" install;
		set_build_script_done "${PKG_NAME}" install finish;
	fi;
	exit 0;
};

# vim:filetype=sh