1 The syntax in Jmake.rules is not elegant at all, but:
3 - It is easy to parse (like sendmail.cf or troff files).
4 - The rules are not supposed to change very often.
5 - It is simple enough to be mastered in five minutes. :-)
7 Here is a small description:
9 o To deal with various cpp implementations:
11 Final @!\ means: end of line, next line starts at the left margin.
12 Final @@\ means: end of line, next line is to be indented by one tab.
14 The conversion occurs during Pass1.
19 >SYMBOL: defines the symbol (Pass 1).
20 ?SYMBOL:<text>: keeps <text> iff SYMBOL is defined (Pass 2).
21 %SYMBOL:<text>: keeps <text> iff SYMBOL is not defined (Pass 2).
23 The ?SYM can be nested (logical AND), as in:
25 ?SYMBOL:%TOKEN:text /* Keeps text if SYMBOL and not TOKEN */
27 To implement a logical OR, see below.
32 Commands can be passed to 'jmake'. They start with a leading '|'.
34 Available commands are:
36 |suffix <sx>: adds <sx> to the .SUFFIXES: list in the makefile (Pass 1 & 2).
37 |rule:<text>: adds <text> to the building rule section (Pass 1 & 2).
38 |rule: <text>: same as before, with a leading tab.
39 |skip: skips text until a line starting with '-skip' is found (Pass 2).
40 |expand <pattern>: expand lines until '-expand' with <pattern> (Pass 2).
41 |once <symbol>: text up to '-once' appears only the first time (Pass 1).
43 Thus, a way to implement a logical OR could be:
45 /* Implements SYMBOL or not TOKEN */
46 ?SYMBOL:text /* Keeps text if SYMBOL */
48 %TOKEN:text /* Keeps text if not TOKEN */
51 Actually, this is ugly, because the text has to appear twice.
52 Fortunately, I did not use it. :-)
54 The '|' commands cannot be nested. In particular, due to the simple
55 implementation of '|skip', it is impossible to put '|skip' inside
56 a skipped part. However, a '|once' section may have '|skip' sections.
58 But actually, as you have surely already guessed, the best way to
59 implement a logical OR is to use De Morgan's Law:
61 not (p or q) <=> not p and not q
63 /* Implements SYMBOL or not TOKEN (attempt #2) */
65 text /* If SYMBOL or not TOKEN */
68 Who said they don't care ? ;-)
72 Expansion is done with the 'expand' command. It has been provided to
73 avoid some cumbersome writings in makefiles when you have to repeat some
74 silly lines that only differ in file names, for instance. Let's look at
77 |expand a!foo bar! b!yes no!
82 Then two rules will be printed, and the values of (a,b) for the first
83 will be (foo, yes), for the second (bar, no). Substitution is controled
84 by the '!' character. If the word to be substituted is part of another
85 one, detach with the ^^ construct as in: !b^^c. It is possible to
86 use Makefile macros in the <pattern>, and they will be expanded by
87 jmake. If this is not what you want, escape the first '$' sign (this is
88 a Makefile escape, i.e. you must double the '$', not precede it with a
89 backslash). A // stands for the null substitution value.
91 Here is another example which shows how the macro Expand can be used.
92 It is defined in Jmake.rules as:
94 #define Expand(rule, pattern) @!\
99 So we can write in the Jmakefile:
106 $(DIR)/!a^^.o: !a^^.o @@\
110 Expand(Rule, a!$(A)!)
112 which will generate in Makefile.SH:
122 The 'A' declaration has been surrounded by skip, so that it does
123 not appear in the generated Makefile.SH, but it will be taken into
124 account by jmake for the substitution in the pattern.
126 The number of expansions is determined by the number of possible
127 values for the _first_ parameter. If other parameters have less
128 substitution values, they will get void ones.
130 It is possible to add a regular expression at the end of '-expand'.
131 This regular expression will be removed from the final set of expansion
132 at the end of each line. It is also possible to do substitutions in the
133 expanded item, by using the syntax (if 'f' is the expanded variable)
134 !f:<p>=<q> where <p> and <q> are two regular expressions (without
135 spaces). The pattern <p> will be replaced by pattern <q> (only the
136 first occurrence will be replaced).
138 Finally, you may refer in the expanded section to variables whose value
139 is computed via another expansion, which makes it easy to define generic
154 which will generate in Makefile.SH:
164 Do not forget to protect special characters in your regular expressions such
165 as backslash, point, etc...
169 The once command is tagged with a name. The first time the name appears,
170 the once construct is ignored and the text up to '-once' will be copied
171 in the generated Makefile.SH. However, future occurences of the same
172 name will be ignored (once will behave like skip).
182 +<line>: Puts the whole line in the initialization section (Pass 1 & 2).
183 ++SYMBOL <value>: Adds <value> to the SYMBOL macro (Pass 1 and 2).
185 o User-defined variables
187 CFLAGS: added flags to C compiler
188 DPFLAGS: cpp flags to be added to mkdep for dependency
189 LDFLAGS: flags/libraries to be added at linking stage