home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / amiga / programm / 17475 < prev    next >
Encoding:
Text File  |  1992-12-17  |  5.9 KB  |  170 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!stanford.edu!rock!concert!sas!mozart.unx.sas.com!walker
  3. From: walker@twix.unx.sas.com (Doug Walker)
  4. Subject: Re: SAS/C 6.1 and GSTs (was Re: SAS 6.1 and IDIR problems
  5. Originator: walker@twix.unx.sas.com
  6. Sender: news@unx.sas.com (Noter of Newsworthy Events)
  7. Message-ID: <BzEq65.9yH@unx.sas.com>
  8. Date: Thu, 17 Dec 1992 14:13:16 GMT
  9. Distribution: inet
  10. References: <BynD5B.35w@srgenprp.sr.hp.com> <Bz3zDo.1Jx@unx.sas.com>     <S37732V.92Dec12145909@lk-hp-20.hut.fi> <Bz95w4.LI7@unx.sas.com> <JRAJA.92Dec15231111@vipunen.hut.fi> <1992Dec16.145012.6828@polaris.utu.fi>
  11. Nntp-Posting-Host: twix.unx.sas.com
  12. Organization: SAS Institute Inc.
  13. Lines: 155
  14.  
  15.  
  16. In article <1992Dec16.145012.6828@polaris.utu.fi>, sutela@polaris.utu.fi (Kari Sutela) writes:
  17. |> Just use a Makefile (or smkfile).  Gather all your include-directives
  18. |> in one file (or a set of files, if you prefer) --- let's call it
  19. |> whatever.h --- and #include this file in your source file(s)
  20. |> (whatever.c):
  21.  
  22. This is indeed a good technique, but I have two or three small points 
  23. that will make it even better, see below:
  24.  
  25. |> # A sample Makefile
  26. |> 
  27. |> PROJECT=whatever
  28. |> CFLAGS=GST $(PROJECT).gst
  29.  
  30. I never use a CFLAGS any more for something that I always want to be
  31. on.  I would put this option in the SCOPTIONS file.  Note that if
  32. you specify both MAKEGST and GST, the GST option is ignored!  Also,
  33. if you have complete different option SETS, you can use the 
  34. WITH <filename> option on the SC command instead of relying on
  35. the scoptions file.
  36.  
  37. |> 
  38. |> $(PROJECT): $(PROJECT).o
  39. |>     slink LIB:c.o $(PROJECT).o LIB LIB:sc.lib LIB:amiga.lib
  40.  
  41. There is really no reason to use slink now for most links.  If you
  42. change your math options, you'll need to change your link libraries
  43. in this method.  I suggest using the following instead:
  44.  
  45.    sc link $(PROJECT).o
  46.  
  47. This has the additional advantage that other linker options can be
  48. added to the scoptions file, like MAP, BATCH, VERBOSE, additional
  49. linker libraries, and so forth.  The additional options won't take
  50. effect until you specify LINK on the SC command (if you are using
  51. a makefile, you don't want to specify LINK in the SCOPTIONS file.)
  52.  
  53. |> 
  54. |> $(PROJECT).o: $(PROJECT).c $(POJECT).gst
  55.  
  56. You need to put the GST first so it will be build before the .o file
  57. in case both of them are out of date.
  58.  
  59. |> 
  60. |> $(PROJECT).gst: $(PROJECT).h
  61. |>     sc MAKEGST $(PROJECT).gst $(PROJECT).h
  62.  
  63. You need to use a .c file that #includes the .h file, not the .h file
  64. directly.  The way GSTs are set up to work, the MAKEGST option ignores
  65. anything found in the file being compiled.  Normally, the file being
  66. compiled is a .c source file, so you don't want #defines or struct
  67. definitions specific to that .c file polluting your GST and being
  68. used when compiling other files.
  69.  
  70. Also, you can specify the NOOBJNAME option when creating the GST and
  71. the compiler won't run the optimizers or code generator.  Not only does
  72. this save time and memory, it prevents the compiler from writing the
  73. extra .o file that you really don't need.
  74.  
  75. |> Kari Sutela    sutela@utu.fi
  76.  
  77. Basically, the above method is what I always use to add GSTs to a
  78. project.  Usually I use one of the .c files in my project as the
  79. file to compile to generate the GST, but I do compile it as a
  80. seperate target in the make script.
  81.  
  82. To summarize:
  83.  
  84.    *) Use the SCOPTIONS file for both compiler and linker options
  85.  
  86.    *) Use SC for linking (and assembling) instead of SLINK (or ASM).
  87.       This allows you to issue simpler commands and also allows you
  88.       to store your options in the SCOPTIONS file.
  89.  
  90.    *) Use a .c file to generate your GST.  It can either be a 
  91.       specially-created .c file like V5.10 required, or it can 
  92.       be one of the .c files in your project.
  93.  
  94.    *) Use the MAKEGST and NOOBJNAME options when creating the GST.
  95.       It's OK to put the GST option in the SCOPTIONS file since it
  96.       will be ignored when using MAKEGST.
  97.  
  98. Here's a typical setup for me.  Assume the following options in the
  99. SCOPTIONS file:
  100.  
  101. Debug=SF
  102. NoStackCheck
  103. StructEquiv
  104. Memsize=Huge
  105. ErrorRexx
  106. Map
  107. MapHunk
  108. MapXref
  109. Batch
  110. Lib lib:memwatch.lib
  111.  
  112. And the following SMAKEFILE:
  113.  
  114. OBJECTS=file1.o file2.o file3.o file4.o
  115. HEADERS=project.h project2.h project3.h
  116.  
  117. project: project.exe
  118.  
  119. # "project.exe" is the debuggable version of the program.  The same
  120. # link step will generate a map file due to the various MAP options
  121. # in the SCOPTIONS file.
  122.  
  123. project.exe: project.gst $(OBJECTS)
  124.    SC LINK $(OBJECTS) TO project.exe
  125.  
  126. # "project" is the stripped version of the program.  It will load
  127. # faster if you aren't debugging it, but the map file is still
  128. # valid for it in case you get enforcer hits.
  129.  
  130. project: project.exe
  131.    SLINK project.exe TO project NODEBUG
  132.  
  133. # Generic compile command
  134. .c.o:
  135.    sc $<
  136.  
  137. # Build the GST.  We use a normal project .c file to compile, but
  138. # the GST actually depends on the .h files in the project, not the
  139. # .c file.   The NOOBJNAME option prevents the compiler from trying
  140. # to generate code.
  141.  
  142. project.gst: $(HEADERS)
  143.    SC MAKEGST project.gst project.c NOOBJNAME
  144.  
  145. # Rules for each .o file
  146. file1.o: file1.c
  147. file2.o: file2.c
  148. file3.o: file3.c
  149. file4.o: file4.c
  150.  
  151. # Special cleanup target.  Build this to clear out the whole thing.
  152. # Note the backslash to escape the # in the commands below.  This
  153. # is needed since # is a comment character by itself.
  154. # If you build from workbench, make this into a seperate build
  155. # script; this way you can click on BUILD, then shift-double-click
  156. # on the script and clean up your project.
  157. clean:
  158.    gst unload project.gst
  159.    delete \#?.o \#?.exe \#?.gst \#?.map project force quiet
  160.  
  161. -- 
  162.   *****
  163. =*|_o_o|\\=====Doug Walker, Software Distiller====== BBS: (919)460-7430 =
  164.  *|. o.| ||                                          1200/2400/9600 Dual
  165.   | o  |//     For all you do, this bug's for you!
  166.   ====== 
  167. usenet: walker@unx.sas.com                            bix: djwalker 
  168. Any opinions expressed are mine, not those of SAS Institute, Inc.
  169.  
  170.