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
8.12

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 2022/17.0), nmake creates a build in the "racket" directory. If your command-prompt environment is not already configured for Visual Studio to run programs like nmake.exe and cl.exe, you can run "racket/src/worksp/msvcprep.bat" (PowerShell: "racket/src/worksp/msvcprep.ps1"} and provide an argument that selects a build mode: x86 (32-bit Intel/AMD mode), x64 or x86_amd64 (64-bit Intel/AMD mode), or x64_arm64 (64-bit Arm mode). Any use of make described in this build guide should also work with nmake, except as noted.

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" 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" 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". Then, copy or move the content of "dest-dir" to the target root "dir"; take care to preserve file timestamps.

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. A first step of make in-place or make unix-style is to build minimal Racket, and you can read "racket/src/README.txt" for more information, including information about dependencies. (The very first step of a build is to compile Zuo, which is a tiny variant of Racket that drives the rest of the build system.)

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. Release tags starting with v7.1 include a default catalog that corresponds to the release. For earlier versions, the 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.

When make -j n is used to specify parallelism, the build system may be able to propagate that choice to intermediate steps and the raco setup part. A more portable alternative is to supply the JOBS variable:

  make JOBS=n

Setting JOBS works with other targets, including make unix-style. For backward compatibility, CPUS is recognized as an alias for JOBS.

Use make 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 minimal Racket. (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 BOOTFILE_RACKET=racket

The make bc target (or make bc-as-is for a rebuild) 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. You can also read "Makefile", which defines and describes many variables that can be supplied via make.

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 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 RACKET=... argument for the top-level makefile instead of using --enable-racket=... for configure.

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.