| mkpkg | "softools" | mkpkg |
mkpkg - make or update a package or library
mkpkg [switches] [module ...] [name=value ...]
The mkpkg utility is used to make or update IRAF packages or libraries. Mkpkg is used to bootstrap the IRAF system hence is implemented as a foreign task, callable either from within the IRAF environment or from the host system. Usage is identical in either case (except that the details of when a particular argument may need to be quoted will vary depending on the command language used). Mkpkg is upwards compatible with the old mklib utility.
1. Introduction
Mkpkg provides two major facilities: a library update capability and a macro preprocessor. The macro preprocessor provides symbol definition and replacement, conditional execution, and a number of builtin commands. The usefulness of these facilities is enhanced by the ability of mkpkg to update entire directory trees, or to enter the hierarchy of mkpkg descriptors at any level. For example, typing "mkpkg" in the root directory of IRAF will make or update the entire system, whereas in the "iraf$sys" directory mkpkg will update only the system libraries, and in the "iraf$sys/fio" directory mkpkg will update only the FIO portion of the system library "libsys.a".
The mkpkg utility is quite simple to use to maintain small packages or libraries, despite the complexity of the discussion which follows. The reader is encouraged to study several examples of working mkpkg-files before reading further; examples will be found throughout the IRAF system. The mkpkg files for applications packages tend to be very similar to one another, and it is quite possible to successfully copy and modify the mkpkg-file from another package without studying the reference information given here.
2. Lexical Conventions
The lexical conventions employed in mkpkg are those used throughout IRAF. Comments may occur anywhere, begin with the character #, and extend to the end of the current line. Blank lines are ignored virtually everywhere. Newline may be escaped with backslash to continue on the next line. All filenames are IRAF virtual filenames with the following extensions.
.a object library .c C source .e executable (e.g., "x_package.e") .f Fortran source .gc generic C source .gx generic SPP source .h C or SPP header file .inc include file .l Lex source .o object file .r Ratfor source .s assembler source .y Yacc source
Since mkpkg is an IRAF utility it recognizes the major IRAF logical directories; these are summarized in the list below. The IRAF (or UNIX) pathname convention is used to specify pathnames rooted in the current directory or a logical directory.
as$ where .s files go host$as/ bin$ installed executables iraf$bin/ dev$ device tables iraf$dev/ hlib$ machdep header files host$hlib/ host$ host system interface [MACHDEP] iraf$ the root directory of IRAF [MACHDEP] lib$ system library iraf$lib/ math$ math sources iraf$math/ pkg$ applications packages iraf$pkg/ sys$ the VOS, system libraries iraf$sys/ tmp$ where temporary files go [MACHDEP]
All other directories should be referenced by giving the path from either the current directory or from one of the system logical directories shown above. For example, "pkg$system/" is the root directory of the SYSTEM package, and ".." is the directory one level up from the current directory.
3. Maintaining Libraries with MKPKG
Libraries are described by a member list module in the "mkpkg" file. The syntax of a library member list module is shown below. Note that the mkpkg module name for a library member list module is the same as the name of the actual library, hence must end with the extension ".a".
libname.a: member1 dep1 dep2 ... depN member2 dep1 dep2 ... depN ... memberN dep1 dep2 ... depN ;
Here, "libname.a" is the IRAF virtual filename of the library (regardless of what directory it resides in), "memberN" is the name of a source file which may contain any number of actual library object modules, and "depN" is the name of a file upon which the named member depends. If any of the named dependency files is newer than the corresponding member source file, or if the member source file is newer than the compiled library object module, the source file is recompiled and replaced in the library. Both source files and dependency files may reside in remote directories. The names of dependency files in system libraries should be enclosed in <> delimiters, e.g., "<fset.h>". Each member must be described on a separate line.
If the library being updated does not reside in the current directory (directory from which the "mkpkg" command was entered) then the library must be "checked out" of the remote directory before it can be updated, and checked back in when updating is complete. These operations are performed by macro preprocessor directives, e.g.:
$checkout libsys.a lib$ $update libsys.a $checkin libsys.a lib$ $exit libsys.a: @symtab # update libsys.a in ./symtab brktime.x <time.h> environ.x environ.com environ.h <ctype.h>\ <fset.h> <knet.h> main.x <clset.h> <config.h> <ctype.h>\ <error.h> <fset.h> <knet.h>\ <printf.h> <xwhen.h> onentry.x <clset.h> <fset.h> <knet.h> spline.x <math.h> <math/interp.h> ;
Note that the checkout operation is required only in the directory from which the "mkpkg" command was entered, since the library has already been checked out when the mkpkg-file in a subdirectory is called to update its portion of the library (as in the "@symtab" in the example above). The checkout commands should however be included in each mkpkg-file in a hierarchy in such a way that the library will be automatically checked out and back in if mkpkg is run from that directory. The checkout commands are ignored if the mkpkg-file is entered when updating the library from a higher level, because in that case mkpkg will search for the named entry for the library being updated, ignoring the remainder of the mkpkg-file.
Sometimes it is necessary or desirable to break the library member list up into separate modules within the same mkpkg-file, e.g., to temporarily change the value of the symbol XFLAGS when compiling certain modules. To do this use the "@" indirection operator in the primary module list to reference a named sublist, as in the example below. Normal indirection cannot be used unless the sublist resides in a subdirectory or in a different file in the current directory, e.g., "@./mki2", since a single mkpkg-file cannot contain two modules with the same name. The same restrictions apply to the $update operator.
libpkg.a: @(i2) alpha.x beta.x zeta.f ; i2: $set XFLAGS = "-cO -i2" gamma.f delta.f ;
In the example above five object modules are to be updated in the library "libpkg.a". The files listed in module "i2", if out of date, will be compiled with the nonstandard XFLAGS (compiler flags) specified by the $set statement shown.
4. The MKPKG Macro Preprocessor
The mkpkg macro preprocessor provides a simple recursive symbol definition and replacement facility, an include file facility, conditional execution facilities, an OS escape facility, and a number of builtin directives. The names of the preprocessor directives always begin with a dollar sign; whitespace is not permitted between the dollar sign and the remainder of the name. Several preprocessor directives may be given on one line if desired. Preprocessor directives are executed as they are encountered, and may appear anywhere, even in the member list for a library.
4.1 Symbol Replacement
Symbol substitution in the mkpkg macro preprocessor is carried out at the character level rather than at the token level, allowing macro expansion within tokens, quoted strings, or OS escape commands. Macros are recursively expanded but may not have arguments.
Macros may be defined on the mkpkg command line, in the argument list to a $call or $update directive (see below), in an include file referenced with the $include directive, or in a $set directive. All symbols are global and hence available to all lower level modules, but symbols are automatically discarded whenever a module exits, hence cannot affect higher level modules. A local symbol may redefine a previously defined symbol. The IRAF and host system environment is treated as an extension of the mkpkg symbol table, i.e., a logical directory such as "iraf" may be referenced like a locally defined symbol.
Macro replacement occurs only when explicitly indicated in the input text, as in the following example, which prints the pathname of the dev$graphcap file on the mkpkg standard output. The sequence "$(" triggers macro substitution. The value of a symbol may be obtained interactively from the standard input by adding a question mark after the left parenthesis, i.e., "$(?terminal)" (this does not work with the -f stdin flag). The contents of a file may be included using the notation "$(@file )". Note that case is ignored in macro names; by convention, logical directories are normally given in lower case, and locally defined symbols in upper case.
$echo $(dev)graphcap !xc $(XFLAGS) filea.x fileb.x
Symbols are most commonly defined locally with the $set directive. The $include directive is useful for sharing symbols amongst different modules, or for isolating any machine dependent definitions in a separate file. The IRAF mkpkg system include file hlib$mkpkg.inc is automatically included whenever mkpkg is run.
The use of the $set directive is illustrated in the example below. Note the doubling of the preprocessor metacharacter to avoid macro expansion when entering the value of the GEN macro into the symbol table. The sequence "$$" is replaced by a single "$" whenever it is encountered in the input stream.
$set GFLAGS = "-k -t silrdx -p ak/" $set GEN = "$generic $$(GFLAGS)" ifolder (amulr.x, amul.x) $(GEN) amul.x $endif
4.2 Conditional Execution
Conditional control flow is implemented by the $if directives introduced in the last example and described below. The character "n" may be inserted after the "$if" prefix of any directive to negate the sense of the test, e.g., "$ifndef" tests whether the named symbol does not exist. Nesting is permitted.
Test if the named file is newer (has been modified more recently) than any of the named files to the right. The colon syntax may be used for clarity when comparing one file to many, but a comma will do.
Test if the named file is older than any of the named files.
4.3 Calling Modules
The following preprocessor directives are available for calling mkpkg modules or altering the normal flow of control.
4.4 Preprocessor Directives
The remaining preprocessor directives are described below in alphabetical order. Additional capability is available via OS escapes, provided the resultant machine dependence is acceptable.
The syntax of a filelist entry is as follows:
modname source_file mkobj_command
where modname is the filename of a library module as it appears in a library module list for the named directory, source_file is the virtual pathname of the source file to be used in lieu of the standard portable source file modname , and mkobj_command is the mkpkg command (e.g., $xc or an OS escape) to be executed to compile the named module. The character "&" appearing in either the source file name or mkobj command is replaced by modname . If the mkobj_command is omitted the specified source file will be compiled with $XC using the current value of XFLAGS.
5. Error Recovery
Mkpkg is implemented in such a way that it is restartable. If a mkpkg operation terminates prematurely for some reason, e.g., because of a compile error, execution error (such as cannot find the mkpkgfile in a subdirectory), interrupt, etc., then the mkpkg command can be repeated after correcting the error, without repeating the operations already completed. If mkpkg is interrupted it may leave checked out files, objects compiled but not yet updated in a library, etc. lying about, but this is harmless and the intermediate files will be cleaned up when the errors have been corrected and the run successfully completes.
Update the current package.
cl> mkpkg
Update the package library but do not relink.
cl> mkpkg libpkg.a
Make a listing of the package.
cl> mkpkg listing
Sample mkpkg-file for the above commands: # Make my package. $call relink $exit relink: $update libpkg.a $omake x_mypkg.x $link x_mypkg.o -lxtools ; libpkg.a: task1.x pkg.h task2.x filea.x pkg.com pkg.h <fset.h> fileb.x pkg.com ; listing: !pr task1.x task2.x file[ab].x | vpr -Pvup ;