1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
3
<!--Converted with LaTeX2HTML 2002-2-1 (1.71)
4
original version by: Nikos Drakos, CBLU, University of Leeds
5
* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
6
* with significant contributions from:
7
Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
10
<TITLE>3 Adding your own plugins</TITLE>
11
<META NAME="description" CONTENT="3 Adding your own plugins">
12
<META NAME="keywords" CONTENT="HowToBuildFromSource">
13
<META NAME="resource-type" CONTENT="document">
14
<META NAME="distribution" CONTENT="global">
16
<META NAME="Generator" CONTENT="LaTeX2HTML v2002-2-1">
17
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
19
<LINK REL="STYLESHEET" HREF="HowToBuildFromSource.css">
21
<LINK REL="next" HREF="HowToBuildFromSource-node6.html">
22
<LINK REL="previous" HREF="HowToBuildFromSource-node4.html">
23
<LINK REL="up" HREF="HowToBuildFromSource.html">
24
<LINK REL="next" HREF="HowToBuildFromSource-node6.html">
29
<DIV CLASS="navigation"><!--Navigation Panel-->
31
HREF="HowToBuildFromSource-node6.html">
32
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A>
34
HREF="HowToBuildFromSource.html">
35
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A>
37
HREF="HowToBuildFromSource-node4.html">
38
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A>
40
HREF="HowToBuildFromSource-node1.html">
41
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>
43
HREF="HowToBuildFromSource-node6.html">
44
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A>
46
<B> Next:</B> <A NAME="tex2html112"
47
HREF="HowToBuildFromSource-node6.html">Index</A>
48
<B> Up:</B> <A NAME="tex2html106"
49
HREF="HowToBuildFromSource.html">Building Unix Squeak (</A>
50
<B> Previous:</B> <A NAME="tex2html100"
51
HREF="HowToBuildFromSource-node4.html">2 Generating your own</A>
52
<B> <A NAME="tex2html108"
53
HREF="HowToBuildFromSource-node1.html">Contents</A></B>
54
<B> <A NAME="tex2html110"
55
HREF="HowToBuildFromSource-node6.html">Index</A></B>
58
<!--End of Navigation Panel-->
59
<!--Table of Child-Links-->
60
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>
62
<UL CLASS="ChildLinks">
63
<LI><A NAME="tex2html113"
64
HREF="HowToBuildFromSource-node5.html#SECTION00051000000000000000"><SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">1</SPAN> Plugin-specific configuration</A>
66
<LI><A NAME="tex2html114"
67
HREF="HowToBuildFromSource-node5.html#SECTION00051100000000000000"><SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">1</SPAN>.<SPAN CLASS="arabic">1</SPAN> <TT>AC_PLUGIN_CHECK_LIB(<SPAN CLASS="textit">lib</SPAN>,<SPAN CLASS="textit">func</SPAN>)</TT></A>
68
<LI><A NAME="tex2html115"
69
HREF="HowToBuildFromSource-node5.html#SECTION00051200000000000000"><SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">1</SPAN>.<SPAN CLASS="arabic">2</SPAN> <TT>AC_PLUGIN_DEFINE_UNQUOTED(<SPAN CLASS="textit">keyword</SPAN>,<SPAN CLASS="textit">text</SPAN>)</TT></A>
70
<LI><A NAME="tex2html116"
71
HREF="HowToBuildFromSource-node5.html#SECTION00051300000000000000"><SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">1</SPAN>.<SPAN CLASS="arabic">3</SPAN> Plugin-specific variables</A>
74
<LI><A NAME="tex2html117"
75
HREF="HowToBuildFromSource-node5.html#SECTION00052000000000000000"><SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">2</SPAN> Plugin-specific <TT>Makefile</TT> declarations and rules</A>
77
<LI><A NAME="tex2html118"
78
HREF="HowToBuildFromSource-node5.html#SECTION00052100000000000000"><SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">2</SPAN>.<SPAN CLASS="arabic">1</SPAN> The anatomy of a plugin's <TT>Makefile</TT></A>
79
<LI><A NAME="tex2html119"
80
HREF="HowToBuildFromSource-node5.html#SECTION00052200000000000000"><SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">2</SPAN>.<SPAN CLASS="arabic">2</SPAN> A note about <TT>$(COMPILE)</TT> and <TT>$(LINK)</TT> commands</A>
81
<LI><A NAME="tex2html120"
82
HREF="HowToBuildFromSource-node5.html#SECTION00052300000000000000"><SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">2</SPAN>.<SPAN CLASS="arabic">3</SPAN> Specifying additional source directories</A>
83
<LI><A NAME="tex2html121"
84
HREF="HowToBuildFromSource-node5.html#SECTION00052400000000000000"><SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">2</SPAN>.<SPAN CLASS="arabic">4</SPAN> Including additional material in the default <TT>Makefile</TT></A>
85
<LI><A NAME="tex2html122"
86
HREF="HowToBuildFromSource-node5.html#SECTION00052500000000000000"><SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">2</SPAN>.<SPAN CLASS="arabic">5</SPAN> Replacing the default <TT>Makefile</TT> entirely</A>
89
<LI><A NAME="tex2html123"
90
HREF="HowToBuildFromSource-node5.html#SECTION00053000000000000000"><SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">3</SPAN> Examples taken from existing plugins</A>
92
<LI><A NAME="tex2html124"
93
HREF="HowToBuildFromSource-node5.html#SECTION00053100000000000000"><SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">1</SPAN> Configuration</A>
94
<LI><A NAME="tex2html125"
95
HREF="HowToBuildFromSource-node5.html#SECTION00053200000000000000"><SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">2</SPAN> Customising the <TT>Makefile</TT></A>
98
<LI><A NAME="tex2html126"
99
HREF="HowToBuildFromSource-node5.html#SECTION00054000000000000000"><SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">4</SPAN> Coping with VMMaker quirks</A>
100
<LI><A NAME="tex2html127"
101
HREF="HowToBuildFromSource-node5.html#SECTION00055000000000000000"><SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">5</SPAN> If all else fails</A>
103
<!--End of Table of Child-Links-->
106
<H1><A NAME="SECTION00050000000000000000">
107
<SPAN CLASS="arabic">3</SPAN> Adding your own plugins</A>
112
<FONT COLOR="#ff0000"> Note: This section is intended primarily for plugin developers.
115
If your plugin<A NAME="189"></A>
116
requires no platform-specific tweaks then there's
117
nothing for you to do. <TT>configure</TT> (and <TT>config.status</TT>)
118
will provide a default <TT>Makefile</TT> for it that should work. If your
119
plugin requires only platform-independent tweaks (and/or additional
120
hand-written code) then these go in <TT>platforms/Cross/plugins</TT>, and
121
there's nothing for you to do (in Unixland).
124
On the other hand, if you require special <TT>configure</TT> tests or
125
additional declarations/rules in your plugin's <TT>Makefile</TT> then you
126
need to specify them explicitly.
130
<FONT COLOR="#ff0000"> Note: Unix Squeak subscribes to the following philopsophy:
133
<BLOCKQUOTE><FONT COLOR="#ff0000"><SPAN CLASS="textit">Absolutely everything that is specific<A NAME="197"></A>
135
headers, <TT>configure</TT> and <TT>Makefile</TT> extensions, etc.) lives
136
under <TT>platforms/unix</TT>.</SPAN>
139
<BLOCKQUOTE><FONT COLOR="#ff0000">In other words: there is not (nor aught there be) <SPAN CLASS="textit">any</SPAN>
140
Unix-related information under the <TT>platforms/Cross</TT>
141
directory. (Unix Squeak is entirely encapsulated
142
under <TT>platforms/unix</TT> and is utterly immune to
143
``random junk'' elsewhere in the <TT>platforms</TT> tree.)
146
First you must create a new directory<A NAME="206"></A>
147
under <TT>platforms/unix/plugins</TT> named after your plugin. This directory
148
will hold the files describing the additional configuration checks
149
and/or <TT>Makefile</TT> contents. For example, if your plugin is
150
called ``MyCoolPlugin'' then
153
<DIV CLASS="alltt" ALIGN="LEFT">
156
<FONT COLOR="#0000ff">
157
<BR> $ mkdir platforms/unix/plugins/MyCoolPlugin
162
would be the thing to do. (The following sections will refer to this
163
directory as <TT>platdep</TT> since the full path is quite a mouthful of
164
typing for my lazy fingers.)
168
<H2><A NAME="SECTION00051000000000000000">
169
<SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">1</SPAN> Plugin-specific configuration</A>
173
Your plugin can ask <TT>configure</TT><A NAME="216"></A>
174
to run additional tests (and to
175
set additional variables in its output files) simply by including a
176
file called <TT>acinclude.m4</TT><A NAME="575"></A>
177
in it's <TT>platdep</TT> directory.
181
<FONT COLOR="#ff0000"> Note: The <TT>configure</TT><A NAME="576"></A>
182
script is `compiled' from several other files. If
183
you create a `<TT>platdep./acinclude.m4</TT>' file then you <SPAN CLASS="textit">must</SPAN>
184
`recompile'<A NAME="577"></A>
185
<TT>configure</TT>. You can do this by `<TT>cd</TT>'ing to
186
<TT>unix/config</TT> and running `<TT>make</TT>', or (if you have GNU
187
<TT>make</TT>) from the <TT>blddir</TT> like this:
190
<DIV CLASS="alltt" ALIGN="LEFT">
193
<FONT COLOR="#ff0000">
194
<BR> $ make -C ../platforms/unix/config
200
In addition to the usual <TT>autoconf</TT> macros, the following
201
macros<A NAME="580"></A>
202
are available specifically for Squeak plugins to use:
206
<H3><A NAME="SECTION00051100000000000000">
207
<SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">1</SPAN>.<SPAN CLASS="arabic">1</SPAN> <TT>AC_PLUGIN_CHECK_LIB(<SPAN CLASS="textit">lib</SPAN>,<SPAN CLASS="textit">func</SPAN>)</TT></A>
212
This is similar to the <TT>autoconf</TT> `<TT>AC_CHECK_LIB</TT>' macro.
215
<SPAN CLASS="textit">func</SPAN> is the name of a function required by the plugin, defined
216
in the external (system) library <SPAN CLASS="textit">lib</SPAN>. The macro checks that
217
the library is available (via `<TT>-l<SPAN CLASS="textit">lib</SPAN></TT>') and then adds it
218
to the list of libraries required by the plugin (see the explanation
219
of <TT>[plibs]</TT> in Section <A HREF="#sec:plibs">3.2.1</A> for a description of
220
how library dependencies for plugins are handled).
223
If <SPAN CLASS="textit">func</SPAN> cannot be found in <SPAN CLASS="textit">lib</SPAN> then the plugin will be
224
disabled and a message to that effect printed during configuration.
225
(The VM can still be built, <SPAN CLASS="textit">without</SPAN> rerunning VMMaker or
226
reconfiguring, and the plugin will simply be ommitted from it.)
230
<H3><A NAME="SECTION00051200000000000000">
231
<SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">1</SPAN>.<SPAN CLASS="arabic">2</SPAN> <TT>AC_PLUGIN_DEFINE_UNQUOTED(<SPAN CLASS="textit">keyword</SPAN>,<SPAN CLASS="textit">text</SPAN>)</TT></A>
235
This<A NAME="585"></A>
236
is similar to the <TT>autoconf</TT> `<TT>AC_DEFINE_UNQUOTED</TT>' macro.
239
<SPAN CLASS="textit">keyword</SPAN> is a <TT>Makefile</TT> keyword (usually of the form
240
`[<SPAN CLASS="textit">name</SPAN>]') and <SPAN CLASS="textit">text</SPAN> is arbitrary text to be
241
associated with it. Calling this macro causes <TT>mkmf</TT> to
242
substitute <SPAN CLASS="textit">text</SPAN> for all occurrences of <SPAN CLASS="textit">keyword</SPAN> in the
243
<TT>Makefile</TT> generated for the plugin.
247
<H3><A NAME="SECTION00051300000000000000">
248
<SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">1</SPAN>.<SPAN CLASS="arabic">3</SPAN> Plugin-specific variables</A>
252
The following variables are also set during the execution of a
253
plugin-specific <TT>acinclude.m4</TT>:
258
<DD><TT>${plugin}</TT> is the name of the plugin;
261
<DD><TT>${topdir}</TT> is the path to the top-level directory (containing
265
<DD><TT>${vmmdir}</TT> is the path to the VMMaker `<TT>src</TT>' directory.
271
<H2><A NAME="SECTION00052000000000000000">
272
<SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">2</SPAN> Plugin-specific <TT>Makefile</TT> declarations and rules</A>
276
Three<A NAME="587"></A>
277
mechanisms are avilable for this:
280
<LI>scanning additional dirrectories for sources and headers;
282
<LI>including a few additional lines into the default <TT>Makefile</TT>;
285
<LI>replacing entirely the default <TT>Makefile</TT> with a
289
(The last option isn't as scary as it might sound: read on...)
293
<H3><A NAME="SECTION00052100000000000000">
294
<SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">2</SPAN>.<SPAN CLASS="arabic">1</SPAN> The anatomy of a plugin's <TT>Makefile</TT></A>
298
Before proceeding, let's take a minute to understand how Unix Squeak
299
compiles and links files in its default <TT>Makefile</TT> for plugins.
301
<TT>Makefile</TT><A NAME="589"></A><A NAME="590"></A>
309
<DIV CLASS="alltt" ALIGN="LEFT">
311
# default Makefile for Unix Squeak plugins
317
XINCLUDES = [includes]
319
OBJS = [targets]
321
TARGET = [target]
323
PLIBS = [plibs]
327
<BR>$(TARGET) : $(OBJS) Makefile
328
<BR> $(LINK) $(TARGET) $(OBJS) $(PLIBS)
341
<FONT COLOR="#ff0000"> Note: The keywords<A NAME="594"></A>
342
appearing between `<TT>[</TT> square brackets <TT>]</TT>'
343
are substituted during configuration by a preprocessor called
344
`<TT>mkmf</TT>'<A NAME="595"></A>
345
according to the kind of plugin (internal/external) being built.
348
<TT><SPAN CLASS="textbf">[make_cfg]</SPAN></TT><A NAME="597"></A>
350
is the configured variable section. It
351
contains the platform-specific information gleaned by <TT>configure</TT>
352
while it was figuring out which compiler you have, what flags your
353
linker needs, where to install stuff, and so on.
356
<TT><SPAN CLASS="textbf">[make_plg]</SPAN></TT><A NAME="600"></A>
358
contains a handful of definitions which
359
depend on whether the plugin is being compiled as internal or
362
<TABLE CELLPADDING=3>
363
<TR><TD ALIGN="LEFT"><TT></TD><TD ALIGN="LEFT">o </TT></TD>
364
<TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT">the extension for object files</TD>
366
<TR><TD ALIGN="LEFT"><TT></TD><TD ALIGN="LEFT">a </TT></TD>
367
<TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT">the extension for plugins</TD>
369
<TR><TD ALIGN="LEFT"><TT></TD><TD ALIGN="LEFT">COMPILE </TT></TD>
370
<TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT">the command to compile a source file into an object file</TD>
372
<TR><TD ALIGN="LEFT"><TT></TD><TD ALIGN="LEFT">LINK </TT></TD>
373
<TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT">the command to link one or more object files into a plugin</TD>
379
For internal plugins: <TT>$o</TT> is `<TT>.o</TT>' and <TT>$a</TT> is
380
`<TT>.a</TT>'. <TT>$(COMPILE)</TT> is the C compiler
381
(`<TT>$(CC) ... -o</TT>', so the first thing after the command
382
<SPAN CLASS="textit">must</SPAN> be the output filename) and <TT>$(LINK)</TT> is archiver
383
(`<TT>ar -rc</TT>', again requiring the output file to follow
384
immediately). Note that internal plugins are built as `<TT>ar</TT>'
385
archives before being linked into the final binary.
388
For external plugins: <TT>$o</TT> is `<TT>.lo</TT>', <TT>$a</TT> is
389
`<TT>.la</TT>', and <TT>$(COMPILE)</TT> and <TT>$(LINK)</TT> are
390
invocations of `<TT>libtool</TT>' to create position-independent objects and
391
shared libraries (with a `<TT>-o</TT>' appearing right at the end, so the
392
first thing after the command <SPAN CLASS="textit">must</SPAN> be the output filename).
395
<TT><SPAN CLASS="textbf">[includes]</SPAN></TT><A NAME="604"></A>
397
is a list of `<TT>-I<SPAN CLASS="textit">dir</SPAN></TT>'
398
compiler flags, one for each of the
399
directories<A NAME="607"></A>
402
<DIV CLASS="alltt" ALIGN="LEFT">
404
src/plugins/<SPAN CLASS="textit">name</SPAN>
405
<BR> src/vm/intplugins/<SPAN CLASS="textit">name</SPAN>
406
<BR> platforms/Cross/plugins/<SPAN CLASS="textit">name</SPAN>
407
<BR> platforms/unix/plugins/<SPAN CLASS="textit">name</SPAN>
410
</SPAN>in which at least one header file is present.
413
<TT><SPAN CLASS="textbf">[targets]</SPAN></TT><A NAME="610"></A>
415
is a list of object files
416
corresponding to the source (<TT>.c</TT>) files found in
417
the directories:<A NAME="612"></A>
420
<DIV CLASS="alltt" ALIGN="LEFT">
422
src/plugins/<SPAN CLASS="textit">name</SPAN>/*.c
423
<BR> src/vm/intplugins/<SPAN CLASS="textit">name</SPAN>/*.c
424
<BR> platforms/Cross/plugins/<SPAN CLASS="textit">name</SPAN>/*.c
425
<BR> platforms/unix/plugins/<SPAN CLASS="textit">name</SPAN>/*.c
428
</SPAN>where each source file has been stripped of the directory name and had the
429
`<TT>.c</TT>' converted into `<TT>$o</TT>'.
432
<TT><SPAN CLASS="textbf">[target]</SPAN></TT><A NAME="615"></A>
434
is the name of the plugin, including the
435
<TT>$a</TT> extension.
438
<TT><SPAN CLASS="textbf">[plibs]</SPAN></TT><A NAME="618"></A>
440
<A NAME="sec:plibs"></A>is a list of zero or more libraries on which the plugin depends (as
441
detected using the macro <TT>AC_PLUGIN_CHECK_LIB</TT> in the
442
plugin-specific <TT>acinclude.m4</TT>). If the plugin
443
is being built internally then this list is empty and the required libraries
444
are included in the final link command. If the plugin is being built
445
externally then the plugin itself (a shared object) is linked against
446
these libraries (via <TT>[plist]</TT>) rather than with the main VM binary.
449
(This is to ensure that a missing shared object needed by an external plugin
450
will only affect the operation of that plugin and not prevent the rest
451
of the VM from running, which would be the case if the entire VM were
455
<TT><SPAN CLASS="textbf">[make_inc]</SPAN></TT><A NAME="621"></A>
457
is the contents of the
458
<TT>Makefile.inc</TT> file in your plugin's <TT>platdep</TT> directory (or
459
empty if this file doesn't exist).
462
<TT><SPAN CLASS="textbf">[make_targets]</SPAN></TT><A NAME="624"></A>
464
is a list of rules<A NAME="626"></A>
465
for building the files listed in <TT>[targets]</TT>.
466
Each rule<A NAME="388"></A>
471
<DIV CLASS="alltt" ALIGN="LEFT">
473
name$o : <SPAN CLASS="textit">original/source/dir/</SPAN>name.c
474
<BR> $(COMPILE) name$o <SPAN CLASS="textit">original/source/dir/</SPAN>name.c
480
<H3><A NAME="SECTION00052200000000000000">
481
<SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">2</SPAN>.<SPAN CLASS="arabic">2</SPAN> A note about <TT>$(COMPILE)</TT> and <TT>$(LINK)</TT> commands</A>
485
You should <SPAN CLASS="textit">never</SPAN> pass additional flags to these
486
commands<A NAME="628"></A><A NAME="629"></A><A NAME="630"></A>
487
explicitly. This is because you cannot know how they are defined.
488
(Their definitions depend on whether the plugin is being built
489
internally or externally -- and might even change radically in future
490
releases of Unix Squeak.)
493
Instead you should pass additional compiler/linker
494
flags<A NAME="631"></A>
495
to these commands by setting the following variables in `<TT>Makefile.inc</TT>' or
496
`<TT>Makefile.in</TT>':
502
<TABLE CELLPADDING=3>
503
<TR><TD ALIGN="LEFT"><TT></TD><TD ALIGN="LEFT">XCPPFLAGS </TT></TD>
504
<TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT">`<TT>-I</TT>' flags for <TT>cpp</TT></TD>
506
<TR><TD ALIGN="LEFT"><TT></TD><TD ALIGN="LEFT">XDEFS </TT></TD>
507
<TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT">`<TT>-D</TT>' flags for <TT>cpp</TT></TD>
509
<TR><TD ALIGN="LEFT"><TT></TD><TD ALIGN="LEFT">XCFLAGS </TT></TD>
510
<TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT">anything to be passed to the compiler</TD>
512
<TR><TD ALIGN="LEFT"><TT></TD><TD ALIGN="LEFT">XLDFLAGS </TT></TD>
513
<TD ALIGN="LEFT"> </TD><TD ALIGN="LEFT">anything to be passed to the linker</TD>
518
<FONT COLOR="#ff0000"> Note: `<TT>mkmf</TT>' already uses `<TT>XINCLUDES</TT>'<A NAME="637"></A>
521
directories containing plugin header files to <TT>cpp</TT>. You can
522
redefine it if you like, but make sure that `<TT>[includes]</TT>'
523
appears in its definition (or in the definition of `<TT>XCPPFLAGS</TT>').
527
<H3><A NAME="SECTION00052300000000000000">
528
<SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">2</SPAN>.<SPAN CLASS="arabic">3</SPAN> Specifying additional source directories</A>
532
<TT>mkmf</TT><A NAME="639"></A>
533
looks for a file in your plugin's
534
<TT>platdep</TT> directory called
535
`<TT>mkmf.subdirs</TT>'.<A NAME="640"></A>
536
If this file exists then it should contain a list of directory names relative to
537
the top-level directory (the one containing the <TT>src</TT> and
538
<TT>platform</TT> directories). These
539
directories<A NAME="434"></A>
540
will be added to the list of locations searched for
541
`<TT>.c</TT>' and `<TT>.h</TT>' files while
542
constructing the substitutions for `<TT>[includes]</TT>',
543
`<TT>[targets]</TT>' and `<TT>[make_targets]</TT>'.
547
<H3><A NAME="SECTION00052400000000000000">
548
<SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">2</SPAN>.<SPAN CLASS="arabic">4</SPAN> Including additional material in the default <TT>Makefile</TT></A>
552
If the file <TT>platdep/Makefile.inc</TT><A NAME="642"></A>
553
exists then <TT>mkmf</TT> will
554
substitute its contents into the <TT>Makefile</TT> in place of the
555
<TT>[make_inc]</TT> keyword.
559
<FONT COLOR="#ff0000"> Note: <TT>Makefile.inc</TT><A NAME="643"></A>
560
is read into the <TT>Makefile</TT> under
561
construction <SPAN CLASS="textit">before</SPAN> <TT>mkmf</TT> performs substitutions on the
562
`<TT>[keyword]</TT>'s. In other words, your <TT>Makefile.inc</TT> can
563
use the above keywords to include relevant declarations and rules
564
without worrying about whether the plugin is internal or external.
568
<H3><A NAME="SECTION00052500000000000000">
569
<SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">2</SPAN>.<SPAN CLASS="arabic">5</SPAN> Replacing the default <TT>Makefile</TT> entirely</A>
573
If neither of the above are sufficient then you can create a complete
574
<TT>Makefile</TT><A NAME="645"></A>
575
template called <TT>platdep/Makefile.in</TT>.<A NAME="646"></A>
576
<TT>mkmf</TT> will use this template instead of the default <TT>Makefile</TT> template
577
shown earlier, and will perform keyword substitutions on it as
578
described above to create the final <TT>Makefile</TT>. (In other words,
579
simply copying the default template shown earlier will result in a
580
<TT>Makefile</TT> identical to the one that <TT>mkmf</TT> would have
585
<H2><A NAME="SECTION00053000000000000000">
586
<SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">3</SPAN> Examples taken from existing plugins</A>
590
By way of example we'll look at how two existing plugins specialise
591
their configuration and <TT>Makefile</TT>s.
595
<H3><A NAME="SECTION00053100000000000000">
596
<SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">1</SPAN> Configuration</A>
600
The <TT>B3DAcceleratorPlugin</TT> requires OpenGL in order to compile.
601
The file <TT>unix/plugins/B3DAcceleratorPlugin/acinclude.m4</TT><A NAME="647"></A>
602
contains a single call to an <TT>autoconf</TT>-style macro:
606
<DIV CLASS="alltt" ALIGN="LEFT">
608
AC_PLUGIN_SEARCH_LIBS(glIsEnabled, GL)
613
This works similarly to the <TT>autoconf</TT> `<TT>AC_SEARCH_LIBS</TT>'
614
macro: If a library <TT>libGL.{a,so}</TT> (OpenGL) exists and exports
615
the function <TT>glIsEnabled()</TT> then `<TT>-lGL</TT>' is added to the
616
final VM link command. Otherwise the plugin is disabled (and a
617
message warning of the fact is printed).
621
<FONT COLOR="#ff0000"> Note: There's a bug here. This should also check for `<TT>GL_VERSION_1_1</TT>' in headers.
625
<H3><A NAME="SECTION00053200000000000000">
626
<SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">2</SPAN> Customising the <TT>Makefile</TT></A>
630
The <TT>Mpeg3Plugin</TT> requires a (modified) <TT>libmpeg</TT> to be
631
compiled along with it. The sources for this library are in (several)
632
subdirectories of <TT>Cross/Meg3Plugin</TT> and they require additional
633
<TT>cpp</TT> definitions in order to compile correctly.
636
To cope with the additional directories,
637
<TT>unix/plugins/Mpeg3Plugin/mkmf.subdirs</TT><A NAME="649"></A>
642
<DIV CLASS="alltt" ALIGN="LEFT">
644
platforms/Cross/plugins/Mpeg3Plugin/libmpeg
645
<BR> platforms/Cross/plugins/Mpeg3Plugin/libmpeg/audio
646
<BR> platforms/Cross/plugins/Mpeg3Plugin/libmpeg/video
651
To cope with the additional <TT>cpp</TT> definitions, we could have
652
written a tiny <TT>Makefile.inc</TT><A NAME="650"></A>
657
<DIV CLASS="alltt" ALIGN="LEFT">
659
XDEFS = -DNOPTHREADS
664
Unfortunately the additional source directories contain various
665
utility and test programs (which <SPAN CLASS="textit">must not</SPAN> be built) so we
666
cannot rely on <TT>mkmf</TT> generating the correct <TT>[targets]</TT> list.
669
Instead we just copy the default <TT>Makefile</TT> ``template'' (shown
670
above) as <TT>Mpeg3Plugin/Makefile.in</TT>
671
and insert the required list of targets (and <TT>cpp</TT>
672
definition) manually. The end result<A NAME="651"></A>
678
<DIV CLASS="alltt" ALIGN="LEFT">
680
# Makefile.in for Mpeg3Plugin in Unix Squeak
686
TARGET = Mpeg3Plugin$a
689
PLUGIN = Mpeg3Plugin$o
691
VIDEO = getpicture$o headers$o idct$o macroblocks$o <SPAN CLASS="textit">etc...</SPAN>
693
AUDIO = dct$o header$o layer1$o layer2$o layer3$o <SPAN CLASS="textit">etc...</SPAN>
695
LIBMPEG = bitstream$o changesForSqueak$o libmpeg3$o <SPAN CLASS="textit">etc...</SPAN>
698
OBJS = $(PLUGIN) $(VIDEO) $(AUDIO) $(LIBMPEG)
701
XINCLUDES = [includes]
703
XDEFS = -DNOPTHREADS
705
<BR>$(TARGET) : $(OBJS) Makefile
706
<BR> $(LINK) $(TARGET) $(OBJS)
719
<FONT COLOR="#ff0000"> Note: The default `<TT>[make_targets]</TT>' will contain additional rules for the
720
objects that we're trying to avoid building (because it's built from
721
an exhaustive list of `<TT>.c</TT>' files in the source directories). This
722
does no harm since the offending rules can never be triggered (their
723
targets are not listed in `<TT>OBJS</TT>').
727
<H2><A NAME="SECTION00054000000000000000">
728
<SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">4</SPAN> Coping with VMMaker quirks</A>
732
VMMaker<A NAME="521"></A>
733
will refuse to compile a plugin if it thinks the plugin
734
requires platform support. This is ``all-or-nothing'': if platform
735
support is required on <SPAN CLASS="textit">one</SPAN> platform then it is required on
736
<SPAN CLASS="textit">all</SPAN> platforms (even if the plugin compiles quite happily
737
without platform support in Unix).
740
The easiest way to add ``null'' platform support is to place an empty
741
`<TT>Makefile.inc</TT>' in the plugin's <TT>platdep</TT> directory. (To see
742
this in action, look in <TT>unix/plugins/JPEGReadWriter2Plugin</TT>.)
746
<H2><A NAME="SECTION00055000000000000000">
747
<SPAN CLASS="arabic">3</SPAN>.<SPAN CLASS="arabic">5</SPAN> If all else fails</A>
751
(Where<A NAME="528"></A>
752
``all else failing'' is defined as: ``after trying for 20
753
minutes and still getting nowhere''.)
756
If you're writing a plugin that needs platform support (beyond dumb
757
inclusion of a few additional `<TT>.c</TT>' files) and this document has
758
been of no help at all (or if you understood it but you're still
759
suffering from ``all else failing'') then send me
761
HREF="mailto:ian.piumarta@squeakland.org">mail</A>
763
happy to help you with the various platdep files.
769
<DIV CLASS="navigation"><HR>
770
<!--Navigation Panel-->
771
<A NAME="tex2html111"
772
HREF="HowToBuildFromSource-node6.html">
773
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A>
774
<A NAME="tex2html105"
775
HREF="HowToBuildFromSource.html">
776
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A>
778
HREF="HowToBuildFromSource-node4.html">
779
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A>
780
<A NAME="tex2html107"
781
HREF="HowToBuildFromSource-node1.html">
782
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>
783
<A NAME="tex2html109"
784
HREF="HowToBuildFromSource-node6.html">
785
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A>
787
<B> Next:</B> <A NAME="tex2html112"
788
HREF="HowToBuildFromSource-node6.html">Index</A>
789
<B> Up:</B> <A NAME="tex2html106"
790
HREF="HowToBuildFromSource.html">Building Unix Squeak (</A>
791
<B> Previous:</B> <A NAME="tex2html100"
792
HREF="HowToBuildFromSource-node4.html">2 Generating your own</A>
793
<B> <A NAME="tex2html108"
794
HREF="HowToBuildFromSource-node1.html">Contents</A></B>
795
<B> <A NAME="tex2html110"
796
HREF="HowToBuildFromSource-node6.html">Index</A></B> </DIV>
797
<!--End of Navigation Panel-->