Porting Free Pascal Example: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | This 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]]. | |
| 2 | 2 | ||
| 3 | 3 | **this example is a work in progress** | |
| 4 | 4 | ||
| 5 | 5 | ## Prerequisites | |
| 6 | 6 | ||
| 7 | 7 | You'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. | |
| 8 | 8 | ||
| 9 | 9 | It's best to create a new directory where you'll work in. | |
| 10 | 10 | ||
| 11 | - | ||
| 12 | - | ||
| 11 | + | ```text | |
| 12 | + | mkdir $HOME/minix-port | |
| 13 | + | cd $HOME/minix-port | |
| 14 | + | ``` | |
| 13 | 15 | ||
| 14 | 16 | Then 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]]): | |
| 15 | 17 | ||
| 16 | - | ||
| 18 | + | ```text | |
| 19 | + | svn checkout http://svn.freepascal.org/svn/fpc/trunk fpc | |
| 20 | + | ``` | |
| 17 | 21 | ||
| 18 | 22 | ### Binutils | |
| 19 | 23 | ||
| 20 | 24 | The 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. | |
| 21 | 25 | ||
| 22 | 26 | Minix 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. | |
| 23 | 27 | ||
| 24 | - | ||
| 28 | + | ```text | |
| 29 | + | svn --username anonymous checkout https://gforge.cs.vu.nl/svn/minix/trunk/bigports/binutils-2.16.1 minix-binutils | |
| 30 | + | ``` | |
| 25 | 31 | ||
| 26 | 32 | We also need the source of Minix, cause we need two include files to build the binutils successfully. | |
| 27 | 33 | ||
| 28 | - | ||
| 34 | + | ```text | |
| 35 | + | svn --username anonymous checkout https://gforge.cs.vu.nl/svn/minix/trunk/src minix | |
| 36 | + | ``` | |
| 29 | 37 | ||
| 30 | 38 | Now copy the needed include files to a directory that is included by the makefiles: | |
| 31 | 39 | ||
| 32 | - | ||
| 33 | - | ||
| 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 | + | ``` | |
| 34 | 44 | ||
| 35 | 45 | You also need to change the include line in *minix-binutils/bfd/i386minix.c* from | |
| 36 | 46 | ||
| 37 | - | ||
| 47 | + | ```text | |
| 48 | + | #include <a.out.h> | |
| 49 | + | ``` | |
| 38 | 50 | ||
| 39 | 51 | to | |
| 40 | 52 | ||
| 41 | - | ||
| 53 | + | ```text | |
| 54 | + | #include <minix-a.out.h> | |
| 55 | + | ``` | |
| 42 | 56 | ||
| 43 | 57 | Now we can build the binutils: | |
| 44 | 58 | ||
| 45 | - | ||
| 46 | - | ||
| 47 | - | ||
| 48 | - | ||
| 49 | - | ||
| 59 | + | ```text | |
| 60 | + | cd minix-binutils | |
| 61 | + | ./configure --host=i686-minix --prefix=../minix-binutils-bin/ | |
| 62 | + | make | |
| 63 | + | make install | |
| 64 | + | cd .. | |
| 65 | + | ``` | |
| 50 | 66 | ||
| 51 | 67 | ## Compiler | |
| 52 | 68 | ||
| 53 | 69 | ### Modifications | |
| 54 | 70 | ||
| 55 | 71 | The following diff shows the changes that were done in already existing files in *compiler* and *utils* directories: | |
| 56 | 72 | ||
| 57 | 73 | Index: compiler/i386/cputarg.pas | |
| 58 | 74 | =================================================================== | |
| 59 | 75 | --- compiler/i386/cputarg.pas (Revision 15151) | |
| 60 | 76 | +++ compiler/i386/cputarg.pas (Arbeitskopie) | |
| 61 | 77 | @@ -80,6 +80,9 @@ | |
| 62 | 78 | {$ifndef NOTARGETNATIVENT} | |
| 63 | 79 | ,t_nativent | |
| 64 | 80 | {$endif} | |
| 65 | 81 | + {$ifndef NOTARGETMINIX} | |
| 66 | 82 | + ,t_minix | |
| 67 | 83 | + {$endif} | |
| 68 | 84 | ||
| 69 | 85 | {************************************** | |
| 70 | 86 | Assemblers | |
| 71 | 87 | Index: compiler/systems.pas | |
| 72 | 88 | =================================================================== | |
| 73 | 89 | --- compiler/systems.pas (Revision 15151) | |
| 74 | 90 | +++ compiler/systems.pas (Arbeitskopie) | |
| 75 | 91 | @@ -151,6 +151,7 @@ | |
| 76 | 92 | system_mips_linux, { 66 } | |
| 77 | 93 | system_mipsel_linux, { 67 } | |
| 78 | 94 | system_i386_nativent, { 68 } | |
| 79 | 95 | + system_i386_minix { 69 } | |
| 80 | 96 | ); | |
| 81 | 97 | ||
| 82 | 98 | type | |
| 83 | 99 | Index: compiler/compiler.pas | |
| 84 | 100 | =================================================================== | |
| 85 | 101 | --- compiler/compiler.pas (Revision 15151) | |
| 86 | 102 | +++ compiler/compiler.pas (Arbeitskopie) | |
| 87 | 103 | @@ -113,6 +113,9 @@ | |
| 88 | 104 | {$ifdef nativent} | |
| 89 | 105 | ,i_nativent | |
| 90 | 106 | {$endif nativent} | |
| 91 | 107 | +{$ifdef minix} | |
| 92 | 108 | + ,i_minix | |
| 93 | 109 | +{$endif minix} | |
| 94 | 110 | ,globtype; | |
| 95 | 111 | ||
| 96 | 112 | function Compile(const cmd:string):longint; | |
| 97 | 113 | Index: utils/fpcm/fpcmake.ini | |
| 98 | 114 | =================================================================== | |
| 99 | 115 | --- utils/fpcm/fpcmake.ini (Revision 15151) | |
| 100 | 116 | +++ utils/fpcm/fpcmake.ini (Arbeitskopie) | |
| 101 | 117 | @@ -972,6 +972,14 @@ | |
| 102 | 118 | SHORTSUFFIX=nativent | |
| 103 | 119 | endif | |
| 104 | 120 | ||
| 105 | 121 | +# Minix | |
| 106 | 122 | +ifeq ($(OS_TARGET),minix) | |
| 107 | 123 | +BATCHEXT=.sh | |
| 108 | 124 | +EXEEXT= | |
| 109 | 125 | +HASSHAREDLIB=0 | |
| 110 | 126 | +SHORTSUFFIX=minix | |
| 111 | 127 | +endif | |
| 112 | 128 | + | |
| 113 | 129 | else | |
| 114 | 130 | # long version for 1.0.x - target specific extensions | |
| 115 | 131 | ||
| 116 | 132 | Index: utils/fpcm/fpcmmain.pp | |
| 117 | 133 | =================================================================== | |
| 118 | 134 | --- utils/fpcm/fpcmmain.pp (Revision 15151) | |
| 119 | 135 | +++ utils/fpcm/fpcmmain.pp (Arbeitskopie) | |
| 120 | 136 | @@ -70,7 +70,8 @@ | |
| 121 | 137 | o_linux,o_go32v2,o_win32,o_os2,o_freebsd,o_beos,o_haiku,o_netbsd, | |
| 122 | 138 | o_amiga,o_atari, o_solaris, o_qnx, o_netware, o_openbsd,o_wdosx, | |
| 123 | 139 | o_palmos,o_macos,o_darwin,o_emx,o_watcom,o_morphos,o_netwlibc, | |
| 124 | 140 | - o_win64,o_wince,o_gba,o_nds,o_embedded,o_symbian,o_nativent | |
| 125 | 141 | + o_win64,o_wince,o_gba,o_nds,o_embedded,o_symbian,o_nativent, | |
| 126 | 142 | + o_minix | |
| 127 | 143 | ); | |
| 128 | 144 | ||
| 129 | 145 | TTargetSet=array[tcpu,tos] of boolean; | |
| 130 | 146 | @@ -92,14 +93,16 @@ | |
| 131 | 147 | 'linux','go32v2','win32','os2','freebsd','beos','haiku','netbsd', | |
| 132 | 148 | 'amiga','atari','solaris', 'qnx', 'netware','openbsd','wdosx', | |
| 133 | 149 | 'palmos','macos','darwin','emx','watcom','morphos','netwlibc', | |
| 134 | 150 | - 'win64','wince','gba','nds','embedded','symbian','nativent' | |
| 135 | 151 | + 'win64','wince','gba','nds','embedded','symbian','nativent', | |
| 136 | 152 | + 'minix' | |
| 137 | 153 | ); | |
| 138 | 154 | ||
| 139 | 155 | OSSuffix : array[TOS] of string=( | |
| 140 | 156 | '_linux','_go32v2','_win32','_os2','_freebsd','_beos','_haiku','_netbsd', | |
| 141 | 157 | '_amiga','_atari','_solaris', '_qnx', '_netware','_openbsd','_wdosx', | |
| 142 | 158 | '_palmos','_macos','_darwin','_emx','_watcom','_morphos','_netwlibc', | |
| 143 | 159 | - '_win64','_wince','_gba','_nds','_embedded','_symbian','_nativent' | |
| 144 | 160 | + '_win64','_wince','_gba','_nds','_embedded','_symbian','_nativent', | |
| 145 | 161 | + '_minix' | |
| 146 | 162 | ); | |
| 147 | 163 | ||
| 148 | 164 | { This table is kept OS,Cpu because it is easier to maintain (PFV) } | |
| 149 | 165 | @@ -133,7 +136,8 @@ | |
| 150 | 166 | { nds } ( false, false, false, false, false, true, false, false, false, false, false, false, false, false), | |
| 151 | 167 | { embedded }( true, true, true, true, true, true, true, true, true , false, false, false, false, false), | |
| 152 | 168 | { symbian } ( true, false, false, false, false, true, false, false, false, false, false, false, false, false), | |
| 153 | 169 | - { nativent }( true, false, false, false, false, false, false, false, false, false, false, false, false, false) | |
| 154 | 170 | + { nativent }( true, false, false, false, false, false, false, false, false, false, false, false, false, false), | |
| 155 | 171 | + { minix } ( true, false, false, false, false, false, false, false, false, false, false, false, false, false) | |
| 156 | 172 | ); | |
| 157 | 173 | ||
| 158 | 174 | type | |
| 159 | 175 | ||
| 160 | 176 | You also need to add the files i_minix.pas and t_minix.pas in compiler/systems directory. | |
| 161 | 177 | ||
| 162 | 178 | TODO | |
| 163 | 179 | ||
| 164 | 180 | ### Compiling | |
| 165 | 181 | ||
| 166 | 182 | ## Adding the new RTL | |
| 167 | 183 | ||
| 168 | 184 | TODO | |
| 169 | 185 | ||
| 170 | 186 | ## See also | |
| 171 | 187 | ||
| 172 | 188 | - [[Porting Free Pascal]] | |
| 173 | 189 | ||
| 174 | 190 | --- | |
| 175 | 191 | *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).* | |
| 176 | 192 | Category: Tutorials |
