From 2705fa24f4188caf63a28a0da9130e471090f25a Mon Sep 17 00:00:00 2001 From: "J.W. Jagersma" Date: Sat, 27 Jan 2024 18:49:18 +0100 Subject: [PATCH] define WIN32_LEAN_AND_MEAN only while compiling gcc fixes: #41 --- build-djgpp.sh | 10 +++++++++- script/build-avr-gcc.sh | 13 ++++++++++++- script/build-newlib-gcc.sh | 13 ++++++++++++- script/init.sh | 4 ++-- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/build-djgpp.sh b/build-djgpp.sh index 398ed9a..980977d 100755 --- a/build-djgpp.sh +++ b/build-djgpp.sh @@ -239,7 +239,9 @@ if [ ! -z ${GCC_VERSION} ]; then cd djcross || exit 1 TEMP_CFLAGS="$CFLAGS" + TEMP_CXXFLAGS="$CXXFLAGS" export CFLAGS="$CFLAGS $GCC_EXTRA_CFLAGS" + export CXXFLAGS="$CXXFLAGS $GCC_EXTRA_CXXFLAGS" GCC_CONFIGURE_OPTIONS+=" --target=${TARGET} --prefix=${PREFIX} ${HOST_FLAG} ${BUILD_FLAG} --enable-languages=${ENABLE_LANGUAGES}" @@ -260,7 +262,8 @@ if [ ! -z ${GCC_VERSION} ]; then echo "Installing gcc (stage 1)" ${SUDO} ${MAKE_J} install-gcc || exit 1 - export CFLAGS="$TEMP_CFLAGS" + CFLAGS="$TEMP_CFLAGS" + CXXFLAGS="$TEMP_CXXFLAGS" fi if [ ! -z ${DJGPP_VERSION} ]; then @@ -313,7 +316,10 @@ if [ ! -z ${GCC_VERSION} ]; then cd $BUILDDIR/djcross || exit 1 TEMP_CFLAGS="$CFLAGS" + TEMP_CXXFLAGS="$CXXFLAGS" export CFLAGS="$CFLAGS $GCC_EXTRA_CFLAGS" + export CXXFLAGS="$CXXFLAGS $GCC_EXTRA_CXXFLAGS" + export STAGE_CC_WRAPPER="${BASE}/script/destdir-hack.sh ${DST}/${TARGET}" ${MAKE_J} || exit 1 [ ! -z $MAKE_CHECK_GCC ] && ${MAKE_J} -s check-gcc | tee ${BASE}/tests/gcc.log @@ -321,7 +327,9 @@ if [ ! -z ${GCC_VERSION} ]; then ${SUDO} ${MAKE_J} install-strip || \ ${SUDO} ${MAKE_J} install-strip || exit 1 ${SUDO} ${MAKE_J} -C mpfr install DESTDIR=${BASE}/build/tmpinst + CFLAGS="$TEMP_CFLAGS" + CXXFLAGS="$TEMP_CXXFLAGS" set_version gcc fi diff --git a/script/build-avr-gcc.sh b/script/build-avr-gcc.sh index b51abb7..3fd3de7 100644 --- a/script/build-avr-gcc.sh +++ b/script/build-avr-gcc.sh @@ -48,7 +48,9 @@ if [ ! -z ${GCC_VERSION} ]; then cd gcc-${GCC_VERSION}/build-${TARGET} || exit 1 TEMP_CFLAGS="$CFLAGS" + TEMP_CXXFLAGS="$CXXFLAGS" export CFLAGS="$CFLAGS $GCC_EXTRA_CFLAGS" + export CXXFLAGS="$CXXFLAGS $GCC_EXTRA_CXXFLAGS" GCC_CONFIGURE_OPTIONS+=" --target=${TARGET} --prefix=${PREFIX} ${HOST_FLAG} ${BUILD_FLAG} --enable-languages=${ENABLE_LANGUAGES} @@ -69,7 +71,8 @@ if [ ! -z ${GCC_VERSION} ]; then echo "Installing gcc (stage 1)" ${SUDO} ${MAKE_J} install-gcc || exit 1 - export CFLAGS="$TEMP_CFLAGS" + CFLAGS="$TEMP_CFLAGS" + CXXFLAGS="$TEMP_CXXFLAGS" fi cd ${BASE}/build/ @@ -103,6 +106,11 @@ if [ ! -z ${GCC_VERSION} ]; then echo "Building gcc (stage 2)" cd gcc-${GCC_VERSION}/build-${TARGET} || exit 1 + TEMP_CFLAGS="$CFLAGS" + TEMP_CXXFLAGS="$CXXFLAGS" + export CFLAGS="$CFLAGS $GCC_EXTRA_CFLAGS" + export CXXFLAGS="$CXXFLAGS $GCC_EXTRA_CXXFLAGS" + export STAGE_CC_WRAPPER="${BASE}/script/destdir-hack.sh ${DST}/${TARGET}" ${MAKE_J} || exit 1 [ ! -z $MAKE_CHECK_GCC ] && ${MAKE_J} -s check-gcc | tee ${BASE}/tests/gcc.log @@ -111,5 +119,8 @@ if [ ! -z ${GCC_VERSION} ]; then ${SUDO} ${MAKE_J} install-strip || exit 1 ${SUDO} ${MAKE_J} -C mpfr install DESTDIR=${BASE}/build/tmpinst + CFLAGS="$TEMP_CFLAGS" + CXXFLAGS="$TEMP_CXXFLAGS" + set_version gcc fi diff --git a/script/build-newlib-gcc.sh b/script/build-newlib-gcc.sh index 082c8ce..cc028bf 100644 --- a/script/build-newlib-gcc.sh +++ b/script/build-newlib-gcc.sh @@ -40,7 +40,9 @@ if [ ! -z ${GCC_VERSION} ]; then cd gcc-${GCC_VERSION}/build-${TARGET} || exit 1 TEMP_CFLAGS="$CFLAGS" + TEMP_CXXFLAGS="$CXXFLAGS" export CFLAGS="$CFLAGS $GCC_EXTRA_CFLAGS" + export CXXFLAGS="$CXXFLAGS $GCC_EXTRA_CXXFLAGS" GCC_CONFIGURE_OPTIONS+=" --target=${TARGET} --prefix=${PREFIX} ${HOST_FLAG} ${BUILD_FLAG} --enable-languages=${ENABLE_LANGUAGES} @@ -61,7 +63,8 @@ if [ ! -z ${GCC_VERSION} ]; then echo "Installing gcc (stage 1)" ${SUDO} ${MAKE_J} install-gcc || exit 1 - export CFLAGS="$TEMP_CFLAGS" + CFLAGS="$TEMP_CFLAGS" + CXXFLAGS="$TEMP_CXXFLAGS" fi cd ${BASE}/build/ @@ -96,7 +99,12 @@ if [ ! -z ${GCC_VERSION} ]; then echo "Building gcc (stage 2)" cd gcc-${GCC_VERSION}/build-${TARGET} || exit 1 + TEMP_CFLAGS="$CFLAGS" + TEMP_CXXFLAGS="$CXXFLAGS" + export CFLAGS="$CFLAGS $GCC_EXTRA_CFLAGS" + export CXXFLAGS="$CXXFLAGS $GCC_EXTRA_CXXFLAGS" export STAGE_CC_WRAPPER="${BASE}/script/destdir-hack.sh ${DST}/${TARGET}" + ${MAKE_J} || exit 1 [ ! -z $MAKE_CHECK_GCC ] && ${MAKE_J} -s check-gcc | tee ${BASE}/tests/gcc.log echo "Installing gcc" @@ -104,5 +112,8 @@ if [ ! -z ${GCC_VERSION} ]; then ${SUDO} ${MAKE_J} install-strip || exit 1 ${SUDO} ${MAKE_J} -C mpfr install DESTDIR=${BASE}/build/tmpinst + CFLAGS="$TEMP_CFLAGS" + CXXFLAGS="$TEMP_CXXFLAGS" + set_version gcc fi diff --git a/script/init.sh b/script/init.sh index 5e5cfcd..5c3eb13 100644 --- a/script/init.sh +++ b/script/init.sh @@ -63,8 +63,8 @@ MINGW*) # Make sure MSYS2 Perl is used on mingw-w64 (see issue #27) export PERL=/usr/bin/perl # Required to build gcc on recent mingw-w64 (see issue #41) - CFLAGS+=' -DWIN32_LEAN_AND_MEAN' - CXXFLAGS+=' -DWIN32_LEAN_AND_MEAN' + GCC_EXTRA_CFLAGS+=' -DWIN32_LEAN_AND_MEAN' + GCC_EXTRA_CXXFLAGS+=' -DWIN32_LEAN_AND_MEAN' ;; esac