Compiling programs

Top  Previous  Next

XFRAME suite provides some scripts to make programmers work easier. This chapter briefly describes the most important tools for XCICS program development. For more detailed information about these tools, please refer to the Programmer's Tools book.

Compiling COBOL programs

The COBOL programs can be easily compiled by means of the xcob compiler script, which provides a set of facility to speed up program development and compiling.

Normally, once correctly configured, an on-line program can be compiled simply issuing:

xcob [options] <PROGRAM>

I.e.

# xcob -sua PRGM0010.pre

Compiling PL/I programs

PL/I programs can be compiled by means of the xpli compiler script, which provides an easy interface to XCICS translator and Liant PL/I compiler.

Once configured, a PL/I program may be compiled issuing:

xpli [options] <PROGRAM>

Compiling C programs

There is no specific script for c compiling, because there are to many C compilers available. Therefore, to compile C programs you have to follow these steps:

1.translate the C source with xpre
2.compile the translated source with your preferred C compiler
3.link the obtained object in a shared library (.so, .sl or .dll)

Translate CICS commands

First of all, CICS commands must be translated into C commands with xpre. It must be invoked with the option --language=c, to activate C language parser.

Compile C source

Then translated C source have to be compiled into PIC (Position Independent Code), with the C compiler (cc or gcc). The C compiler must be invoked adding the XFRAME headers path to the include search list and properly defining the HWFLAG and OSFLAG symbols, according to the XFRAME configuration.

Create the shared library

The code object obtained from the compiling, must be included into a shared library.

UNIX/Linux

XFRAME provides an include for makefiles to define configuration dependant symbols and commands for program compiling: xport.make. Programmers simply have to include this file in their makefiles.

#
# makefile
#
 
include $(XFRAMEHOME)/include/xport.make
XFRAMEINCLUDES=-I$(XFRAMEHOME)/include \
            -I$(XFRAMEHOME)/xcics/cpy \
            -I$(XFRAMEHOME)/xvsam6/cpy \
            -I$(XFRAMEHOME)/xisc/cpy \
            -I$(XFRAMEHOME)/xsdf/cpy \
            -I$(ISAMCPY)
 
 
LIB=$(HOME)/lib
PRECOMPILER=$(XFRAMEHOME)/bin/xpre --language=c --cvda
GCC=gcc -DOSFLAG=$(OSFLAG) -DHWFLAG=$(HWFLAG) -g $(XFRAMEINCLUDES)
all:    $(LIB)/CPROG1.$(SHLSUFFIX)
 
$(LIB)/CPROG1.$(SHLSUFFIX): CPROG1.cx
     $(PRECOMPILER) --output=CPROG1.c CPROG1.cx
     $(GCC) -c CPROG1.c -o CPROG1.o
     $(LDSHARED) -o $(LIB)/CPROG1.$(SHLSUFFIX) CPROG1.o

Windows

On Windows systems, XFRAME provides an NMAKE compatible source to be included in user NMAKE makefiles, that sets some NMAKE variable to compile and link C/CICS programs correctly. This file is named xframe.nmake and may be found in the directory %XFRAMEHOME%/include.

In your makefile, you have to:

set a variable named XFRAMEHOME with the path to the current XFRAMEHOME
include this file in your makefile
precompile C/CICS code with xpre
compile C code with CL.EXE (the microsoft compiler) providing the options contained in $(XFRAME_CFLAGS)
create a DLL with LINK.EXE (the microsoft linker), including libcx.lib

Example

#
# NMAKE makefile
#
       
XFRAMEHOME=D:\xframe
 
include D:\xframe\include\xframe.nmake
 
all: CPROG01.dll
 
CPROG01.dll:     CPROG01.cx
       xpre --language=c --cvda -o $*.c $*.cx
       cl $(XFRAME_CFLAGS) -c $*.c
       link /dll /out:$*.dll $*.obj $(XFRAMEHOME)/bin/libcx.lib

If you plan to build your C/CICS programs with Microsoft Visual Studio, you may use either makefile based project types or DLL project types. In this case rememeber to include the settings contained in xframe.nmake in the your Visual Studio project.

Compiling Java programs

Java programs may be compiled directly using JDK compiler, the javac command. Simply add to the following jars to classpath:

$XFRAMEHOME/lib/hdm.jar
$XFRAMEHOME/lib/xcics.jar

I.e.

javac -classpath $XFRAMEHOME/lib/hdm.jar:$XFRAMEHOME/lib/xcics.jar:. JavaCicsClass.java

Of course, Java programmers may use ant

<!-- build.xml -->
<project name="xje" default="all" basedir=".">
     <property environment="env"/>
     <property name="j2ee.home"      value="${env.J2EE_HOME}"/>
     <property name="xframe"         value="${env.XFRAMEHOME}"/>
     <property name="build"          value="${env.HOME}/objs/classes"/>
     <property name="int"            value="${env.HOME}/objs/int"/>
     <path id="xframe.classpath">
             <pathelement location="${xframe}/lib/xcics.jar"/>
             <pathelement location="${xframe}/lib/hdm.jar"/>
     </path>
 
     <target name="all" depends="compile"/>
    
     <target name="compile">
             <javac  srcdir="."
                     destdir="${build}"
                     deprecation="on"
                     optimize="on"
                     debug="on">
                     <classpath>
                             <path refid="xframe.classpath"/>
                     </classpath>
             </javac>
     </target>
</project>