On this page:
1.1 Git Repository versus Source Distribution
1.2 Git Repository Build Modes
1.3 Quick Instructions:   In-Place Build
1.4 Quick Instructions:   Unix-Style Install
1.5 More Instructions:   Building Racket
1.6 More Instructions:   Building Racket CS and Racket BC
1.7 Even More Instructions:   Building Racket Pieces
1.7.1 Building Minimal Racket
1.7.2 Installing Packages
1.7.3 Linking Packages for In-Place Development Mode
7.9

1 Building Racket from Source

In a checkout of the Racket Git repository, you could try just running

  make

but we recommend that you at least consider the information in Git Repository versus Source Distribution and Git Repository Build Modes.

1.1 Git Repository versus Source Distribution

Instead of building from the Git repository, consider getting source for the current Racket release from

http://download.racket-lang.org/

or get a source snapshot (updated daily) from

http://snapshot.racket-lang.org/

The Source + built packages options from those sites will build and install especially quickly, because platform-independent bytecode and documentation are pre-built.

In contrast to the Git repository, release and snapshot source distributions will work in the

  configure --prefix=... && make && make install

way that you probably expect.

1.2 Git Repository Build Modes

The rest of this chapter assumes that you’re sticking with the source repository. In that case, you still have several options:

1.3 Quick Instructions: In-Place Build

On Unix (including Linux) and Mac OS, make (or make in-place) creates a build in the "racket" directory.

On Windows with Microsoft Visual Studio (any version between 2008/9.0 and 2019/16.0), nmake win creates a build in the "racket" directory. For information on configuring your command-line environment for Visual Studio, see "racket/src/worksp/README.txt".

In all cases, an in-place build includes (via links) a few packages that are in the "pkgs" directory. To get new versions of those packages, as well as the Racket core, then use git pull. Afterward, or to get new versions of any other package, use make in-place again, which includes a raco pkg update step.

See More Instructions: Building Racket for more information.

1.4 Quick Instructions: Unix-Style Install

On Unix (including Linux), make unix-style PREFIX=dir builds and installs into "dir" (which must be an absolute path) with binaries in "dir/bin", packages in "dir/share/racket/pkgs", documentation in "dir/share/racket/doc", etc.

On Mac OS, make unix-style PREFIX=dir builds and installs into "dir" (which must be an absolute path) with binaries in "dir/bin", packages in "dir/share/pkgs", documentation in "dir/doc", etc.

On Windows, Unix-style install is not supported.

A Unix-style install leaves no reference to the source directory.

To split the build and install steps of a Unix-style installation, supply DESTDIR=dest-dir with make unix-style PREFIX=dir, which assembles the installation in "dest-dir" (which must be an absolute path). Then, copy the content of "dest-dir" to the target root "dir".

See More Instructions: Building Racket for more information.

1.5 More Instructions: Building Racket

The "racket" directory contains minimal Racket, which is just enough to run raco pkg to install everything else. The first step of make in-place or make unix-style is to build minimal Racket, and you can read "racket/src/README" for more information.

If you would like to provide arguments to configure for the minimal Racket build, then you can supply them with by adding CONFIGURE_ARGS="options" to make in-place or make unix-style.

The "pkgs" directory contains packages that are tied to the Racket core implementation and are therefore kept in the same Git repository. A make in-place links to the package in-place, while make unix-style copies packages out of "pkgs" to install them.

To install a subset of the packages that would otherwise be installed, supply a PKGS value to make. For example,

  make PKGS="gui-lib readline-lib"

installs only the "gui-lib" and "readline-lib" packages and their dependencies. The default value of PKGS is "main-distribution main-distribution-test". If you run make a second time, all previously installed packages remain installed and are updated, while new packages are added. To uninstall previously selected package, use raco pkg remove.

To build anything other than the latest sources in the repository (e.g., when building from the v6.2.1 tag), you need a catalog that’s compatible with those sources. Note that a release distribution is configured to use a catalog specific to that release, so you can extract the catalog’s URL from there.

Using make (or make in-place) sets the installation’s name to development, unless the installation has been previously configured (i.e., unless the "racket/etc/config.rktd" file exists). The installation name affects, for example, the directory where user-specific documentation is installed. Using make also sets the default package scope to installation, which means that packages are installed by default into the installation’s space instead of user-specific space. The name and/or default-scope configuration can be changed through raco pkg config.

Note that make -j n controls parallelism for the makefile part of a build, but not for the raco setup part. To control both the makefile and the raco setup part, use

  make CPUS=n

which recurs with make -j n JOB_OPTIONS="-j n". Setting CPUS also works with make unix-style.

Use make as-is (or nmake win-as-is) to perform the same build actions as make in-place, but without consulting any package catalogs or package sources to install or update packages. In other words, use make as-is to rebuild after local changes that could include changes to the Racket core. (If you change only packages, then raco setup should suffice.)

If you need even more control over the build, carry on to Even More Instructions: Building Racket Pieces further below.

1.6 More Instructions: Building Racket CS and Racket BC

The default build of Racket, also known as Racket CS, uses and incorporates Chez Scheme. Chez Scheme sources are included in the Racket repository.

Building Racket CS requires either an existing Racket or pb (portable bytecode) boot files for Chez Scheme. By default, pb boot files are downloaded from a separate Git repository by make. If you have Racket v7.1 or later, then you can choose instead to bootstrap using that Racket implementation with

  make cs RACKET=racket

The make bc target (or make bc-as-is for a rebuild, or nmake win-bc on Windows with Visual Studio) builds an older variant of Racket, called Racket BC, which does not use Chez Scheme. By default, the executables for the Racket BC variant all have a bc or BC suffix, and they coexist with a Racket CS build by keeping compiled files in a "bc" subdirectory of the "compiled" directory. You can remove the bc suffix and the subdirectory in "compiled" by providing RACKETBC_SUFFIX="" to make bc.

Along similar lines, you can add a cs suffix to the Racket CS executables and cause them to use a machine-specific subdirectory of "compiled" by providing RACKETCS_SUFFIX="cs" to make or make cs.

Use make both to build both Racket BC and Racket CS, where packages are updated and documentation is built only once (using Racket CS).

1.7 Even More Instructions: Building Racket Pieces

Instead of just using make in-place or make unix-style, you can take more control over the build by understanding how the pieces fit together.

1.7.1 Building Minimal Racket

Instead of using the top-level makefile, you can go into "racket/src" and follow the "README.txt" there, which gives you more configuration options.

If you don’t want any special configuration and you just want the base build, you can use make base (or nmake win-base) with the top-level makefile.

Minimal Racket does not require additional native libraries to run, but under Windows, encoding-conversion, extflonum, and SSL functionality is hobbled until native libraries from the "racket-win32-i386" or "racket-win32-x86_64" package are installed.

On all platforms, from the top-level makefile, the PLT_SETUP_OPTIONS makefile variable is passed on to the raco setup that is used to build minimal-Racket libraries. See the documentation for raco setup for information on the options. (The JOB_OPTIONS makefile variable is also passed on, but it is meant to be set by some makefile targets when CPUS is non-empty.)

For cross compilation, add configuration options to CONFIGURE_ARGS="options" as described in the "README.txt" of "racket/src", but also add a PLAIN_RACKET=... argument for the top-level makefile to specify the same executable as in an --enable-racket=... for configure. In general, the PLAIN_RACKET setting should have the form PLAIN_RACKET="exec -C" to ensure that cross-compilation mode is used and that any foreign libraries needed for build time can be found, but many cross-compilation scenarios work without -C.

Specify SETUP_MACHINE_FLAGS=options to set Racket flags that control the target machine of compiled bytecode for raco setup and raco pkg install. For example SETUP_MACHINE_FLAGS=-M causes the generated bytecode to be machine-independent, which is mainly useful when the generated installation will be used as a template for other platforms or for cross-compilation.

1.7.2 Installing Packages

After you’ve built and installed minimal Racket, you could install packages via the package-catalog server, completely ignoring the content of "pkgs".

If you want to install packages manually out of the "pkgs" directory, the local-catalog target creates a catalog as "racket/local/catalog" that merges the currently configured catalog’s content with pointers to the packages in "pkgs". A Unix-style build works that way: it builds and installs minimal Racket, and then it installs packages out of a catalog that is created by make local-catalog.

To add a package catalog that is used after the content of "pkgs" but before the default package catalogs, specify the catalog’s URL as the SRC_CATALOG makefile variable:

  make .... SRC_CATALOG=url

1.7.3 Linking Packages for In-Place Development Mode

With an in-place build, you can edit packages within "pkgs" directly or update those packages with git pull plus raco setup, since the packages are installed with the equivalent of raco pkg install -i --static-link path.

Instead of actually using raco pkg install --static-link ..., the pkgs-catalog makefile target creates a catalog that points to the packages in "pkgs", and the catalog indicates that the packages are to be installed as links. The pkgs-catalog target further configures the new catalog as the first one to check when installing packages. The configuration adjustment is made only if no configuration file "racket/etc/config.rktd" exists already.

All other packages (as specified by PKGS) are installed via the configured package catalog. They are installed in installation scope, but the content of "racket/share/pkgs" is not meant to be edited. To reinstall a package in a mode suitable for editing and manipulation with Git tools, use

  raco pkg update --clone extra-pkgs/pkg-name

The "extra-pkgs" directory name is a convention that is supported by a ".gitignore" entry in the repository root.