systems.pas 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. {
  2. $Id$
  3. Copyright (C) 1995,97 by Florian Klaempfl
  4. This unit contains informations about the target systems supported
  5. (these are not processor specific)
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit systems;
  20. interface
  21. type
  22. ttarget = (target_GO32V1,target_GO32V2,target_LINUX,target_OS2,
  23. target_WIN32,target_Amiga,target_Atari,target_Mac68k);
  24. tos = (os_GO32V1, os_GO32V2, os_Linux, os_OS2,
  25. os_WIN32, os_Amiga, os_Atari, os_Mac68k);
  26. tasm = (as_o
  27. {$ifdef i386}
  28. ,as_nasmcoff, as_nasmelf, as_nasmobj, as_tasm, as_masm
  29. {$endif}
  30. {$ifdef m68k}
  31. ,as_gas,as_mit,as_mot
  32. {$endif}
  33. );
  34. tlink = (link_ld
  35. {$ifdef i386}
  36. ,link_ldgo32v1, link_ldgo32v2, link_ldw, link_ldos2
  37. {$endif i386}
  38. {$ifdef m68k}
  39. {$endif}
  40. );
  41. tendian = (endian_little,en_big_endian);
  42. tosinfo = record
  43. name : string[30];
  44. sharedlibext,
  45. staticlibext,
  46. sourceext,
  47. pasext,
  48. exeext,
  49. scriptext : string[4];
  50. Cprefix : string[2];
  51. newline : string[2];
  52. endian : tendian;
  53. use_function_relative_addresses : boolean;
  54. end;
  55. tasminfo = record
  56. id : tasm;
  57. idtxt : string[8];
  58. asmbin : string[8];
  59. asmcmd : string[50];
  60. externals : boolean;
  61. labelprefix : string[2];
  62. comment : string[2];
  63. end;
  64. tlinkinfo = record
  65. linkbin : string[8];
  66. linkcmd : string[50];
  67. stripopt : string[2];
  68. libpathprefix : string[12];
  69. libpathsuffix : string[2];
  70. groupstart : string[8];
  71. groupend : string[2];
  72. inputstart : string[8];
  73. inputend : string[2];
  74. libprefix : string[2];
  75. end;
  76. ttargetinfo = record
  77. target : ttarget;
  78. short_name : string[8];
  79. unit_env : string[12];
  80. system_unit : string[8];
  81. smartext,
  82. unitext,
  83. unitlibext,
  84. asmext,
  85. objext : string[4];
  86. os : tos;
  87. link : tlink;
  88. assem : tasm;
  89. end;
  90. var
  91. target_info : ttargetinfo;
  92. target_os : tosinfo;
  93. target_asm : tasminfo;
  94. target_link : tlinkinfo;
  95. source_os : tosinfo;
  96. function set_string_target(const s : string) : boolean;
  97. function set_string_asm(const s : string) : boolean;
  98. implementation
  99. const
  100. {****************************************************************************
  101. OS Info
  102. ****************************************************************************}
  103. os_infos : array[tos] of tosinfo = (
  104. (
  105. name : 'GO32 V1 DOS extender';
  106. sharedlibext : '.DLL';
  107. staticlibext : '.A';
  108. sourceext : '.PP';
  109. pasext : '.PAS';
  110. exeext : '.EXE';
  111. scriptext : '.BAT';
  112. Cprefix : '_';
  113. newline : #13#10;
  114. endian : endian_little;
  115. use_function_relative_addresses : true
  116. ),
  117. (
  118. name : 'GO32 V2 DOS extender';
  119. sharedlibext : '.DLL';
  120. staticlibext : '.A';
  121. sourceext : '.PP';
  122. pasext : '.PAS';
  123. exeext : '.EXE';
  124. scriptext : '.BAT';
  125. Cprefix : '_';
  126. newline : #13#10;
  127. endian : endian_little;
  128. use_function_relative_addresses : true
  129. ),
  130. (
  131. name : 'Linux';
  132. sharedlibext : '.so';
  133. staticlibext : '.a';
  134. sourceext : '.pp';
  135. pasext : '.pas';
  136. exeext : '';
  137. scriptext : '.sh';
  138. Cprefix : '';
  139. newline : #10;
  140. endian : endian_little;
  141. use_function_relative_addresses : true
  142. ),
  143. (
  144. name : 'OS/2 (32bit)';
  145. sharedlibext : '.ao2';
  146. staticlibext : '.a';
  147. sourceext : '.pp';
  148. pasext : '.pas';
  149. exeext : '.exe';
  150. scriptext : '.cmd';
  151. Cprefix : '_';
  152. newline : #13#10;
  153. endian : endian_little;
  154. use_function_relative_addresses : false
  155. ),
  156. (
  157. name : 'Win32';
  158. sharedlibext : '.dll';
  159. staticlibext : '.a';
  160. sourceext : '.pp';
  161. pasext : '.pas';
  162. exeext : '.exe';
  163. scriptext : '.bat';
  164. Cprefix : '_';
  165. newline : #13#10;
  166. endian : endian_little;
  167. use_function_relative_addresses : true
  168. ),
  169. (
  170. name : 'Commodore Amiga';
  171. sharedlibext : '.library';
  172. staticlibext : '.a';
  173. sourceext : '.pp';
  174. pasext : '.pas';
  175. exeext : '';
  176. scriptext : '';
  177. Cprefix : '';
  178. newline : #10;
  179. endian : en_big_endian;
  180. use_function_relative_addresses : false
  181. ),
  182. (
  183. name : 'Atari ST/STE';
  184. sharedlibext : '.dll';
  185. staticlibext : '.a';
  186. sourceext : '.pp';
  187. pasext : '.pas';
  188. exeext : '.tpp';
  189. scriptext : '';
  190. Cprefix : '';
  191. newline : #10;
  192. endian : en_big_endian;
  193. use_function_relative_addresses : false
  194. ),
  195. (
  196. name : 'Macintosh m68k';
  197. sharedlibext : '.dll';
  198. staticlibext : '.a';
  199. sourceext : '.pp';
  200. pasext : '.pas';
  201. exeext : '.tpp';
  202. scriptext : '';
  203. Cprefix : '';
  204. newline : #10;
  205. endian : en_big_endian;
  206. use_function_relative_addresses : false
  207. )
  208. );
  209. {****************************************************************************
  210. Assembler Info
  211. ****************************************************************************}
  212. as_infos : array[tasm] of tasminfo = (
  213. (
  214. id : as_o;
  215. idtxt : 'O';
  216. asmbin : 'as';
  217. asmcmd : '-D -o $OBJ $ASM';
  218. externals : false;
  219. labelprefix : '.L';
  220. comment : '# '
  221. )
  222. {$ifdef i386}
  223. ,(
  224. id : as_nasmcoff;
  225. idtxt : 'NASMCOFF';
  226. asmbin : 'nasm';
  227. asmcmd : '-f coff -o $OBJ $ASM';
  228. externals : true;
  229. labelprefix : 'L';
  230. comment : '; '
  231. )
  232. ,(
  233. id : as_nasmelf;
  234. idtxt : 'NASMELF';
  235. asmbin : 'nasm';
  236. asmcmd : '-f elf -o $OBJ $ASM';
  237. externals : true;
  238. labelprefix : 'L';
  239. comment : '; '
  240. )
  241. ,(
  242. id : as_nasmobj;
  243. idtxt : 'NASMOBJ';
  244. asmbin : 'nasm';
  245. asmcmd : '-f obj -o $OBJ $ASM';
  246. externals : true;
  247. labelprefix : 'L';
  248. comment : '; '
  249. )
  250. ,(
  251. id : as_tasm;
  252. idtxt : 'TASM';
  253. asmbin : 'tasm';
  254. asmcmd : '/m2 $ASM $OBJ';
  255. externals : true;
  256. labelprefix : '.L';
  257. comment : '; '
  258. )
  259. ,(
  260. id : as_tasm;
  261. idtxt : 'MASM';
  262. asmbin : 'masm';
  263. asmcmd : '$ASM $OBJ';
  264. externals : true;
  265. labelprefix : '.L';
  266. comment : '; '
  267. )
  268. {$endif}
  269. {$ifdef m68k}
  270. ,(
  271. id : as_gas;
  272. idtxt : 'GAS';
  273. asmbin : 'as68k'; { Gas for the Amiga}
  274. asmcmd : '-D --register-prefix-optional -o $OBJ $ASM';
  275. externals : false;
  276. labelprefix : '__L';
  277. comment : '| '
  278. )
  279. ,(
  280. id : as_mit;
  281. idtxt : 'MIT';
  282. asmbin : '';
  283. asmcmd : '-o $OBJ $ASM';
  284. externals : false;
  285. labelprefix : '__L';
  286. comment : '| '
  287. )
  288. ,(
  289. id : as_mot;
  290. idtxt : 'MOT';
  291. asmbin : '';
  292. asmcmd : '-o $OBJ $ASM';
  293. externals : false;
  294. labelprefix : '__L';
  295. comment : '| '
  296. )
  297. {$endif}
  298. );
  299. {****************************************************************************
  300. Linker Info
  301. ****************************************************************************}
  302. link_infos : array[tlink] of tlinkinfo = (
  303. (
  304. linkbin : 'ld';
  305. linkcmd : '$OPT -o $EXE $RES';
  306. stripopt : '-s';
  307. libpathprefix : 'SEARCH_DIR(';
  308. libpathsuffix : ')';
  309. groupstart : 'GROUP(';
  310. groupend : ')';
  311. inputstart : 'INPUT(';
  312. inputend : ')';
  313. libprefix : '-l'
  314. )
  315. {$ifdef i386}
  316. ,(
  317. linkbin : 'ld';
  318. linkcmd : '-oformat coff-go32 $OPT -o $EXE @$RES';
  319. stripopt : '-s';
  320. libpathprefix : '-L';
  321. libpathsuffix : '';
  322. groupstart : '-(';
  323. groupend : '-)';
  324. inputstart : '';
  325. inputend : '';
  326. libprefix : '-l'
  327. )
  328. ,(
  329. linkbin : 'ld';
  330. linkcmd : '-oformat coff-go32-exe $OPT -o $EXE @$RES';
  331. stripopt : '-s';
  332. libpathprefix : '-L';
  333. libpathsuffix : '';
  334. groupstart : '-(';
  335. groupend : '-)';
  336. inputstart : '';
  337. inputend : '';
  338. libprefix : '-l'
  339. )
  340. ,(
  341. linkbin : 'ldw';
  342. linkcmd : '$OPT -o $EXE $RES';
  343. stripopt : '-s';
  344. libpathprefix : 'SEARCH_DIR(';
  345. libpathsuffix : ')';
  346. groupstart : 'GROUP(';
  347. groupend : ')';
  348. inputstart : 'INPUT(';
  349. inputend : ')';
  350. libprefix : '-l'
  351. )
  352. ,(
  353. linkbin : 'ld';
  354. linkcmd : '-o $EXE @$RES';
  355. stripopt : '-s';
  356. libpathprefix : '-L';
  357. libpathsuffix : '';
  358. groupstart : '-(';
  359. groupend : '-)';
  360. inputstart : '';
  361. inputend : '';
  362. libprefix : ''
  363. )
  364. {$endif i386}
  365. );
  366. {****************************************************************************
  367. Targets Info
  368. ****************************************************************************}
  369. target_infos : array[ttarget] of ttargetinfo = (
  370. (
  371. target : target_GO32V1;
  372. short_name : 'GO32V1';
  373. unit_env : 'GO32V1UNITS';
  374. system_unit : 'SYSTEM';
  375. smartext : '.SL';
  376. unitext : '.PP1';
  377. unitlibext : '.PPL';
  378. asmext : '.S1';
  379. objext : '.O1';
  380. os : os_GO32V1;
  381. link : link_ldgo32v1;
  382. assem : as_o
  383. ),
  384. (
  385. target : target_GO32V2;
  386. short_name : 'GO32V2';
  387. unit_env : 'GO32V2UNITS';
  388. system_unit : 'SYSTEM';
  389. {$ifndef UseAnsiString}
  390. smartext : '.SL';
  391. unitext : '.PPU';
  392. unitlibext : '.PPL';
  393. asmext : '.S';
  394. objext : '.O';
  395. {$else UseAnsiString}
  396. smartext : '.SL';
  397. unitext : '.PAU';
  398. unitlibext : '.PPL';
  399. asmext : '.SA';
  400. objext : '.OA';
  401. {$endif UseAnsiString}
  402. os : os_GO32V2;
  403. link : link_ldgo32v2;
  404. assem : as_o
  405. ),
  406. (
  407. target : target_LINUX;
  408. short_name : 'LINUX';
  409. unit_env : 'LINUXUNITS';
  410. system_unit : 'syslinux';
  411. smartext : '.sl';
  412. unitext : '.ppu';
  413. unitlibext : '.ppl';
  414. asmext : '.s';
  415. objext : '.o';
  416. os : os_Linux;
  417. link : link_ld;
  418. assem : as_o
  419. ),
  420. (
  421. target : target_OS2;
  422. short_name : 'OS2';
  423. unit_env : 'OS2UNITS';
  424. system_unit : 'SYSOS2';
  425. smartext : '.sl';
  426. unitext : '.ppo';
  427. unitlibext : '.ppl';
  428. asmext : '.so2';
  429. objext : '.oo2';
  430. os : os_OS2;
  431. link : link_ldos2;
  432. assem : as_o
  433. ),
  434. (
  435. target : target_WIN32;
  436. short_name : 'WIN32';
  437. unit_env : 'WIN32UNITS';
  438. system_unit : 'SYSWIN32';
  439. smartext : '.sl';
  440. unitext : '.ppw';
  441. unitlibext : '.ppl';
  442. asmext : '.s';
  443. objext : '.o';
  444. os : os_Win32;
  445. link : link_ldw;
  446. assem : as_o
  447. ),
  448. (
  449. target : target_Amiga;
  450. short_name : 'AMIGA';
  451. unit_env : '';
  452. system_unit : 'sysamiga';
  453. smartext : '.sl';
  454. unitext : '.ppa';
  455. unitlibext : '.ppl';
  456. asmext : '.asm';
  457. objext : '.o';
  458. os : os_Amiga;
  459. link : link_ld;
  460. assem : as_o
  461. ),
  462. (
  463. target : target_Atari;
  464. short_name : 'ATARI';
  465. unit_env : '';
  466. system_unit : 'SYSATARI';
  467. smartext : '.sl';
  468. unitext : '.ppt';
  469. unitlibext : '.ppl';
  470. asmext : '.s';
  471. objext : '.o';
  472. os : os_Atari;
  473. link : link_ld;
  474. assem : as_o
  475. ),
  476. (
  477. target : target_Mac68k;
  478. short_name : 'MACOS';
  479. unit_env : '';
  480. system_unit : 'sysmac';
  481. smartext : '.sl';
  482. unitext : '.ppt';
  483. unitlibext : '.ppl';
  484. asmext : '.s';
  485. objext : '.o';
  486. os : os_Mac68k;
  487. link : link_ld;
  488. assem : as_o
  489. )
  490. );
  491. {****************************************************************************
  492. Helpers
  493. ****************************************************************************}
  494. procedure set_target(t : ttarget);
  495. begin
  496. target_info:=target_infos[t];
  497. target_os:=os_infos[target_info.os];
  498. target_asm:=as_infos[target_info.assem];
  499. target_link:=link_infos[target_info.link];
  500. end;
  501. {****************************************************************************
  502. Load from string
  503. ****************************************************************************}
  504. function set_string_target(const s : string) : boolean;
  505. var
  506. t : ttarget;
  507. begin
  508. set_string_target:=false;
  509. for t:=target_GO32V1 to target_mac68k do
  510. if target_infos[t].short_name=s then
  511. begin
  512. set_string_target:=true;
  513. set_target(t);
  514. end;
  515. end;
  516. function set_string_asm(const s : string) : boolean;
  517. var
  518. j : longint;
  519. begin
  520. set_string_asm:=false;
  521. for j:=0 to (sizeof(as_infos) div sizeof(tasminfo))-1 do
  522. if as_infos[tasm(j)].idtxt=s then
  523. begin
  524. target_asm:=as_infos[tasm(j)];
  525. set_string_asm:=true;
  526. end;
  527. end;
  528. {****************************************************************************
  529. Initialization of default target
  530. ****************************************************************************}
  531. procedure default_os(t:ttarget);
  532. begin
  533. set_target(t);
  534. source_os:=os_infos[target_info.os];
  535. end;
  536. begin
  537. {$ifdef tp}
  538. default_os(target_GO32V2);
  539. {$else}
  540. {$ifdef DOS}
  541. default_os(target_GO32V1);
  542. {$endif}
  543. {$ifdef GO32V1}
  544. default_os(target_GO32V1);
  545. {$endif}
  546. {$ifdef GO32V2}
  547. default_os(target_GO32V2);
  548. {$endif}
  549. {$ifdef OS2}
  550. default_os(target_OS2);
  551. {$endif}
  552. {$ifdef LINUX}
  553. default_os(target_LINUX);
  554. {$endif}
  555. {$ifdef WIN32}
  556. default_os(target_WIN32);
  557. {$endif}
  558. {$ifdef AMIGA}
  559. default_os(target_AMIGA);
  560. {$endif}
  561. {$ifdef ATARI}
  562. default_os(target_ATARI);
  563. {$endif}
  564. {$ifdef MACOS}
  565. default_os(target_MAC68k);
  566. {$endif}
  567. {$endif}
  568. end.
  569. {
  570. $Log$
  571. Revision 1.12 1998-05-23 01:21:32 peter
  572. + aktasmmode, aktoptprocessor, aktoutputformat
  573. + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
  574. + $LIBNAME to set the library name where the unit will be put in
  575. * splitted cgi386 a bit (codeseg to large for bp7)
  576. * nasm, tasm works again. nasm moved to ag386nsm.pas
  577. Revision 1.11 1998/05/22 12:32:49 peter
  578. * fixed -L on the commandline, Dos commandline is only 128 bytes
  579. Revision 1.10 1998/05/11 13:07:58 peter
  580. + $ifdef NEWPPU for the new ppuformat
  581. + $define GDB not longer required
  582. * removed all warnings and stripped some log comments
  583. * no findfirst/findnext anymore to remove smartlink *.o files
  584. Revision 1.9 1998/05/06 08:38:49 pierre
  585. * better position info with UseTokenInfo
  586. UseTokenInfo greatly simplified
  587. + added check for changed tree after first time firstpass
  588. (if we could remove all the cases were it happen
  589. we could skip all firstpass if firstpasscount > 1)
  590. Only with ExtDebug
  591. Revision 1.8 1998/05/04 20:19:54 peter
  592. * small fix for go32v2
  593. Revision 1.7 1998/05/04 17:54:29 peter
  594. + smartlinking works (only case jumptable left todo)
  595. * redesign of systems.pas to support assemblers and linkers
  596. + Unitname is now also in the PPU-file, increased version to 14
  597. Revision 1.6 1998/05/01 07:43:57 florian
  598. + basics for rtti implemented
  599. + switch $m (generate rtti for published sections)
  600. Revision 1.5 1998/04/29 10:34:06 pierre
  601. + added some code for ansistring (not complete nor working yet)
  602. * corrected operator overloading
  603. * corrected nasm output
  604. + started inline procedures
  605. + added starstarn : use ** for exponentiation (^ gave problems)
  606. + started UseTokenInfo cond to get accurate positions
  607. Revision 1.4 1998/04/27 15:45:20 peter
  608. + -Xl for smartlink
  609. + target_info.arext = .a
  610. Revision 1.3 1998/04/16 10:50:45 daniel
  611. * Fixed some things that were broken for OS/2.
  612. }