![]() |
![]() |
![]() |
![]() |
![]() |
Creating a New Library
This section describes how to generate a new library. The following topics are covered:
- The directory structure for source and object code.
- The sdtsct.knl file, which determines what libraries the Analyzer knows about, that is, what libraries that will be shown when Generate-Options is selected.
- The comp.opt file and the makeoptions (make.opt in Windows) file, which determines the properties of an object code library.
- The make file Makefile, which includes the makeoptions (make.opt) file and generates a new object code library with the properties given by the included makeoptions (make.opt) file.
- The relations with the generated make files for SDL systems will also be discussed.
Directory Structure
The structure of files and directories used for the Cadvanced/Cbasic SDL to C Compiler libraries is shown in Figure 561 The directory sdtdir is in the installation:
<installation directory>/sdt/sdtdir/<machine
dependent dir>where <machine dependent dir> is for example sunos5sdtdir on SunOS 5 and wini386 in Windows. (In Windows, / should be replaced by \ in the path above.)
This directory is here called sdtdir and is in UNIX normally referred to by the environment variable sdtdir.
"sctdir" is a reference to an object library and is usually setup as a parameter in the call to make. It can also be an environment variable.
In the sdtdir directory three important files are found:
- predef.sdl contains the definition of the predefined sorts in SDL.
- sdtsct.knl contains a list of the available libraries that can be used together with code generated by the Cadvanced/Cbasic SDL to C Compiler.
- help_sct.hlp contains the help information that can be obtained using the monitor command help.
The file predef.sdl is read by the SDL Analyzer during analysis, while the file sdtsct.knl is used to present the available libraries in the Make dialog in the Organizer (see Make).
In the INCLUDE directory, there are two important groups of files:
- The source code files for the runtime library:
scttypes.h, sctlocal.h, sctsdl.c, sctutil.c, sctpost.c, sctpred.h, sctpred.c, sctmon.c, sctos.c and sctenv.c- The files necessary to include communication with other SCT applications: post.h, post.o (post64.o for solaris 64-bit, post.lib in Windows), sdt.h, itex.h.
In parallel with the INCLUDE directory there are a number of directories for libraries in object form. The SCTDEBCOM directory in Figure 561 is an example of such a directory. Each of these directories will contain three files: comp.opt, makeoptions (make.opt in Windows).
The comp.opt file determines the contents of the generated makefile and how make is called. For more details see below.
The makeoptions (make.opt) file describes the properties of the library, such as the compiler used, compiler options, linker options, and so on.
To guarantee the consistency of, for example, compilation flags between the SDL system and the kernel, the makeoptions (make.opt) file is used both by the make file compiling the library (Makefile) and by the generated make files used to compile the generated SDL system. Non-consistency in this sense between the library and the SDL system will make the result unpredictable.
File sdtsct.knl
The sdtsct.knl file describes which libraries that are available. This is presented by the Organizer in the Make dialog see Make). The sdtsct.knl file has the following structure. Each available library is described on a line of its own. Such a line should first contain the name of the library (the name presented in the dialog), then the path to the directory containing the library, and last a comment up to end of line.
The path to the library can either be the complete path or a relative path. A relative path is relative to the environment variable sdtdir (on UNIX) or SDTDIR (in Windows), if that variable is defined. Otherwise it is relative to the SDL Suite installation.
Simulation SCTDEBCOMRealTimeSimulation SCTDEBCLCOMApplication SCTAPPLCLENVApplicationDebug /util/sct/SCTDEBCLENVCOMApplicationDebug x:\sdt\sdtdir\dbclecomMyTestLibrary ..\testlib\dbcomNot that the two last lines is examples for Windows, while the fourth line is for UNIX.
The Organizer will look for an sdtsct.knl file first in the directory the SDL Suite is started from, then in the home directory for the user, and then in the directory referenced by the environment variable sdtdir (SDTDIR) if it is defined, and in the directory where the SDL Suite was installed.
File Makefile
In each directory that contains a library version there is a Makefile that can "make" the library. To create a new library after an update of the source code, change directory to the directory for the library and execute the Makefile. The Makefile uses the makeoptions (make.opt) file in the directory to get the correct compilation switches and other relevant information.
Do not generate and test libraries in the installation directory structure. Create an appropriate copy.
File comp.opt
This file determines the details of the generated make files, and the command issued to execute the makefile. A comp.opt file contains zero, one or more initial lines starting with a #. These lines are treated as comments. After that it contains five lines of essential data.
- Line 1: How to include the makeoptions (make.opt) file
- Line 2: Compile script
- Line 3: Link script
- Line 4: Command to run make
- Line 5: How to build a library (archive). Used for coders/decoders.
On each of these lines % codes can be used to insert specific information.
%n : newline%t : tab%d : target directory%s : source directory%k : kernel directory%f : base name of generated executable (no path, nofile extension). NOT on line 2 or 5.On line 2, the compile script:
%c : c file in compile script%C : c file in compile script, without extension%o : resulting object file in compile script%o : list of all object files in link script%O : list of all object files in link script, with
\ followed by newline between files%e : executable file in link script%m : name of generated makefileOn line 5, the archive command:
%o : list of object files, i.e. $(sctCODER_OBJS).%a : the archive file, i.e.libstcoder$(sctLIBEXTENSION)Example 517 : comp.opt file for UNIX
# makefile for unix makeinclude $(sctdir)/makeoptions%t$(sctCC) $(sctCPPFLAGS) $(sctCCFLAGS) $(sctIFDEF) %c -o %o%t$(sctLD) $(sctLDFLAGS) %o -o %emake -f %m sctdir=%k%t$(sctAR) $(sctARFLAGS) %a %oFile makeoptions / make.opt
This file has the following structure:
# #sctLIBNAME = SimulationsctIFDEF = -DSCTDEBCOMsctEXTENSION = _smd.sctsctOEXTENSION = _smd.osctLIBEXTENSION= _smd.asctKERNEL = $(sctdir)/../INCLUDEsctCODERDIR = $(sctdir)/../coder#Compiling, linkingsctCC = ccsctCODERFLAGS = -I$(sctCODERDIR)sctCPPFLAGS = -I. -I$(sctKERNEL) $(sctCODERFLAGS)$(sctCOMPFLAGS) $(sctUSERDEFS)sctCCFLAGS = -c -XcsctLD = ccsctLDFLAGS =sctAR = arsctARFLAGS = rcuall : default# below this point there are a large number of# compilation rules for compiling the Master Library# and the Coder library (used for encoding/decoding)# The following name of any importance are defined:sctLINKKERNEL =sctLINKKERNELDEP =sctLINKCODERLIB =sctLINKCODERLIBDEP =The information to the right of the equal signs should be seen as an example. These environment variables set in the makeoptions (make.opt) file should specify:
- sctLIBNAME. This is only used by the Makefile to report what it is doing.
- sctIFDEF. This variable should specify what compilation switches, among those defined by the Cadvanced/Cbasic SDL to C Compiler system, that should be used. Usually there is one switch defining the library version.
- sctEXTENSION. This is used to determine the file extension of the executable files.
- sctOEXTENSION. This is used to determine the file extension of the object files.
- sctLIBEXTENSION. The extension of the archive/library
- sctKERNEL. Directory of Master Library source code.
- sctCODERDIR. The directory for the source code of the coders/decoders.
- sctCC. This defines the compiler to be used.
- sctCODERFLAGS. Compilation options needed to compile the coder/decoder files
- sctCPPFLAGS. This variable should give the compilation flag necessary to specify where the C preprocessor can find the include files scttypes.h, sctlocal.h, sctpred.h, sdt.h, and post.h.
- sctCCFLAGS. This should specify other compiler flags that should be used, as for example -g (Sun cc) or -v (Borland bcc32) for debug information, -O for optimization.
- sctLD. This defines the linker to be used.
- sctLDFLAGS. This should specify other flags that should be used in the link operation.
- sctAR. The archive application
- sctARFLAGS. Flags to sctAR.
- sctLINKKERNEL. This variable should specify the .o files for the Master Library source files. It will be used in the link command in the generated make file.
- sctLINKKERNELDEP. Used to implement the dependencies to recompile the kernel when it is needed.
- sctLINKCODERLIB. This variable should specify the .o files for the Coder Library source files. It will be used in the link command in the generated make file.
- sctLINKCODERLIBDEP. Used to implement the dependencies to recompile the Coder Library when it is needed.
Generated Make Files
The generated make files for an SDL system will as first action include the makeoptions (make.opt) file in the directory referenced by the environment variable sctdir. It will then use the variables sctIFDEF, sctLINKKERNEL, sctCC, sctCPPFLAGS, sctCCFLAGS, sctLD, and sctLDFLAGS to compile and link the SDL system with the selected library.
The make file is generated and executed by the Cadvanced/Cbasic SDL to C Compiler.
Below, a UNIX make file generated for the SDL system example is shown.
# makefile for System: examplesctAUTOCFGDEP =sctCOMPFLAGS = -DXUSE_GENERIC_FUNCinclude $(sctdir)/makeoptionsdefault: example$(sctEXTENSION)example$(sctEXTENSION): \example$(sctOEXTENSION) \$(sctLINKKERNELDEP)$(sctLD) $(sctLDFLAGS) \example$(sctOEXTENSION) $(sctLINKKERNEL) \-o example$(sctEXTENSION)example$(sctOEXTENSION): \example.c$(sctCC) $(sctCPPFLAGS) $(sctCCFLAGS) \$(sctIFDEF) example.c -o example$(sctOEXTENSION)
http://www.ibm.com/rational |
![]() |
![]() |
![]() |
![]() |