
**************CODE SEGMENT OPTIMIZATION********************** 

6/28/91 Yi-Hsin Sung

---------------------------------------------------
I. How to make use of the code segment optimization
---------------------------------------------------
Finally, there is an easy way to do it! All you have to do is:

1. Decide on which files go into the same segment.
2. Name the segments using macros SEG00, SEG01, ... in local rules.mk
   SEG00 = string_0
   SEG01 = string_1         (Must be defined before the include)
   :
   :
   !include ..\rules.mk

   Note: Don't append _text to the segment names in order to
         differentiate between default segment names given by the linker
	 and segments named by you.

   Note: Always start with SEG00 and continue with SEG01, SEG02,...
                 The rules (in uioptseg.mk and uidepseg.mk) for code 
                 segment optimization will only be included if SEG00 is defined.

   Note: The limit is 8 segments per directory in the current uidepseg.mk
                 and uioptseg.mk. However, it's easy to increase the number of
                 segments. The method will be described later on. 

3. List the files:
   All files listed in macros ending with _00 will end up in SEG00.
   Similarly, files listed in macros ending with _01 will end up in SEG01.
   And so on.

   CXXSRC_COMMON_00 = string.cxx strmisc.cxx .....
   CXXSRC_COMMON_01 = strchr.cxx .....
   CXXSRC_LM21_00 = ....
   CXXSRC_LM30_00 = ....
   CXXSRC_WIN_00 = ....
   CXXSRC_OS2_00 = ....
   CXXSRC_DOS_00 = ....
   and all the corresponding CSRC macros.

4. Execute "nmake depend" to generate a new depend.mk.

----------------------------------------------------------
II. If you want to use more than 8 segments per directory, 
----------------------------------------------------------
1. Get the makefile in $(UI)\common\src
2. There are two new targets in the makefile, uidepend and uiglobal.
   "nmake uidepend" will create the files uideprul.mk and uidepseg.mk 
   which will be included in uidepend.mk. "nmake uiglobal" will create
   the files uirules.mk and uioptseg.mk which will be included in 
   uiglobal.mk as needed. 
   a. Add a $(SED) at the end of target uidepend
      Add a $(SED) at the end of target uiglobal
          Look at the last few lines of both targets to write the in-line
          SED script.
   c. Change the line "echo !IFDEF SEG07" to "echo !IFDEF SEG(# segments)"
          If # segments is single digit, append a zero in front.
   d. "nmake uidepend uiglobal"

-------------------------------------------------
III. If you don't want code segment optimization, 
-------------------------------------------------
NOTHING will be affected by all the changes. As long as you
don't define SEG00, no additional rules will be included. 

-------------------------------------------------------------------
IV. If you want to change build rules originally in uiglobal.mk or 
    rules in uidepend.mk
-------------------------------------------------------------------
       master copy    automatically generated files    included by
       ___________________________________________________________ 
       uiglobal.src           uirules.mk               uiglobal.mk
                                                       uioptseg.mk
       ___________________________________________________________ 
       uidepend.src           uideprul.mk              uidepend.mk
                                                       uidepopt.mk
       ___________________________________________________________ 

 Make changes in uiglobal.src  and uidepend.src only. 


-------------------------------------------------------------------
V. If you want to define some segments as preload, or ... (something
   besides the default attributes)
-------------------------------------------------------------------
1. For libraries in $(UI)\common\lib, there is a .def file associated
   with each of them with the same name but with the extension .def.
   For example, uistrw.def is associated with uistrw.lib. 
   The ORIGINAL copy of this .def file is in the directory
   which builds the library (the makefile in that directory should 
   say $(LIBUTIL) ). In the string library case, the .def is in 
   $(UI)\common\src\string\string. This .def is copied over to 
   $(UI)\common\lib whenever the library is rebuilt. If there is no
   .def associated with the library, then a dummy .def is created in
   $(UI)\common\lib. If you want to make some segments in some library
   preload or ..., just change the ORIGINAL .def file or if none exist,
   create a new one (Make sure you create this file  in the directory
   that says $(LIBUTIL)). 

2. For the segments not in the libraries, you have to add the segment
   name and attributes to the project's .def file.  The usual stuff!
   Look at the makefile in $(UI)\shell\bin for some insight.


