9.5 Examples for Makefiles

In the following chapter the various environments are introduced in form of listed makefiles. These makefiles are part of the distribution and therefore you do not need to type them in. In the chapter "Peculiarities" all special features of the system are mentioned, in "General Part of Declarations" the beginning part of a makefile is shown, in the chapter "Compiling" you will find a description of a command line and of how the COBOL source can be compiled, in the chapter "Compiling the C Source" you will learn how to compile a generated C file and finally in the chapter "Linking" you will learn how to link the application together. For illustrating purposes, there is always an example attached to the text.

9.5.1 Micro Focus COBOL on Microsoft Windows

9.5.1.1 Peculiarities

When translating the COBOL sources the switch /LITLINK has to be set, when translating the C sources the switches -DUFCOB and -DUFCOB_LINK have to be set.

For the COBOL programs being able to call up the Dialog Manager, the module mfc6intw.obj of the COBOL compiler has to be linked to them. If the module coboljmp.obj is linked to them, the interface functions in the Dialog Manager can be called up without a prefixed underline "_".

9.5.1.2 General Part of Declarations

##############################################################

 

TOPDIR=        \idm

 

##############################################################

 

BINDIR=        $(TOPDIR)

LIBDIR=    $(TOPDIR)\lib

IDMCOBDIR=    $(TOPDIR)\cobol

INCLDIR=    $(TOPDIR)\include

 

##############################################################

 

IDM=    wx $(BINDIR)\idm

 

##############################################################

 

CC=        cl

COPTS=    -AL -Zp -Gct5 -W4 -nologo -G3 -f- -GA -Owcegilnot \

        -Ob1 -Gsy

COUTOPTS=    -Fo

CDEFS=    -DDOS -DPC -DVERMAJOR=3 -DVERMINOR=1 -DMSW -DMSC \

        -D_WINDOWS -DUFCOB -DUFCOB_LINK

CINCL=    -I. -I$(INCLDIR) -I$(TOPDIR)\cobol

CFLAGS=    $(CDEFS) $(CINCL) $(LOCAL_DEFINES)

CL=        $(COPTS)

Cobol=    cobol

CobolC=    c:\cobol\lib\mfc6intw.obj

GENPRG=    $(TOPDIR)\cobol\gencobfx

 

LD=        link

LDFLAGS=    /ONERROR:N /ALIGN:32 /NOE /SEG:512 /MAP /NOD

STACKSIZE=27648

HEAPSIZE=    5120

 

RC=        rc

RCFLAGS=    -T -K -30

 

CP=        copy

MV=        rename

DEL=       del

 

##############################################################

 

SYSSTARTUP=    

SYSLIBS=         llibcew.lib libw.lib

SYSLIBS_DLL=    llibcew.lib libw.lib

COBLIBS=        lcobolw.lib lcobol.lib cobw.lib

DDELIBS=        ddeml.lib

MATHLIBS=    

SOCKETLIBS=    

 

##############################################################

 

STARTUP_DEV=    $(IDMCOBDIR)\ufcob.obj

BIND_COB=        $(IDMCOBDIR)\coboljmp.obj

DMLIBS=        $(LIBDIR)\dminit.lib $(LIBDIR)\dm.lib

9.5.1.3 Compiling a COBOL Source

obj\table.obj: src\table.cob

    @echo [cobol table]

    @$(Cobol) src\table.cob, obj\table.obj,,,/LITLINK

9.5.1.4 Compiling the Generated C Source

obj\tablec.obj : src\tablec.c

    $(CC) -c $(CFLAGS) -DUFCOB -DUFCOB_LINK src\tablec.c

9.5.1.5 Linking the Application

exe\table.exe: $(TABLE_OBJ)

    @echo [generating table.lnk]

    @echo $(SYSSTARTUP) +> table.lnk

    @echo $(STARTUP_DEV) +>> table.lnk

    @echo $(BIND_COB) +>> table.lnk

    @echo obj\table.obj +>> table.lnk

    @echo obj\putaddr.obj +>> table.lnk

    @echo obj\getaddr.obj +>> table.lnk

    @echo obj\table_.obj +>> table.lnk

    @echo obj\FuncTabl.obj +>> table.lnk

    @echo obj\tablec.obj +>> table.lnk

    @echo obj\FillTab.obj +>> table.lnk

    @echo obj\TabFunc.obj +>> table.lnk

    @echo $(CobolC) >> table.lnk

    @echo exe\table.exe $(LDFLAGS)>> table.lnk

    @echo table.map>> table.lnk

    @echo $(DMLIBS) +>> table.lnk

    @echo $(SYSLIBS) +>> table.lnk

    @echo $(COBLIBS)>> table.lnk

    @echo table.def>> table.lnk

    @echo [linking table]

    @$(LD) @table.lnk

    @$(RC) $(RCFLAGS) $@

    @$(DEL) table.*

 

table.def: mkdef.bat

    @echo [generating table.def]

    mkdef table $(STACKSIZE) $(HEAPSIZE) $(TOOLKIT)

mkdef.bat is the script supplied by the Dialog Manager; it looks as follows:

@echo off

 

if not X%3 == X goto OK

    echo usage: mkdef "def-name" "stacksize" "heapsize"

    goto END

 

:OK

echo ; module-definition file for DM -- used by LINK.EXE > %1.def

echo NAME         %1 >>%1.def

echo DESCRIPTION  'ISA Dialog Manager Application' >>%1.def

echo EXETYPE WINDOWS;required for Windows appl >>%1.def

echo STUB 'WINSTUB.EXE' ; >>%1.def

echo ;CODE can be moved in memory and discarded >>%1.def

echo CODE  PRELOAD MOVEABLE DISCARDABLE >>%1.def

echo ;DATA must be MULTIPLE if program can run more than once >>%1.def

echo DATA  PRELOAD FIXED MULTIPLE >>%1.def

echo HEAPSIZE %3 >>%1.def

echo STACKSIZE %2; recommended minimum for DM appl >>%1.def

 

echo ; All functions that will be called by any >>%1.def

echo ; routine Windows MUST be exported. >>%1.def

 

echo EXPORTS >>%1.def

echo   YITOPWINPROCHOOK @1  ; subclass function top-window-function >>%1.def

echo   YIWINPROCHOOK @2  ; function to subclass all other window-functions >>%1.def

echo   YIWINDOWPROC @3  ; window-function for window >>%1.def

echo   YIWINDOWFRAMEPROC @4  ; window-function for mdi-frame-window >>%1.def

echo   YIWINDOWCHILDPROC @5  ; window-function for mdi-child-window >>%1.def

echo   YICLIENTWINPROCHOOK @6  ; function to subclass mdi-client-window-functions >>%1.def

echo   YINODEBOXPROC @7  ; window-function for nodebox >>%1.def

echo   YICANVASPROC @8  ; window-function for canvas >>%1.def

echo   YPRINTABORTDLG @9  ; window-Dialog for printing >>%1.def

echo   YPRINTABORTPROC  @10 ; window-function for printing >>%1.def

echo   YITABLEPROC  @11 ; window-function for tablefield >>%1.def

echo   YITABLEEDITPROCHOOK @12 ; function to subclass edittext assigned to tablefield >>%1.def

 

if not X%5 == XEDT goto END

echo   YEDFONTENUM  @13 ; function to get fontnames for editor >>%1.def

 

:END

9.5.2 Micro Focus COBOL on Unix

9.5.2.1 Peculiarities

On the UNIX systems the dynamic reloading of the COBOL modules can be used by the COBOL runtime system. To do so, the names of the functions defined in the dialog have to correspond with the functions included in it. If this behavior shall be used, the COBOL sources have to be compiled in an intermediate format ".gnt" or ".int" and do not need to be linked to the application. At the actual runtime the intermediate files have to be found by the COBOL runtime system. To do so, the environment variable COBLIB has to be set accordingly. You also have the possibility to compile the COBOL sources to object files and to link them to a normal application.

To compile the generated C file, the switch -DUFCOB has to be set. If a program shall be linked without the COBOL runtime system, the switch -DUFCOB_LINK has to be set additionally when translating the generated C file.

9.5.2.2 General Part of Declarations

shell= /bin/sh

 

NOECHO=

IDMSRC=/usr/local/IDM

include $(IDMSRC)/lib/IDM/MakeDefs

 

IDM_INC=    -I$(IDMSRC)/include

IDM_LIB=    $(IDMSRC)/lib/libIDM.a

GENCOBFX=    $(IDMSRC)/lib/IDM/gencobfx

IDM=        $(IDMSRC)/bin/idm

IDMCOBCOPY=    $(IDMSRC)/include

IDM_BINDING=    $(IDMSRC)/lib/ufcob.o

COBDEFS=    -x -c

COBCPY=    $$COBDIR/srclib:$(IDMCOBCOPY)::

COB=        COBCPY="$(COBCPY)";export COBCPY; cob

 

VCDMLINK=    ufdmlink -root $(IDMSRC)

VCDMLIBS=    $(WINLIBS) $(SYSLIBS)

9.5.2.3 Compiling a COBOL Source

table.o:    table.cbl

        @echo [Compiling table]

        $(NOECHO) $(COB) $(COBDEFS) table.cbl

9.5.2.4 Compiling a Generated C Source

tablec.o:    tablec.c

        $(CC) $(COPTS) $(CDEFS) $(IDM_INC) -c tablec.c

9.5.2.5 Linking the Application

If a server stub is to be linked together, the switch -net has to be set on calling the script ufdmlink.

Tablenet:    table.o tablec.o table_.o

        @echo [Linking tablenet]

        $(NOECHO) $(VCDMLINK) -net -o tablenet table.o

            tablec.o table_.o

If a local application is to be linked together, the switch -dvl has to be set on calling the script ufdmlink.

Table:    table.o tablec.o table_.o

        @echo [Linking table]

        $(NOECHO) $(VCDMLINK) -dvl -o table table.o tablec.o

                 table_.o

The shell script ufdmlink looks as follows:

#!/bin/sh -e

#

#  Link Micro Focus COBOL executable for use with ISA Dialog

# Manager.Call this script without arguments to see a brief

# description or with -help for full documentation.

#

 

    cobswitches=""

    isasrc="FALSE"

    idmroot="/usr"

    version=""

    winlibs=""

    syslibs=""

    target=""

 

    #

    #  Parse command line.

    #

 

    while [ $# -gt 0 ]

    do

    case $1 in

        -dvl|-rls|-net)

        if [ "$version" = "" ]

        then

            version="$1"

        else

            echo >&2 "$0: Options -dvl, -rls and -net are mutually exclusive"

            exit 1

        fi

        ;;

 

        -root)

        shift

        idmroot="$1"

        ;;

 

        -n|-d)

        cobswitches="$cobswitches $1"

        ;;

        -o)

        shift

        target="-o $1"

        ;;

 

        *)

        break

        ;;

    esac

    shift

    done

 

    #

    #  Check required arguments.

    #

 

    if [ "$version" = "" ]

    then

    echo >&2 "$0: One of the switches -dvl, -rls and -net must be given"

    exit 1

    fi

 

    #

    #  Determine location of files.

    #

 

    case $isasrc in

    FALSE)

        case $version in

        -dvl)

        binding="$idmroot/lib/ufcob.o"

        library="$idmroot/lib/libIDM.a \

                $idmroot/lib/libIDMinit.a"

        ;;

 

        -rls)

        binding="$idmroot/lib/ufcobrt.o"

        library="$idmroot/lib/libIDMrt.a \

                $idmroot/lib/libIDMinit.a"

        ;;

 

        -net)

        binding="$idmroot/lib/ufcobnet.o"

        library="$idmroot/lib/libIDMnet.a \

                $idmroot/lib/libIDMinit.a"

        ;;

        esac

        ;;

    esac

 

args="$binding $args $library $*"

 

    #

    #  Link the program.

    #

 

    echo cob -x -F $target $cobswitches $args

    cob -x -F $target $cobswitches $args