From b3d9fd6fccc86557390e955874309b3d1aa1405a Mon Sep 17 00:00:00 2001 From: Stephen Moody Date: Fri, 29 Jun 2018 11:30:22 +0100 Subject: [PATCH] Updated to allow building under MSYS2/MinGW To get the code to build successfully under MinGW the following changes were made. The configure command for some of the projects had to be changed from absolute paths to relative paths to avoid build errors relating to path name issues under windows. GMP, MPC and MPFR are built as part of GCC. fd2sfd has a patch for it to build under MinGW. sfdc is patched to remove carrage returns from the sfd files. This was causing errors in the generated include files. --- Makefile | 73 +++++++++++++++++++++++++++++---- patches/fd2sfd/fd2inline.c.diff | 14 +++++++ patches/sfdc/sfdc.diff | 12 ++++++ 3 files changed, 90 insertions(+), 9 deletions(-) create mode 100644 patches/fd2sfd/fd2inline.c.diff create mode 100644 patches/sfdc/sfdc.diff diff --git a/Makefile b/Makefile index 6b5643a..6d415cf 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,15 @@ EXEEXT=$(MYMAKEEXE:%=.exe) UNAME_S := $(shell uname -s) +# Files for GMP, MPC and MPFR + +GMP = gmp-6.1.2 +GMPFILE = $(GMP).tar.bz2 +MPC = mpc-1.0.3 +MPCFILE = $(MPC).tar.gz +MPFR = mpfr-3.1.6 +MPFRFILE = $(MPFR).tar.bz2 + # ================================================= .PHONY: x @@ -73,13 +82,22 @@ all: gcc binutils fd2sfd fd2pragma ira sfdc vbcc vasm vlink libnix ixemul libgcc # ================================================= # clean # ================================================= -.PHONY: clean-prefix clean clean-gcc clean-binutils clean-fd2sfd clean-fd2pragma clean-ira clean-sfdc clean-vasm clean-vbcc clean-vlink clean-libnix clean-ixemul clean-libgcc clean-clib2 clean-libdebug clean-libSDL12 clean-newlib clean-ndk -clean: clean-gcc clean-binutils clean-fd2sfd clean-fd2pragma clean-ira clean-sfdc clean-vasm clean-vbcc clean-vlink clean-libnix clean-ixemul clean-clib2 clean-libdebug clean-libSDL12 clean-newlib clean-ndk +.PHONY: clean-prefix clean clean-gcc clean-binutils clean-fd2sfd clean-fd2pragma clean-ira clean-sfdc clean-vasm clean-vbcc clean-vlink clean-libnix clean-ixemul clean-libgcc clean-clib2 clean-libdebug clean-libSDL12 clean-newlib clean-ndk clean-gmp clean-mpc clean-mpfr +clean: clean-gcc clean-binutils clean-fd2sfd clean-fd2pragma clean-ira clean-sfdc clean-vasm clean-vbcc clean-vlink clean-libnix clean-ixemul clean-clib2 clean-libdebug clean-libSDL12 clean-newlib clean-ndk clean-gmp clean-mpc clean-mpfr rm -rf build clean-gcc: rm -rf build/gcc +clean-gmp: + rm -rf projects/gcc/gmp + +clean-mpc: + rm -rf projects/gcc/mpc + +clean-mpfr: + rm -rf projects/gcc/mpfr + clean-libgcc: rm -rf build/gcc/m68k-amigaos rm build/gcc/_libgcc_done @@ -140,8 +158,8 @@ clean-prefix: # ================================================= # update all projects # ================================================= -.PHONY: update update-gcc update-binutils update-fd2sfd update-fd2pragma update-ira update-sfdc update-vasm update-vbcc update-vlink update-libnix update-ixemul update-clib2 update-libdebug update-libSDL12 update-ndk update-newlib update-netinclude -update: update-gcc update-binutils update-fd2sfd update-fd2pragma update-ira update-sfdc update-vasm update-vbcc update-vlink update-libnix update-ixemul update-clib2 update-libdebug update-libSDL12 update-ndk update-newlib update-netinclude +.PHONY: update update-gcc update-binutils update-fd2sfd update-fd2pragma update-ira update-sfdc update-vasm update-vbcc update-vlink update-libnix update-ixemul update-clib2 update-libdebug update-libSDL12 update-ndk update-newlib update-netinclude update-gmp update-mpc update-mpfr +update: update-gcc update-binutils update-fd2sfd update-fd2pragma update-ira update-sfdc update-vasm update-vbcc update-vlink update-libnix update-ixemul update-clib2 update-libdebug update-libSDL12 update-ndk update-newlib update-netinclude update-gmp update-mpc update-mpfr update-gcc: projects/gcc/configure cd projects/gcc && export DEPTH=16; while true; do echo "trying depth=$$DEPTH"; git pull --depth $$DEPTH && break; export DEPTH=$$(($$DEPTH+$$DEPTH));done @@ -200,6 +218,30 @@ update-newlib: projects/newlib-cygwin/newlib/configure update-netinclude: projects/amiga-netinclude/README.md cd projects/amiga-netinclude && git pull +update-gmp: + @mkdir -p download + if [ -a download/$(GMPFILE) ]; \ + then rm -rf projects/$(GMP); rm -rf projects/gcc/gmp; \ + else cd download && wget ftp://ftp.gnu.org/gnu/gmp/$(GMPFILE); \ + fi; + cd projects && tar xf ../download/$(GMPFILE) + +update-mpc: + @mkdir -p download + if [ -a download/$(MPCFILE) ]; \ + then rm -rf projcts/$(MPC); rm -rf projects/gcc/mpc; \ + else cd download && wget ftp://ftp.gnu.org/gnu/mpc/$(MPCFILE); \ + fi; + cd projects && tar xf ../download/$(MPCFILE) + +update-mpfr: + @mkdir -p download + if [ -a download/$(MPFRFILE) ]; \ + then rm -rf projects/$(MPFR); rm -rf projects/gcc/mpfr; \ + else cd download && wget ftp://ftp.gnu.org/gnu/mpfr/$(MPFRFILE); \ + fi; + cd projects && tar xf ../download/$(MPFRFILE) + status-all: GCC_VERSION=$(shell cat 2>/dev/null projects/gcc/gcc/BASE-VER) # ================================================= @@ -210,7 +252,7 @@ status-all: # gcc # ================================================= CONFIG_GCC=--prefix=$(PREFIX) --target=m68k-amigaos --enable-languages=c,c++,objc --enable-version-specific-runtime-libs --disable-libssp --disable-nls \ - --with-headers=$(PWD)/projects/newlib-cygwin/newlib/libc/sys/amigaos/include/ --disable-shared + --with-headers=../../projects/newlib-cygwin/newlib/libc/sys/amigaos/include/ --disable-shared GCC_CMD = m68k-amigaos-c++ m68k-amigaos-g++ m68k-amigaos-gcc-$(GCC_VERSION) m68k-amigaos-gcc-nm \ @@ -231,8 +273,15 @@ build/gcc/_done: build/gcc/Makefile $(shell find 2>/dev/null $(GCCD) -maxdepth 1 build/gcc/Makefile: projects/gcc/configure build/binutils/_done @mkdir -p build/gcc + @mkdir -p projects/gcc/gmp + @mkdir -p projects/gcc/mpc + @mkdir -p projects/gcc/mpfr + + rsync -a projects/$(GMP)/* projects/gcc/gmp + rsync -a projects/$(MPC)/* projects/gcc/mpc + rsync -a projects/$(MPFR)/* projects/gcc/mpfr # if [ "$(UNAME_S)" == "Darwin" ]; then cd build/gcc && contrib/download_prerequisites; fi - cd build/gcc && $(E) $(PWD)/projects/gcc/configure $(CONFIG_GCC) $(LOG) + cd build/gcc && $(E) ../../projects/gcc/configure $(CONFIG_GCC) $(LOG) projects/gcc/configure: @mkdir -p projects @@ -268,7 +317,7 @@ build/binutils/_done: build/binutils/gas/Makefile $(shell find 2>/dev/null proje build/binutils/gas/Makefile: projects/binutils/configure @mkdir -p build/binutils - cd build/binutils && $(E) $(PWD)/projects/binutils/configure $(CONFIG_BINUTILS) $(LOG) + cd build/binutils && $(E) ../../projects/binutils/configure $(CONFIG_BINUTILS) $(LOG) projects/binutils/configure: @mkdir -p projects @@ -297,6 +346,9 @@ build/fd2sfd/Makefile: projects/fd2sfd/configure projects/fd2sfd/configure: @mkdir -p projects cd projects && git clone -b master --depth 4 https://github.com/cahirwpz/fd2sfd + for i in $$(find patches/fd2sfd/ -type f); \ + do if [[ "$$i" == *.diff ]] ; \ + then j=$${i:8}; patch -N "projects/$${j%.diff}" "$$i"; fi ; done # ================================================= # fd2pragma @@ -363,6 +415,9 @@ build/sfdc/Makefile: projects/sfdc/configure projects/sfdc/configure: @mkdir -p projects cd projects && git clone -b master --depth 4 https://github.com/adtools/sfdc + for i in $$(find patches/sfdc/ -type f); \ + do if [[ "$$i" == *.diff ]] ; \ + then j=$${i:8}; patch -N "projects/$${j%.diff}" "$$i"; fi ; done # ================================================= # vasm @@ -666,7 +721,7 @@ build/libdebug/_done: build/libdebug/Makefile build/libdebug/Makefile: build/libnix/_done projects/libdebug/configure $(shell find 2>/dev/null projects/libdebug -not \( -path projects/libdebug/.git -prune \) -type f) mkdir -p build/libdebug - cd build/libdebug && CFLAGS="$(TARGET_C_FLAGS)" $(PWD)/projects/libdebug/configure $(CONFIG_LIBDEBUG) $(LOG) + cd build/libdebug && CFLAGS="$(TARGET_C_FLAGS)" ../../projects/libdebug/configure $(CONFIG_LIBDEBUG) $(LOG) projects/libdebug/configure: @mkdir -p projects @@ -740,7 +795,7 @@ endif build/newlib/newlib/Makefile: projects/newlib-cygwin/configure mkdir -p build/newlib/newlib - cd build/newlib/newlib && $(NEWLIB_CONFIG) CFLAGS="$(TARGET_C_FLAGS)" $(PWD)/projects/newlib-cygwin/newlib/configure --host=m68k-amigaos --prefix=$(PREFIX) $(LOG) + cd build/newlib/newlib && $(NEWLIB_CONFIG) CFLAGS="$(TARGET_C_FLAGS)" ../../../projects/newlib-cygwin/newlib/configure --host=m68k-amigaos --prefix=$(PREFIX) $(LOG) projects/newlib-cygwin/newlib/configure: @mkdir -p projects diff --git a/patches/fd2sfd/fd2inline.c.diff b/patches/fd2sfd/fd2inline.c.diff new file mode 100644 index 0000000..6624e83 --- /dev/null +++ b/patches/fd2sfd/fd2inline.c.diff @@ -0,0 +1,14 @@ +--- fd2sfd/fd2inline.c 2018-06-28 14:37:19.772087300 +0100 ++++ fd2sfd-patched/fd2inline.c 2018-06-28 09:06:12.977739500 +0100 +@@ -46,6 +46,11 @@ + #define REGS 16 /* d0=0,...,a7=15 */ + #define FDS 1000 + ++ ++#ifdef __MINGW32__ ++#define bcopy(s1, s2, n) memmove((s2), (s1), (n)) ++#endif ++ + typedef enum + { + d0, d1, d2, d3, d4, d5, d6, d7, a0, a1, a2, a3, a4, a5, a6, a7, illegal diff --git a/patches/sfdc/sfdc.diff b/patches/sfdc/sfdc.diff new file mode 100644 index 0000000..e835d22 --- /dev/null +++ b/patches/sfdc/sfdc.diff @@ -0,0 +1,12 @@ +--- sfdc/sfdc 2018-06-28 14:37:26.434918400 +0100 ++++ sfdc-patched/sfdc 2018-06-28 14:42:58.370540300 +0100 +@@ -484,7 +484,8 @@ + while (my $line = ) { + + ++$line_no; +- ++ $line =~ s/\r//g; ++ + for ($line) { + /==copyright\s/ && do { + ( $$result{'copyright'} = $_ ) =~ s/==copyright\s+(.*)\s*/$1/;