2
0

systems.pas 20 KB

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