@@ -13,10 +13,17 @@ THREADS="--enable-threads=win32"
1313TC_ARCH=" win32"
1414BUILD_DIR=" /opt/$TC_ARCH "
1515PREFIX=" $BUILD_DIR "
16- TARGET=" i686-w64-mingw32"
16+ TARGET=" i586-w64-mingw32" # Pentium baseline (safe for Win95/NT4)
17+ I686_TARGET=" i686-w64-mingw32" # i686 overlay for 200/XP+
1718JOBS=" $( nproc) "
1819SOURCE=" src-$TC_ARCH "
1920
21+ # ##########################################################################
22+ # Default to NT4/Win95 headersl override per-project of you need 2000/XP+ #
23+ # ##########################################################################
24+ CFLAGS+=" -DWINVER=0x0400 -D_WIN32_WINNT=0x0400"
25+ CXXFLAGS+=" $CFLAGS "
26+
2027# ########################
2128# URLs of sources files #
2229# ########################
@@ -129,7 +136,13 @@ HOST=$(~/$SOURCE/gcc-13.1.0/config.guess)
129136echo " Starting Binutils build..."
130137cd binutils-${BINUTILS_VER}
131138mkdir -p build && cd build
132- ../configure --target=$TARGET --host=$HOST --prefix=$PREFIX --with-sysroot=$PREFIX --disable-multilib --disable-nls
139+ ../configure \
140+ --target=$TARGET \
141+ --host=$HOST \
142+ --prefix=$PREFIX \
143+ --with-sysroot=$PREFIX \
144+ --disable-multilib \
145+ --disable-nls
133146make -j$JOBS
134147make install
135148
@@ -147,12 +160,18 @@ mkdir -p build && cd build
147160# as per Mingw/GCC documentation for Toolchain #
148161# ###############################################
149162
150- ../configure --prefix=$PREFIX /$TARGET --host=$TARGET --with-sysroot=$PREFIX --enable-sdk=all --enable-idl --with-default-msvcrt=msvcrt
163+ ../configure \
164+ --prefix=$PREFIX /$TARGET \
165+ --host=$TARGET \
166+ --with-sysroot=$PREFIX \
167+ --enable-sdk=all \
168+ --enable-idl \
169+ --with-default-msvcrt=msvcrt
151170make install
152171
153172echo " Creating Symlinks"
154- ln -s $PREFIX /$TARGET $PREFIX /mingw
155- ln -s $PREFIX /$TARGET /lib $PREFIX /$TARGET /lib64
173+ ln -sf $PREFIX /$TARGET $PREFIX /mingw
174+ ln -sf $PREFIX /$TARGET /lib $PREFIX /$TARGET /lib64
156175echo " "
157176echo " Now mingw and lib64 is symlinked"
158177echo " to correct paths accepted by GCC"
@@ -176,15 +195,28 @@ cd ~/$SOURCE/gcc-${GCC_VER}
176195# Download GCC Pre Requisites
177196echo " Downloading GCC Pre Requisites"
178197./contrib/download_prerequisites
179- mkdir -p build && cd build
198+ mkdir -p build-phase-1 && cd build-phase-1
180199
181200# #########################################
182201# Configure GGC for Phase 1 #
183202# as per GCC documentation for Toolchain #
184203# #########################################
185204echo " Building GCC ${GCC_VERSION} with C only"
186- # Building with c++ cause errors about SSE2 and AVX, help to fix that is appreciated
187- ../configure --target=$TARGET --host=$HOST --prefix=$PREFIX --with-sysroot=$PREFIX --disable-multilib --enable-languages=c --disable-nls --without-headers --with-default-msvcrt=msvcrt --disable-shared $THREADS
205+ ../configure \
206+ --target=$TARGET \
207+ --host=$HOST \
208+ --prefix=$PREFIX \
209+ --with-sysroot=$PREFIX \
210+ --disable-multilib \
211+ --enable-languages=c \
212+ --disable-nls \
213+ --without-headers \
214+ --with-default-msvcrt=msvcrt \
215+ --disable-shared \
216+ --with-arch=pentium \
217+ --with-tune=generic \
218+ --enable-sjlj-exceptions \
219+ $THREADS
188220make all-gcc -j$JOBS
189221make install-gcc
190222
@@ -202,15 +234,33 @@ mkdir -p build && cd build
202234# as per Mingw/GCC documentation for Toolchain #
203235# ###############################################
204236
205- ../configure --host=$TARGET --prefix=$PREFIX /$TARGET --with-sysroot=$PREFIX --with-default-msvcrt=msvcrt
237+ ../configure \
238+ --host=$TARGET \
239+ --prefix=$PREFIX /$TARGET \
240+ --with-sysroot=$PREFIX \
241+ --with-default-msvcrt=msvcrt
206242make -j$JOBS
207243make install
208244
209245# ###########################################
210246# Built GCC Phase 2 (Continues the Phase 1 #
211247# ###########################################
212248echo " Building GCC ${GCC_VER} Phase 2"
213- cd ~ /$SOURCE /gcc-13.1.0/build
249+ cd ~ /$SOURCE /gcc-13.1.0
250+ mkdir -p build-phase-2 && cd build-phase-2
251+ ../configure \
252+ --target=$TARGET \
253+ --host=$HOST \
254+ --prefix=$PREFIX \
255+ --with-sysroot=$PREFIX \
256+ --disable-multilib \
257+ --enable-languages=c,c++ \
258+ --disable-nls \
259+ --disable-shared \
260+ --with-arch=pentium \
261+ --with-tune=generic \
262+ --enable-sjlj-exceptions \
263+ $THREADS
214264
215265# #########################################
216266# Configure GGC for Phase 2 #
@@ -230,29 +280,65 @@ make install
230280
231281echo " Building Mingw-w64 tools"
232282
233- echo " Building gendef"
234- cd ~ /$SOURCE /mingw-w64-v12.0.0/mingw-w64-tools/gendef
235- ./configure
236- make -j$JOBS
237- make install
283+ build_tool () {
284+ local tool=$1
285+ echo " Building $tool "
286+
287+ cd ~ /$SOURCE /mingw-w64-v12.0.0/mingw-w64-tools/$tool
288+ if [ " $tool " == " widl" ]; then
289+ ./configure --target=$TARGET --prefix=$PREFIX --bindir=$PREFIX /bin
290+ else
291+ ./configure
292+ fi
293+ make -j$JOBS
294+ make install
295+ }
238296
239- echo " Building genidl"
240- cd ~ /$SOURCE /mingw-w64-v12.0.0/mingw-w64-tools/genidl
241- ./configure
242- make -j$JOBS
243- make install
297+ build_tool gendef
298+ build_tool genidl
299+ build_tool genpeimg
300+ build_tool widl
244301
245- echo " Building genpeimg"
246- cd ~ /$SOURCE /mingw-w64-v12.0.0/mingw-w64-tools/genpeimg
247- ./configure
248- make -j$JOBS
249- make install
302+ # ########################
303+ # Optional i686 overlay #
304+ # ########################
250305
251- echo " Building widl"
252- cd ~ /$SOURCE /mingw-w64-v12.0.0/mingw-w64-tools/widl
253- ./configure --target=$TARGET --prefix=$PREFIX --bindir=$PREFIX /bin
306+ # ###############################################
307+ # Build and install Binutils 2.40 i686 overlay #
308+ # ###############################################
309+ echo " Starting Binutils i686 build..."
310+ cd ~ /$SOURCE /binutils-${BINUTILS_VER}
311+ mkdir -p build-i686 && cd build-i686
312+ ../configure \
313+ --target=$I686_TARGET \
314+ --host=$HOST \
315+ --prefix=$PREFIX \
316+ --disable-multilib \
317+ --disable-nls
254318make -j$JOBS
255319make install
256320
321+ # ############################################
322+ # Build and install GCC 13.1.0 i686 overlay #
323+ # ############################################
324+ echo " Starting GCC ${GCC_VER} i686 build ..."
325+ cd ~ /$SOURCE /gcc-${GCC_VER}
326+ mkdir build-i686 && cd build-i686
327+ ../configure \
328+ --target=$I686_TARGET \
329+ --host=$HOST \
330+ --prefix=$PREFIX \
331+ --with-sysroot=$PREFIX \
332+ --disable-multilib \
333+ --enable-languages=c,c++ \
334+ --disable-nls \
335+ --disable-shared \
336+ --with-arch=pentiumpro \
337+ --with-tune=generic \
338+ --enable-sjlj-exceptions \
339+ $THREADS
340+ make all-gcc -j$JOBS
341+ make install-gcc
342+
257343echo " Built all done! Toolchain is located in $TARGET "
258344echo " Don't forget to add the $TARGET in PATH to use"
0 commit comments