home *** CD-ROM | disk | FTP | other *** search
- /* Edge macro: hn_compile
- **
- ** $VER: hn_compile.edge 1.11 (Saturday 23-Oct-93 13:19:10)
- **
- ** Usage: hn_compile [COMPILE|LINK|LINKONLY]
- ** COMPILE Compile file
- ** LINK Compile & link file
- ** LINKONLY Only link file
- **
- ** Synopsis: Compile, and optionally link current file
- **
- ** Special case linkoptions:
- ** <empty> -> Automatically adjust according to compiler & flags
- ** AUTO -> Use compilers builtin linking instead
- ** See the hn_compile_<type>.edge for detailed info
- ** See hn_link.edge for format specifiers
- **
- ** Author: Henrik Nordström
- ** Ängsvägen 1
- ** S 756 45 Uppsala
- */
-
- parse upper arg mode .
-
- options results
-
- parse source . . . rexxfile .
- st=lastpos('/',rexxfile)
- if st=0 then st=lastpos(':',rexxfile)
- rexxdir=left(rexxfile,st)
-
- /*FS:Init*/
- 'getenvvar _fe_user8 RAW'
- parse var result compilerflags ',' linkoptions ',' outdir ',' arguments
-
- 'getenvvar _fe_name'
- fullname = result
- parse var fullname filename '.' ext
- ext=upper(ext)
-
- 'getenvvar _fe_path'
- call pragma(d,result)
- call pragma(d,outdir)
-
- 'clearerr'
- compilefail=0
- /*FE:Init*/
-
- /*FS:Translate 'Equal' modes */
- select
- when ext='S' then type='ASM'
- when ext='A' then type='ASM'
- otherwise type=ext
- end
- /*FE:Translate...*/
-
- /*FS:Call compiler script */
- if exists(rexxdir'hn_compile_'type'.edge') then do
- interpret call ''''rexxdir'hn_compile_'type'.edge''('''mode''','''filename''','''ext''','''compilerflags''','''linkoptions''','''outdir''')'
- linkoptions=RESULT
- compilefail=RESULT
- end
- else do
- 'adderr 1 0 "Can''t compile file: No compiler found for filetype **.'type'"'
- 'requestnotify "Can''t compile file:*nNo compiler script found for filetype **.'type'"'
- compilefail=RC+5
- end
- /*FE:Call...*/
-
- /*FS:Check for errors */
- if mode ~= 'LINKONLY' & (datatype(compilefail,'W') | ~exists(filename'.o')) then do /* Something went wrong... */
- say "Compilation failed!"
- 'adderr 1 0 "Compilation failed"'
- if exists(filename'.o') then
- address command delete filename'.o'
- exit compilefail
- end
- /*FE:Check...*/
-
- /*FS:Link file if requested, and AUTO linking not used */
- if (mode='LINK' | mode='LINKONLY') & linkoptions~="AUTO" then do
- call hn_link(fullname,outdir,linkoptions)
- if result >0 then do
- 'adderr 1 0 "Link FAILED!"'
- exit 10
- end
- end
- /*FE:Link...*/
-
- say "File compiled."
- exit 0
-