Smackage is a prototype package manager for Standard ML libraries. Right now it does only minimal installation; it is mainly designed to provide a standard way of getting Standard ML code that understands where other Standard ML code might be found on the filesystem.
Installation takes five steps, and the first and last two steps are optional.
Step 1: Pick a
SMACKAGE_HOME directory (optional).
$SMACKAGE_HOME directory is where Smackage will put all of its files.
This will be
~/.smackage by default if you don't do anything; see the
section "The $SMACKAGE_HOME directory" towards the bottom if you'd like
Smackage to put its files somewhere else.
Step 2: Set up your SML compilers to use Smackage.
You have to configure your SML compilers to find the code that Smackage will put on your system. This is a bit system-dependent; see the section "Setting up your SML path map" below for details.
Step 3: Download.
Finally, you can actually build Smackage with the following commands; the
git clone... command is just one of the ways you can get smackage
onto your hard drive; an alternative would be to download one of the
tarred or zipped releases.
Note: the directory (probably named
smackage) that you put the initial
Smackage code into should not be the same as the
$ git clone https://github.com/standardml/smackage.git # or something $ cd smackage $ make mlton # (or `smlnj', or `win+smlnj' if you're in Cygwin) $ bin/smackage
Smackage now lives in the
bin subdirectory of the current directory.
To install smackage in $SMACKAGE_HOME,
$ DESTDIR=$SMACKAGE_HOME make install
Now you can proceed to update your path and use smackage without having the build repository available.
Step 4: Update your PATH (optional).
Smackage-aware applications have a makefile option
install that places
a binary in
$SMACKAGE_HOME/bin IF the makefile is invoked through
smackage make. If you want to use Smackage to install applications,
you should add
$SMACKAGE_HOME/bin to your
PATH environment variable.
(Remember: don't literally add
$SMACKAGE_HOME with the absolute path of whatever directory you picked
in Step 1. So you'll really add something like
/Users/myusername/.smackage/bin to your path.)
Step 5: Bootstrap (optional).
Smackage is a smackage-aware application! If you added
$SMACKAGE_HOME/bin to your search path, then you can run the following:
$ bin/smackage refresh $ bin/smackage make smackage mlton # or smlnj, or win+smlnj, etc $ bin/smackage make smackage install $ which smackage
bin/smackage make smackage to see all the possible installation
options: polyml, win+mlton, mlkit, etc...)
The last command,
which smackage, should report that Smackage can be found
$SMACKAGE_HOME/bin/smackage. Now you've bootstrapped Smackage: you no
longer need the current directory where you downloaded Smackage, you just
Referring to Smackage packages
If you've performed all the steps described above, you will be able to
refer to cmlib as
$SMACKAGE/cmlib/v1/cmlib.cm (in SML/NJ .cm files) or as
$(SMACKAGE)/cmlib/v1/cmlib.mlb (in .mlb files).
You want to add
$SMACKAGE_HOME/bin to your path if you want to use
applications compiled through Smackage.
Building Smackage packages
Smackage doesn't have a uniform build process, at least not yet. Instead, we
support a simple
smackage make command. If you type
smackage make package blah blah blah, smackage will try to run
make blah blah blah in the directory where
package lives. We suggest that
if your tool compiles into binaries, say, you add a makefile option
install that copies the
created binaries to the directory
$(DESTDIR)/bin, in the style
For instance, the following commands get and install Twelf.
$ smackage refresh $ smackage get twelf $ smackage make twelf smlnj # or mlton, ... $ smackage make twelf install
$SMACKAGE_HOME/bin is on your search path, you can then refer to the
twelf-server binary like this:
$ which twelf-server /Users/rjsimmon/.smackage/bin/twelf-server $ twelf-server Twelf 1.7.1+ (built 10/30/11 at 00:37:12 on concordia.wv.cc.cmu.edu) %% OK %%
Setting up your SML path map
Smackage will live in a directory that we'll refer to
$SMACKAGE_HOME in this section. This directory is probably
~/.smackage, but see the section on
$SMACKAGE_HOME below for more
information. Whenever you see the string
$SMACKAGE_HOME in the text below, you
should replace it with the appropriate absolute file path, for instance I
wouldn't actually write
in a pathconfig file for Standard ML of New Jersey; instead, I'd write
Make sure you use an absolute path - starting with "/", or whatever your system uses to refer to the file system root.
Setting up SML/NJ (system-wide)
Find the file
lib/pathconfig in the installation directory for SML/NJ, and
add the following line:
Setting up SML/NJ (user-only)
Create a file
~/.smlnj-pathconfig containing the following line (or add
the following line to
~/.smlnj-pathconfig if it exists already):
Setting up MLton (system-wide)
Find the MLBasis Path Map, stored
in a file called
mlb-path-map, usually somewhere like
/usr/local/lib/mlton/mlb-path-map, depending on your system. Add the line
Setting up MLton (user-only)
MLton allows mlb path variables to be set on the
line. If you don't want to edit the global
mlb-path-map file, you
can pass the SMACKAGE path as a command line argument to
doing this all the time is tedious and would break build scripts, you
probably want to set up a wrapper script somewhere in your path that
#!/bin/sh $MLTON_PATH -mlb-path-var 'SMACKAGE $SMACKAGE_HOME/lib' "$@"
$SMACKAGE_HOME are replaced with the appropriate
paths. For example, on my system, I have a file
#!/bin/sh /usr/bin/mlton -mlb-path-var 'SMACKAGE /home/sully/.smackage/lib' "$@"
Setting up MLKit or SMLtoJs
To allow for MLKit or SMLtoJs to find a definition for the
MLB path variable, add a line to the appropriate
Be aware that when MLKit (or SMLtoJs) is compiling a package, it will
write files within
MLB/ subfolders of the package's folder. This
behavior may cause problems if you don't have write access to the
The $SMACKAGE_HOME directory
Smackage has to figure out where it lives on the file system whenever it
starts up; the installation instructions referred to the directory where
smackage lives as
$SMACKAGE_HOME. Smackage goes through the following process
to try and determine
- If the
SMACKAGE_HOMEenvironment variable is defined, then smackage will always use that as
$SMACKAGE_HOME. If this directory does not exist, smackage will try to create it. Otherwise,
/usr/local/smackageexists, smackage will use that as
/opt/smackage/exists, smackage will use that as
- As a last resort, smackage will try to use
~is defined by the
HOMEenvironment variable. If this directory does not exist, smackage will try to create it.