Jesper’s ToolBox for IBM i – Make

MakeMake is a command that will re-build objects when one of it’s components is changed.

Make will check each component and issue the commands necessary to re-build the object.

In order to use this command, you must first create a Make member in a source file.

Documentation

The name of the source file is not important, but it is a good idea to call it QMAKESRC.

Next, create a member in the QMAKESRC source file. For ease of use, call the member the same name as your program/command/application.

Edit the member and enter the commands that you want Make to execute when checking and possibly building the application.

When all that is done, enter the Make command on a iSeries command line in order to run Make:

JWTOOLS/MAKE

and press [F4] to prompt. Fill out the fields and press [ENTER].

The Make command works by processing a source member that contains information about what components of the object to check. In the source member your enter the relation between objects and their components. Make will then check if any of the components are newer than the object, and if it is the case a series of commands (provided by you) will be issued to re-create the object.

Let’s take a look at this snippet of a Make source member, and I will explain how it works:

o &lib makecl *pgm
u &srclib make *module
u &srclib makecl *module
u &srclib make2cl *module
u &srclib make3cl *module
u &srclib qrpglesrc *file make
u &lib make *cmd
ci DltPgm &lib/makecl
c CrtPgm &lib/makecl module(&srclib/makecl &srclib/make2cl +
  &srclib/make3cl &srclib/make) Text('Make')

What the above snippet ‘says’ is: That a look at the object MAKECL *PGM in the library in variable ‘&lib’. If the creation date/time of this program is older than the creation date/time of one of it’s components (MAKE *MODULE, MAKECL *MODULE, MAKE2CL *MODULE, MAKE3CL *MODULE, QRPGLESRC *FILE Member(MAKE) or MAKE *CMD) then issue the following commands (DLTPGM and CRTPGM).

Note that the commands ‘CI’ and ‘C’ are only issued if Make has found that the creation date/time of the object in the O (Object) command is older that the creation date/time of just one of the objects stated in a U (Uses) command.

In the example above, it is possible that the object &lib/MAKECL *PGM has not yet been created (which will trigger that it must be re-build), and because of that, the DLTPGM command would fail when issued. This is the reason that the DLTPGM command has been placed on a CI (Command Ignore) command. The DLTPGM command will be issued and if it fails, it will not cause the Make command to stop.

The CRTPGM command must be issued to re-create the program, and it is listed in the C (Command) command with all the parameters needed to re-create the program MAKECL. If the CRTPGM command fails, Make will stop, displaying an error message. You will then have to check the joblog to find out what the problem is.

The Make command has an option to force a re-build of objects. Simply enter *YES to the keyword FORCE().

Commands supported by Make

In the Make member, you can use these commands.

  • V – Variable.
    A variable to be used in subsequent O, U, C or CI commands. Please note, that variables are implemented as simple ‘scan and replace’, no validation of any kind is made. You must not use variables that share part of their names. That is the two variables ‘&lib’ and ‘&libname’ will eventually clash.Instead use variables e.g. as this ‘&lib’ ‘&namelib’. There is no special syntax that must be meet, but again, as variables is a simple scan and replace process, using a variable with the name ‘lib’ will mess up a line like this ‘… LIB(QGPL)…’ as ‘lib’ will be replaced by the value.Variables are case sensitive. ‘&LIB’ and ‘&Lib’ are two different variables.
    Parameters:
    – Name of variable.
    – Value to assign to variable.
    Example:
    v &mylib CODELIB
  • O – Object.
    An object whose creation time stamp is used for reference.
    Parameters:
    – Library
    – Object
    – Object type
    – Member (if file)
    Example:
    o jwtools make *cmd
  • U – Uses.
    Objects whose creation date must be older that the creation date of the object specified in the O command. There can be several U lines but one is required.
    Parameters:
    – Library
    – Object
    – Object type
    – Member (if file)
    Example:
    u jwtoolssrc make *module
  • C – Command.
    Command to be run when MAKE determines that an object must be recreated. If the command that is run, returns an error, the MAKE command halts and returns an error. The command can be extended to the next line by adding a plus sign (‘+’) at the end of each line.
    Parameters:
    – Command line to be run.
    Example:
    c CRTRPGMOD jwtoolssrc/make srcfile(jwtoolssrc/make)
  • CI – Command Ignore.
    Command to be run when MAKE determines that an object must be recreated. If the command that is run, returns an error, the MAKE command continues. The command can be extended to the next line by adding a plus sign (‘+’) at the end of each line.
    Parameters:
    – Command line to be run.
    Example:
    c CRTRPGMOD jwtoolssrc/make srcfile(jwtoolssrc/make)
  • X – Exit.
    The MAKE command stops to process the MAKE member.
    Parameter:
    *None
    Example:
    x
  • ; – Comment.
    Enter comment.
    Parameter:
    – Comment
    Example:
    ; This is a comment.

Leave at least one space after the command and the parameters on the line. You can enter command in upper-case or lower-case. Variables can be used on all lines except comment lines.

Example Make member

Below please find an example of a Make member. The member is the one I use when building the Make command.

;
; MAKE
; ----
; MAKE member for the command MAKE. To serve as an example.
; Jesper Wachs, November 2014.
;
; A MAKE member contains the list of object to build and what to
; check in order to trigger the build.
;
; Variables defined once and used though out make member.
;
v &debug *source
v &lib jwtools
v &srclib jwtoolssrc
;
; First check and possibly build modules.
;
; Note that &mod is set here for the first time.
;
v &mod makecl
o &srclib &mod *module
u &srclib qclsrc *file &mod
ci dltmod &srclib/&mod
c CRTCLMOD &srclib/&mod srcfile(&srclib/qclsrc) dbgview(&debug)
;
; Note that &mod is set here for the second time.
;
v &mod make2cl
o &srclib &mod *module
u &srclib qclsrc *file &mod
ci dltmod &srclib/&mod
c CRTCLMOD &srclib/&mod srcfile(&srclib/qclsrc) dbgview(&debug)
;
; Note that &mod is set here for the third time.
;
v &mod make3cl
o &srclib &mod *module
u &srclib qclsrc *file &mod
ci dltmod &srclib/&mod
c CRTCLMOD &srclib/&mod srcfile(&srclib/qclsrc) dbgview(&debug)
;
; Note that &mod is set here for the fourth time.
;
v &mod make
o &srclib &mod *module
u &srclib qrpglesrc *file &mod
ci dltmod &srclib/&mod
c CRTRPGMOD &srclib/&mod srcfile(&srclib/qrpglesrc) dbgview(&debug)
;
; Second check and possibly build the command.
;
o &lib make *cmd
u &srclib make *module
u &srclib makecl *module
u &srclib make2cl *module
u &srclib make3cl *module
u &srclib qrpglesrc *file make
u &srclib qcmdsrc *file make
ci DltCmd &lib/make
c CrtCmd &lib/make pgm(&lib/makecl) srcfile(&srclib/qcmdsrc) +
  prdlib(&lib) enbgui(*yes)
;
; Third check and possibly build the program.
;
o &lib makecl *pgm
u &srclib make *module
u &srclib makecl *module
u &srclib make2cl *module
u &srclib make3cl *module
u &srclib qrpglesrc *file make
u &lib make *cmd
ci DltPgm &lib/makecl
c CrtPgm &lib/makecl module(&srclib/makecl &srclib/make2cl +
  &srclib/make3cl &srclib/make) Text('Make')

Known issues

The Make command works on object creation date/time and for source files, the source file change date/time. It does not check file level identifiers nor ILE module signatures. This can lead to objects being rebuild even no changes has been made.