From: walker@twix.unx.sas.com (Doug Walker)
Subject: Re: "Converting" to SAS/C 6.0
Originator: walker@twix.unx.sas.com
Date: Tue, 6 Oct 1992 20:38:51 GMT
Organization: SAS Institute Inc.


In article <8493@orbit.cts.com>, chucks@pnet51.orb.mn.org (Erik Funkenbusch) writes:
|> I keep hearing people mention that they have to "convert" their code to be
|> compatible with SAS/C 6.0.  What are the reasons for these conversions?  Is it
|> merely ANSI compliance?  or have keywords changed?  or is the functionality
|> different?  How much work is involved for various things?

The syntax of the compiler front-end has changed.  It now uses 
AmigaDOS 2.0-style keywords instead of options starting with "-".
We do provide two utilities to help: sc5, which takes the same
command-line options as the version 5 lc command, and lctosc,
which reads version 5 options and spits out version 6 options.
In addition to the compiler, the names of the linker and editor
have changed.

We have added one new keyword, __stackext, and extended a couple
of other keywords to have new meanings in situations which they
did not have meaning before.

We have gotten tighter about warning messages, and we now catch
many cases of incorrect code that got by the 5.10 compiler.  
Sometimes this means you have to change your code to get a 
clean compile; usually the new messages are only warnings, so you
don't technically have to change if you are willing to suppress
the warnings.

This looks like an opportune time to post the following:  it is a
shell script that attempts to convert version 5 lmkfiles to version 6
smakefiles.  (Call it "LMKTOSMAKE").  It was originally developed by
Steve Evans in our testing group, and expanded upon by myself.

LMKTOSMAKE takes up to two parameters.  The first parameter, if specified, is
the name of the input file to convert.  The default is "lmkfile".  The second
parameter is the name of the output file.  The default is "smakefile".

LMKTOSMAKE uses the "grep", "splat" and "lctosc" utilities provided with
SAS/C version 6 to try to convert a working version 5 makefile or lmkfile 
to a version 6 smakefile.

LMKTOSMAKE works by substituting certain strings for other
strings.  The substitutions listed below are made.  All source
strings can be specified in either upper case, lower case, or
mixed case.

FROM        TO
----        ---
lc:         sc:c/
lc          sc5
blink       slink
lmk         smake
small.lib   amiga.lib
lc.lib      sc.lib
lcr.lib     sc.lib
lcm.lib     scm.lib
lcmr.lib    scm.lib
lcmieee.lib scmieee.lib
lcmffp.lib  scmffp.lib
lcms.lib    scms.lib
lcmsr.lib   scms.lib
lcnb.lib    scnb.lib
lcs.lib     scs.lib
lcsr.lib    scs.lib
lcsnb.lib   scsnb.lib
__main      ___main
@_main      ___main
__tinymain  ___tinymain
@_tinymain  ___tinymain

(The last four are sometimes used in BLINK options to tell the linker to use
 a smaller version of the startup code in __main().  The name of the function
 being redefined was changed in 6.0 to add an extra underscore.)

After performing its substitutions, LMKTOSMAKE looks for a SASCOPTS file and,
if present, converts it to a SCOPTIONS file suitable for use with version 6.

LMKTOSMAKE is not foolproof, and your new smakefile may need additional 
attention.  One common technique used in Version 5 was to invoke each phase
of the compiler as a seperate command - i.e. the "lc1", "lc2" and "go" 
commands were used instead of the "lc" front-end.  LMKTOSMAKE cannot convert
these commands to version 6, since version 6 does not allow you to invoke
each compiler phase seperately.  LMKTOSMAKE will search your source makefile
for the use of these commands, and it will display any such lines to the
Shell you invoked it from.

===============CUT HERE
.key source,target
.bra {
.ket }
.def source lmkfile
.def target smakefile

failat 20

; LMKTOSMAKE Version 1.0
; By Steve Evans and Doug Walker
;
; Attempts to convert makefiles intended for Lattice C and 
; SAS/C Version 5 to the format required by SAS/C Version 6
;
; USAGE: LMKTOSMAKE <source> <target>
;
; If not specified, "lmkfile" is used for the source and "smakefile"
; for the target.

if not exists {source}
   echo "USAGE: lmktosmake <source> <target>"
   quit 20
endif

echo "LMKTOSMAKE Makefile Converter Version 1.0"

if {source} eq {target}
   echo " "
   echo "source and target are the same file!"
   quit 20
endif

if exists {target}
   echo " "
   ask "{target} about to be overwritten, proceed? (Y/N):"
   if not warn 
      quit 20
   endif
endif      

echo " "
echo "Converting *"{source}*" to *"{target}*"."

echo >{target}  "# Makefile converted using LMKTOSMAKE version 1.0"
echo >>{target} " "
echo >>{target} "CC = sc5"  ;needed because some makefiles omit this
echo >>{target} " "
type >>{target} {source}

; First off, let's get any constructs that we know we can't recognize
; Invoking the seperate phases of the compiler individually is a problem
; because the individual phases are now libraries and not invokable as
; seperate programs.

echo " "
echo "LMKTOSMAKE cannot translate any V5 file that invokes the phases of"
echo "the compiler seperately (lc1, lc1b, lc2, and go).  I am now checking"
echo "for such invocations.  If you see any such lines in the following"
echo "output, you must fix them by hand."
echo " "
grep -$ "lc1 "   {target}
grep -$ "lc1b "  {target}
grep -$ "lc2 "   {target}
grep -$ "go "    {target}
echo " "
echo "Done checking."

; Substitute for the LC: path assign.  LC: pointed to the subdirectory of the
; V5 tree that contained the commands; the equivalent directory in V6 is not
; SC:, but rather SC:C/ .
;
; The funny [] syntax allows mixed-case to be matched.
;
echo " "
echo "Substituting for lc: and command names..."

splat -o "[Ll][Cc]:"   "sc:c/"       {target}

; Substitute for the actual compiler and linker commands.  We use the SC5 command 
; since it is command-line compatible with Version 5, and translating options would
; be very, very difficult.  Slink is command-line compatible with Blink.

; "LC " => "sc5 "
splat -o "[Ll][Cc][ \t]"              "sc5 "    {target}

; "LC\n" => "sc5\n"
splat -o "[Ll][Cc][\n]"               "sc5\n"   {target}

; "BLINK " => "slink "
splat -o "[Bb][Ll][Ii][Nn][Kk][ \t]"  "slink "  {target}

; "BLINK\n" => "slink\n"
splat -o "[Bb][Ll][Ii][Nn][Kk][\n]"   "slink\n" {target}

; "LMK " => "smake "
splat -o "[Ll][Mm][Kk][ \t]"          "smake "  {target}

; "LMK\n" => "smake\n"
splat -o "[Ll][Mm][Kk][\n]"           "smake\n" {target}

;
; Substitute for the link libraries.  Note that in V6, the registerized
; and nonregisterized libraries have been combined into one.  This means,
; for example, that "lc.lib" and "lcr.lib" should both get translated
; to "sc.lib".
;
; Note that the double asterisk is necessary to get a single asterisk into
; the strings; AmigaDOS treats the first one as an escape character.
;
echo " "
echo "Substituting for link libraries and DEFINEs..."
splat -o "[Ss][Mm][Aa][Ll][Ll]\.[Ll][Ii][Bb]"    "amiga.lib"   {target}
splat -o "[Ll][Cc][Rr]**\.[Ll][Ii][Bb]"          "sc.lib"      {target}
splat -o "[Ll][Cc][Mm][Rr]**\.[Ll][Ii][Bb]"      "scm.lib"     {target}
splat -o "[Ll][Cc][Mm][Ii][Ee][Ee][Ee]\.[Ll][Ii][Bb]" "scmieee.lib" {target}
splat -o "[Ll][Cc][Mm][Ff][Ff][Pp]\.[Ll][Ii][Bb]"  "scmffp.lib"  {target}
splat -o "[Ll][Cc][Mm][Ss][Rr]**\.[Ll][Ii][Bb]"  "scms.lib"    {target}
splat -o "[Ll][Cc][Mm][Rr]**881\.[Ll][Ii][Bb]"   "scm881.lib"  {target}
splat -o "[Ll][Cc][Nn][Bb]\.[Ll][Ii][Bb]"        "scnb.lib"    {target}
splat -o "[Ll][Cc][Ss][Rr]**\.[Ll][Ii][Bb]"      "scs.lib"     {target}
splat -o "[Ll][Cc][Ss][Nn][Bb]\.[Ll][Ii][Bb]"    "scsnb.lib"   {target}

; Version 5.x users often added a DEFINE statement to the link
; line to get rid of part of the normal startup.  This statement
; took the form 
;
;    DEFINE __main=__tinymain
;
; or a variant.  The correct change in 6.0 is
;
;    DEFINE ___main=___tinymain
;
splat -o "[_@]_main"      "___main"     {target}
splat -o "[_@]_tinymain"  "___tinymain" {target}

if exists SASCOPTS then
   if not exists SCOPTIONS then
      echo " "
      echo "Converting SASCOPTS file"
      lctosc >SCOPTIONS
      copy sc:starter_project/SCOPTIONS.info SCOPTIONS.info
   endif
endif

echo " "
echo "LMKTOSMAKE finished.  Output filename is *"{target}*"."

quit 0
=============END OF SCRIPT FILE

-- 
  *****
=*|_o_o|\\=====Doug Walker, Software Distiller====== BBS: (919)460-7430 =
 *|. o.| ||                                          1200/2400/9600 Dual
  | o  |//     For all you do, this bug's for you!
  ====== 
usenet: walker@unx.sas.com                            bix: djwalker 
Any opinions expressed are mine, not those of SAS Institute, Inc.

Newsgroups: comp.sys.amiga.programmer