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#
251251
252252 djver=205
253253 gccver=710
254- djgppgccversiondir=7.1.0
254+ djgppgccversiondir=7
255255 bnuver=229
256256 gdbver=771
257257 djpkg=current
@@ -268,23 +268,31 @@ dos)
268268 download_djgpp ${djpkg} /v2gnu/ fil41br2
269269 download_djgpp ${djpkg} /v2gnu/ mak421b
270270 download_djgpp ${djpkg} /v2gnu/ shl2011br2
271+ download_djgpp ${djpkg} /v2gnu/ pth207b
272+
273+ download_djgpp ${djpkg} /v2tk/ ls080b
271274
272275 # Sources for stuff that goes into the FB-dos package (needs updating to new versions)
273276 download_djgpp ${djpkg} /v2gnu/ bnu${bnuver} s
274277 download_djgpp ${djpkg} /v2gnu/ gcc${gccver} s
275278 download_djgpp ${djpkg} /v2gnu/ gdb${gdbver} s
276279 download_djgpp ${djpkg} /v2/ djlsr${djver}
277280
278- unzip -q ../input/DJGPP/djdev${djver} .zip
281+ unzip -qo ../input/DJGPP/djdev${djver} .zip
282+
283+ unzip -qo ../input/DJGPP/shl2011br2.zip
284+ unzip -qo ../input/DJGPP/fil41br2.zip
285+ unzip -qo ../input/DJGPP/mak421b.zip
286+ unzip -qo ../input/DJGPP/pth207b.zip
287+
288+ unzip -qo ../input/DJGPP/ls080b.zip
279289
280- unzip -q ../input/DJGPP/shl2011br2.zip
281- unzip -q ../input/DJGPP/fil41br2.zip
282- unzip -q ../input/DJGPP/mak421b.zip
290+ unzip -qo ../input/DJGPP/gdb${gdbver} b.zip
291+ unzip -qo ../input/DJGPP/bnu${bnuver} b.zip
292+ unzip -qo ../input/DJGPP/gcc${gccver} b.zip
293+ unzip -qo ../input/DJGPP/gpp${gccver} b.zip
283294
284- unzip -q ../input/DJGPP/gdb${gdbver} b.zip
285- unzip -q ../input/DJGPP/bnu${bnuver} b.zip
286- unzip -q ../input/DJGPP/gcc${gccver} b.zip
287- unzip -q ../input/DJGPP/gpp${gccver} b.zip
295+ patch -p0 < ../djgpp-fix-pthread.patch
288296 ;;
289297win32)
290298 get_mingww64_toolchain 32 i686
@@ -322,8 +330,14 @@ win32-mingworg)
322330 download_extract_mingw mpfr-3.1.2-2-mingw32-dll.tar.lzma
323331
324332 # Add ddraw.h and dinput.h for FB's gfxlib2
325- copyfile " ../input/MinGW.org/ddraw.h" " include/ddraw.h"
326- copyfile " ../input/MinGW.org/dinput.h" " include/dinput.h"
333+
334+ # if ddraw.h & dinput.h were added manually:
335+ # copyfile "../input/MinGW.org/ddraw.h" "include/ddraw.h"
336+ # copyfile "../input/MinGW.org/dinput.h" "include/dinput.h"
337+
338+ # download link for dx80_mgw.zip from https://liballeg.org/old.html
339+ download dx80_mgw.zip https://download.tuxfamily.org/allegro/files/dx80_mgw.zip
340+ unzip ../input/dx80_mgw.zip include/ddraw.h include/dinput.h
327341
328342 # Work around http://sourceforge.net/p/mingw/bugs/2039/
329343 patch -p0 < ../mingworg-fix-wcharh.patch
@@ -422,14 +436,17 @@ EOF
422436 cmd /c build.bat
423437
424438 echo " building standalone fbc:"
425- rm fbc/src/compiler/obj/fbc.o
439+ rm fbc/src/compiler/obj/$fbtarget / fbc.o
426440 cmd /c buildsa.bat
427441
428442 mkdir -p fbc/bin/dos
429443 cp bin/ar.exe bin/as.exe bin/gdb.exe bin/gprof.exe bin/ld.exe fbc/bin/dos/
444+ cp bin/dxe3gen.exe fbc/bin/dos/
430445 cp lib/crt0.o lib/gcrt0.o lib/libdbg.a lib/libemu.a lib/libm.a fbc/lib/dos/
431446 cp lib/libstdcxx.a fbc/lib/dos/libstdcx.a
432447 cp lib/libsupcxx.a fbc/lib/dos/libsupcx.a
448+ cp lib/libsocket.a fbc/lib/dos/libsocket.a
449+ cp lib/libpthread.a fbc/lib/dos/libpthread.a
433450 cp lib/gcc/djgpp/$djgppgccversiondir /libgcc.a fbc/lib/dos/
434451
435452 cd fbc
@@ -461,11 +478,19 @@ linuxbuild() {
461478 cp fbc/contrib/manifest/FreeBASIC-$fbtarget .lst ../output
462479}
463480
464- windowsbuild () {
465- # Add our toolchain's bin/ to the PATH, so hopefully we'll only use
466- # its gcc and not one from the host
467- origPATH=" $PATH "
468- export PATH=" $PWD /bin:$PATH "
481+ libffibuild () {
482+
483+ # do we already have the files we need?
484+ if [ -f " ../input/$libffi_title /$target /ffi.h" ]; then
485+ if [ -f " ../input/$libffi_title /$target /ffitarget.h" ]; then
486+ if [ -f " ../input/$libffi_title /$target /libffi.a" ]; then
487+ echo
488+ echo " using cached libffi: $libffi_title /$target "
489+ echo
490+ return
491+ fi
492+ fi
493+ fi
469494
470495 echo
471496 echo " building libffi"
@@ -475,16 +500,32 @@ windowsbuild() {
475500 cd " $libffi_build "
476501 if [ " $target " = win64 ]; then
477502 CFLAGS=-O2 ../$libffi_title /configure --disable-shared --enable-static --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32
503+ elif [ " $target " = win32 ]; then
504+ # force host even for 32-bit, we might be cross compiling from x86_64 to x86
505+ CFLAGS=-O2 ../$libffi_title /configure --disable-shared --enable-static --host=i686-w64-mingw32
478506 else
479507 CFLAGS=-O2 ../$libffi_title /configure --disable-shared --enable-static
480508 fi
481509 make
482- case " $target " in
483- win32) cp include/ffi.h include/ffitarget.h ../i686-w64-mingw32/include;;
484- win32-mingworg) cp include/ffi.h include/ffitarget.h ../include;;
485- win64) cp include/ffi.h include/ffitarget.h ../x86_64-w64-mingw32/include;;
486- esac
510+ # stash some files in the input folder to make rebuilding faster
511+ mkdir -p ../../input/$libffi_title /$target
512+ cp include/ffi.h include/ffitarget.h ../../input/$libffi_title /$target
513+ cp .libs/libffi.a ../../input/$libffi_title /$target
487514 cd ..
515+ }
516+
517+ windowsbuild () {
518+ # Add our toolchain's bin/ to the PATH, so hopefully we'll only use
519+ # its gcc and not one from the host
520+ origPATH=" $PATH "
521+ export PATH=" $PWD /bin:$PATH "
522+
523+ libffibuild
524+ case " $target " in
525+ win32) cp ../input/$libffi_title /$target /ffi.h ../input/$libffi_title /$target /ffitarget.h ./i686-w64-mingw32/include;;
526+ win32-mingworg) cp ../input/$libffi_title /$target /ffi.h ../input/$libffi_title /$target /ffitarget.h ./include;;
527+ win64) cp ../input/$libffi_title /$target /ffi.h ../input/$libffi_title /$target /ffitarget.h ./x86_64-w64-mingw32/include;;
528+ esac
488529
489530 cd fbc
490531 echo
@@ -503,7 +544,7 @@ windowsbuild() {
503544 echo
504545 echo " building standalone fbc"
505546 echo
506- rm src/compiler/obj/fbc.o
547+ rm src/compiler/obj/$fbtarget / fbc.o
507548 make ENABLE_STANDALONE=1
508549 cd ..
509550
@@ -540,11 +581,14 @@ windowsbuild() {
540581 ;;
541582 esac
542583
543- # TODO: GoRC.exe should really be taken from its homepage
544- # <http://www.godevtool.com/>, but it was offline today
545- cp $bootfb_title /bin/$fbtarget /GoRC.exe fbc/bin/$fbtarget
584+ # get GoRC.exe from previous fb release
585+ # cp $bootfb_title/bin/$fbtarget/GoRC.exe fbc/bin/$fbtarget
586+
587+ # get GoRC.exe from author site
588+ download " Gorc.zip" " http://www.godevtool.com/Gorc.zip"
589+ unzip ../input/Gorc.zip GoRC.exe -d fbc/bin/$fbtarget
546590
547- cp " $libffi_build " /.libs /libffi.a fbc/lib/$fbtarget
591+ cp ../input/ $libffi_title / $target /libffi.a fbc/lib/$fbtarget
548592
549593 # Reduce .exe sizes by dropping debug info
550594 # (this was at least needed for MinGW.org's gdb, and probably nothing else,
0 commit comments