5959#
6060# --recipe name
6161# specify which build recipe to use. Not all recipes are supported on all targets.
62- # -gcc-5.2.0
63- # -gcc-7.1.0
64- # -gcc-7.1.0r0
65- # -gcc-7.1.0r2
66- # -gcc-7.3.0
67- # -gcc-8.1.0
62+ # -gcc-5.2.0 (mingw-w64 project)
63+ # -gcc-7.1.0 (mingw-w64 project)
64+ # -gcc-7.1.0r0 (mingw-w64 project)
65+ # -gcc-7.1.0r2 (mingw-w64 project)
66+ # -gcc-7.3.0 (mingw-w64 project)
67+ # -gcc-8.1.0 (mingw-w64 project)
68+ # -winlibs-gcc-8.4.0 (winlibs)
69+ # -equation-gcc-8.3.0 (Equation)
6870#
6971# Requirements:
7072# - MSYS environment on Windows with: bash, wget/curl, zip, unzip, patch, make, findutils
@@ -192,7 +194,7 @@ if [ ! -z "$repo_url" ]; then
192194fi
193195
194196# grab the FBSHA1 now, instead of forcing fbc/makefile to do it
195- # and we don't want to rely on host having git it the path
197+ # and we don't want to rely on host having git in the path
196198FBSHA1=" $( git rev-parse HEAD) "
197199
198200cd ../..
@@ -249,11 +251,59 @@ download_mingw() {
249251 download " MinGW.org/$1 " " http://downloads.sourceforge.net/mingw/${1} ?download"
250252}
251253
254+ repack_equation_exe () {
255+ packname=" $1 "
256+ instname=" $packname -installer"
257+
258+ echo " Removing previous repack directories"
259+ rm -rf repack
260+ mkdir repack
261+
262+ cd repack
263+ mkdir $packname
264+ mkdir $instname
265+
266+ echo " Extracting installer files from $packname .exe"
267+ cd $instname
268+ 7z x -y ../../$packname .exe > /dev/null
269+
270+ echo " Copying directory structure"
271+ cd source
272+ find . -type d | xargs -L 1 -I % mkdir -p ../../$packname /%
273+
274+ echo " Decompressing individual files"
275+ # careful here with the quoting; this uses stdout redirection
276+ find . -type f -exec sh -c " bzip2 -d -c '{}' > '../../$packname /{}'" \;
277+
278+ cd ../..
279+
280+ echo " Creating normal 7z archive $packname .7z in cache"
281+ 7z a ../$packname .7z $packname > /dev/null
282+
283+ cd ..
284+
285+ # clean-up
286+ rm -rf ./repack
287+ }
288+
252289get_mingww64_toolchain () {
253290 bits=" $1 "
254291 arch=" $2 "
292+ toolchain=mingw-w64
255293
256294 case " $recipe " in
295+ -winlibs-gcc-8.4.0)
296+ gccversion=8.4.0
297+ mingwbuildsrev=
298+ mingwruntime=7.0.0-r1
299+ toolchain=winlibs
300+ ;;
301+ -equation-gcc-8.3.0)
302+ gccversion=8.3.0
303+ mingwbuildsrev=
304+ mingwruntime=
305+ toolchain=equation
306+ ;;
257307 -gcc-8.1.0)
258308 gccversion=8.1.0
259309 mingwbuildsrev=rev0
@@ -279,24 +329,72 @@ get_mingww64_toolchain() {
279329 mingwbuildsrev=rev0
280330 mingwruntime=v4
281331 ;;
282- * )
283- gccversion=5.2.0
332+ " " )
333+ # default build recipe
334+ gccversion=8.1.0
284335 mingwbuildsrev=rev0
285- mingwruntime=v4
336+ mingwruntime=v6
286337 ;;
338+ * )
339+ echo " unknown recipe $recipe "
340+ exit 1
287341 esac
288342
289- dir=Toolchains%20targetting%20Win$bits /Personal%20Builds/mingw-builds/$gccversion /threads-win32/sjlj/
290- file=$arch -$gccversion -release-win32-sjlj-rt_$mingwruntime -$mingwbuildsrev .7z
343+ case " $toolchain " in
344+ equation)
345+ dir=http://www.equation.com/ftpdir/gcc/
291346
292- mkdir -p ../input/MinGW-w64
293- download " MinGW-w64/ $file " " http://sourceforge.net/projects/mingw-w64/files/ $ dir$file/download "
347+ file=gcc- $gccversion - $bits
348+ binUrl= $ dir$file.exe
294349
295- srcfile=src -$gccversion -release-rt_ $mingwruntime - $mingwbuildsrev .tar.7z
296- download " MinGW-w64/ $srcfile " " http://sourceforge.net/projects/mingw-w64/files/Toolchain%20sources/Personal%20Builds/mingw-builds/ $gccversion / $ srcfile/download "
350+ srcfile=gcc -$gccversion .tar.xz
351+ srcUrl= $dir$ srcfile
297352
298- 7z x " ../input/MinGW-w64/$file " > /dev/null
299- }
353+ mkdir -p ../input/equation
354+ download " equation/$file .exe" $binUrl
355+ download " equation/$srcfile " $srcUrl
356+ if [ -f " ../input/equation/$file .7z" ]; then
357+ echo " found $file .7z already repacked"
358+ else
359+ lastdir=" $PWD "
360+ cd ../input/equation
361+ repack_equation_exe $file
362+ cd " $lastdir "
363+ fi
364+ 7z x " ../input/equation/$file .7z" > /dev/null
365+ mv ./$file ./mingw$bits
366+ ;;
367+ winlibs)
368+ dir=brechtsanders/winlibs_mingw/releases/download/$gccversion -$mingwruntime /
369+
370+ file=mingw-w64-$arch -$gccversion -$mingwruntime .7z
371+ binUrl=https://github.com/$dir$file
372+
373+ srcfile=src-$gccversion -$mingwruntime .tar.gz
374+ srcUrl=https://github.com/brechtsanders/winlibs_mingw/archive/refs/tags/$gccversion -$mingwruntime .tar.gz
375+
376+ mkdir -p ../input/winlibs
377+ download " winlibs/$file " $binUrl
378+ download " winlibs/$srcfile " $srcUrl
379+ 7z x " ../input/winlibs/$file " > /dev/null
380+ ;;
381+ * )
382+ # mingw-w64 project - personal builds
383+ dir=Toolchains%20targetting%20Win$bits /Personal%20Builds/mingw-builds/$gccversion /threads-win32/sjlj/
384+
385+ file=$arch -$gccversion -release-win32-sjlj-rt_$mingwruntime -$mingwbuildsrev .7z
386+ binUrl=http://sourceforge.net/projects/mingw-w64/files/$dir$file /download
387+
388+ srcfile=src-$gccversion -release-rt_$mingwruntime -$mingwbuildsrev .tar.7z
389+ srcUrl=http://sourceforge.net/projects/mingw-w64/files/Toolchain%20sources/Personal%20Builds/mingw-builds/$gccversion /$srcfile /download
390+
391+ mkdir -p ../input/MinGW-w64
392+ download " MinGW-w64/$file " $binUrl
393+ download " MinGW-w64/$srcfile " $srcUrl
394+ 7z x " ../input/MinGW-w64/$file " > /dev/null
395+ ;;
396+ esac
397+ }
300398
301399case " $target " in
302400dos)
454552
455553case $fbtarget in
456554win32|win64)
457- # libffi sources
458- # TODO : new libffi package? at https://github.com/libffi/libffi/releases/download/v3.3-rc0/libffi-3.3-rc0.tar.gz
459- libffi_title=libffi-3.2.1
555+ # libffi sources https://github.com/libffi/libffi/releases/download/v3.3/libffi-3.3.tar.gz.
556+ libffi_title=libffi-3.3
460557 libffi_package=" ${libffi_title} .tar.gz"
461558 download " $libffi_package " " ftp://sourceware.org/pub/libffi/$libffi_package "
462559 echo " extracting $libffi_package "
@@ -549,32 +646,34 @@ linuxbuild() {
549646
550647libffibuild () {
551648
649+ # on fbc 1.08.0 we changed the libffi version so
650+ # don't use any cached files when building the packages
651+ # commented out for future reference
552652 # do we already have the files we need?
553- if [ -f " ../input/$libffi_title /$target$recipe /ffi.h" ]; then
554- if [ -f " ../input/$libffi_title /$target$recipe /ffitarget.h" ]; then
555- if [ -f " ../input/$libffi_title /$target$recipe /libffi.a" ]; then
556- echo
557- echo " using cached libffi: $libffi_title /$target$recipe "
558- echo
559- return
560- fi
561- fi
562- fi
563-
564- # just grab the files we need from the package?
565- # TODO : maybe once libffi 3.3 is released, we can go back
566- # to building libffi ourselves.
567-
568- # copy files from opt/lib/libffi-3.2.1
569- case " $recipe " in
570- -gcc-7.1.0|-gcc-7.1.0r0|-gcc-7.1.0r2|-gcc-7.3.0|-gcc-8.1.0)
571- mkdir -p ../input/$libffi_title /$target$recipe
572- cp opt/lib/libffi-3.2.1/include/ffi.h ../input/$libffi_title /$target$recipe
573- cp opt/lib/libffi-3.2.1/include/ffitarget.h ../input/$libffi_title /$target$recipe
574- cp opt/lib/libffi.a ../input/$libffi_title /$target$recipe
575- return
576- ;;
577- esac
653+ # if [ -f "../input/$libffi_title/$target$recipe/ffi.h" ]; then
654+ # if [ -f "../input/$libffi_title/$target$recipe/ffitarget.h" ]; then
655+ # if [ -f "../input/$libffi_title/$target$recipe/libffi.a" ]; then
656+ # echo
657+ # echo "using cached libffi: $libffi_title/$target$recipe"
658+ # echo
659+ # return
660+ # fi
661+ # fi
662+ # fi
663+
664+ # or just grab the files we need from the package?
665+ # we might copy in the files directly if we unable to build libffi ourselves
666+ # as was the case for libffi-3.2.1 and some gcc tool chains
667+ # so just leave this section commented out for reference
668+ # case "$recipe" in
669+ # -gcc-7.1.0|-gcc-7.1.0r0|-gcc-7.1.0r2|-gcc-7.3.0|-gcc-8.1.0)
670+ # mkdir -p ../input/$libffi_title/$target$recipe
671+ # cp opt/lib/libffi-3.3/include/ffi.h ../input/$libffi_title/$target$recipe
672+ # cp opt/lib/libffi-3.3/include/ffitarget.h ../input/$libffi_title/$target$recipe
673+ # cp opt/lib/libffi.a ../input/$libffi_title/$target$recipe
674+ # return
675+ # ;;
676+ # esac
578677
579678 echo
580679 echo " building libffi"
@@ -606,10 +705,20 @@ windowsbuild() {
606705
607706 libffibuild
608707 # copy our stored files to the build
609- case " $target " in
610- win32) cp ../input/$libffi_title /$target$recipe /ffi.h ../input/$libffi_title /$target$recipe /ffitarget.h ./i686-w64-mingw32/include;;
611- win32-mingworg) cp ../input/$libffi_title /$target$recipe /ffi.h ../input/$libffi_title /$target$recipe /ffitarget.h ./include;;
612- win64) cp ../input/$libffi_title /$target$recipe /ffi.h ../input/$libffi_title /$target$recipe /ffitarget.h ./x86_64-w64-mingw32/include;;
708+ case " $toolchain " in
709+ equation)
710+ case " $target " in
711+ win32) cp ../input/$libffi_title /$target$recipe /ffi.h ../input/$libffi_title /$target$recipe /ffitarget.h ./i686-pc-mingw32/include;;
712+ win64) cp ../input/$libffi_title /$target$recipe /ffi.h ../input/$libffi_title /$target$recipe /ffitarget.h ./x86_64-w64-mingw32/include;;
713+ esac
714+ ;;
715+ * )
716+ case " $target " in
717+ win32) cp ../input/$libffi_title /$target$recipe /ffi.h ../input/$libffi_title /$target$recipe /ffitarget.h ./i686-w64-mingw32/include;;
718+ win32-mingworg) cp ../input/$libffi_title /$target$recipe /ffi.h ../input/$libffi_title /$target$recipe /ffitarget.h ./include;;
719+ win64) cp ../input/$libffi_title /$target$recipe /ffi.h ../input/$libffi_title /$target$recipe /ffitarget.h ./x86_64-w64-mingw32/include;;
720+ esac
721+ ;;
613722 esac
614723
615724 cd fbc
@@ -650,32 +759,88 @@ windowsbuild() {
650759 cp bin/gprof.exe fbc/bin/$fbtarget
651760 cp bin/ld.exe fbc/bin/$fbtarget
652761
653- cd fbc && make mingw-libs ENABLE_STANDALONE=1 && cd ..
654-
655- if [ $fbtarget = " win32" ]; then
656- cd fbc/lib/win32 && make && cd ../../..
657- fi
762+ case " $recipe " in
763+ -equation-gcc-8.3.0)
764+ cp bin/gcc.exe fbc/bin/$target
765+ cp bin/gdb.exe fbc/bin/$target
766+
767+ case " $target " in
768+ win32)
769+ # copy all the dll's from libexec; they are needed for cc1.exe
770+ cp --parents libexec/gcc/i686-pc-mingw32/$gccversion /cc1.exe fbc/bin
771+ ;;
772+ win64)
773+ # copy all the dll's from libexec; they are needed for cc1.exe
774+ cp --parents libexec/gcc/x86_64-w64-mingw32/$gccversion /cc1.exe fbc/bin
775+ ;;
776+ * )
777+ echo " invalid target $target "
778+ exit 1
779+ ;;
780+ esac
658781
659- case " $target " in
660- win32)
661- # Take MinGW.org's gdb, because the gdb from the MinGW-w64 toolchain has much more
662- # dependencies (e.g. Python for scripting purposes) which we probably don't want/need.
663- # (this should probably be reconsidered someday)
664- cp mingworg-gdb/bin/gdb.exe fbc/bin/win32
665- cp mingworg-gdb/bin/libgcc_s_dw2-1.dll fbc/bin/win32
666- cp mingworg-gdb/bin/zlib1.dll fbc/bin/win32
667782 ;;
668- win32-mingworg)
669- cp bin/gdb.exe fbc/bin/win32
670- cp bin/libgcc_s_dw2-1.dll fbc/bin/win32
671- cp bin/zlib1.dll fbc/bin/win32
783+ -winlibs-gcc-8.4.0)
784+ # -winlibs-gcc-X.X is being built from winlibs and the binutils have a few dependencies
785+ # copy these to the bin directory - they go with the executables and should
786+ # not be used as general libraries
787+ cp bin/libdl.dll fbc/bin/$fbtarget
788+ cp bin/libiconv-2.dll fbc/bin/$fbtarget
789+ cp bin/libintl-8.dll fbc/bin/$fbtarget
790+ cp bin/libwinpthread-1.dll fbc/bin/$fbtarget
791+ cp bin/zlib1.dll fbc/bin/$fbtarget
792+ cp bin/gcc.exe fbc/bin/$target
793+
794+ case " $target " in
795+ win32)
796+ cp bin/libgcc_s_dw2-1.dll fbc/bin/$fbtarget
797+ # copy all the dll's from libexec; they are needed for cc1.exe
798+ cp --parents libexec/gcc/i686-w64-mingw32/$gccversion /cc1.exe fbc/bin
799+ cp --parents libexec/gcc/i686-w64-mingw32/$gccversion /* .dll fbc/bin
800+ ;;
801+ win64)
802+ cp bin/libgcc_s_seh-1.dll fbc/bin/$fbtarget
803+ # copy all the dll's from libexec; they are needed for cc1.exe
804+ cp --parents libexec/gcc/x86_64-w64-mingw32/$gccversion /cc1.exe fbc/bin
805+ cp --parents libexec/gcc/x86_64-w64-mingw32/$gccversion /* .dll fbc/bin
806+ ;;
807+ * )
808+ echo " invalid target $target "
809+ exit 1
810+ ;;
811+ esac
672812 ;;
673- win64)
674- cp bin/gcc.exe fbc/bin/win64
675- cp --parents libexec/gcc/x86_64-w64-mingw32/$gccversion /cc1.exe fbc/bin
813+ * )
814+ case " $target " in
815+ win32)
816+ # !!! TODO !!! re-evaluate the gdb used with later gcc versions
817+ # !!! TODO !!! maybe package the 32-bit gcc too even for mingw-w64
818+ # Take MinGW.org's gdb, because the gdb from the MinGW-w64 toolchain has much more
819+ # dependencies (e.g. Python for scripting purposes) which we probably don't want/need.
820+ # (this should probably be reconsidered someday)
821+ cp mingworg-gdb/bin/gdb.exe fbc/bin/win32
822+ cp mingworg-gdb/bin/libgcc_s_dw2-1.dll fbc/bin/win32
823+ cp mingworg-gdb/bin/zlib1.dll fbc/bin/win32
824+ ;;
825+ win32-mingworg)
826+ cp bin/gdb.exe fbc/bin/win32
827+ cp bin/libgcc_s_dw2-1.dll fbc/bin/win32
828+ cp bin/zlib1.dll fbc/bin/win32
829+ ;;
830+ win64)
831+ cp bin/gcc.exe fbc/bin/win64
832+ cp --parents libexec/gcc/x86_64-w64-mingw32/$gccversion /cc1.exe fbc/bin
833+ ;;
834+ esac
676835 ;;
677836 esac
678837
838+ cd fbc && make mingw-libs ENABLE_STANDALONE=1 && cd ..
839+
840+ if [ $fbtarget = " win32" ]; then
841+ cd fbc/lib/win32 && make && cd ../../..
842+ fi
843+
679844 cp ../input/$libffi_title /$target$recipe /libffi.a fbc/lib/$fbtarget
680845
681846 # Reduce .exe sizes by dropping debug info
0 commit comments