1 ''' $Id: jmake.man,v 3.0.1.1 1995/05/12 11:57:58 ram Exp $
3 ''' Copyright (c) 1991-1993, Raphael Manfredi
5 ''' You may redistribute only under the terms of the Artistic Licence,
6 ''' as specified in the README file that comes with the distribution.
7 ''' You may reuse parts of this distribution only within the terms of
8 ''' that same Artistic Licence; a copy of which may be found at the root
9 ''' of the source tree for dist 3.0.
11 ''' $Log: jmake.man,v $
12 ''' Revision 3.0.1.1 1995/05/12 11:57:58 ram
13 ''' patch54: updated my e-mail address
15 ''' Revision 3.0 1993/08/18 12:04:18 ram
16 ''' Baseline for dist 3.0 netwide release.
20 jmake \- a generic makefile builder
28 builds a makefile out of a rather high level description held in a
30 file. The generated file is a
32 rather than a simple makefile, which means it is ready to be used in
35 In particular, parameters such as "where to install executables" will
36 be automatically determined by
38 and only the needed parameters will be taken into account.
44 first, which describes the way things are to be built. Your
46 will be included inside a generic template through the C pre-processor.
47 This means you may use the usual C /**/ comments, but not the shell # comments.
48 The C comments will not appear in the generated
50 but lines starting with ;# will finally appear as shell comments. If you
51 have to write the string /* in the generated
53 then you have to escape it (otherwise
55 will think of it as the start of a C comment). Simply put a # in front
58 You have a set of macros at your disposal, and all these macros are
59 listed in the Index file, along with the piece of code they will
62 is fairly small and thus easier to maintain than a huge
64 Some internal powerful commands allow you to write
65 portable makefiles easily, without having to spend many efforts, because
66 someone else already did the job for you :-).
68 When you want to generate your makefile, you usually do not run
72 script which is a wrapper and will invoke
74 with the correct options.
78 is held in two files: the template
80 and the macro definition file
82 The first file includes the second, along with the
84 It is sometimes necessary to know how things works to be able to correctly
85 use all the features provided. For instance, you may have to write your
86 own rules for a specific project. Although you cannot overwrite the
87 predefined rules, you can extent the
89 file or simply add your macros in your
93 statements when you want to share these macros and do not want to duplicate
96 The syntax in Jmake.rules is not elegant at all, but:
100 It is easy to parse (like sendmail.cf or troff files).
102 The rules are not supposed to change very often.
104 It is simple enough to be mastered in five minutes. :-)
106 Here is a small description:
109 To deal with various \fIcpp\fR implementations:
113 Final @!\\ means: end of line, next line starts at the left margin.
115 Final @@\\ means: end of line, next line is to be indented by one tab.
118 There should always be one of @!\\ or @@\\ at the end of each line.
119 The only exception is for macros that are to be used as part of a
120 rule body (e.g. \fIRemoveTargetProgram\fR). In that case, the first
121 line (which holds the \fI#define\fR) should end with a single backslash.
129 >SYMBOL: defines the symbol.
131 ?SYMBOL:<text>: keeps <text> iff SYMBOL is defined.
133 %SYMBOL:<text>: keeps <text> iff SYMBOL is not defined.
136 The ?SYM can be nested (logical AND), as in:
142 which will keep text if SYMBOL is defined and TOKEN undefined.
143 To implement a logical OR, see below.
150 Commands can be passed to \fIjmake\fR. They start with a leading '|'.
151 Available commands are:
154 |suffix <sx>: adds <sx> to the .SUFFIXES: list in the makefile.
156 |rule:<text>: adds <text> to the building rule section.
158 |rule: <text>: same as before, with a leading tab.
160 |skip: skips text until a line starting with '-skip' is found.
162 |expand <pattern>: expand lines until '-expand' with <pattern>. A
163 complete example is shown below.
165 |once <symbol>: text up to '-once' appears only the first time.
168 Here is a way to implement a logical OR:
172 /* Implements SYMBOL or not TOKEN */
173 ?SYMBOL:text /* Keeps text if SYMBOL */
175 %TOKEN:text /* Keeps text if not TOKEN */
180 Actually, this is ugly, because the text has to appear twice.
181 Fortunately, I did not use it. :-)
184 The '|' commands cannot be nested. In particular, due to the simple
185 implementation of \fI|skip\fR, it is impossible to put \fI|skip\fR inside
186 a skipped part. However, a \fI|once\fR section may have \fI|skip\fR sections.
188 But actually, as you have surely already guessed, the best way to
189 implement a logical OR is to use De Morgan's Law:
193 not (p or q) <=> not p and not q
195 /* Implements SYMBOL or not TOKEN (attempt #2) */
197 text /* If SYMBOL or not TOKEN */
202 Who said they don't care ? ;-)
205 Expansion is done with the \fIexpand\fR command. It has been provided to
206 avoid some cumbersome writings in makefiles when you have to repeat some
207 silly lines that only differ in file names, for instance. Let's look at
212 |expand a!foo bar! b!yes no!
220 Then two rules will be printed, and the values of (a,b) for the first
221 will be (foo, yes), for the second (bar, no). Substitution is controled
222 by the '!' character. If the word to be substituted is part of another
223 one, detach with the ^^ construct as in: !b^^c. It is possible to
224 use Makefile macros in the <pattern>, and they will be expanded by
225 jmake. If this is not what you want, escape the first '$' sign (this is
226 a Makefile escape, i.e. you must double the '$', not precede it with a
227 backslash). A // stands for the null substitution value.
230 Here is another example which shows how the macro Expand can be used.
231 It is defined in \fIJmake.rules\fR as:
235 #define Expand(rule, pattern) @!\\
242 So we can write in the \fIJmakefile\fR:
251 $(DIR)/!a^^.o: !a^^.o @@\\
255 Expand(Rule, a!$(A)!)
259 which will generate in \fIMakefile.SH\fR:
275 The 'A' declaration has been surrounded by \fIskip\fR, so that it does
276 not appear in the generated Makefile.SH, but it will be taken into
277 account by \fIjmake\fR for the substitution in the pattern.
280 The number of expansions is determined by the number of possible
281 values for the \fBfirst\fR parameter. If other parameters have less
282 substitution values, they will get void ones.
285 It is possible to add a regular expression at the end of '-expand'. This
286 regular expression will be removed from the final set of expansion at the
287 end of each line. It is also possible to do substitutions in the expanded
288 item, by using the syntax (if 'f' is the expanded variable)
289 !f:\fI<p>\fR=\fI<q>\fR
290 where \fI<p>\fR and \fI<q>\fR are two regular expressions (without spaces).
291 The pattern \fI<p>\fR will be replaced by the pattern \fI<q>\fR (only the first
292 occurrence will be replaced).
295 Finally, you may refer in the expanded section to variables whose value is
296 computed via another expansion, which makes it easy to define generic
315 which will generate in \fIMakefile.SH\fR:
329 Do not forget to protect special characters in your regular expressions such
330 as backslash, point, etc...
333 The \fIonce\fR command is tagged with a name. The first time the name
334 appears, the once construct is ignored and the text up to '-once' will
335 be copied in the generated Makefile.SH. However, future occurences of
336 the same name will be ignored (\fIonce\fR will behave like \fIskip\fR).
355 +<line>: Puts the whole line in the initialization section.
357 ++SYMBOL <value>: Adds <value> to the SYMBOL macro.
361 User-defined variables:
363 The user may define CFLAGS, LDFLAGS or DPFLAGS as additional flags to be used
364 in C compilation, linking phase or depend target. It is thus possible to add
365 some extra flags such as -I or libraries for Makefiles in specific
370 Raphael Manfredi <ram@hptnos02.grenoble.hp.com>
375 High level description of Makefile.SH
378 File holding the macro definitions
381 Template used to mould Makefile.SH
386 reduces multiple tabs and spaces to a single space,
388 attempts to put back any necessary tabs (which
390 expects in front of rules) but does not properly formats the
391 body of the rule itself.
393 There is a bootstraping problem when creating the first Makefile.SH, because
394 you cannot run it through a shell until there is a decent Configure
395 script, but you can't run \fImetaconfig\fR before there is a Makefile.SH
396 or some needed symbols will not be defined.
398 jmkmf(1), metaconfig(1).