The Tornado tool we build and install in this example was presented in 4. The WTX Protocol as an example of using the WTX C API. It allocates memory from the target memory pool managed by the target server until no more memory is available. It then frees the allocated memory and repeats this sequence until the user issues a CTRL+C. The tool is called wtxapp. When the tool is used with the Tornado browser in auto-update mode, it displays a changing memory-in-use chart.
The tool main program is made up of two files, wtxapp.h and wtxapp.c. It makes use of the WTX C API requests wtxMemAlloc( ) and wtxMemFree( ). The code for the application is located in 4.5.6 Application Example.
Note that the wtxapp tool installs a signal handler that not only stops the program on CTRL+C but also terminates the communication session with the target server properly. All Tornado tools should implement this type of signal handling.
|
NOTE: For UNIX hosts, installDir is $WIND_BASE. For Windows users who use the command line, installDir is %WIND_BASE%.
|
||||||||||||||||||
Use a makefile that incorporates the Tornado generic makefile rules and macros found in the directory installDir/host/include/make to build Tornado applications. This type of makefile automatically generates a secondary makefile called Makefile.gen that contains the dependencies list. It installs the wtxapp executable in the bin directory for the host (for example, in installDir/host/sun4-solaris2/bin). The makefile for wtxapp appears in Example 6-1.
The Tornado include files are located in the installDir/host/include directory. This path is available in the makefile through the INCLUDES macro.
wtxapp uses routines from libwtxapi shared library. This library is included by the $UTIL_LIB macro in the makefile. wtxapp is also linked with extra libraries required by a particular tool chain on a given host. These extra libraries are defined by EXTRA_LIBS in the makefile.
For more information about the available makefile macros defined with Tornado, see installDir/host/include/make/generic.mh.
# Makefile - for simple Tornado Application # # modification history # -------------------- # 01c,28jan99,wcc add $(CFLAGS) to $(WTXAPP) rule # 01b,13jan97,bcc port to Windows # 01a,25jul95,p_m written # # DESCRIPTION # This file contains the makefile rules for building a simple # Tornado application # # SUBSTITUTION # # INCLUDES # $(WIND_BASE)/host/include/make/generic.mh # $(WIND_BASE)/host/include/make/$(HOST).mh # $(WIND_BASE)/host/include/make/generic2.mh # include $(WIND_BASE)/host/include/make/generic.mh include $(WIND_BASE)/host/include/make/$(HOST).mh INCLUDES = $(WIND_INC) WTXAPP = $(WIND_BIN)/wtxapp # documentation related variables DOC_FILES = wtxapp.c DOC_DIR = $(DOCS_ROOT)/tornado-app/wtxapp VERSION_DEFINE = $(CFLAGS) LIBRARIES = PROGRAMS = $(WTXAPP) TESTS = DOCS = doc ## Add special build targets and default here. default: prog $(WTXAPP): wtxapp.c $(SH_UTIL_LIB) $(CC) $(CFLAGS) -DHOST=$(HOST) $(INCLUDES) wtxapp.c -o $@ \ $(UTIL_LIB) $(EXTRA_LIBS) doc: $(DOC_FILES) $(WIND_BIN)/refgen $(REFGEN_OPT) -book Tornado_Applications \ -chapter WTX_Applications -out $(DOC_DIR) $(DOC_FILES) $(WIND_BIN)/htmlLink $(DOC_DIR) include $(WIND_BASE)/host/include/make/generic2.mh
The specific commands for compiling wtxapp depend on your host. For example, to compile on a Sun4 workstation running Solaris 2.5.1., issue the following commands from a UNIX shell (this example assume the c-shell; issue the appropriate commands for your shell):
% setenv WIND_BASE installdir % setenv WIND_HOST_TYPE sun4-solaris2 % set path=(installDir/host/$WIND_HOST_TYPE/bin $path) % cd installDir/host/src/wtxapp % make HOST=$WIND_HOST_TYPE
wtxapp-d.exe targetServer@host wtxapp.exe targetServer@host
The man makefile rule permits the HTML documentation generation for the specified files.The wtxapp application code located in 4.5.6 Application Example can generate an example of documentation.
The DOC_FILES macro specifies which files are to be documented. The following excerpt from a makefile generates HTML documentation for the given files:
DOC_FILES = wtxapp.c DOC_DIR = $(DOCS_ROOT)/tornado-app/wtxapp ... DOCS = doc ...
|
CAUTION: The DOCS macro must appear in all the makefiles, or a make man (or rman) would build the application instead of building the doc.
|
||||||||||||||||||