Sign in Join
Wiki copytemporary

Porting Free Pascal Example: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11This is an example of how to port Free Pascal to a new target. The target used here is i386-minix, which is a Unix based microkernel system. Host system is a i386-linux system. For more information about the port see [[Target Minix|here]].
22
33**this example is a work in progress**
44
55## Prerequisites
66
77You'll need the source code of Free Pascal (preferably the most recent version in svn), a SVN client, a working last release of Free Pascal (currently 2.4.0) and a working version of GCC.
88
99It's best to create a new directory where you'll work in.
1010
11-`mkdir $HOME/minix-port`\
12-`cd $HOME/minix-port`
11+```text
12+mkdir $HOME/minix-port
13+cd $HOME/minix-port
14+```
1315
1416Then either copy an existing Free Pascal working copy on your machine or load a fresh one from the repository. I'll use the second possibility here (for additional help see [[Getting Lazarus|here]]):
1517
16-`svn checkout `[`http://svn.freepascal.org/svn/fpc/trunk`](http://svn.freepascal.org/svn/fpc/trunk)` fpc`
18+```text
19+svn checkout http://svn.freepascal.org/svn/fpc/trunk fpc
20+```
1721
1822### Binutils
1923
2024The first compiler for a new target is always a cross compiler, so we need utilities that allow us to create executables for our target on our host system.
2125
2226Minix supports the GNU binutils. As the current binutils (2.20) are not "up to date" regarding the output format of Minix we will use the port provided by the Minix distribution.
2327
24-`svn --username anonymous checkout `[`https://gforge.cs.vu.nl/svn/minix/trunk/bigports/binutils-2.16.1`](https://gforge.cs.vu.nl/svn/minix/trunk/bigports/binutils-2.16.1)` minix-binutils`
28+```text
29+svn --username anonymous checkout https://gforge.cs.vu.nl/svn/minix/trunk/bigports/binutils-2.16.1 minix-binutils
30+```
2531
2632We also need the source of Minix, cause we need two include files to build the binutils successfully.
2733
28-`svn --username anonymous checkout `[`https://gforge.cs.vu.nl/svn/minix/trunk/src`](https://gforge.cs.vu.nl/svn/minix/trunk/src)` minix`
34+```text
35+svn --username anonymous checkout https://gforge.cs.vu.nl/svn/minix/trunk/src minix
36+```
2937
3038Now copy the needed include files to a directory that is included by the makefiles:
3139
32-`cp minix/include/minix/a.out.h minix-binutils/include/minix-a.out.h`\
33-`cp minix/include/ansi.h minix-binutils/include/ansi.h`
40+```text
41+cp minix/include/minix/a.out.h minix-binutils/include/minix-a.out.h
42+cp minix/include/ansi.h minix-binutils/include/ansi.h
43+```
3444
3545You also need to change the include line in *minix-binutils/bfd/i386minix.c* from
3646
37-`#include <a.out.h>`
47+```text
48+#include <a.out.h>
49+```
3850
3951to
4052
41-`#include <minix-a.out.h>`
53+```text
54+#include <minix-a.out.h>
55+```
4256
4357Now we can build the binutils:
4458
45-`cd minix-binutils`\
46-`./configure --host=i686-minix --prefix=../minix-binutils-bin/`\
47-`make`\
48-`make install`\
49-`cd ..`
59+```text
60+cd minix-binutils
61+./configure --host=i686-minix --prefix=../minix-binutils-bin/
62+make
63+make install
64+cd ..
65+```
5066
5167## Compiler
5268
5369### Modifications
5470
5571The following diff shows the changes that were done in already existing files in *compiler* and *utils* directories:
5672
5773 Index: compiler/i386/cputarg.pas
5874 ===================================================================
5975 --- compiler/i386/cputarg.pas (Revision 15151)
6076 +++ compiler/i386/cputarg.pas (Arbeitskopie)
6177 @@ -80,6 +80,9 @@
6278 {$ifndef NOTARGETNATIVENT}
6379 ,t_nativent
6480 {$endif}
6581 + {$ifndef NOTARGETMINIX}
6682 + ,t_minix
6783 + {$endif}
6884
6985 {**************************************
7086 Assemblers
7187 Index: compiler/systems.pas
7288 ===================================================================
7389 --- compiler/systems.pas (Revision 15151)
7490 +++ compiler/systems.pas (Arbeitskopie)
7591 @@ -151,6 +151,7 @@
7692 system_mips_linux, { 66 }
7793 system_mipsel_linux, { 67 }
7894 system_i386_nativent, { 68 }
7995 + system_i386_minix { 69 }
8096 );
8197
8298 type
8399 Index: compiler/compiler.pas
84100 ===================================================================
85101 --- compiler/compiler.pas (Revision 15151)
86102 +++ compiler/compiler.pas (Arbeitskopie)
87103 @@ -113,6 +113,9 @@
88104 {$ifdef nativent}
89105 ,i_nativent
90106 {$endif nativent}
91107 +{$ifdef minix}
92108 + ,i_minix
93109 +{$endif minix}
94110 ,globtype;
95111
96112 function Compile(const cmd:string):longint;
97113 Index: utils/fpcm/fpcmake.ini
98114 ===================================================================
99115 --- utils/fpcm/fpcmake.ini (Revision 15151)
100116 +++ utils/fpcm/fpcmake.ini (Arbeitskopie)
101117 @@ -972,6 +972,14 @@
102118 SHORTSUFFIX=nativent
103119 endif
104120
105121 +# Minix
106122 +ifeq ($(OS_TARGET),minix)
107123 +BATCHEXT=.sh
108124 +EXEEXT=
109125 +HASSHAREDLIB=0
110126 +SHORTSUFFIX=minix
111127 +endif
112128 +
113129 else
114130 # long version for 1.0.x - target specific extensions
115131
116132 Index: utils/fpcm/fpcmmain.pp
117133 ===================================================================
118134 --- utils/fpcm/fpcmmain.pp (Revision 15151)
119135 +++ utils/fpcm/fpcmmain.pp (Arbeitskopie)
120136 @@ -70,7 +70,8 @@
121137 o_linux,o_go32v2,o_win32,o_os2,o_freebsd,o_beos,o_haiku,o_netbsd,
122138 o_amiga,o_atari, o_solaris, o_qnx, o_netware, o_openbsd,o_wdosx,
123139 o_palmos,o_macos,o_darwin,o_emx,o_watcom,o_morphos,o_netwlibc,
124140 - o_win64,o_wince,o_gba,o_nds,o_embedded,o_symbian,o_nativent
125141 + o_win64,o_wince,o_gba,o_nds,o_embedded,o_symbian,o_nativent,
126142 + o_minix
127143 );
128144
129145 TTargetSet=array[tcpu,tos] of boolean;
130146 @@ -92,14 +93,16 @@
131147 'linux','go32v2','win32','os2','freebsd','beos','haiku','netbsd',
132148 'amiga','atari','solaris', 'qnx', 'netware','openbsd','wdosx',
133149 'palmos','macos','darwin','emx','watcom','morphos','netwlibc',
134150 - 'win64','wince','gba','nds','embedded','symbian','nativent'
135151 + 'win64','wince','gba','nds','embedded','symbian','nativent',
136152 + 'minix'
137153 );
138154
139155 OSSuffix : array[TOS] of string=(
140156 '_linux','_go32v2','_win32','_os2','_freebsd','_beos','_haiku','_netbsd',
141157 '_amiga','_atari','_solaris', '_qnx', '_netware','_openbsd','_wdosx',
142158 '_palmos','_macos','_darwin','_emx','_watcom','_morphos','_netwlibc',
143159 - '_win64','_wince','_gba','_nds','_embedded','_symbian','_nativent'
144160 + '_win64','_wince','_gba','_nds','_embedded','_symbian','_nativent',
145161 + '_minix'
146162 );
147163
148164 { This table is kept OS,Cpu because it is easier to maintain (PFV) }
149165 @@ -133,7 +136,8 @@
150166 { nds } ( false, false, false, false, false, true, false, false, false, false, false, false, false, false),
151167 { embedded }( true, true, true, true, true, true, true, true, true , false, false, false, false, false),
152168 { symbian } ( true, false, false, false, false, true, false, false, false, false, false, false, false, false),
153169 - { nativent }( true, false, false, false, false, false, false, false, false, false, false, false, false, false)
154170 + { nativent }( true, false, false, false, false, false, false, false, false, false, false, false, false, false),
155171 + { minix } ( true, false, false, false, false, false, false, false, false, false, false, false, false, false)
156172 );
157173
158174 type
159175
160176You also need to add the files i_minix.pas and t_minix.pas in compiler/systems directory.
161177
162178TODO
163179
164180### Compiling
165181
166182## Adding the new RTL
167183
168184TODO
169185
170186## See also
171187
172188- [[Porting Free Pascal]]
173189
174190---
175191*From the Free Pascal wiki, page "Porting Free Pascal Example", as it stood on 2011-02-01 after a change by Chronos, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
176192Category: Tutorials

Back to history