1010# - fbc sources are retrieved from Git; you can specify the exact commit to
1111# build, the default is "master".
1212#
13+ # 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
15+ # ENABLE_STANDALONE, except for the directory layout). This way we avoid
16+ # unnecessary full rebuilds.
17+ #
1318# ./build.sh <target> [<fbc-commit>]
1419#
1520# <target> can be one of:
@@ -229,16 +234,12 @@ linux*)
229234
230235 # fbc sources
231236 cp -R ../input/fbc fbc
232- cp -R ../input/fbc fbcsa
233- cd fbc && git reset --hard " $fbccommit " && cd ..
234- cd fbcsa && git reset --hard " $fbccommit " && cd ..
235- echo " prefix := ` pwd -W` " > fbc/config.mk
236- echo " ENABLE_STANDALONE := 1" > fbcsa/config.mk
237+ cd fbc && git reset --hard " $fbccommit " && cd ..
238+ echo " prefix := ` pwd -W` " > fbc/config.mk
237239
238240 # On 64bit, we have to override the FB makefile's uname check, because MSYS uname reports 32bit still
239241 if [ $fbtarget = win64 ]; then
240242 echo " TARGET_ARCH := x86_64" >> fbc/config.mk
241- echo " TARGET_ARCH := x86_64" >> fbcsa/config.mk
242243 fi
243244 ;;
244245esac
@@ -257,41 +258,11 @@ esac
257258function dosbuild() {
258259 dospath=` pwd -W`
259260
260- cat << EOF > open-djgpp.bat
261- set DJGPP=$dospath /djgpp.env
262- set PATH=$dospath /bin;%PATH%
263- cmd
264- EOF
265-
266261 cat << EOF > build.bat
267262@echo off
268-
269263set DJGPP=$dospath /djgpp.env
270264set PATH=$dospath /bin
271265
272- echo build PATH = %PATH%
273- echo.
274-
275- echo uname:
276- uname
277- if ERRORLEVEL 1 exit /b
278- echo.
279-
280- echo make --version:
281- make --version
282- if ERRORLEVEL 1 exit /b
283- echo.
284-
285- echo gcc --version:
286- gcc --version
287- if ERRORLEVEL 1 exit /b
288- echo.
289-
290- echo gcc -print-file-name=libgcc.a:
291- gcc -print-file-name=libgcc.a
292- if ERRORLEVEL 1 exit /b
293- echo.
294-
295266echo bootstrapping normal fbc:
296267cd fbc
297268make FBC=../$bootfb_title /fbc.exe
@@ -309,45 +280,43 @@ if ERRORLEVEL 1 exit /b
309280make install
310281if ERRORLEVEL 1 exit /b
311282cd ..
283+ EOF
312284
313- echo building standalone fbc:
314- cd fbcsa
315- make
285+ cat << EOF > buildsa.bat
286+ @echo off
287+ set DJGPP=$dospath /djgpp.env
288+ set PATH=$dospath /bin
289+
290+ cd fbc
291+ make ENABLE_STANDALONE=1
316292if ERRORLEVEL 1 exit /b
317293cd ..
318294EOF
319295
320296 cmd /c build.bat
321297
322- echo
323- echo " copying binutils/libs/etc. "
324- echo
298+ echo " building standalone fbc: "
299+ rm fbc/src/compiler/obj/fbc.o
300+ cmd /c buildsa.bat
325301
326- mkdir -p fbcsa /bin/dos
327- cp bin/ar.exe bin/as.exe bin/gdb.exe bin/gprof.exe bin/ld.exe fbcsa /bin/dos/
328- cp lib/crt0.o lib/gcrt0.o lib/libdbg.a lib/libemu.a lib/libm.a fbcsa /lib/dos/
329- cp lib/libstdcxx.a fbcsa /lib/dos/libstdcx.a
330- cp lib/libsupcxx.a fbcsa /lib/dos/libsupcx.a
331- cp lib/gcc/djgpp/4.92/libgcc.a fbcsa /lib/dos/
302+ mkdir -p fbc /bin/dos
303+ cp bin/ar.exe bin/as.exe bin/gdb.exe bin/gprof.exe bin/ld.exe fbc /bin/dos/
304+ cp lib/crt0.o lib/gcrt0.o lib/libdbg.a lib/libemu.a lib/libm.a fbc /lib/dos/
305+ cp lib/libstdcxx.a fbc /lib/dos/libstdcx.a
306+ cp lib/libsupcxx.a fbc /lib/dos/libsupcx.a
307+ cp lib/gcc/djgpp/4.92/libgcc.a fbc /lib/dos/
332308
333309 cd fbc
334310 make bindist TARGET_OS=dos DISABLE_DOCS=1
335- cd ..
336- cd fbcsa
337- make bindist TARGET_OS=dos
311+ make bindist TARGET_OS=dos ENABLE_STANDALONE=1
338312 cd ..
339313
340- mv fbc/* .zip fbcsa/ * .zip ../output
341- mv fbc/contrib/manifest/fbc-dos.lst ../output
342- mv fbcsa /contrib/manifest/FreeBASIC-dos.lst ../output
314+ cp fbc/* .zip ../output
315+ cp fbc/contrib/manifest/fbc-dos.lst ../output
316+ cp fbc /contrib/manifest/FreeBASIC-dos.lst ../output
343317}
344318
345319function linuxbuild() {
346- echo
347- echo " uname = ` uname` "
348- echo " gcc -print-file-name=libgcc.a = ` gcc -print-file-name=libgcc.a` "
349- echo
350-
351320 cd fbc
352321 echo
353322 echo " bootstrapping normal fbc"
@@ -364,8 +333,6 @@ function linuxbuild() {
364333 cd fbc && make bindist && cd ..
365334 cp fbc/* .tar.* ../output
366335 cp fbc/contrib/manifest/FreeBASIC-$fbtarget .lst ../output
367-
368- cd ..
369336}
370337
371338function windowsbuild() {
@@ -374,13 +341,6 @@ function windowsbuild() {
374341 origPATH=" $PATH "
375342 export PATH=" $PWD /bin:$PATH "
376343
377- echo
378- echo " build PATH = $PATH "
379- echo " uname = ` uname` "
380- echo " which gcc = ` which gcc` "
381- echo " gcc -print-file-name=libgcc.a = ` gcc -print-file-name=libgcc.a` "
382- echo
383-
384344 echo
385345 echo " building libffi"
386346 echo
@@ -413,76 +373,74 @@ function windowsbuild() {
413373 make
414374 cd ..
415375
416- cd fbcsa
376+ cd fbc
417377 echo
418378 echo " building standalone fbc"
419379 echo
420- make
380+ rm src/compiler/obj/fbc.o
381+ make ENABLE_STANDALONE=1
421382 cd ..
422383
423- echo
424- echo " copying binutils/libs/etc."
425- echo
426-
427- mkdir -p fbcsa/bin/$fbtarget
428- cp bin/ar.exe fbcsa/bin/$fbtarget
429- cp bin/as.exe fbcsa/bin/$fbtarget
430- cp bin/dlltool.exe fbcsa/bin/$fbtarget
431- cp bin/gprof.exe fbcsa/bin/$fbtarget
432- cp bin/ld.exe fbcsa/bin/$fbtarget
384+ mkdir -p fbc/bin/$fbtarget
385+ cp bin/ar.exe fbc/bin/$fbtarget
386+ cp bin/as.exe fbc/bin/$fbtarget
387+ cp bin/dlltool.exe fbc/bin/$fbtarget
388+ cp bin/gprof.exe fbc/bin/$fbtarget
389+ cp bin/ld.exe fbc/bin/$fbtarget
433390
434- cd fbcsa && make mingw-libs && cd ..
391+ cd fbc && make mingw-libs ENABLE_STANDALONE=1 && cd ..
435392
436393 if [ $fbtarget = " win32" ]; then
437- cd fbcsa /lib/win32 && make && cd ../../..
394+ cd fbc /lib/win32 && make && cd ../../..
438395 fi
439396
440397 case " $target " in
441398 win32)
442399 # Take MinGW.org's gdb, because the gdb from the MinGW-w64 toolchain has much more
443400 # dependencies (e.g. Python for scripting purposes) which we probably don't want/need.
444401 # (this should probably be reconsidered someday)
445- cp mingworg-gdb/bin/gdb.exe fbcsa /bin/win32
446- cp mingworg-gdb/bin/libgcc_s_dw2-1.dll fbcsa /bin/win32
447- cp mingworg-gdb/bin/zlib1.dll fbcsa /bin/win32
402+ cp mingworg-gdb/bin/gdb.exe fbc /bin/win32
403+ cp mingworg-gdb/bin/libgcc_s_dw2-1.dll fbc /bin/win32
404+ cp mingworg-gdb/bin/zlib1.dll fbc /bin/win32
448405 ;;
449406 win32-mingworg)
450- cp bin/gdb.exe fbcsa /bin/win32
451- cp bin/libgcc_s_dw2-1.dll fbcsa /bin/win32
452- cp bin/zlib1.dll fbcsa /bin/win32
407+ cp bin/gdb.exe fbc /bin/win32
408+ cp bin/libgcc_s_dw2-1.dll fbc /bin/win32
409+ cp bin/zlib1.dll fbc /bin/win32
453410 ;;
454411 win64)
455- cp bin/gcc.exe fbcsa /bin/win64
456- cp --parents libexec/gcc/x86_64-w64-mingw32/4.9.2/cc1.exe fbcsa /bin
412+ cp bin/gcc.exe fbc /bin/win64
413+ cp --parents libexec/gcc/x86_64-w64-mingw32/4.9.2/cc1.exe fbc /bin
457414 ;;
458415 esac
459416
460417 # TODO: GoRC.exe should really be taken from its homepage
461418 # <http://www.godevtool.com/>, but it was offline today
462- cp $bootfb_title /bin/$fbtarget /GoRC.exe fbcsa /bin/$fbtarget
419+ cp $bootfb_title /bin/$fbtarget /GoRC.exe fbc /bin/$fbtarget
463420
464- cp " $libffi_build " /.libs/libffi.a fbcsa /lib/$fbtarget
421+ cp " $libffi_build " /.libs/libffi.a fbc /lib/$fbtarget
465422
466423 # Reduce .exe sizes by dropping debug info
467424 # (this was at least needed for MinGW.org's gdb, and probably nothing else,
468425 # but it shouldn't hurt either)
469- strip -g fbcsa /bin/$fbtarget /*
426+ strip -g fbc /bin/$fbtarget /*
470427
428+ cd fbc
471429 case " $target " in
472430 win32|win64)
473- cd fbc && make bindist DISABLE_DOCS=1 && cd ..
474- cd fbcsa && make bindist && cd ..
431+ make bindist DISABLE_DOCS=1
432+ make bindist ENABLE_STANDALONE=1
475433 ;;
476434 win32-mingworg)
477- cd fbc && make bindist DISABLE_DOCS=1 FBPACKSUFFIX=-mingworg && cd ..
478- cd fbcsa && make bindist FBPACKSUFFIX=-mingworg && cd ..
435+ make bindist DISABLE_DOCS=1 FBPACKSUFFIX=-mingworg
436+ make bindist ENABLE_STANDALONE=1 FBPACKSUFFIX=-mingworg
479437 ;;
480438 esac
439+ cd ..
481440
482- cp fbc/* .zip fbc/* .7z ../output
483- cp fbcsa/* .zip fbcsa/* .7z ../output
484- cp fbc/contrib/manifest/fbc-$target .lst ../output
485- cp fbcsa/contrib/manifest/FreeBASIC-$target .lst ../output
441+ cp fbc/* .zip fbc/* .7z ../output
442+ cp fbc/contrib/manifest/fbc-$target .lst ../output
443+ cp fbc/contrib/manifest/FreeBASIC-$target .lst ../output
486444
487445 export PATH=" $origPATH "
488446 cd ..
0 commit comments