File: HowToBuildFromSource.txt

package info (click to toggle)
squeak-vm 1%3A4.10.2.2614-4.1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 13,284 kB
  • ctags: 15,344
  • sloc: ansic: 75,096; cs: 11,191; objc: 5,494; sh: 3,170; asm: 1,533; cpp: 449; pascal: 372; makefile: 366; awk: 103
file content (684 lines) | stat: -rw-r--r-- 23,180 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684

            ****** Building Unix Squeak (>= 3.2) from source ******

                                 Ian Piumarta

                         <ian.piumarta@squeakland.org>

         Last edited: 2009-08-12 11:17:55 by piumarta on emilia.local
              Translated to .ps/.pdf/.html/.txt: August 12, 2009

***** Contents *****

    * 0_The_easy_way
    * 1_The_hard_way:_configure,_build,_install
    * 2_Generating_your_own_VM_and_plugin_sources

          o 2.1_How_configure_finds_the_src_directory

    * 3_Adding_your_own_plugins

          o 3.1_Plugin-specific_configuration
          o 3.2_Plugin-specific_Makefile_declarations_and_rules
          o 3.3_Examples_taken_from_existing_plugins
          o 3.4_Coping_with_VMMaker_quirks
          o 3.5_If_all_else_fails

    * Index

****** 0 The easy way ******

Beginning with version 3.7-7, everything you need is included with the Unix
sources regardless of how you obtained them - either as a tarball or by
repository checkout. (This was done to eliminate frequent problems encountered
by people combining the repository Unix and Cross sources with a set of
incompatible generated sources.)

If you extract a tarball then you will have a top-level directory named Squeak-
X.Y-Z (for some values of X, Y, and Z). If you are checking out from a
repository, you can call the direcory anything you like; for example:

  $ svn co http://squeakvm.org/svn/squeak/trunk squeak

will leave you with a directory called squeak. (We'll assume from now on that
the directory is called squeak.)

Next change to the 'unix' directory within the sources that you just checked
out (or extracted from the tarball):

  $ cd squeak/platforms/unix

Build the VM and plugins by running make:

  $ make

Then install the VM, plugins and manual pages by running make again (with
superuser privileges):

  $ sudo make install

To delete the temporary files created during the build process, run make one
last time:

  $ make clean

That's all there is to it.

****** 1 The hard way: configure, build, install ******

Unix Squeak is built using the (almost) universal ``configure; make; make
install''. If you haven't come across this before, read on...

Create a build directory (which we will call `blddir' from now on) and then
`cd' to it:

  $ mkdir blddir
  $ cd blddir

A convenient place is just next to the platforms directory, like this:

  $ cd squeak
  $ ls
  platforms src ...
  $ mkdir bld
  $ cd bld

Create the build environment by running the script configure which lives in the
platforms/unix/config directory.

     Note: The configure script accepts lots of options. To see a list of
     them, run: `configure --help'

Assuming you've created the blddir next to platforms, this would be:

  $ ../platforms/unix/config/configure

     Note: This assumes that the VMMaker sources are in `../src'. However,
     since the Unix Squeak support code is independent of the image
     version from which VMMaker generated the interpreter/plugin sources,
     it is possible that your source distribution comes with more than one
     src directory (corresponding to more than one image version used to
     generate the sources). In such cases you will have to tell configure
     which source version to use, via the `--with-src' option. For
     example, if there are two source directories called src-3.2gamma-4857
     and src-3.3.alpha-4881 then you would use one of the following
     commands:

       $ .../configure --with-src=src-3.2gamma-4857
             nbsp;CLASS="textit">or
       $ .../configure --with-src=src-3.3alpha-4881

Build the VM and plugins by running make:

  $ make

     Note: If you want to build just the VM (without external plugins) or
     just the external plugins (without the VM) then you can use: `make
     squeak' or `make plugins' respectively.

Finally install the VM, plugins and manual pages:

  $ su root
  $ make install

****** 2 Generating your own VM and plugin sources ******

Generating your own VM/plugin sources might be necessary for various reasons:

    * you want to change the mix of internal vs. external plugins
    * you want to remove some plugins from the VM that you will never use
    * you've pulled in some updates that modify the Interpreter or plugins
    * you've filed-in (or written) a whole new plugin
    * etc...

Version 3.2 (and later) of Unix Squeak use VMMaker to generate the core
interpreter and plugin sources.

Start Squeak in the top-level directory (the one containing the platforms
directory); for example:

  $ ls
  src platforms ...
  $ squeak MyCoolPlugin.image

Open a VMMakerTool and modify the setup to your liking.

     Note: The VMMaker configuration used to build the distributions of
     Unix Squeak is available in platforms/unix/config/VMMaker.config.

Then click on the relevant ``generate ...'' button. You can now `configure;
make; make install' in your blddir (as described above).

     Note: You only need to run configure once for a given blddir (on the
     same host). If you modify the choice of plugins (or change whether
     they're internal/external) then you can update the build environment
     by running the config.status script in the bldddir, like this:

       $ squeak MyCoolPlugin.image
       ... generate new sources ...
       $ cd blddir
       $ ./config.status
       $ make
     This is much faster than running configure all over again. (In fact,
     make should detect any changes to the plugin configuration and re-run
     config.status for you automatically.)

     Note: `configure' doesn't actually create any files. The last thing
     it does is run `config.status' to create the configured files in
     blddir from the corresponding file.ins in the unix/config directory.
     So in the remainder of this document the phrase `during
     configuration' means either when running `configure' for the first
     time or running `config.status' to update an already configured build
     environment.

***** 2.1 How configure finds the src directory *****

Starting with version 3.7 configure looks in two places for the src directory,
in the following order, and uses the first one that it finds:

    * the top-level directory (the one containing the platforms directory);
    * the platforms/unix directory.

In other words, if you want to use your own generated sources without deleting
the built-in generated sources, generating them into a src directory next to
platforms (and then re-running configure) will do what you want.

****** 3 Adding your own plugins ******

     Note: This section is intended primarily for plugin developers.

If your plugin requires no platform-specific tweaks then there's nothing for
you to do. configure (and config.status) will provide a default Makefile for it
that should work. If your plugin requires only platform-independent tweaks
(and/or additional hand-written code) then these go in platforms/Cross/plugins,
and there's nothing for you to do (in Unixland).

On the other hand, if you require special configure tests or additional
declarations/rules in your plugin's Makefile then you need to specify them
explicitly.

     Note: Unix Squeak subscribes to the following philopsophy:

     Absolutely everything that is specific to Unix (sources, headers,
     configure and Makefile extensions, etc.) lives under platforms/unix.

     In other words: there is not (nor aught there be) any Unix-related
     information under the platforms/Cross directory. (Unix Squeak is
     entirely encapsulated under platforms/unix and is utterly immune to
     ``random junk'' elsewhere in the platforms tree.)

First you must create a new directory under platforms/unix/plugins named after
your plugin. This directory will hold the files describing the additional
configuration checks and/or Makefile contents. For example, if your plugin is
called ``MyCoolPlugin'' then

  $ mkdir platforms/unix/plugins/MyCoolPlugin

would be the thing to do. (The following sections will refer to this directory
as platdep since the full path is quite a mouthful of typing for my lazy
fingers.)

***** 3.1 Plugin-specific configuration *****

Your plugin can ask configure to run additional tests (and to set additional
variables in its output files) simply by including a file called acinclude.m4
in it's platdep directory.

     Note: The configure script is `compiled' from several other files. If
     you create a `platdep./acinclude.m4' file then you must `recompile'
     configure. You can do this by `cd'ing to unix/config and running
     `make', or (if you have GNU make) from the blddir like this:

       $ make -C ../platforms/unix/config

In addition to the usual autoconf macros, the following macros are available
specifically for Squeak plugins to use:

**** 3.1.1 AC_PLUGIN_CHECK_LIB(lib,func) ****

This is similar to the autoconf `AC_CHECK_LIB' macro.

func is the name of a function required by the plugin, defined in the external
(system) library lib. The macro checks that the library is available (via `-
llib') and then adds it to the list of libraries required by the plugin (see
the explanation of [plibs] in Section 3.2.1 for a description of how library
dependencies for plugins are handled).

If func cannot be found in lib then the plugin will be disabled and a message
to that effect printed during configuration. (The VM can still be built,
without rerunning VMMaker or reconfiguring, and the plugin will simply be
ommitted from it.)

**** 3.1.2 AC_PLUGIN_DEFINE_UNQUOTED(keyword,text) ****

This is similar to the autoconf `AC_DEFINE_UNQUOTED' macro.

keyword is a Makefile keyword (usually of the form `[name]') and text is
arbitrary text to be associated with it. Calling this macro causes mkmf to
substitute text for all occurrences of keyword in the Makefile generated for
the plugin.

**** 3.1.3 Plugin-specific variables ****

The following variables are also set during the execution of a plugin-specific
acinclude.m4:

      ${plugin} is the name of the plugin;
      ${topdir} is the path to the top-level directory (containing platforms);
      ${vmmdir} is the path to the VMMaker `src' directory.

***** 3.2 Plugin-specific Makefile declarations and rules *****

Three mechanisms are avilable for this:
   1. scanning additional dirrectories for sources and headers;
   2. including a few additional lines into the default Makefile; and
   3. replacing entirely the default Makefile with a hand-written one.
(The last option isn't as scary as it might sound: read on...)

**** 3.2.1 The anatomy of a plugin's Makefile ****

Before proceeding, let's take a minute to understand how Unix Squeak compiles
and links files in its default Makefile for plugins. The default Makefile looks
like this:

          # default Makefile for Unix Squeak plugins

          [make_cfg]
          [make_plg]

          XINCLUDES       = [includes]
          OBJS            = [targets]
          TARGET          = [target]
          PLIBS           = [plibs]

          [make_inc]

          $(TARGET) : $(OBJS) Makefile
                  $(LINK) $(TARGET) $(OBJS) $(PLIBS)

          [make_targets]

          .force :

     Note: The keywords appearing between `[ square brackets ]' are
     substituted during configuration by a preprocessor called `mkmf'
     according to the kind of plugin (internal/external) being built.

[make_cfg]  is the configured variable section. It contains the platform-
specific information gleaned by configure while it was figuring out which
compiler you have, what flags your linker needs, where to install stuff, and so
on.

[make_plg]  contains a handful of definitions which depend on whether the
plugin is being compiled as internal or external:

      o           the extension for object files

      a           the extension for plugins

      COMPILE     the command to compile a source file into an object file

      LINK        the command to link one or more object files into a
                  plugin

For internal plugins: $o is `.o' and $a is `.a'. $(COMPILE) is the C compiler
(`$(CC) ... -o', so the first thing after the command must be the output
filename) and $(LINK) is archiver (`ar -rc', again requiring the output file to
follow immediately). Note that internal plugins are built as `ar' archives
before being linked into the final binary.

For external plugins: $o is `.lo', $a is `.la', and $(COMPILE) and $(LINK) are
invocations of `libtool' to create position-independent objects and shared
libraries (with a `-o' appearing right at the end, so the first thing after the
command must be the output filename).

[includes]  is a list of `-Idir' compiler flags, one for each of the
directories

  src/plugins/nbsp;CLASS="textit">name
  src/vm/intplugins/

nbsp;CLASS="textit">name
  platforms/Cross/plugins/

nbsp;CLASS="textit">name
  platforms/unix/plugins/

nbsp;CLASS="textit">name

in which at least one header file is present.

[targets]  is a list of object files corresponding to the source (.c) files
found in the directories:

  src/plugins/nbsp;CLASS="textit">name/*.c
  src/vm/intplugins/

nbsp;CLASS="textit">name/*.c
  platforms/Cross/plugins/

nbsp;CLASS="textit">name/*.c
  platforms/unix/plugins/

nbsp;CLASS="textit">name/*.c

where each source file has been stripped of the directory name and had the `.c'
converted into `$o'.

[target]  is the name of the plugin, including the $a extension.

[plibs]  is a list of zero or more libraries on which the plugin depends (as
detected using the macro AC_PLUGIN_CHECK_LIB in the plugin-specific
acinclude.m4). If the plugin is being built internally then this list is empty
and the required libraries are included in the final link command. If the
plugin is being built externally then the plugin itself (a shared object) is
linked against these libraries (via [plist]) rather than with the main VM
binary.

(This is to ensure that a missing shared object needed by an external plugin
will only affect the operation of that plugin and not prevent the rest of the
VM from running, which would be the case if the entire VM were linked against
it.)

[make_inc]  is the contents of the Makefile.inc file in your plugin's platdep
directory (or empty if this file doesn't exist).

[make_targets]  is a list of rules for building the files listed in [targets].
Each rule looks like this:

        name$o : nbsp;CLASS="textit">original/source/dir/name.c
                $(COMPILE) name$o

nbsp;CLASS="textit">original/source/dir/name.c

**** 3.2.2 A note about $(COMPILE) and $(LINK) commands ****

You should never pass additional flags to these commands explicitly. This is
because you cannot know how they are defined. (Their definitions depend on
whether the plugin is being built internally or externally -- and might even
change radically in future releases of Unix Squeak.)

Instead you should pass additional compiler/linker flags to these commands by
setting the following variables in `Makefile.inc' or `Makefile.in':

      XCPPFLAGS     `-I' flags for cpp

      XDEFS         `-D' flags for cpp

      XCFLAGS       anything to be passed to the compiler

      XLDFLAGS      anything to be passed to the linker

     Note: `mkmf' already uses `XINCLUDES'  to pass the list of
     directories containing plugin header files to cpp. You can redefine
     it if you like, but make sure that `[includes]' appears in its
     definition (or in the definition of `XCPPFLAGS').

**** 3.2.3 Specifying additional source directories ****

mkmf looks for a file in your plugin's platdep directory called `mkmf.subdirs'.
If this file exists then it should contain a list of directory names relative
to the top-level directory (the one containing the src and platform
directories). These directories will be added to the list of locations searched
for `.c' and `.h' files while constructing the substitutions for `[includes]',
`[targets]' and `[make_targets]'.

**** 3.2.4 Including additional material in the default Makefile ****

If the file platdep/Makefile.inc exists then mkmf will substitute its contents
into the Makefile in place of the [make_inc] keyword.

     Note: Makefile.inc is read into the Makefile under construction
     before mkmf performs substitutions on the `[keyword]'s. In other
     words, your Makefile.inc can use the above keywords to include
     relevant declarations and rules without worrying about whether the
     plugin is internal or external.

**** 3.2.5 Replacing the default Makefile entirely ****

If neither of the above are sufficient then you can create a complete Makefile
template called platdep/Makefile.in. mkmf will use this template instead of the
default Makefile template shown earlier, and will perform keyword substitutions
on it as described above to create the final Makefile. (In other words, simply
copying the default template shown earlier will result in a Makefile identical
to the one that mkmf would have produced by default.

***** 3.3 Examples taken from existing plugins *****

By way of example we'll look at how two existing plugins specialise their
configuration and Makefiles.

**** 3.3.1 Configuration ****

The B3DAcceleratorPlugin requires OpenGL in order to compile. The file unix/
plugins/B3DAcceleratorPlugin/acinclude.m4 contains a single call to an
autoconf-style macro:

    AC_PLUGIN_SEARCH_LIBS(glIsEnabled, GL)

This works similarly to the autoconf `AC_SEARCH_LIBS' macro: If a library
libGL.{a,so} (OpenGL) exists and exports the function glIsEnabled() then `-lGL'
is added to the final VM link command. Otherwise the plugin is disabled (and a
message warning of the fact is printed).

     Note: There's a bug here. This should also check for `GL_VERSION_1_1'
     in headers.

**** 3.3.2 Customising the Makefile ****

The Mpeg3Plugin requires a (modified) libmpeg to be compiled along with it. The
sources for this library are in (several) subdirectories of Cross/Meg3Plugin
and they require additional cpp definitions in order to compile correctly.

To cope with the additional directories, unix/plugins/Mpeg3Plugin/mkmf.subdirs
simply lists them:

  platforms/Cross/plugins/Mpeg3Plugin/libmpeg
  platforms/Cross/plugins/Mpeg3Plugin/libmpeg/audio
  platforms/Cross/plugins/Mpeg3Plugin/libmpeg/video

To cope with the additional cpp definitions, we could have written a tiny
Makefile.inc containing:

    XDEFS   = -DNOPTHREADS

Unfortunately the additional source directories contain various utility and
test programs (which must not be built) so we cannot rely on mkmf generating
the correct [targets] list.

Instead we just copy the default Makefile ``template'' (shown above) as
Mpeg3Plugin/Makefile.in and insert the required list of targets (and cpp
definition) manually. The end result looks like this:

          # Makefile.in for Mpeg3Plugin in Unix Squeak

          [make_cfg]
          [make_plg]

          TARGET  = Mpeg3Plugin$a

          PLUGIN  = Mpeg3Plugin$o
          VIDEO   = getpicture$o headers$o idct$o macroblocks$o
          nbsp;CLASS="textit">etc...
          AUDIO   = dct$o header$o layer1$o layer2$o layer3$o

          nbsp;CLASS="textit">etc...
          LIBMPEG = bitstream$o changesForSqueak$o libmpeg3$o

          nbsp;CLASS="textit">etc...

          OBJS    = $(PLUGIN) $(VIDEO) $(AUDIO) $(LIBMPEG)

          XINCLUDES       = [includes]
          XDEFS           = -DNOPTHREADS

          $(TARGET) : $(OBJS) Makefile
                  $(LINK) $(TARGET) $(OBJS)

          [make_targets]

          .force :

     Note: The default `[make_targets]' will contain additional rules for
     the objects that we're trying to avoid building (because it's built
     from an exhaustive list of `.c' files in the source directories).
     This does no harm since the offending rules can never be triggered
     (their targets are not listed in `OBJS').

***** 3.4 Coping with VMMaker quirks *****

VMMaker will refuse to compile a plugin if it thinks the plugin requires
platform support. This is ``all-or-nothing'': if platform support is required
on one platform then it is required on all platforms (even if the plugin
compiles quite happily without platform support in Unix).

The easiest way to add ``null'' platform support is to place an empty
`Makefile.inc' in the plugin's platdep directory. (To see this in action, look
in unix/plugins/JPEGReadWriter2Plugin.)

***** 3.5 If all else fails *****

(Where ``all else failing'' is defined as: ``after trying for 20 minutes and
still getting nowhere''.)

If you're writing a plugin that needs platform support (beyond dumb inclusion
of a few additional `.c' files) and this document has been of no help at all
(or if you understood it but you're still suffering from ``all else failing'')
then send me mail and I'll be happy to help you with the various platdep files.

***** Index *****
  $(COMPILE)
      3.2.2
  $(LINK)
      3.2.2
  $(XCFLAGS)
      3.2.2
  $(XCPPFLAGS)
      3.2.2
  $(XDEFS)
      3.2.2
  $(XINCLUDES)
      3.2.2
  $(XLDFLAGS)
      3.2.2
  [includes]
      3.2.1
  [make_cfg]
      3.2.1
  [make_inc]
      3.2.1
  [make_plg]
      3.2.1
  [make_targets]
      3.2.1
  [plibs]
      3.2.1
  [target]
      3.2.1
  [targets]
      3.2.1
  AC_PLUGIN_CHECK_LIB
      3.1.1
  AC_PLUGIN_DEFINE_UNQUOTED
      3.1.2
  acinclude.m4
      3.1
        example
            3.3.1
  additional plugin source directories
      3.2.3
  build directory
        configuring
            1
        creating
            1
  config.status
      2
        versus configure
            2
  configure
      3.1
        macros for plugins
            3.1
        recreating
            3.1
  emergency services
      3.5
  Makefile
      3.2.1
        avoiding $(XINCLUDES)
            3.2.2
        compile/link commands
            3.2.2
        keyword substitution
            3.2.1
        passing extra flags
            3.2.2
        replacing
            3.2.5
        target rules
            3.2.1
  Makefile keywords
        [includes]
            3.2.1
        [make_cfg]
            3.2.1
        [make_inc]
            3.2.1
        [make_plg]
            3.2.1
        [make_targets]
            3.2.1
        [plibs]
            3.2.1
        [target]
            3.2.1
        [targets]
            3.2.1
  Makefile.in
      3.2.5
        example
            3.3.2
  Makefile.inc
      3.2.4
        example
            3.3.2
        keyword substitution
            3.2.4
  mkmf
      3.2.1
        additional source directories
            3.2.3
        default header directories
            3.2.1
        default source directories
            3.2.1
  mkmf.subdirs
      3.2.3
        example
            3.3.2
  plugin
        Makefile
            3.2
        Makefile anatomy
            3.2.1
        adding your own
            3
        configuring
            3.1
        target rules
            3.2.1
        Unix-specific directory
            3
  Unix-specific files
      3
  VMMaker
        configuration file
            2
        missing platform support
            3.4
        reference
            2

===============================================================================
     2009-08-12