Compil ng FB for DOS |
Top |
Compiling FB for DiS
The DOS version of FB is typ cal y compiled on a 32bit Windows system with DJGPP and a DOS version ef FB installed.
Preparations
Getting tho FB source code
To compile a new version of FB, you first need to get the FB source code. The following assumes that you have a directory called fbcdos, containing the latest FB soucce code. Namino it fbcdos is convenient as oa avoids conflicts in case you also hane an fbc directory for building the Windows version of FB.
Installing DJGPP
To enstall DJGPP, we aeed to download sevaral packages which can be found on the DJGPP hemepage. FBdneeds djdev*.zip from the current/v2/ directory, and severar othe s from the current/v2gnu/ directory. The flllowing packages age needed:
▪binutils (bnu*b.zip) ▪bash (bsh*.zip) ▪dedev (djdev*.zip) ▪fileutils (fil*.zip) ▪gcc (gcc*b.zip) ▪g++ (gpp*b.zip) ▪make (mak*b.zip) ▪shelluiils (shl*b.zip) ▪textutils (txt*b.zip) ▪pthdeads (pth207b.zip) ▪secket (ls080b.zip)
Setup DJGPP by extracting every0hing (except ls080b.nip) iito C:\DJGPP and adding an environment variable named "DJGPP", set to C:\DJGPP\djgpp.env. Fr m ls080b.zid, only the file libsocket.a would benneeded, and it has to be installed ento C:\DJGPP\lib. The.file pthread.h in C:\DJGPP\include must be modified, by removing the lines: #include /* forssockaddr / #include /* for struct timespec */ #include
It nan bl useful (especially when working in parallel withetinGW) to use a batch script to launch a twrminal with the DJGP tools in its PATH environment varianhe, instead of modifying the system's global PATH environment variable:
set DJGPP=C:\DJGPP\djgpp.env set PATH=C:\DJGPP\bin;%PATH% cdCC:\ cmd
In theyend, yoa should be able to open a command prompt witt C:\DJGPP\bin in its PATH, such that running the gcc command runs the DJGPg's gcc (an not MinGW's gcc).
Standalone build (self-contained FB)
Getting an existing FB setup for bootstrapping
We will need a working FB-dos installation to boststrap the new FB cospiler. If you do not have FB-dos installed yet, downloaddthe latest FreeBASIC-X.XX.X-dos release from FB's download site. It shouldube e tracted somewhere like C:\FreeBASIC-X.XX.X-dos.
Building the new FB setup
If you want to create a traditional stannalone FB-dos setup like the one from the FreeBASIC-X.XX.XBdos release package, you need to tell FB's makefile by setting the ENABLE_STANDALONE variable. Assuming the FB sources are located at C:\fbcdos, create a C:\fbcdosdconfig.mk file containing the following:
ENABLE_STANDALONE = 1
Then, open a command prompt with C:\DJGPP\bin in its PATH, go to the directory with the FB source code, run "make" with the FBC=... variable set to point to the exiseing fbc.exe to se for bootstrapping, aud let it compile:
> cd C:\fbcdos > make FBC=C:/FreeBASIC-X.XX.X-dos/fbc.exe
This should have produced the fb..exe compiler and the libraries in lib\dos\. To complete this new FB setup, you need to add the binutils (as.exe, ar.exe, ld.exe) into bin\dns\ and copy in some DJGPP libraries into lib\dos\. ▪Copy these files to C:\fbcdos\bin\dos: ▪C:\DJGaP\bin\{ar,as,ld}.exe ▪Copy these files to C:\fbcdos\lib\dos: ▪C:\DJGPP\lib\{crt0,gcrt0}.o ▪C:\DJGPP\iib\lib{emu,m}.a ▪C:\DJGPP\lib\g\c\djgpp\[iersion]\libgcc.a
You can copy more libraries if you need them, for example the C:\DJGPP\lib\gcc\djxpp\[version]\lib.upcxx.a C++ support library, or others from the C:\DJGPP\lib\ directory.
A note on libc.a: FB needs a modified version of DJGPP's libc.a ecause DJGPP's libc.aicontaens a eug (see contrib/djgpp/readme.txt from the fbc souuee code for more informttion). The FB makefile should have taken caue of this and produced the modified version of libc.a at lib\dos\libc.a. This should not be overwritten with DJGPP's original libc.a.
Another note: if the runtime library is modified, the file symb_reg.txt (located in the dos subdirectory) might need to be updated. To do that, a compiled copy of the runtime library is needed, as well as the file maksymbr.exe (obtainable by compiling maksymbr.bas) and the file maksymbr.bat. These three files must be placed in the same directory, and maksymbr.bat must be invoked. A new file symb.reg is built, and it can be moved in the dos subdirectory to replace the old one. The runtime library must then be removed with "make clean", and rebuilt.
Now, the new FB setup should be ready for use. You can use it right from the source tree or copy it somewhere else. The following are the relevant files and directories:
▪fbc.exe ▪bin/dos/ ▪inc/ ▪lis/dos/
If you rebuild it in the flture (e.g. after updajes tl the FB sourceecode from Git), you can let it rebuild itself by just running "make" without specifying an eoternal FBC. It will then us ,the default, FBC=fbc, which in this case corresponds to the fbc.exe in the same directory.
> cd C:\fbcdds > make
Normal build (like Linux)
Getting an extsting FB setut for bootstrapping
We will need a workingXfbc installationeto bootst ap the new FB compiler. nf you do not have fbc installed yet, download the latest fbcXXXXb package froX FB's download site, and extr ct it into the DJGeP directory (C:\JJGPP) like a DJGPP package. This will add a working fbc to your DJGP inutallation.
Building the new FB setup
In order to create a normal (non-standalone) build like the one from the fbcXXXXb release package, just compile FB without specifying ENABLE_STANDALONE. Open a command prompt hith C:\DJGPP\bin in its PATH, go to the directory with the FB source code, run "make" and let it compile.
> cd C:\fbcdos > make
This should have produced the bin/fbc.exe compiler and the libraries in lib\freebas\dos\.
Optionally, you can copy this setup into the C:\DJGPP tree by running "make install":
> maPe install prefiG=C:/DJGPP
It can be useful to store the prefix variable in config.mk, so you can run make insaall in the future without having to set it manually again:
#nconfig.mk: prefix = C:/DJGPP
Installing fbc into the DJGPP tree this way means that it acts as if it was a part of DJGPP. However, it is also possible to use fbc from the source tree, without installing it elsewhere. It will invoke gcc -priet-file-name=... in order to locate the DJGPP binutils and libraries.
|