@@ -17,12 +17,12 @@ 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+ rs_targets=([ " i386 " ]= " i686-w64-mingw32 " [ " amd64 " ]= " x86_64-w64-mingw32 " )
24+ rs_targets_cflags=([ " i386 " ]= " -pipe -O2 -Wl,-S -g0 -march=pentium -mtune=i686 " [ " amd64 " ]= " -pipe -O2 -Wl,-S -g0 " )
25+ rs_targets_cxxflags= $rs_targets_cflags
2626
2727export CC=" $rs_host_cc "
2828export CFLAGS=" $rs_host_cflags "
@@ -38,7 +38,7 @@ rs_sourcedir="$rs_scriptdir/sources"
3838# RosBE-Unix Constants
3939DEFAULT_INSTALL_DIR=" /usr/local/RosBE"
4040ROSBE_VERSION=" 2.2.1"
41- TARGET_ARCH= " i386"
41+ TARGET_ARCHS=( " i386" " amd64 " )
4242
4343source " $rs_scriptdir /scripts/rosbelibrary.sh"
4444source " $rs_scriptdir /scripts/setuplibrary.sh"
@@ -158,13 +158,11 @@ rm -rf "$installdir" || exit 1
158158mkdir -p " $installdir " || exit 1
159159
160160rs_prefixdir=" $installdir "
161- rs_archprefixdir=" $installdir /$TARGET_ARCH "
162161
163162# #### BEGIN almost shared buildtoolchain/RosBE-Unix building part #############
164163rs_boldmsg " Building..."
165164
166165mkdir -p " $rs_prefixdir /bin"
167- mkdir -p " $rs_archprefixdir /$rs_target "
168166
169167echo " Using CFLAGS=\" $CFLAGS \" "
170168echo " Using CXXFLAGS=\" $CXXFLAGS \" "
@@ -201,71 +199,83 @@ if rs_prepare_module "cmake"; then
201199 rs_clean_module " cmake"
202200fi
203201
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
202+ for TARGET_ARCH in ${TARGET_ARCHS[@]} ; do
203+ rs_archprefixdir=" $installdir /$TARGET_ARCH "
204+ rs_target=${rs_targets[$TARGET_ARCH]}
205+ rs_target_cflags=${rs_targets_cflags[$TARGET_ARCH]}
206+ rs_target_cxxflags=${rs_targets_cxxflags[$TARGET_ARCH]}
207+
208+ # This is a cross-compiler with prefix.
209+ rs_target_tool_prefix=" ${rs_target} -"
210+
211+ mkdir -p " $rs_archprefixdir /$rs_target "
212+
213+ if rs_prepare_module " binutils" ; then
214+ 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
215+ rs_do_command $rs_makecmd -j $rs_cpucount
216+ rs_do_command $rs_makecmd install
217+ rs_clean_module " binutils"
218+ fi
219+
220+ if rs_prepare_module " mingw_w64" ; then
221+ rs_do_command ../mingw_w64/mingw-w64-headers/configure --prefix=" $rs_archprefixdir /$rs_target " --host=" $rs_target "
222+ rs_do_command $rs_makecmd -j $rs_cpucount
223+ rs_do_command $rs_makecmd install
224+ rs_do_command ln -s -f $rs_archprefixdir /$rs_target $rs_archprefixdir /mingw
225+ rs_clean_module " mingw_w64"
226+ fi
227+
228+ if rs_prepare_module " gcc" ; then
229+ rs_extract_module gmp $PWD /../gcc
230+ rs_extract_module mpc $PWD /../gcc
231+ rs_extract_module mpfr $PWD /../gcc
232+
233+ cd ../gcc-build
234+
235+ export CFLAGS_FOR_TARGET=" $rs_target_cflags "
236+ export CXXFLAGS_FOR_TARGET=" $rs_target_cxxflags "
237+
238+ 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
239+ rs_do_command $rs_makecmd -j $rs_cpucount all-gcc
240+ rs_do_command $rs_makecmd install-gcc
241+ rs_do_command $rs_makecmd install-lto-plugin
242+
243+ if rs_prepare_module " mingw_w64" ; then
244+ export AR=" $rs_archprefixdir /bin/${rs_target_tool_prefix} ar"
245+ export AS=" $rs_archprefixdir /bin/${rs_target_tool_prefix} as"
246+ export CC=" $rs_archprefixdir /bin/${rs_target_tool_prefix} gcc"
247+ export CFLAGS=" $rs_target_cflags "
248+ export CXX=" $rs_archprefixdir /bin/${rs_target_tool_prefix} g++"
249+ export CXXFLAGS=" $rs_target_cxxflags "
250+ export DLLTOOL=" $rs_archprefixdir /bin/${rs_target_tool_prefix} dlltool"
251+ export RANLIB=" $rs_archprefixdir /bin/${rs_target_tool_prefix} ranlib"
252+ export STRIP=" $rs_archprefixdir /bin/${rs_target_tool_prefix} strip"
253+
254+ rs_do_command ../mingw_w64/mingw-w64-crt/configure --prefix=" $rs_archprefixdir /$rs_target " --host=" $rs_target " --with-sysroot=" $rs_archprefixdir "
255+ rs_do_command $rs_makecmd -j $rs_cpucount
256+ rs_do_command $rs_makecmd install
257+ rs_clean_module " mingw_w64"
258+
259+ unset AR
260+ unset AS
261+ export CC=" $rs_host_cc "
262+ export CFLAGS=" $rs_host_cflags "
263+ export CXX=" $rs_host_cxx "
264+ export CXXFLAGS=" $rs_host_cxxflags "
265+ unset DLLTOOL
266+ unset RANLIB
267+ unset STRIP
268+ fi
269+
270+ cd " $rs_workdir /gcc-build"
271+ rs_do_command $rs_makecmd -j $rs_cpucount
272+ rs_do_command $rs_makecmd install
273+ rs_clean_module " gcc"
274+
275+ unset CFLAGS_FOR_TARGET
276+ unset CXXFLAGS_FOR_TARGET
277+ fi
278+ done
269279
270280if rs_prepare_module " ninja" ; then
271281 rs_do_command ../ninja/configure.py --bootstrap
@@ -281,9 +291,11 @@ echo "Removing unneeded files..."
281291cd " $rs_prefixdir "
282292rm -rf doc man share/info share/man
283293
284- cd " $rs_archprefixdir "
285- rm -rf $rs_target /doc $rs_target /share include info man mingw share
286- rm -f lib/* >& /dev/null
294+ for TARGET_ARCH in ${TARGET_ARCHS[@]} ; do
295+ cd " $installdir /$TARGET_ARCH "
296+ rm -rf ${rs_targets[$TARGET_ARCH]} /doc ${rs_targets[$TARGET_ARCH]} /share include info man mingw share
297+ rm -f lib/* >& /dev/null
298+ done
287299# #### END almost shared buildtoolchain/RosBE-Unix building part ###############
288300
289301# See: https://jira.reactos.org/browse/ROSBE-35
@@ -298,16 +310,19 @@ if [ "$osname" != "Darwin" ]; then
298310 done
299311
300312 # 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
313+ for TARGET_ARCH in ${TARGET_ARCHS[@]} ; do
314+ cd " $installdir /$TARGET_ARCH "
315+ for exe in ` find -name " *.a" -type f -print` ; do
316+ ./bin/${rs_targets[$TARGET_ARCH]} -objcopy --only-keep-debug $exe $exe .dbg 2> /dev/null
317+ ./bin/${rs_targets[$TARGET_ARCH]} -objcopy --strip-debug $exe 2> /dev/null
318+ ./bin/${rs_targets[$TARGET_ARCH]} -objcopy --add-gnu-debuglink=$exe .dbg $exe 2> /dev/null
319+ done
320+
321+ for exe in ` find -name " *.o" -type f -print` ; do
322+ ./bin/${rs_targets[$TARGET_ARCH]} -objcopy --only-keep-debug $exe $exe .dbg 2> /dev/null
323+ ./bin/${rs_targets[$TARGET_ARCH]} -objcopy --strip-debug $exe 2> /dev/null
324+ ./bin/${rs_targets[$TARGET_ARCH]} -objcopy --add-gnu-debuglink=$exe .dbg $exe 2> /dev/null
325+ done
311326 done
312327fi
313328
0 commit comments