Skip to content

Commit

Permalink
Test new makefile layout
Browse files Browse the repository at this point in the history
  • Loading branch information
NoMore201 committed Oct 21, 2024
1 parent 3d73f30 commit f8b8407
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 133 deletions.
49 changes: 42 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

jobs:
linux-build:
name: Toolchain build
name: Toolchain Linux build
runs-on: ubuntu-22.04

steps:
Expand All @@ -24,8 +24,7 @@ jobs:
run: |
sudo apt-get update
sudo apt-get -y install build-essential build-essential texinfo \
flex bison libmpfr-dev libgmp-dev libmpc-dev zip libdebuginfod-dev \
gcc-mingw-w64 g++-mingw-w64
flex bison libmpfr-dev libgmp-dev libmpc-dev zip libdebuginfod-dev
- name: Build
run: |
Expand All @@ -39,15 +38,51 @@ jobs:
- name: Package
run: |
cd /opt/gcc/linux
cd /opt/gcc
zip -r9 ../linux.zip .
cd /opt/gcc/win32
zip -r9 ../win32.zip .
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: tricore-gcc-artifacts
path: /opt/gcc/*.zip
path: /opt/linux.zip

win32-build:
name: Toolchain Windows build
runs-on: ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install build-essential build-essential texinfo \
flex bison libmpfr-dev libgmp-dev libmpc-dev zip libdebuginfod-dev \
gcc-mingw-w64 g++-mingw-w64
- name: Build
run: |
mkdir build
cd build
export CFLAGS="-O2"
export CXXFLAGS="-O2"
export LDFLAGS="-static -s"
../configure --prefix /opt/gcc --with-host=x86_64-w64-mingw32
make -j$(nproc)
- name: Package
run: |
cd /opt/gcc
zip -r9 ../win32.zip .
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: tricore-gcc-artifacts
path: /opt/win32.zip
158 changes: 32 additions & 126 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,18 @@ BINUTILS_SRCDIR := @with_binutils_src@
NEWLIB_SRCDIR := @with_newlib_src@
GCC_SRCDIR := @with_gcc_src@

all: stamps/build-gcc-stage2-win
CONFIGURE_HOST = @configure_host@

ifeq (--host=x86_64-w64-mingw32, $(CONFIGURE_HOST))
STAGE1_PREFIX := /tmp/stage1
FINAL_PREFIX := $(INSTALL_DIR)
else
STAGE1_PREFIX := $(INSTALL_DIR)
FINAL_PREFIX := $(INSTALL_DIR)
endif


all: stamps/build-gcc-stage2

clean-binutils-tc:
rm -rf build-binutils-tc stamps/build-binutils-tc
Expand All @@ -23,15 +34,6 @@ clean-newlib:
clean-gcc-stage2:
rm -rf build-gcc-stage2 stamps/build-gcc-stage2

clean-binutils-tc-win:
rm -rf build-binutils-tc-win stamps/build-binutils-tc-win

clean-binutils-mcs-win:
rm -rf build-binutils-mcs-win stamps/build-binutils-mcs-win

clean-gcc-stage2-win:
rm -rf build-gcc-stage2-win stamps/build-gcc-stage2-win

clean:
rm -rf build-* stamps

Expand All @@ -45,7 +47,8 @@ stamps/build-binutils-mcs: $(BINUTILS_SRCDIR)
cd $(notdir $@) && $</configure \
--target=mcs-elf \
--program-prefix=mcs-elf- \
--prefix=$(INSTALL_DIR)/linux \
--prefix=$(FINAL_PREFIX) \
$(CONFIGURE_HOST) \
--disable-threads \
--enable-nls \
--disable-itcl \
Expand Down Expand Up @@ -76,7 +79,8 @@ stamps/build-binutils-tc: $(BINUTILS_SRCDIR) stamps/build-binutils-mcs
--target=tricore-elf \
--enable-targets=mcs-elf \
--program-prefix=tricore-elf- \
--prefix=$(INSTALL_DIR)/linux \
--prefix=$(FINAL_PREFIX) \
$(CONFIGURE_HOST) \
--disable-threads \
--enable-nls \
--disable-itcl \
Expand Down Expand Up @@ -107,7 +111,7 @@ stamps/build-gcc-stage1: $(GCC_SRCDIR) stamps/install-deps stamps/build-binutils
CFLAGS_FOR_TARGET='-g -O2 -gdwarf-3' \
CXXFLAGS_FOR_TARGET='-g -O2 -gdwarf-3' \
--target=tricore-elf \
--prefix=$(INSTALL_DIR)/linux \
--prefix=$(STAGE1_PREFIX) \
--enable-lib32 \
--disable-lib64 \
--enable-languages=c,c++ \
Expand Down Expand Up @@ -136,38 +140,38 @@ stamps/build-newlib: $(NEWLIB_SRCDIR) stamps/build-gcc-stage1
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $</configure \
CC_FOR_TARGET=$(INSTALL_DIR)/linux/bin/tricore-elf-gcc \
CXX_FOR_TARGET=$(INSTALL_DIR)/linux/bin/tricore-elf-c++ \
GCC_FOR_TARGET=$(INSTALL_DIR)/linux/bin/tricore-elf-gcc \
AR_FOR_TARGET=$(INSTALL_DIR)/linux/bin/tricore-elf-ar \
AS_FOR_TARGET=$(INSTALL_DIR)/linux/bin/tricore-elf-as \
LD_FOR_TARGET=$(INSTALL_DIR)/linux/bin/tricore-elf-ld \
NM_FOR_TARGET=$(INSTALL_DIR)/linux/bin/tricore-elf-nm \
OBJDUMP_FOR_TARGET=$(INSTALL_DIR)/linux/bin/tricore-elf-objdump \
RANLIB_FOR_TARGET=$(INSTALL_DIR)/linux/bin/tricore-elf-ranlib \
STRIP_FOR_TARGET=$(INSTALL_DIR)/linux/bin/tricore-elf-strip \
READELF_FOR_TARGET=$(INSTALL_DIR)/linux/bin/tricore-elf-readelf \
CC_FOR_TARGET=$(STAGE1_PREFIX)/bin/tricore-elf-gcc \
CXX_FOR_TARGET=$(STAGE1_PREFIX)/bin/tricore-elf-c++ \
GCC_FOR_TARGET=$(STAGE1_PREFIX)/bin/tricore-elf-gcc \
AR_FOR_TARGET=$(STAGE1_PREFIX)/bin/tricore-elf-ar \
AS_FOR_TARGET=$(STAGE1_PREFIX)/bin/tricore-elf-as \
LD_FOR_TARGET=$(STAGE1_PREFIX)/bin/tricore-elf-ld \
NM_FOR_TARGET=$(STAGE1_PREFIX)/bin/tricore-elf-nm \
OBJDUMP_FOR_TARGET=$(STAGE1_PREFIX)/bin/tricore-elf-objdump \
RANLIB_FOR_TARGET=$(STAGE1_PREFIX)/bin/tricore-elf-ranlib \
STRIP_FOR_TARGET=$(STAGE1_PREFIX)/bin/tricore-elf-strip \
READELF_FOR_TARGET=$(STAGE1_PREFIX)/bin/tricore-elf-readelf \
CFLAGS_FOR_TARGET='-g -gdwarf-3 -O2 -ffunction-sections -mfast-div -fno-common' \
CXXFLAGS_FOR_TARGET='-g -gdwarf-3 -O2 -ffunction-sections -mfast-div -fno-common' \
--target=tricore-elf \
--prefix=$(INSTALL_DIR)/linux \
--prefix=$(FINAL_PREFIX) \
--host=i686-w64-mingw32 \
--build=i686-pc-mingw32
$(MAKE) -C $(notdir $@) all
$(MAKE) -C $(notdir $@) install
$(MAKE) -C $(notdir $@) install prefix=$(INSTALL_DIR)/win32
mkdir -p $(dir $@) && touch $@

stamps/build-gcc-stage2: $(GCC_SRCDIR) stamps/install-deps stamps/build-newlib
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $</configure \
cd $(notdir $@) && PATH=$(STAGE1_PREFIX)/bin:$$PATH $</configure \
CFLAGS_FOR_TARGET='-g -gdwarf-3 -O2 -ffast-math -ffunction-sections -mfast-div -fno-common -mno-eabi-bitfield-limit' \
CPPFLAGS_FOR_TARGET='-g -gdwarf-3 -O2 -ffast-math -ffunction-sections -mfast-div -fno-common -mno-eabi-bitfield-limit' \
--target=tricore-elf \
--enable-lib32 \
--disable-lib64 \
--prefix=$(INSTALL_DIR)/linux \
--prefix=$(FINAL_PREFIX) \
$(CONFIGURE_HOST) \
--enable-languages=c,c++ \
--enable-libstdcxx-debug-flags='-gdwarf-3 -g -O0 -D_GLIBCXX_ASSERTIONS' \
--enable-c99 \
Expand All @@ -191,101 +195,3 @@ stamps/build-gcc-stage2: $(GCC_SRCDIR) stamps/install-deps stamps/build-newlib
$(MAKE) -C $(notdir $@) all
$(MAKE) -C $(notdir $@) install
mkdir -p $(dir $@) && touch $@

stamps/build-binutils-mcs-win: $(BINUTILS_SRCDIR) stamps/build-gcc-stage2
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $</configure \
--target=mcs-elf \
--program-prefix=mcs-elf- \
--host=x86_64-w64-mingw32 \
--prefix=$(INSTALL_DIR)/win32 \
--disable-threads \
--enable-nls \
--disable-itcl \
--disable-tk \
--disable-tcl \
--disable-winsup \
--disable-gdbtk \
--disable-libgui \
--disable-rda \
--disable-sid \
--disable-sim \
--disable-gdb \
--disable-newlib \
--disable-libgloss \
--disable-test-suite \
--enable-checking=release \
--with-gnu-ld \
--with-gnu-as \
--disable-werror
$(MAKE) -C $(notdir $@)
$(MAKE) -C $(notdir $@) install
mkdir -p $(dir $@) && touch $@

stamps/build-binutils-tc-win: $(BINUTILS_SRCDIR) stamps/build-binutils-mcs-win
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $</configure \
--target=tricore-elf \
--enable-targets=mcs-elf \
--program-prefix=tricore-elf- \
--host=x86_64-w64-mingw32 \
--prefix=$(INSTALL_DIR)/win32 \
--disable-threads \
--enable-nls \
--disable-itcl \
--disable-tk \
--disable-tcl \
--disable-winsup \
--disable-gdbtk \
--disable-libgui \
--disable-rda \
--disable-sid \
--disable-sim \
--disable-gdb \
--disable-newlib \
--disable-libgloss \
--disable-test-suite \
--enable-checking=release \
--with-gnu-ld \
--with-gnu-as \
--disable-werror
$(MAKE) -C $(notdir $@)
$(MAKE) -C $(notdir $@) install
mkdir -p $(dir $@) && touch $@

stamps/build-gcc-stage2-win: $(GCC_SRCDIR) stamps/install-deps stamps/build-binutils-tc-win
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && PATH=$(INSTALL_DIR)/linux/bin:$$PATH $</configure \
CFLAGS_FOR_TARGET='-g -gdwarf-3 -O2 -ffast-math -ffunction-sections -mfast-div -fno-common -mno-eabi-bitfield-limit' \
CPPFLAGS_FOR_TARGET='-g -gdwarf-3 -O2 -ffast-math -ffunction-sections -mfast-div -fno-common -mno-eabi-bitfield-limit' \
--target=tricore-elf \
--enable-lib32 \
--disable-lib64 \
--host=x86_64-w64-mingw32 \
--prefix=$(INSTALL_DIR)/win32 \
--enable-languages=c,c++ \
--enable-libstdcxx-debug-flags='-gdwarf-3 -g -O0 -D_GLIBCXX_ASSERTIONS' \
--enable-c99 \
--enable-long-long \
--enable-checking \
--enable-nls \
--enable-static \
--disable-threads \
--disable-shared \
--with-headers=yes \
--with-gnu-ld \
--with-gnu-as \
--with-newlib=yes \
--enable-mingw-wildcard \
--disable-libstdcxx-pch \
--enable-newlib-elix-level=3 \
--enable-newlib-io-long-long \
--disable-newlib-supplied-syscalls \
--disable-libssp \
--disable-test-suite
$(MAKE) -C $(notdir $@) all
$(MAKE) -C $(notdir $@) install
mkdir -p $(dir $@) && touch $@
25 changes: 25 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ LIBOBJS
with_gcc_src
with_newlib_src
with_binutils_src
configure_host
NEED_GCC_EXTERNAL_LIBRARIES
BASH
LEXLIB
Expand Down Expand Up @@ -673,6 +674,7 @@ SHELL'
ac_subst_files=''
ac_user_opts='
enable_option_checking
with_host
with_binutils_src
with_newlib_src
with_gcc_src
Expand Down Expand Up @@ -1305,6 +1307,9 @@ if test -n "$ac_init_help"; then
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-host=x86_64-w64-mingw32
Sets the host for the tools, you probably want
nothing
--with-binutils-src Set binutils source path, use builtin source by
default
--with-newlib-src Set newlib source path, use builtin source by
Expand Down Expand Up @@ -3683,6 +3688,26 @@ else $as_nop
fi
# Check whether --with-host was given.
if test ${with_host+y}
then :
withval=$with_host;
else $as_nop
with_host=default
fi
if test "x$with_host" != xdefault
then :
configure_host=--host=$with_host
else $as_nop
configure_host=""
fi
# Check whether --with-binutils-src was given.
if test ${with_binutils_src+y}
then :
Expand Down
11 changes: 11 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ AS_IF([test x"$need_gcc_external_libraries" != xno],
[AC_SUBST(NEED_GCC_EXTERNAL_LIBRARIES,true)],
[AC_SUBST(NEED_GCC_EXTERNAL_LIBRARIES,false)])

AC_ARG_WITH(host,
[AS_HELP_STRING([--with-host=x86_64-w64-mingw32],
[Sets the host for the tools, you probably want nothing])],
[],
[with_host=default]
)

AS_IF([test "x$with_host" != xdefault],
[AC_SUBST(configure_host,--host=$with_host)],
[AC_SUBST(configure_host,"")])

AC_ARG_WITH(binutils-src,
[AS_HELP_STRING([--with-binutils-src],[Set binutils source path, use builtin source by default])],
[],
Expand Down

0 comments on commit f8b8407

Please sign in to comment.