blob: 388b7adc5e84e6a6cfe4f896c731e297086b1d23 (
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
|
#
# set +o errexit -o noglob -o nounset is assumed.
# Order: stage1_host, runtime_host, libstdcpp_v3_host, full_host, full
# Order: stage1_mingw32, native_mingw32
#
#
# Private subroutines
#
pkgp_gcc_build_dir() { PKG_BUILD_DIR="${1}-${2}-${PKG_TARGET}"; };
pkgp_gcc_state_set() {
printf "step unknown %s %s\n" "${PKG_NAME}" "${1}" >&3;
ex_pkg_state_set "${PKG_NAME}" "${1}" ${2:+"${2}"};
};
pkgp_gcc_configure() {
if ! rtl_fileop rm "${PKG_BASE_DIR}/${PKG_BUILD_DIR}" \
|| ! rtl_fileop mkdir "${PKG_BASE_DIR}/${PKG_BUILD_DIR}" \
|| ! rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}" \
|| ! "../cbb-gcc-${PKG_VERSION}/configure" "${@}" \
--disable-bootstrap \
--disable-libmudflap \
--disable-multilib \
--disable-nls \
--disable-obsolete \
--disable-symvers \
--enable-canonical-system-headers \
--enable-__cxa_atexit \
--enable-debug \
--enable-gnu-indirect-function \
--enable-gnu-unique-object \
--enable-initfini-array \
--enable-languages=c,c++,fortran,objc,lto \
--enable-libstdcxx-debug \
--enable-lto \
--enable-multiarch \
--enable-secureplt \
--enable-shared \
--enable-threads=posix \
--target="${PKG_TARGET}" \
--with-fpmath=sse; then
return 1;
else
pkgp_gcc_state_set "configure" "build";
fi;
};
pkgp_gcc_setup_env() {
local _vname="";
for _vname in CFLAGS CFLAGS_FOR_BUILD CPPFLAGS_FOR_BUILD \
CXXFLAGS CXXFLAGS_FOR_BUILD; do
export "${_vname}=${GCCFLAGS}";
done;
for _vname in CFLAGS_FOR_TARGET CPPFLAGS_FOR_TARGET CXXFLAGS_FOR_TARGET \
LIBCFLAGS_FOR_TARGET XGCC_FLAGS_FOR_TARGET; do
export "${_vname}=${GCCTARGET_FLAGS}";
done;
for _vname in cbb_cflags_for_stage1 cbb_cflags_for_stage2 \
cbb_cflags_for_stage3 cbb_cflags_for_stage4; do
export "${_vname}=${CFLAGS_FOR_BUILD}" ;
done;
};
pkgp_gcc_setup_vars() {
local _unwind_midipix_h="";
export cbb_target="${PKG_TARGET}" MAKE="make LIBTOOL=slibtool";
_unwind_midipix_h="$(readlink -f "${PKG_BASE_DIR}/cbb-gcc-${PKG_VERSION}/gcc/unwind-midipix.h")";
case "${PKG_NAME}" in
gcc_full)
GCCTARGET_FLAGS="-DIN_TARGET_LIBRARY_BUILD --sysroot=${PKG_PREFIX}";
GCCTARGET_FLAGS="$(rtl_lconcat "${GCCTARGET_FLAGS}" "--include=${_unwind_midipix_h}")";
GCCTARGET_FLAGS="$(rtl_lconcat "${GCCTARGET_FLAGS}" "-DTARGET_PERSONALITY_FUNCTION")";
GCCTARGET_FLAGS="$(rtl_lconcat "${GCCTARGET_FLAGS}" "-DTARGET_PERSONALITY_FUNCTION_MIDIPIX")";
GCCTARGET_FLAGS="$(rtl_lconcat "${GCCTARGET_FLAGS}" "${DEFAULT_CFLAGS_DEBUG_RUNTIME}")";
export cbb_ldflags_for_target=--sysroot="${PKG_PREFIX}" \
cbb_sysroot_for_libgcc="${PKG_PREFIX}" \
cbb_xgcc_for_specs="${PKG_TARGET}-gcc" \
sysroot_headers_suffix="${PKG_PREFIX}"; ;;
gcc_stage1_cross_mingw32)
GCCTARGET_FLAGS="-DIN_TARGET_LIBRARY_BUILD --sysroot=${PREFIX_MINGW32} -midata";
export cbb_ldflags_for_target=--sysroot="${PREFIX_MINGW32}" \
cbb_neutral_libiberty=no \
cbb_sysroot_for_libgcc="${PREFIX_MINGW32}" \
cbb_xgcc_for_specs="${PKG_BASE_DIR}/${PKG_BUILD_DIR}/gcc/xgcc"; ;;
gcc_stage1_host)
GCCTARGET_FLAGS="-DIN_TARGET_LIBRARY_BUILD --sysroot=${PREFIX_CROSS}";
GCCTARGET_FLAGS="$(rtl_lconcat "${GCCTARGET_FLAGS}" "--include=${_unwind_midipix_h}")";
GCCTARGET_FLAGS="$(rtl_lconcat "${GCCTARGET_FLAGS}" "-DTARGET_PERSONALITY_FUNCTION")";
GCCTARGET_FLAGS="$(rtl_lconcat "${GCCTARGET_FLAGS}" "-DTARGET_PERSONALITY_FUNCTION_MIDIPIX")";
GCCTARGET_FLAGS="$(rtl_lconcat "${GCCTARGET_FLAGS}" "${DEFAULT_CFLAGS_DEBUG_RUNTIME}")";
export cbb_ldflags_for_target="--sysroot=${PREFIX_CROSS}" \
cbb_neutral_libiberty="no" \
cbb_sysroot_for_libgcc="${PREFIX_CROSS}" \
cbb_xgcc_for_specs="${PKG_BASE_DIR}/${PKG_BUILD_DIR}/gcc/xgcc" \
LDFLAGS="${PKG_LDFLAGS_CONFIGURE}"; ;;
gcc_stage1_native_mingw32)
GCCTARGET_FLAGS="-DIN_TARGET_LIBRARY_BUILD --sysroot=${PKG_PREFIX} -midata";
export cbb_ldflags_for_target=--sysroot="${PKG_PREFIX}" \
cbb_neutral_libiberty=no \
cbb_sysroot_for_libgcc="${PKG_PREFIX}" \
cbb_xgcc_for_specs="${PKG_TARGET}-gcc"; ;;
esac;
GCCFLAGS="$(rtl_lconcat "${PKG_CFLAGS_CONFIGURE}" \
"--include $(readlink -f "${PKG_BASE_DIR}/cbb-gcc-${PKG_VERSION}/libc/cbb-musl-pe.h")")";
};
pkgp_gcc_stage1_all() {
local _restart_at="${1}" _rc=0;
case "${PKG_NAME}" in
gcc_stage1_cross_mingw32)
pkgp_gcc_build_dir "cbb-gcc-${PKG_VERSION}" mingw32; ;;
gcc_stage1_host)
if ! rtl_fileop ln_symbolic . "${PREFIX_CROSS}/usr"\
|| ! rtl_fileop mkdir "${PREFIX_CROSS}/usr/include"\
|| ! pkgp_gcc_build_dir "cbb-gcc-${PKG_VERSION}" cross; then
_rc=1;
fi; ;;
gcc_stage1_native_mingw32)
pkgp_gcc_build_dir "cbb-gcc-${PKG_VERSION}" native; ;;
esac;
if [ "${_rc}" -ne 0 ]; then
return 1;
fi;
if ! ex_pkg_state_test "${PKG_NAME}" fetch "${_restart_at}"; then
if ! pkg_fetch_download_dlcache_subdir; then
return 1;
elif ! rtl_fetch_urls_git \
"${BUILD_DLCACHEDIR}/${PKG_NAME}" "${DEFAULT_GIT_ARGS}" "${PKG_BASE_DIR}" \
"${PKG_NAME}" "${PKG_MIRRORS_GIT:-}" \
"cbb-gcc-${PKG_VERSION}=${PKG_GITROOT}/cbb/cbb-gcc-${PKG_VERSION}"; then
return 1;
else
pkgp_gcc_state_set "fetch" "patch";
fi;
fi;
if ! ex_pkg_state_test "${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" || return 1;
fi;
pkgp_gcc_state_set "patch" "configure";
fi;
pkgp_gcc_setup_vars; pkgp_gcc_setup_env;
if ! ex_pkg_state_test "${PKG_NAME}" configure "${_restart_at}"; then
case "${PKG_NAME}" in
gcc_stage1_cross_mingw32)
pkgp_gcc_configure \
--enable-sjlj-exceptions \
--prefix="${PREFIX}" \
--with-gmp="${PREFIX}" \
--with-mpc="${PREFIX}" \
--with-mpfr="${PREFIX}" \
--with-sysroot="${PREFIX_MINGW32}" \
--without-headers; ;;
gcc_stage1_host)
pkgp_gcc_configure \
--disable-sjlj-exceptions \
--prefix="${PREFIX}" \
--with-gmp="${PREFIX}" \
--with-mpc="${PREFIX}" \
--with-mpfr="${PREFIX}" \
--with-sysroot="${PREFIX_CROSS}"; ;;
gcc_stage1_native_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;
if [ "${?}" -ne 0 ]; then
return 1;
fi;
else rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}" || return 1;
fi;
if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then
make ${PKG_MAKEFLAGS_BUILD} "all-gcc" || return 1;
pkgp_gcc_state_set "build" "install_subdirs";
fi;
if ! ex_pkg_state_test "${PKG_NAME}" install_subdirs "${_restart_at}"; then
pkg_install_subdirs || return 1;
pkgp_gcc_state_set "install_subdirs" "install_make";
fi;
if ! ex_pkg_state_test "${PKG_NAME}" install_make "${_restart_at}"; then
case "${PKG_NAME}" in
gcc_stage1_cross_mingw32)
make ${PKG_MAKEFLAGS_BUILD} "prefix=${PKG_DESTDIR}" "install-gcc"; ;;
gcc_stage1_host)
make ${PKG_MAKEFLAGS_BUILD} "prefix=${PKG_DESTDIR}" "install-gcc"; ;;
gcc_stage1_native_mingw32)
make ${PKG_MAKEFLAGS_BUILD} "prefix=${PKG_DESTDIR}" "install-gcc"; ;;
esac;
if [ "${?}" -ne 0 ]; then
return 1;
else case "$(uname -s)" in
CYGWIN_*)
if ! rtl_fileop ln_symbolic "${PKG_DESTDIR}/libexec/gcc/${PKG_TARGET}/${PKG_VERSION}/liblto_plugin.dll.a"\
|| ! rtl_fileop ln_symbolic "${PKG_DESTDIR}/libexec/gcc/${PKG_TARGET}/${PKG_VERSION}/liblto_plugin.so"; then
return 1;
fi; ;;
esac;
pkgp_gcc_state_set "install_make" "install";
fi;
fi;
if ! ex_pkg_state_test "${PKG_NAME}" install "${_restart_at}"; then
pkg_install || return 1;
pkgp_gcc_state_set "install";
fi;
pkgp_gcc_state_set "finish";
};
pkg_gcc_full_all() {
local _restart_at="${1}" _configure_host="" _vis_hide="vis_hide=-fvisibility=hidden";
export MAKE="make LIBTOOL=slibtool ${_vis_hide}";
pkgp_gcc_build_dir "cbb-gcc-${PKG_VERSION}" native;
if ! ex_pkg_state_test "${PKG_NAME}" fetch "${_restart_at}"; then
if ! pkg_fetch_download_dlcache_subdir; then
return 1;
elif ! rtl_fetch_urls_git \
"${BUILD_DLCACHEDIR}/${PKG_NAME}" "${DEFAULT_GIT_ARGS}" \
"${PKG_BASE_DIR}" "${PKG_NAME}" \
"${PKG_MIRRORS_GIT:-}" \
"cbb-gcc-${PKG_VERSION}=${PKG_GITROOT}/cbb/cbb-gcc-${PKG_VERSION}"; then
return 1;
else
pkgp_gcc_state_set "fetch" "patch";
fi;
fi;
if ! ex_pkg_state_test "${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" || return 1;
fi;
pkgp_gcc_state_set "patch" "configure";
fi;
pkgp_gcc_setup_vars; pkgp_gcc_setup_env;
if ! ex_pkg_state_test "${PKG_NAME}" configure "${_restart_at}"; then
rtl_fileop mkdir "${PKG_PREFIX}/${PKG_TARGET}" || return 1;
if [ \! -d "${PKG_PREFIX}/${PKG_TARGET}/usr" ]; then
rtl_fileop ln_symbolic . "${PKG_PREFIX}/${PKG_TARGET}/usr" || return 1;
fi;
case "${ARCH}" in
nt32) _configure_host="i686-nt32-midipix"; ;;
nt64) _configure_host="x86_64-nt64-midipix"; ;;
esac;
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="" || return 1;
else rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}" || return 1;
fi;
if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then
if ! make ${PKG_MAKEFLAGS_BUILD} "all-gcc"\
|| ! make ${PKG_MAKEFLAGS_BUILD} "all-target-libgcc" ${_vis_hide}\
|| ! make ${PKG_MAKEFLAGS_BUILD} "all-target-libstdc++-v3"\
|| ! make ${PKG_MAKEFLAGS_BUILD} "all-target-libgfortran"\
|| ! make ${PKG_MAKEFLAGS_BUILD} "all"; then
return 1;
else pkgp_gcc_state_set "build" "install_subdirs";
fi;
fi;
if ! ex_pkg_state_test "${PKG_NAME}" install_subdirs "${_restart_at}"; then
pkg_install_subdirs || return 1;
pkgp_gcc_state_set "install_subdirs" "install_make";
fi;
if ! ex_pkg_state_test "${PKG_NAME}" install_make "${_restart_at}"; then
make ${PKG_MAKEFLAGS_BUILD} "prefix=${PKG_DESTDIR}" "install" || return 1;
pkgp_gcc_state_set "install_make" "install";
fi;
if ! ex_pkg_state_test "${PKG_NAME}" install "${_restart_at}"; then
pkg_install || return 1;
pkgp_gcc_state_set "install";
fi;
pkgp_gcc_state_set "finish";
};
pkg_gcc_full_host_all() {
local _restart_at="${1}";
export MAKE="make LIBTOOL=slibtool";
if ! pkgp_gcc_build_dir "cbb-gcc-${PKG_VERSION}" cross\
|| ! rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; then
return 1;
else if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then
make ${PKG_MAKEFLAGS_BUILD} || return 1;
pkgp_gcc_state_set "build" "install_subdirs";
fi;
if ! ex_pkg_state_test "${PKG_NAME}" install_subdirs "${_restart_at}"; then
pkg_install_subdirs || return 1;
pkgp_gcc_state_set "install_subdirs" "install_make";
fi;
if ! ex_pkg_state_test "${PKG_NAME}" install_make "${_restart_at}"; then
make ${PKG_MAKEFLAGS_BUILD} "prefix=${PKG_DESTDIR}" "install" || return 1;
pkgp_gcc_state_set "install_make" "install";
fi;
if ! ex_pkg_state_test "${PKG_NAME}" install "${_restart_at}"; then
pkg_install || return 1;
pkgp_gcc_state_set "install";
fi;
pkgp_gcc_state_set "finish";
fi;
};
pkg_gcc_libstdcpp_v3_host_all() {
local _restart_at="${1}";
export MAKE="make LIBTOOL=slibtool";
if ! pkgp_gcc_build_dir "cbb-gcc-${PKG_VERSION}" cross\
|| ! rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; then
return 1;
else if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then
make ${PKG_MAKEFLAGS_BUILD} "all-target-libstdc++-v3" || return 1;
pkgp_gcc_state_set "build" "install_subdirs";
fi;
if ! ex_pkg_state_test "${PKG_NAME}" install_subdirs "${_restart_at}"; then
pkg_install_subdirs || return 1;
pkgp_gcc_state_set "install_subdirs" "install_make";
fi;
if ! ex_pkg_state_test "${PKG_NAME}" install_make "${_restart_at}"; then
make ${PKG_MAKEFLAGS_BUILD} "prefix=${PKG_DESTDIR}" "install-target-libstdc++-v3" || return 1;
pkgp_gcc_state_set "install_make" "install";
fi;
if ! ex_pkg_state_test "${PKG_NAME}" install "${_restart_at}"; then
pkg_install || return 1;
pkgp_gcc_state_set "install";
fi;
pkgp_gcc_state_set "finish";
fi;
};
pkg_gcc_runtime_host_all() {
local _restart_at="${1}" _vis_hide="vis_hide=-fvisibility=hidden";
export MAKE="make LIBTOOL=slibtool ${_vis_hide}";
if ! pkgp_gcc_build_dir "cbb-gcc-${PKG_VERSION}" cross\
|| ! rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; then
return 1;
else if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then
make ${PKG_MAKEFLAGS_BUILD} "all-target-libgcc" ${_vis_hide} || return 1;
pkgp_gcc_state_set "build" "install_subdirs";
fi;
if ! ex_pkg_state_test "${PKG_NAME}" install_subdirs "${_restart_at}"; then
pkg_install_subdirs || return 1;
pkgp_gcc_state_set "install_subdirs" "install_make";
fi;
if ! ex_pkg_state_test "${PKG_NAME}" install_make "${_restart_at}"; then
make ${PKG_MAKEFLAGS_BUILD} "prefix=${PKG_DESTDIR}" "install-target-libgcc" || return 1;
pkgp_gcc_state_set "install_make" "install";
fi;
if ! ex_pkg_state_test "${PKG_NAME}" install "${_restart_at}"; then
pkg_install || return 1;
pkgp_gcc_state_set "install";
fi;
pkgp_gcc_state_set "finish";
fi;
};
pkg_gcc_stage1_all() {
pkgp_gcc_stage1_all "${@}";
};
pkg_gcc_stage1_cross_mingw32_all() {
if ! rtl_fileop ln_symbolic . "${PKG_PREFIX}/x86_64-w64-mingw32/mingw"\
|| ! rtl_fileop mkdir "${PKG_DESTDIR}/x86_64-w64-mingw32"\
|| ! rtl_fileop ln_symbolic . "${PKG_DESTDIR}/x86_64-w64-mingw32/mingw"\
|| ! rtl_fileop mkdir "${PKG_PREFIX}/x86_64-w64-mingw32/include"\
|| ! pkgp_gcc_stage1_all "${@}"; then
return 1;
fi;
};
pkg_gcc_stage1_host_all() {
pkgp_gcc_stage1_all "${@}";
};
pkg_gcc_stage1_native_mingw32_all() {
if ! rtl_fileop ln_symbolic . "${PKG_PREFIX}/x86_64-w64-mingw32/mingw"\
|| ! rtl_fileop mkdir "${PKG_DESTDIR}/x86_64-w64-mingw32"\
|| ! rtl_fileop ln_symbolic . "${PKG_DESTDIR}/x86_64-w64-mingw32/mingw"\
|| ! rtl_fileop mkdir "${PKG_PREFIX}/x86_64-w64-mingw32/include"\
|| ! pkgp_gcc_stage1_all "${@}"; then
return 1;
fi;
};
# vim:filetype=sh textwidth=0
|