[VM] Linking and external libs

Lex Spoon lex at cc.gatech.edu
Fri May 31 06:09:43 UTC 2002


"Stephen Pair" <spair at advantive.com> wrote:
> I want to create a plugin that links against an external library using
> the existing VMMaker/make scheme.  Does the existing configure/make
> system allow for this?  I can modify the existing makefiles and such
> easy enough, but I'd like to not touch those if possible.  I would
> imagine that it should be possible to list the libs that are needed by a
> given plugin in a special file included in the plugin's directory
> (either the "Cross" or platform specific directory within "platforms")
> and have the build scripts detect it and generate the Makefile with the
> appropriate -l options.  Does something like this currently exist, or do
> I need to modify the build scripts?
> 

You can certainly just hack the makefile to get yourself going.  Also,
there have been issues in the past with linking libraries to libraries,
and I don't know where that is nowadays.  For lack of time, I'm going to
ignore that issue.  It's important though; I'd suggest getting the most
recent libtool and looking at its documentation.

What I will mention is how to modify makefile rules, once you have 
figured out what you want to do.  Details are in the BUILD.details file
in the Unix area of Source Forge, but I'll overview it here.


By default, mkMake will generate rules to build your plugin which
essentially:

	1. compile each .c file
	2. link the results into a .so or .a file

You should be able to skim through the generate makefile to see what
mkMake does for you by default.

If you want to change these rules at all, then you must write a
mkMakeRules script which prints your rules to stdout.  To get started,
your script could be as simple as:

	#!/bin/sh
	cat <<EOF
      #...insert your modified make rules here...
      EOF

When you re-run configure (eg with "make update"), your custom rules
will replace the default rules.

Once you have a basic script working, the extra mile is to make sure
your script works whether the plugin is internal or external, and to
make sure you didn't hard code any absolute path names.  There are two
arguments to the mkMakeRules script that will help you with this: $1 is
the path to the top of the VMMaker directory, and $2 is either
"internal" or "external".


Overall this seems like a pretty simple system, now that it is
documented.  


> The contents of SomePlugin.cfg might look something like:
> 
> LIBS = -L/some/path/lib -lsomelib
> INCLUDES = -I/some/path/include
> 

This would be an excellent special case to support in a simple way.  It shouldn't be hard, either -- anyone want to peek at mkMake and try for it?  To make things even simpler, you could have two files named "make.libs" and "make.includes" instead of a single Plugin.cfg file.

If you want to actually go through autoconf, however, then things are much more complex....

Lex



More information about the Squeak-dev mailing list