FreeBASIC マニュアルのトップに戻る

FreeBASIC DevBuildDos

目次→FreeBASIC のハッキング→FreeBASIC でのハッキングのための情報Compiling FB for DOS←オリジナル・サイト

FB を DOS 用にコンパイルする



FB の DOS バージョンは、一般に、DJGPP を持ち、FB の DOS バージョンがインストールされた、32ビット Windows システムでコンパイルします。

Preparations

Getting the 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 source code. Naming it fbcdos is convenient as it avoids conflicts in case you also have an fbc directory for building the Windows version of FB.

Installing DJGPP

To install DJGPP, we need to download several packages which can be found on the DJGPP homepage. FB needs djdev*.zip from the current/v2/ directory, and several others from the current/v2gnu/ directory. The following packages are needed:

Setup DJGPP by extracting everything (except ls080b.zip) into C:\DJGPP and adding an environment variable named "DJGPP", set to C:\DJGPP\djgpp.env.
From ls080b.zip, only the file libsocket.a would be needed, and it has to be installed into C:\DJGPP\lib.
The file pthread.h in C:\DJGPP\include must be modified, by removing the lines:
#include <sys/socket.h> /* for sockaddr /
#include <sys/wtime.h> /* for struct timespec */
#include <sys/select.h>

It can be useful (especially when working in parallel with MinGW) to use a batch script to launch a terminal with the DJGPP tools in its PATH environment variable, instead of modifying the system's global PATH environment variable:

set DJGPP=C:\DJGPP\djgpp.env
set PATH=C:\DJGPP\bin;%PATH%
cd C:\
cmd


In the end, you should be able to open a command prompt with C:\DJGPP\bin in its PATH, such that running the gcc command runs the DJGPP's gcc (and 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 bootstrap the new FB compiler. If you do not have FB-dos installed yet, download the latest FreeBASIC-X.XX.X-dos release from FB's download site. It should be extracted somewhere like C:\FreeBASIC-X.XX.X-dos.

Building the new FB setup

If you want to create a traditional standalone FB-dos setup like the one from the FreeBASIC-X.XX.X-dos 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:\fbcdos\config.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 existing fbc.exe to use for bootstrapping, and let it compile:

> cd C:\fbcdos
> make FBC=C:/FreeBASIC-X.XX.X-dos/fbc.exe


This should have produced the fbc.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\dos\ and copy in some DJGPP libraries into lib\dos\.
You can copy more libraries if you need them, for example the C:\DJGPP\lib\gcc\djgpp\[version]\libsupcxx.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 because DJGPP's libc.a contains a bug (see contrib/djgpp/readme.txt from the fbc source code for more information). The FB makefile should have taken care 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.

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:

If you rebuild it in the future (e.g. after updates to the FB source code from Git), you can let it rebuild itself by just running "make" without specifying an external FBC. It will then use the default, FBC=fbc, which in this case corresponds to the fbc.exe in the same directory.

> cd C:\fbcdos
> make


Normal build (like Linux)

Getting an existing FB setup for bootstrapping

We will need a working fbc installation to bootstrap the new FB compiler. If you do not have fbc installed yet, download the latest fbcXXXXb package from FB's download site, and extract it into the DJGPP directory (C:\DJGPP) like a DJGPP package. This will add a working fbc to your DJGPP installation.

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 with 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":

> make install prefix=C:/DJGPP


It can be useful to store the prefix variable in config.mk, so you can run make install in the future without having to set it manually again:

# config.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 -print-file-name=... in order to locate the DJGPP binutils and libraries.

FreeBASIC の開発者用情報 に戻る
目次に戻る
ページ歴史:2017-10-18 15:23:28
日本語翻訳:WATANABE Makoto、原文著作者:DkLwikki

ホームページのトップに戻る

表示-非営利-継承