@@ -17,12 +17,17 @@ rs_host_cxx="${CXX:-g++}"
1717rs_host_cxxflags=" ${CXXFLAGS:- $rs_host_cflags } "
1818rs_needed_tools=" as bzip2 find $CC $CXX grep m4 makeinfo python tar" # GNU Make has a special check
1919rs_needed_libs=" zlib"
20- rs_target=" i686-w64-mingw32"
21- rs_target_cflags=" -pipe -O2 -Wl,-S -g0 -march=pentium -mtune=i686"
22- rs_target_cxxflags=" $rs_target_cflags "
23-
24- # This is a cross-compiler with prefix.
25- rs_target_tool_prefix=" ${rs_target} -"
20+ declare -A rs_targets
21+ declare -A rs_targets_cflags
22+ declare -A rs_targets_cxxflags
23+ declare -A rs_gcc_configures_flags
24+ rs_targets=([" i386" ]=" i686-w64-mingw32" [" amd64" ]=" x86_64-w64-mingw32" )
25+ rs_targets_cflags=([" i386" ]=" -pipe -O2 -Wl,-S -g0 -march=pentium -mtune=i686" [" amd64" ]=" -pipe -O2 -Wl,-S -g0" )
26+ rs_targets_cxxflags=([" i386" ]=" -pipe -O2 -Wl,-S -g0 -march=pentium -mtune=i686" [" amd64" ]=" -pipe -O2 -Wl,-S -g0" )
27+ rs_gcc_configures_flags=(
28+ [" i386" ]=" --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-shared --disable-multilib --disable-nls --disable-werror --disable-win32-registry --enable-sjlj-exceptions --disable-libstdcxx-verbose"
29+ [" amd64" ]=" --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-shared --disable-multilib --disable-nls --disable-werror --disable-win32-registry --disable-libstdcxx-verbose"
30+ )
2631
2732export CC=" $rs_host_cc "
2833export CFLAGS=" $rs_host_cflags "
@@ -38,7 +43,7 @@ rs_sourcedir="$rs_scriptdir/sources"
3843# RosBE-Unix Constants
3944DEFAULT_INSTALL_DIR=" /usr/local/RosBE"
4045ROSBE_VERSION=" 2.2.1"
41- TARGET_ARCH= " i386"
46+ TARGET_ARCHS=( " i386" " amd64 " )
4247
4348source " $rs_scriptdir /scripts/rosbelibrary.sh"
4449source " $rs_scriptdir /scripts/setuplibrary.sh"
@@ -158,13 +163,11 @@ rm -rf "$installdir" || exit 1
158163mkdir -p " $installdir " || exit 1
159164
160165rs_prefixdir=" $installdir "
161- rs_archprefixdir=" $installdir /$TARGET_ARCH "
162166
163167# #### BEGIN almost shared buildtoolchain/RosBE-Unix building part #############
164168rs_boldmsg " Building..."
165169
166170mkdir -p " $rs_prefixdir /bin"
167- mkdir -p " $rs_archprefixdir /$rs_target "
168171
169172echo " Using CFLAGS=\" $CFLAGS \" "
170173echo " Using CXXFLAGS=\" $CXXFLAGS \" "
@@ -201,71 +204,91 @@ if rs_prepare_module "cmake"; then
201204 rs_clean_module " cmake"
202205fi
203206
204- if rs_prepare_module " binutils" ; then
205- rs_do_command ../binutils/configure --prefix=" $rs_archprefixdir " --target=" $rs_target " --with-sysroot=" $rs_archprefixdir " --disable-multilib --disable-werror --enable-lto --enable-plugins --with-zlib=yes --disable-nls
206- rs_do_command $rs_makecmd -j $rs_cpucount
207- rs_do_command $rs_makecmd install
208- rs_clean_module " binutils"
209- fi
210-
211- if rs_prepare_module " mingw_w64" ; then
212- rs_do_command ../mingw_w64/mingw-w64-headers/configure --prefix=" $rs_archprefixdir /$rs_target " --host=" $rs_target "
213- rs_do_command $rs_makecmd -j $rs_cpucount
214- rs_do_command $rs_makecmd install
215- rs_do_command ln -s -f $rs_archprefixdir /$rs_target $rs_archprefixdir /mingw
216- rs_clean_module " mingw_w64"
217- fi
218-
219- if rs_prepare_module " gcc" ; then
220- rs_extract_module gmp $PWD /../gcc
221- rs_extract_module mpc $PWD /../gcc
222- rs_extract_module mpfr $PWD /../gcc
223-
224- cd ../gcc-build
225-
226- export CFLAGS_FOR_TARGET=" $rs_target_cflags "
227- export CXXFLAGS_FOR_TARGET=" $rs_target_cxxflags "
228-
229- rs_do_command ../gcc/configure --prefix=" $rs_archprefixdir " --target=" $rs_target " --with-sysroot=" $rs_archprefixdir " --with-pkgversion=" RosBE-Unix" --enable-languages=c,c++ --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-shared --disable-multilib --disable-nls --disable-werror --disable-win32-registry --enable-sjlj-exceptions --disable-libstdcxx-verbose
230- rs_do_command $rs_makecmd -j $rs_cpucount all-gcc
231- rs_do_command $rs_makecmd install-gcc
232- rs_do_command $rs_makecmd install-lto-plugin
233-
234- if rs_prepare_module " mingw_w64" ; then
235- export AR=" $rs_archprefixdir /bin/${rs_target_tool_prefix} ar"
236- export AS=" $rs_archprefixdir /bin/${rs_target_tool_prefix} as"
237- export CC=" $rs_archprefixdir /bin/${rs_target_tool_prefix} gcc"
238- export CFLAGS=" $rs_target_cflags "
239- export CXX=" $rs_archprefixdir /bin/${rs_target_tool_prefix} g++"
240- export CXXFLAGS=" $rs_target_cxxflags "
241- export DLLTOOL=" $rs_archprefixdir /bin/${rs_target_tool_prefix} dlltool"
242- export RANLIB=" $rs_archprefixdir /bin/${rs_target_tool_prefix} ranlib"
243- export STRIP=" $rs_archprefixdir /bin/${rs_target_tool_prefix} strip"
244-
245- rs_do_command ../mingw_w64/mingw-w64-crt/configure --prefix=" $rs_archprefixdir /$rs_target " --host=" $rs_target " --with-sysroot=" $rs_archprefixdir "
246- rs_do_command $rs_makecmd -j $rs_cpucount
247- rs_do_command $rs_makecmd install
248- rs_clean_module " mingw_w64"
249-
250- unset AR
251- unset AS
252- export CC=" $rs_host_cc "
253- export CFLAGS=" $rs_host_cflags "
254- export CXX=" $rs_host_cxx "
255- export CXXFLAGS=" $rs_host_cxxflags "
256- unset DLLTOOL
257- unset RANLIB
258- unset STRIP
259- fi
260-
261- cd " $rs_workdir /gcc-build"
262- rs_do_command $rs_makecmd -j $rs_cpucount
263- rs_do_command $rs_makecmd install
264- rs_clean_module " gcc"
265-
266- unset CFLAGS_FOR_TARGET
267- unset CXXFLAGS_FOR_TARGET
268- fi
207+ for TARGET_ARCH in ${TARGET_ARCHS[@]} ; do
208+ rs_archprefixdir=" $installdir /$TARGET_ARCH "
209+ rs_target=${rs_targets[$TARGET_ARCH]}
210+ rs_target_cflags=${rs_targets_cflags[$TARGET_ARCH]}
211+ rs_target_cxxflags=${rs_targets_cxxflags[$TARGET_ARCH]}
212+ rs_gcc_configure_flags=${rs_gcc_configures_flags[$TARGET_ARCH]}
213+
214+ # This is a cross-compiler with prefix.
215+ rs_target_tool_prefix=" ${rs_target} -"
216+
217+ mkdir -p " $rs_archprefixdir /$rs_target "
218+
219+ echo " Building toolchain for ${TARGET_ARCH} "
220+ echo " Prefix: $rs_archprefixdir "
221+ echo " Target: $rs_target "
222+ echo " Target C flags: $rs_target_cflags "
223+ echo " Target C++ flags: $rs_target_cxxflags "
224+ echo " GCC configure flags: $rs_gcc_configure_flags "
225+
226+ if rs_prepare_module " binutils" ; then
227+ rs_do_command ../binutils/configure --prefix=" $rs_archprefixdir " --target=" $rs_target " --with-sysroot=" $rs_archprefixdir " --disable-multilib --disable-werror --enable-lto --enable-plugins --with-zlib=yes --disable-nls
228+ rs_do_command $rs_makecmd -j $rs_cpucount
229+ rs_do_command $rs_makecmd install
230+ rs_clean_module " binutils"
231+ fi
232+
233+ if rs_prepare_module " mingw_w64" ; then
234+ rs_do_command ../mingw_w64/mingw-w64-headers/configure --prefix=" $rs_archprefixdir /$rs_target " --host=" $rs_target "
235+ rs_do_command $rs_makecmd -j $rs_cpucount
236+ rs_do_command $rs_makecmd install
237+ rs_do_command ln -s -f $rs_archprefixdir /$rs_target $rs_archprefixdir /mingw
238+ rs_clean_module " mingw_w64"
239+ fi
240+
241+ if rs_prepare_module " gcc" ; then
242+ rs_extract_module gmp $PWD /../gcc
243+ rs_extract_module mpc $PWD /../gcc
244+ rs_extract_module mpfr $PWD /../gcc
245+
246+ cd ../gcc-build
247+
248+ export CFLAGS_FOR_TARGET=" $rs_target_cflags "
249+ export CXXFLAGS_FOR_TARGET=" $rs_target_cxxflags "
250+
251+ rs_do_command ../gcc/configure --prefix=" $rs_archprefixdir " --target=" $rs_target " --with-sysroot=" $rs_archprefixdir " --with-pkgversion=" RosBE-Unix" --enable-languages=c,c++ $rs_gcc_configure_flags
252+ rs_do_command $rs_makecmd -j $rs_cpucount all-gcc
253+ rs_do_command $rs_makecmd install-gcc
254+ rs_do_command $rs_makecmd install-lto-plugin
255+
256+ if rs_prepare_module " mingw_w64" ; then
257+ export AR=" $rs_archprefixdir /bin/${rs_target_tool_prefix} ar"
258+ export AS=" $rs_archprefixdir /bin/${rs_target_tool_prefix} as"
259+ export CC=" $rs_archprefixdir /bin/${rs_target_tool_prefix} gcc"
260+ export CFLAGS=" $rs_target_cflags "
261+ export CXX=" $rs_archprefixdir /bin/${rs_target_tool_prefix} g++"
262+ export CXXFLAGS=" $rs_target_cxxflags "
263+ export DLLTOOL=" $rs_archprefixdir /bin/${rs_target_tool_prefix} dlltool"
264+ export RANLIB=" $rs_archprefixdir /bin/${rs_target_tool_prefix} ranlib"
265+ export STRIP=" $rs_archprefixdir /bin/${rs_target_tool_prefix} strip"
266+
267+ rs_do_command ../mingw_w64/mingw-w64-crt/configure --prefix=" $rs_archprefixdir /$rs_target " --host=" $rs_target " --with-sysroot=" $rs_archprefixdir "
268+ rs_do_command $rs_makecmd -j $rs_cpucount
269+ rs_do_command $rs_makecmd install
270+ rs_clean_module " mingw_w64"
271+
272+ unset AR
273+ unset AS
274+ export CC=" $rs_host_cc "
275+ export CFLAGS=" $rs_host_cflags "
276+ export CXX=" $rs_host_cxx "
277+ export CXXFLAGS=" $rs_host_cxxflags "
278+ unset DLLTOOL
279+ unset RANLIB
280+ unset STRIP
281+ fi
282+
283+ cd " $rs_workdir /gcc-build"
284+ rs_do_command $rs_makecmd -j $rs_cpucount
285+ rs_do_command $rs_makecmd install
286+ rs_clean_module " gcc"
287+
288+ unset CFLAGS_FOR_TARGET
289+ unset CXXFLAGS_FOR_TARGET
290+ fi
291+ done
269292
270293if rs_prepare_module " ninja" ; then
271294 rs_do_command ../ninja/configure.py --bootstrap
@@ -281,9 +304,11 @@ echo "Removing unneeded files..."
281304cd " $rs_prefixdir "
282305rm -rf doc man share/info share/man
283306
284- cd " $rs_archprefixdir "
285- rm -rf $rs_target /doc $rs_target /share include info man mingw share
286- rm -f lib/* >& /dev/null
307+ for TARGET_ARCH in ${TARGET_ARCHS[@]} ; do
308+ cd " $installdir /$TARGET_ARCH "
309+ rm -rf ${rs_targets[$TARGET_ARCH]} /doc ${rs_targets[$TARGET_ARCH]} /share include info man mingw share
310+ rm -f lib/* >& /dev/null
311+ done
287312# #### END almost shared buildtoolchain/RosBE-Unix building part ###############
288313
289314# See: https://jira.reactos.org/browse/ROSBE-35
@@ -298,16 +323,19 @@ if [ "$osname" != "Darwin" ]; then
298323 done
299324
300325 # Executables are created for the host system while most libraries are linked to target components
301- for exe in ` find -name " *.a" -type f -print` ; do
302- $rs_archprefixdir /bin/${rs_target_tool_prefix} objcopy --only-keep-debug $exe $exe .dbg 2> /dev/null
303- $rs_archprefixdir /bin/${rs_target_tool_prefix} objcopy --strip-debug $exe 2> /dev/null
304- $rs_archprefixdir /bin/${rs_target_tool_prefix} objcopy --add-gnu-debuglink=$exe .dbg $exe 2> /dev/null
305- done
306-
307- for exe in ` find -name " *.o" -type f -print` ; do
308- $rs_archprefixdir /bin/${rs_target_tool_prefix} objcopy --only-keep-debug $exe $exe .dbg 2> /dev/null
309- $rs_archprefixdir /bin/${rs_target_tool_prefix} objcopy --strip-debug $exe 2> /dev/null
310- $rs_archprefixdir /bin/${rs_target_tool_prefix} objcopy --add-gnu-debuglink=$exe .dbg $exe 2> /dev/null
326+ for TARGET_ARCH in ${TARGET_ARCHS[@]} ; do
327+ cd " $installdir /$TARGET_ARCH "
328+ for exe in ` find -name " *.a" -type f -print` ; do
329+ ./bin/${rs_targets[$TARGET_ARCH]} -objcopy --only-keep-debug $exe $exe .dbg 2> /dev/null
330+ ./bin/${rs_targets[$TARGET_ARCH]} -objcopy --strip-debug $exe 2> /dev/null
331+ ./bin/${rs_targets[$TARGET_ARCH]} -objcopy --add-gnu-debuglink=$exe .dbg $exe 2> /dev/null
332+ done
333+
334+ for exe in ` find -name " *.o" -type f -print` ; do
335+ ./bin/${rs_targets[$TARGET_ARCH]} -objcopy --only-keep-debug $exe $exe .dbg 2> /dev/null
336+ ./bin/${rs_targets[$TARGET_ARCH]} -objcopy --strip-debug $exe 2> /dev/null
337+ ./bin/${rs_targets[$TARGET_ARCH]} -objcopy --add-gnu-debuglink=$exe .dbg $exe 2> /dev/null
338+ done
311339 done
312340fi
313341
0 commit comments