home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / EDGE1_704.DMS / in.adf / ExtraStuff / Edge_SasC.lha / rexx / hn_compile.edge < prev    next >
Encoding:
Text File  |  1993-10-23  |  2.3 KB  |  92 lines

  1. /* Edge macro: hn_compile
  2. **
  3. ** $VER: hn_compile.edge 1.11 (Saturday 23-Oct-93 13:19:10)
  4. **
  5. ** Usage:    hn_compile [COMPILE|LINK|LINKONLY]
  6. **            COMPILE  Compile file
  7. **            LINK     Compile & link file
  8. **            LINKONLY Only link file
  9. **
  10. ** Synopsis: Compile, and optionally link current file
  11. **
  12. ** Special case linkoptions:
  13. **           <empty> -> Automatically adjust according to compiler & flags
  14. **           AUTO -> Use compilers builtin linking instead
  15. **           See the hn_compile_<type>.edge for detailed info
  16. **         See hn_link.edge for format specifiers
  17. **    
  18. ** Author:   Henrik Nordström
  19. **           Ängsvägen 1
  20. **           S 756 45 Uppsala
  21. */
  22.  
  23. parse upper arg mode .
  24.  
  25. options results
  26.  
  27. parse source . . . rexxfile .
  28. st=lastpos('/',rexxfile)
  29. if st=0 then st=lastpos(':',rexxfile)
  30. rexxdir=left(rexxfile,st)
  31.  
  32. /*FS:Init*/
  33. 'getenvvar _fe_user8 RAW'
  34. parse var result compilerflags ',' linkoptions ',' outdir ',' arguments
  35.  
  36. 'getenvvar _fe_name'
  37. fullname = result
  38. parse var fullname filename '.' ext
  39. ext=upper(ext)
  40.  
  41. 'getenvvar _fe_path'
  42. call pragma(d,result)
  43. call pragma(d,outdir)
  44.  
  45. 'clearerr'
  46. compilefail=0
  47. /*FE:Init*/
  48.  
  49. /*FS:Translate 'Equal' modes */
  50. select
  51.  when ext='S' then type='ASM'
  52.  when ext='A' then type='ASM'
  53.  otherwise type=ext
  54. end
  55. /*FE:Translate...*/
  56.  
  57. /*FS:Call compiler script */
  58. if exists(rexxdir'hn_compile_'type'.edge') then do
  59.    interpret call ''''rexxdir'hn_compile_'type'.edge''('''mode''','''filename''','''ext''','''compilerflags''','''linkoptions''','''outdir''')'
  60.    linkoptions=RESULT
  61.    compilefail=RESULT
  62. end
  63. else do
  64.    'adderr 1 0 "Can''t compile file: No compiler found for filetype **.'type'"'
  65.    'requestnotify "Can''t compile file:*nNo compiler script found for filetype **.'type'"'
  66.    compilefail=RC+5
  67. end
  68. /*FE:Call...*/
  69.  
  70. /*FS:Check for errors */
  71. if mode ~= 'LINKONLY' & (datatype(compilefail,'W') | ~exists(filename'.o')) then do /* Something went wrong... */
  72.     say "Compilation failed!"
  73.     'adderr 1 0 "Compilation failed"'
  74.     if exists(filename'.o') then
  75.        address command delete filename'.o'
  76.     exit compilefail
  77. end
  78. /*FE:Check...*/
  79.  
  80. /*FS:Link file if requested, and AUTO linking not used */
  81. if (mode='LINK' | mode='LINKONLY') & linkoptions~="AUTO" then do
  82.    call hn_link(fullname,outdir,linkoptions)
  83.    if result >0 then do
  84.      'adderr 1 0 "Link FAILED!"'
  85.      exit 10
  86.    end
  87. end
  88. /*FE:Link...*/
  89.  
  90. say "File compiled."
  91. exit 0
  92.