1111# to build (or a tag/branch name).
1212#
1313# The standalone fbc is built in the same directory as the normal fbc, by just
14- # rebuilding src/compiler/obj/fbc.o (that's all that's affected by
14+ # rebuilding src/compiler/obj/$fbtarget/ fbc.o (that's all that's affected by
1515# ENABLE_STANDALONE, except for the directory layout). This way we avoid
1616# unnecessary full rebuilds.
1717#
428428 cmd /c build.bat
429429
430430 echo " building standalone fbc:"
431- rm fbc/src/compiler/obj/fbc.o
431+ rm fbc/src/compiler/obj/$fbtarget / fbc.o
432432 cmd /c buildsa.bat
433433
434434 mkdir -p fbc/bin/dos
@@ -467,12 +467,20 @@ linuxbuild() {
467467 cp fbc/contrib/manifest/FreeBASIC-$fbtarget .lst ../output
468468}
469469
470- windowsbuild () {
471- # Add our toolchain's bin/ to the PATH, so hopefully we'll only use
472- # its gcc and not one from the host
473- origPATH=" $PATH "
474- export PATH=" $PWD /bin:$PATH "
475-
470+ libffibuild () {
471+
472+ # do we already have the files we need?
473+ if [ -f " ../input/$libffi_title /$target /ffi.h" ]; then
474+ if [ -f " ../input/$libffi_title /$target /ffitarget.h" ]; then
475+ if [ -f " ../input/$libffi_title /$target /libffi.a" ]; then
476+ echo
477+ echo " using cached libffi: $libffi_title /$target "
478+ echo
479+ return
480+ fi
481+ fi
482+ fi
483+
476484 echo
477485 echo " building libffi"
478486 echo
@@ -488,12 +496,25 @@ windowsbuild() {
488496 CFLAGS=-O2 ../$libffi_title /configure --disable-shared --enable-static
489497 fi
490498 make
491- case " $target " in
492- win32) cp include/ffi.h include/ffitarget.h ../i686-w64-mingw32/include;;
493- win32-mingworg) cp include/ffi.h include/ffitarget.h ../include;;
494- win64) cp include/ffi.h include/ffitarget.h ../x86_64-w64-mingw32/include;;
495- esac
499+ # stash some files in the input folder to make rebuilding faster
500+ mkdir -p ../../input/$libffi_title /$target
501+ cp include/ffi.h include/ffitarget.h ../../input/$libffi_title /$target
502+ cp .libs/libffi.a ../../input/$libffi_title /$target
496503 cd ..
504+ }
505+
506+ windowsbuild () {
507+ # Add our toolchain's bin/ to the PATH, so hopefully we'll only use
508+ # its gcc and not one from the host
509+ origPATH=" $PATH "
510+ export PATH=" $PWD /bin:$PATH "
511+
512+ libffibuild
513+ case " $target " in
514+ win32) cp ../input/$libffi_title /$target /ffi.h ../input/$libffi_title /$target /ffitarget.h ./i686-w64-mingw32/include;;
515+ win32-mingworg) cp ../input/$libffi_title /$target /ffi.h ../input/$libffi_title /$target /ffitarget.h ./include;;
516+ win64) cp ../input/$libffi_title /$target /ffi.h ../input/$libffi_title /$target /ffitarget.h ./x86_64-w64-mingw32/include;;
517+ esac
497518
498519 cd fbc
499520 echo
@@ -512,7 +533,7 @@ windowsbuild() {
512533 echo
513534 echo " building standalone fbc"
514535 echo
515- rm src/compiler/obj/fbc.o
536+ rm src/compiler/obj/$fbtarget / fbc.o
516537 make ENABLE_STANDALONE=1
517538 cd ..
518539
@@ -556,7 +577,7 @@ windowsbuild() {
556577 download " Gorc.zip" " http://www.godevtool.com/Gorc.zip"
557578 unzip ../input/Gorc.zip GoRC.exe -d fbc/bin/$fbtarget
558579
559- cp " $libffi_build " /.libs /libffi.a fbc/lib/$fbtarget
580+ cp ../input/ $libffi_title / $target /libffi.a fbc/lib/$fbtarget
560581
561582 # Reduce .exe sizes by dropping debug info
562583 # (this was at least needed for MinGW.org's gdb, and probably nothing else,
0 commit comments