[VM][SF] Replacement of make by jam? [was: Re: [SF][VM] Re: better directory structure]

Stephan Rudlof sr at evolgo.de
Sat Jul 22 17:09:14 UTC 2000


Dear VM-Hackers, Lex!

I have taken a - very short - look onto jam and the jam-file below. It
looks better and seems to be better than the makefile stuff.
It could be reasonable to switch to this tool and to go away from this
annoying make, IMHO.

What do others think about this idea?


I would like to have some discussion about the pros and contras and kind
of a consensus before making a decision and possibly starting with using
it.

Are there any experiences from you - beside Lex - with this tool?


Lex:

Have you tested your jam-file below? I think I have found a typos, see
below (search for 'typos').
If so: Does it generate the same result as the current makefile.in?


BTW: jam is not in my SuSE Linux distribution.
BTW2: License: Very free (more free as GNU); no problems there.


Greetings,

Stephan


Lex Spoon wrote:
> 
> Bert Freudenberg <bert at isg.cs.uni-magdeburg.de> wrote:
> > > In fact, isn't it reasonable to compile modules *both* ways
> > > in the same build?
> >
> > Not if you want to have a slim VM. And it makes no sense to have the exact
> > same module both in the VM and external, as the internal would never be
> > used.
> >
> 
> I meant the latter.  But you're right, it's not a terribly big deal.  It
> would just be nice if it were easier to recompile things internally or
> externally without having to regenerate the sources.
> 
> It's hard to do right now, because the files actually *change* depending
> on whether they're going to be compiled internally or externally.  I
> suppose one could get around this by having the image code generate both
> versions, but even then, the sqNamedPrims file would need to get split
> up somehow.
> 
> > > As a final note, if make(1) gets annoying, we might think about
> > > "jam"....
> > >
> > >     http://www.perforce.com/jam/jam.html
> > >
> > > I've never actually used it, but it sounds pretty nice.
> >
> > Don't know. IMO it'd be hard to find anything more complete than autoconf.
> >
> 
> jam is a replacement for make, not for autoconf.  (Though I've expressed
> my opinions on autoconf!).  For anyone curious, and as an excercise for
> myself, I've put together a simple set of "jamfiles" for building Squeak
> and its plugins, and appended them.  Comments are welcome--I find these
> files easier to read and work with, for a number of small reasons:
> 
>         1. no recursion when you go into subdirectories
>         2. local variables
>         3. explicit rules, instead of pattern-matching on filenames
>         4. rule definitions and specifying-files-under-rules are separated
>         5. a nicer "foreach" construct than in GNU make  :)
> 
> Anyway, not a big deal, but I think this is easier to read and work with
> than make.  And jam is at least as easy to obtain as GNU make.
> 
> -Lex
> 
> ====
> 
> ------------- Jamfile.conf ---------------
> # configuration for the build
> 
> # version of Squeak
> SQVERSION = 2.9a ;
> 
> # location of X11 tree
> X11_DIR = /usr/X11R6/ ;
> 
> # directories (can usually be left alone)
> CORE_VM_DIR = "src/CoreVM/" ;
> UNIX_MODULES_DIR = "src/" ;
> INTERNAL_PLUGINS_DIR = "src/InternalModules/" ;
> EXTERNAL_PLUGINS_DIR = "src/ExternalModules/" ;
> UTIL_DIR = "util/" ;
> BUILD_DIR = build/$(OS).$(OSPLAT)/ ;
> 
> # settings for compiling regular C files
> CC = gcc ;
> OPTIM = -O3  -fomit-frame-pointer ;
> CCFLAGS = -DHAVE_CONFIG_H -I$(CORE_VM_DIR) -I$(UNIX_MODULES_DIR) -DUNIX -DSQVERSION=\\\"$(SQVERSION)\\\" -I$(X11_DIR)include ;
> LINKFLAGS = -L$(X11_DIR)lib -lX11 -lXext -lm -ldl -rdynamic ;
> 
> # settings for compiling shared libraries
> SHARED_CC = $(CC) ;
> SHARED_CCFLAGS = $(CCFLAGS) -fpic ;
> SHARED_LINKER = $(SHARED_CC) ;
> SHARED_LINKFLAGS = "-shared" ;
> SUFSHR = ".so" ;
> 
> ----------- Jamfile ---------
> include Jamfile.conf ;
> 
> # make sure the build directory gets made
> MkDir $(BUILD_DIR) ;
> 
> # instruct jam to scan these directories for header dependencies
> HDRS = $(CORE_VM_DIR) $(UNIX_MODULES_DIR) ;
> 
> # standard rule for compiling an internal module
> rule SQInternalModule {
>   DEPENDS $(1) : $(BUILD_DIR) ;
>   Object $(1) : $(2) ;
> 
>   VMOBJECTS += $(1) ;
> }
> 
> # modules in CoreVM/
> rule CoreVM {
>   SQInternalModule $(BUILD_DIR)$(1).o :  $(CORE_VM_DIR)/$(1).c ;
> }
> 
> # Unix-specific modules
> rule UnixInternal {
>   SQInternalModule $(BUILD_DIR)$(1).o : $(UNIX_MODULES_DIR)$(1).c ;

typos:                                                       ^ here the
'/' is missing, isn't it?

> }
> 
> # compiling a C file for a shared library
> rule SharedObject {
>   DEPENDS  $(1) : $(2) ;
> }
> 
> actions SharedObject {
>   $(SHARED_CC) $(SHARED_CCFLAGS) -o $(1) -c $(2) ;
> }
> 
> rule SharedLibraryFromObjects {
>   DEPENDS $(1) : $(2) ;
> }
> 
> actions SharedLibraryFromObjects {
>   $(SHARED_LINKER) $(SHARED_LINKFLAGS) -o $(1) $(2) ;
> }
> 
> # rule for compiling an external plugin
> rule ExternalModule {
>   local sofile = $(BUILD_DIR)$(1)$(SUFSHR) ;
>   local sourcedir = $(EXTERNAL_PLUGINS_DIR)$(1)/ ;
> 
>   EXTERNAL_PLUGINS +=  $(sofile) ;
> 
>   MkDir $(BUILD_DIR)$(1) ;
>   DEPENDS $(sofile) : $(BUILD_DIR)$(1) ;
> 
>   local soobjects ;
>   for source in $(2)  {
>     local soobject = $(BUILD_DIR)$(1)/$(source).o ;
>     soobjects += $(soobject) ;
> 
>     SharedObject $(soobject) : $(sourcedir)$(source).c ;
>     SHARED_CCFLAGS on $(soobject) = $(SHARED_CCFLAGS) -IModules/$(1) ;
>   }
>   SharedLibraryFromObjects $(sofile) : $(soobjects) ;
> }
> 
> # rule for compiling an internal plugin
> rule InternalModule {
>   local o_file = $(BUILD_DIR)$(1).o ;
>   SQInternalModule $(o_file) : $(INTERNAL_PLUGINS_DIR)$(1)/$(1).c ;
>   CCFLAGS on $(o_file) += -I$(INTERNAL_PLUGINS_DIR)$(1) ;
> }
> 
> # rule to build the version file
> rule VersionFile {
>     SQInternalModule $(1:S=.o) : $(1:S=.c) ;
> }
> actions VersionFile {
>     $(UTIL_DIR)verstamp $(1) ;
> }
> 
> # rule to update modules.jam
> rule ModuleRules {
>     ALWAYS $(1) ;
>     include $(1) ;
> }
> actions ModuleRules {
>     $(UTIL_DIR)modulesRules > $(1) ;
> }
> 
> # finally, the list and types of all files to compile
> 
> VersionFile $(BUILD_DIR)sqUnixVersion.c ;
> 
> CoreVM interp ;
> CoreVM sqMiscPrims ;
> CoreVM sqSoundPrims ;
> CoreVM sqADPCMPrims ;
> CoreVM sqNamedPrims ;
> CoreVM sqOldSoundPrims ;
> CoreVM sqVirtualMachine ;
> 
> UnixInternal sqUnixExternalPrims ;
> UnixInternal sqUnixPluginSupport ;
> UnixInternal sqXWindow ;
> 
> ModuleRules modules.jam ;
> 
> MainFromObjects $(BUILD_DIR)squeak : $(VMOBJECTS) ;
> 
> DEPENDS plugins : $(EXTERNAL_PLUGINS) ;
> DEPENDS all : modules.jam ;
> DEPENDS all : plugins ;
> 
> --------- modules.jam ---------
> # Automatically generated by util/modulesRules
> InternalModule BitBltPlugin ;
> ExternalModule B2DPlugin : B2DPlugin ;
> ExternalModule FFTPlugin : FFTPlugin ;
> ExternalModule FilePlugin : FilePlugin sqFilePrims sqUnixDirectory ;
> ExternalModule FloatArrayPlugin : FloatArrayPlugin ;
> ExternalModule LargeIntegers : LargeIntegers ;
> ExternalModule Matrix2x3Plugin : Matrix2x3Plugin ;
> ExternalModule SerialPlugin : SerialPlugin sqUnixSerialAndMIDIPort ;
> ExternalModule SocketPlugin : SocketPlugin sqUnixNetwork ;
> ExternalModule SoundPlugin : SoundPlugin sqUnixSound ;
> ExternalModule SurfacePlugin : SurfacePlugin ;
> ExternalModule ZipPlugin : ZipPlugin ;
> 
> ----------- util/modulesRules -------
> #!/bin/sh
> # generate Jam rules for all modules.
> # Must be run from the top-level directory!
> 
> echo "# Automatically generated by $0" ;
> 
> # internal modules
> for module in `(cd src/InternalModules; echo *)`
> do
>     if [ $module != CVS ]
>     then
>         echo "InternalModule $module ;"
>     fi
> done
> 
> # external modules
> for module in `(cd src/ExternalModules; echo *)`
> do
>     if [ $module != CVS ]
>     then
>         cFiles=`(cd src/ExternalModules/$module; echo *.c | sed -e s/\\\.c//g)`
>         echo "ExternalModule $module : $cFiles ;"
>     fi
> done

-- 
Stephan Rudlof (sr at evolgo.de)
   "Genius doesn't work on an assembly line basis.
    You can't simply say, 'Today I will be brilliant.'"
    -- Kirk, "The Ultimate Computer", stardate 4731.3





More information about the Squeak-dev mailing list