============================================================================= ICMAKE --- by Frank B. Brokken and Karel Kubat F.B.Brokken@icce.rug.nl, K.Kubat@icce.rug.nl Version: 6.07 ============================================================================= PROGRAMS OF THE ICMAKE FAMILY: icmake - the top level program, calls icm-pp, icm-comp, icm-exec icmun - unassembler, for maintenance purposes icm-pp, icm-comp, icm-exec - internal programs for preprocessing, compilation, execution PROGRAM INVOCATION: icmake [flags] source[.im] [dest[.bim]] [-- [args]] flags: optional flags: -a : information about ICMAKE -b : blunt execution of the destinationfile -c : the destination file is compiled -i file: 'file': name of source, end of icmake arguments -o file: all icmake output is redirected to `file' -p : only the preprocessor is activated -q : quiet mode: copyright banner not displayed source: make description source file (default extension: .im) dest: binary make file (default: source.bim) -- : optional icmake-file arguments separator args: optional arguments following -- received by the icmake file in its argv-list Note: -o is not implemented on unix platforms icmun bimfile bimfile: file to unassemble SYNTAX OF A MAKEFILE: (a) Preprocessor directives: // comment : comment until end-of-line /* comment */ : comment between /* and */ #include "filename" : includes a file #include : includes a file from directory pointed to by IM variable #define ident redef : defines ident to expand to redef #! ... : ignored line Note: Don't use comment on lines containing #include or #define. Note: #! may be used on unix platforms to use icmake-shell scripts, in combination with the -i flag. E.g., if the first line of an (executable) icmakefile 'icm' (no extension) contains #! /usr/local/bin/icmake -qi then 'icm' may be given as command, thus executing /usr/local/bin/icmake -qi icm (b) Types and variables: int (-0x8000..0x7fff or 'x', x: ASCII character) string (a piece of text) list (a number of strings) void (may be used for user-defined functions) Global and local variables are supported, as well as arguments to user-defined functions. (c) Escape sequences in strings: \a \b \f \n \r \t \other: other taken literally, e.g., \\ for \ (d) Flow control statements: if (condition) statement if (condition) statement else statement for (init; condition; increment) statement - init, condition and increment are optional return (expression) - no (expression) with void functions break exit (expression) (e) The user-defined function main(): Arguments may be (int argc, list argv, list envp) or a subset of those, similar to C. Argc is the number of elements in argv. Argv holds the arguments, with element 0 the .bim filename, element 1 the first argument etc. Envp holds the environment, element 0 is the first variable, element 1 its setting, element 2 the second variable, element 3 its setting, etc. (f) Operators: The ternary C-operator ?: is not supported. All other arithmetic operators of C are supported, operating on int-operands. Operators available for string-operands: a + b concatenates b to a += concatenation and assignment == != <= >= < > equality testing !a empty string test a younger b true if file a is more recent a older b true if file b is more recent a newer b synonym for younger Note: Equality testing is also alphabetically, using the ordering of the ASCII-set. Internally strcmp() is used to compare strings. Operators available for list-operands: a + b merging of lists a - b opposite += -= merging/subtraction and assignment == != equality testing !a empty list test Typecasts: Strings may be cast to ints and vv. Strings may be cast to lists. (g) Predefined constants: Used with makelist(): --------------------- O_ALL 8 O_FILE 1 O_DIR 2 O_SUBDIR 4 Used with echo(): ----------------- OFF 0 ON 1 Used with execute() and system() etc.: -------------------------------------- P_CHECK 0 P_NOCHECK 1 Used with stat(): ----------------- S_IFCHR 1 S_IFDIR 2 S_IFREG 4 S_IREAD 8 S_IWRITE 16 S_IEXEC 32 BUILT-IN FUNCTIONS: Note: In parameterlists below, the notation [type = value,] indicates a default function argument of the indicated type and value. An argument of the indicated type may be prvided to overrule the default. arghead (string h) defines argument head, to be used with execute () argtail (string t) defines argument tail, to be used with execute () int ascii (string s) returns first character of 's' as an int; e.g., ascii ("A") gives 65 string ascii (int i) returns i as a string, e.g., ascii (65) gives "A" string change_base (string file, string newbase) changes basename of file, returns changed name string change_ext (string file, string newext) changes extension of file, returns changed name string change_path (string file, string newpath) changes path specification of file, returns changed name string chdir ([int = P_CHECK,] string newdir) changes directory, returns the previous dir. Use "." for newdir to get current working directory. Use "" for newdir to get startup working directory. cmdhead (string h) defines command head, to be used with execute () cmdtail (string t) defines command tail, to be used with execute () echo (int opt) sets re-echoing of called programs, OFF for no echo (default: ON) string element (int index, list lst) returns index-th string from list string element (int index, string str) returns index-th character from string as a mini-string exec ([int = P_CHECK,] string cmd, ...) runs command with arguments. execute ([int = P_CHECK,] string cmd, string cmdhd, string arghd, ..., string argtl, string cmdtl) same as exec(), except for command head/tail and argument head/tail. The actual executed program will start with the cmd, followed by the cmdhd. Next is a series of arguments, all enclosed by arghd and argtl. The command terminates with cmdtl. int exists (string file) returns non-zero if file exists list fgets (string file, int offset) reads next string from file at offset. Return value: element(0,retlist) is the read string (including \n), element(1,retlist) is the next offset to read. An empty return list signifies EOF. fprintf (string file, ...) same as printf, but appends to file string get_base (string file) returns basename of file string get_ext (string file) returns extension of file string getch () returns keypress as mini-string string get_path (string file) returns path of file int getpid () returns process-id (UNIX) or PSP-paragraph (DOS) of icm-exec string gets () returns string read from keyboard list makelist ([int = O_FILE,] string mask) returns list of all files matching mask Use: O_ALL to obtain all directory entries, O_DIR to obtain a list of (sub)directories, O_FILE (default) to obtain a list of only files, O_SUBDIR to obtain a list of only subdirectories. list makelist ([int = O_FILE,] string mask, newer, string comparefile) returns list of all files matching mask which are newer than the comparefile. Operator younger is synonymous to newer. list makelist ([int = O_FILE,] string mask, older, string comparefile) see above; returns list of files older than the comparefile. list makelist ([int = O_FILE,] string mask, newer, string comparefile) returns list of all files matching mask which are newer than the comparefile. Operator younger is synonymous to newer. list makelist ([int = O_FILE,] string mask, older, string comparefile) see above; returns list of files which are older than the comparefile. printf (...) prints arguments to screen putenv (string) adds string to environment (as long as icmake is running). Use format: "VAR=value". int sizeof (list l), int sizeoflist (list l) returns number of strings in list list stat ([int = P_CHECK,] string entry) returns 'stat' information of directory entry 'entry' as a list. The following list-elements are defined: Element Definition -------------------------------------- 0 attribute value 1 size of the file -------------------------------------- Attributes are returned as bit-flags, composed from the following predefined constants: ----------------------------------------------------- S_IFCHR 1 S_IFDIR 2 S_IFREG 4 S_IREAD 8 S_IWRITE 16 S_IEXEC 32 ----------------------------------------------------- int strlen (string s) returns number of characters in s (as C's strlen() function) string strlwr (string s) returns lower-case duplicate of s string strupr (string s) returns upper-case duplicate of s list strtok (string str, string separators) returns list holding substrings of cut-up string int substr (string big, string small) returns index in big where small occurs, or -1 if small does not occur in big int system ([int = P_CHECK,] string command) runs command. Return value indicates exit status. (end of info)