070241473dfc406ad0a5442093ec611f9267ccd3
1 #! /bin/sh
3 set -e
5 ###^^^^^^^^^^^^^^^^^^###
6 ### Global variables ###
7 ###__________________###
11 _cpu=
12 _target=
13 _system=
14 _compiler=
15 _linker=
16 _docompile=true
17 _dolink=true
20 _useposix=false
22 ###^^^^^^^^^^^###
23 ### Functions ###
24 ###___________###
26 usage() {
46 exit 2
47 }
49 error() {
51 exit 1
52 }
54 copy_source() {
55 for _src
56 do
59 fi
60 done
61 }
63 native_compile() {
65 }
67 native_link() {
74 fi
75 shift
77 fi
78 }
80 cpfront_import_list() {
81 echo
83 do
85 shift
88 fi
89 done
90 }
92 cpfront_main_module() {
94 shift
96 echo
98 echo
100 }
102 cpfront_compile() {
104 }
106 cpfront_link() {
111 fi
112 shift
114 local _list=
116 do
118 done
119 local _cc_cflags=
121 *gcc) _cc_cflags="-Wno-int-conversion -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types -Wno-implicit-function-declaration" ;;
123 esac
124 local _cpu_cflags=
129 esac
130 local _system_cflags=
134 esac
135 "$CC" $_cc_cflags $_cpu_cflags $CFLAGS -o "${_main}" -I "$_this/C" "$_this/C/SYSTEM.c" $_list -lm -ldl $_system_cflags
136 fi
137 }
139 compile() {
144 esac
145 }
147 link() {
152 esac
153 }
155 compile_all() {
156 ###^^^^^^^^^^^^^^^^^^^^^^^^###
157 ### Compile POSIX bindings ###
158 ###________________________###
161 compile Posix/Mod/Ctypes.cp \
162 Posix/Mod/Csys_types.cp \
163 Posix/Mod/Cstdlib.cp Posix/Mod/Cstdio.cp Posix/Mod/Cunistd.cp \
164 Posix/Mod/Cdirent.cp Posix/Mod/Clocale.cp Posix/Mod/Ctime.cp \
165 Posix/Mod/Csys_stat.cp Posix/Mod/Cfcntl.cp Posix/Mod/Cerrno.cp \
166 Posix/Mod/Ciconv.cp Posix/Mod/Cwctype.cp Posix/Mod/Csys_mman.cp \
167 Posix/Mod/Cdlfcn.cp Posix/Mod/Csignal.cp Posix/Mod/Csetjmp.cp \
168 Posix/Mod/Clibgen.cp \
169 Posix/Mod/Cmacro.cp
170 fi
172 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
173 ### Compile BlackBox Framework ###
174 ###____________________________###
176 compile System/Mod/Int.odc
178 compile System/Mod/Long.odc
179 compile System/Mod/Math.odc System/Mod/SMath.odc
180 else
181 compile System/Mod/Math.cp System/Mod/SMath.cp
182 fi
183 compile System/Mod/Kernel.cp \
184 System/Mod/Console.odc System/Mod/Files.odc System/Mod/Dates.odc \
185 System/Mod/Log.odc System/Mod/Strings.odc System/Mod/Services.odc \
186 System/Mod/Integers.odc
189 mv -t System Code Sym
190 fi
192 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
193 ### Compile Linux Host subsystem ###
194 ###______________________________###
196 compile Host/Mod/Lang.cp Host/Mod/Dates.cp Host/Mod/Console.cp \
197 Host/Mod/Files.cp
199 ###^^^^^^^^^^^^^^^^^^^^^^^###
200 ### Compile Dev subsystem ###
201 ###_______________________###
203 compile Dev/Mod/CPM.cp Dev/Mod/CPT.odc Dev/Mod/CPS.odc Dev/Mod/CPB.odc \
204 Dev/Mod/CPP.odc Dev/Mod/CPE.odc Dev/Mod/CPH.odc Dev/Mod/CPL486.odc \
205 Dev/Mod/CPC486.odc Dev/Mod/CPV486.odc
207 ###^^^^^^^^^^^^^^^^^^^^^^^^###
208 ### Compile Dev2 subsystem ###
209 ###________________________###
211 compile Dev2/Mod/LnkBase.odc Dev2/Mod/LnkChmod.odc Dev2/Mod/LnkLoad.odc \
212 Dev2/Mod/LnkWriteElf.odc Dev2/Mod/LnkWriteElfStatic.odc \
213 Dev2/Mod/LnkWritePe.odc
215 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^###
216 ### Compile CPfront subsystem ###
217 ###___________________________###
219 compile CPfront/Mod/CPG.odc CPfront/Mod/CPC.odc CPfront/Mod/CPV.odc
221 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
222 ### Compile bbdsw-specific modules ###
223 ###________________________________###
226 compile Dsw/Mod/Debug.odc
227 fi
228 compile Dsw/Mod/Documents.cp Dsw/Mod/Log.odc Dsw/Mod/Compiler486Main.cp \
229 Dsw/Mod/CompilerCPfrontMain.cp Dsw/Mod/Linker486Main.cp
230 }
232 link_all() {
233 local _debug_module=
235 _debug_module=DswDebug
236 fi
238 link cpc486 \
239 PosixCtypes PosixCmacro \
240 Kernel Console Files Dates Math Strings Services Log \
242 DevCPM DevCPT DevCPS DevCPB DevCPP DevCPE DevCPH \
243 DevCPL486 DevCPC486 DevCPV486 \
244 DswDocuments DswCompiler486Main
246 link cpl486 \
247 PosixCtypes PosixCmacro \
248 Kernel Console Files Math Strings Services Log \
250 Dev2LnkBase Dev2LnkChmod Dev2LnkLoad Dev2LnkWriteElf \
251 Dev2LnkWriteElfStatic Dev2LnkWritePe \
252 DswLinker486Main
254 link cpfront \
255 PosixCtypes PosixCmacro \
256 Kernel Console Files Dates Math Strings Services Log \
258 DevCPM DevCPT DevCPS DevCPB DevCPP DevCPE DevCPH \
259 CPfrontCPG CPfrontCPC CPfrontCPV\
260 DswDocuments DswCompilerCPfrontMain
263 chmod a+x cpc486 cpl486 cpfront
264 fi
265 }
267 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
268 ### Parse arguments and options ###
269 ###_____________________________###
271 while getopts c:l:o:bxh _name
272 do
277 b) _docompile=false ;;
278 x) _dolink=false ;;
279 h|?) usage ;;
280 esac
281 done
284 usage
285 fi
293 export CC=cc
294 fi
296 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
297 ### Check for supported cpu/target/os ###
298 ###___________________________________###
301 386|486|586|686) _cpu=486 ;;
302 arm|armv6|armv7) _cpu=arm ;;
305 esac
308 native) _target=native ;;
309 cpfront|c) _target=cpfront ;;
312 esac
315 linux) _useposix=true ;;
316 cygwin) _useposix=true ;;
319 esac
321 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
322 ### Select default compiler if not specified ###
323 ###__________________________________________###
327 native)
329 486) _compiler=cpc486 ;;
331 esac
332 ;;
333 cpfront) _compiler=cpfront ;;
335 esac
336 fi
340 native)
342 486) _linker=cpl486 ;;
344 esac
345 ;;
346 cpfront) _linker= ;;
348 esac
349 fi
354 else
356 fi
357 fi
362 else
364 fi
365 fi
367 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
368 ### Copy sources for changed system ###
369 ###_________________________________###
373 fi
380 fi
385 fi
389 ###^^^^^^^^^^^^^^^###
390 ### Build modules ###
391 ###_______________###
394 compile_all
395 fi
397 ###^^^^^^^^^^^^^^###
398 ### Link modules ###
399 ###______________###
401 link_all