Skip to content

Commit

Permalink
makefile: make bc and cs rules more symmetic
Browse files Browse the repository at this point in the history
Currently, `make` is the same as `make bc`, but the idea is that
`make` can become the same as `make cs` when some other pieces are in
place.

The source of the top-level makefile is now ".makefile", and it's
turned into "Makefile" using "racket/src/makemake.rkt". The
transformation makes non-GNU `make` variants and `nmake` act like GNU
make to propagate variables, which makes abstraction through targets
plus variables (admitedly an abuse of `make`) more reliable and
consistent.

Why abuse `make` this way? Because `make` variants and `nmake` are
similar enough that to constitute a portable scripting language, and
one that conveniently provides a large number of entry points.
  • Loading branch information
mflatt committed Jul 30, 2020
1 parent a4b6ac7 commit 1d9db6e
Show file tree
Hide file tree
Showing 13 changed files with 1,869 additions and 900 deletions.
1,131 changes: 1,131 additions & 0 deletions .makefile

Large diffs are not rendered by default.

1,260 changes: 397 additions & 863 deletions Makefile

Large diffs are not rendered by default.

21 changes: 9 additions & 12 deletions build.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ 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 win32-in-place` creates a build in the `"racket"`
directory. For information on configuring your command-line environment
for Visual Studio, see `"racket/src/worksp/README.txt"`.
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"`.

On Windows with MinGW, use `make PLAIN_RACKET=racket/racket`, since
MinGW uses Unix-style tools but generates a Windows-layout Racket build.
Expand Down Expand Up @@ -166,10 +166,7 @@ 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_qq="<options>"` to `make in-place` or `make unix-style`.
(The `_qq` suffix on the variable name `CONFIGURE_ARGS_qq` is a
convention that indicates that single- and double-quote marks are
allowed in the value.)
`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
Expand Down Expand Up @@ -213,7 +210,7 @@ and the `raco setup` part, use
which recurs with `make -j <n> JOB_OPTIONS="-j <n>"`. Setting `CPUS`
also works with `make unix-style`.

Use `make as-is` (or `nmake win32-as-is`) to perform the same build
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
Expand All @@ -228,7 +225,7 @@ below.
### 1.6. More Instructions: Building Racket on Chez Scheme

The `make cs` target (or `make cs-as-is` for a rebuild, or `nmake
win32-cs` on Windows with Visual Studio) builds a variant of Racket that
win-cs` on Windows with Visual Studio) builds a variant of Racket that
runs on Chez Scheme. By default, the executables for the Racket CS
variant all have a `cs` or `CS` suffix, and they coexist with a Racket
BC build by keeping compiled files in a machine-specific subdirectory of
Expand Down Expand Up @@ -261,8 +258,8 @@ 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 win32-base`) with the
top-level makefile.
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
Expand All @@ -276,7 +273,7 @@ libraries. See the documentation for `raco setup` for information on the
options.

For cross compilation, add configuration options to
`CONFIGURE_ARGS_qq="<options>"` as described in the `"README.txt"` of
`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`
Expand Down
16 changes: 7 additions & 9 deletions pkgs/racket-build-guide/build.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ On Unix (including Linux) and Mac OS, @exec{make} (or @exec{make in-place})
creates a build in the @filepath{racket} directory.

On Windows with Microsoft Visual Studio (any version between 2008/9.0
and 2019/16.0), @exec{nmake win32-in-place} creates a build in the
and 2019/16.0), @exec{nmake win} creates a build in the
@filepath{racket} directory. For information on configuring your
command-line environment for Visual Studio, see
@filepath{racket/src/worksp/README.txt}.
Expand Down Expand Up @@ -144,10 +144,8 @@ information.

If you would like to provide arguments to @exec{configure} for the
minimal Racket build, then you can supply them with by adding
@exec{CONFIGURE_ARGS_qq="@nonterm{options}"} to @exec{make in-place}
or @exec{make unix-style}. (The @tt{_qq} suffix on the variable name
@tt{CONFIGURE_ARGS_qq} is a convention that indicates that single- and
double-quote marks are allowed in the value.)
@exec{CONFIGURE_ARGS="@nonterm{options}"} to @exec{make in-place}
or @exec{make unix-style}.

The @filepath{pkgs} directory contains packages that are tied to the
Racket core implementation and are therefore kept in the same Git
Expand Down Expand Up @@ -193,7 +191,7 @@ which recurs with @exec{make -j @nonterm{n} JOB_OPTIONS="-j
@nonterm{n}"}. Setting @exec{CPUS} also works with @exec{make
unix-style}.

Use @exec{make as-is} (or @exec{nmake win32-as-is}) to perform the
Use @exec{make as-is} (or @exec{nmake win-as-is}) to perform the
same build actions as @exec{make in-place}, but without consulting any
package catalogs or package sources to install or update packages. In
other words, use @exec{make as-is} to rebuild after local changes that
Expand All @@ -208,7 +206,7 @@ If you need even more control over the build, carry on to
@section[#:tag "build-cs"]{More Instructions: Building Racket on Chez Scheme}

The @exec{make cs} target (or @exec{make cs-as-is} for a rebuild, or
@exec{nmake win32-cs} on Windows with Visual Studio) builds a variant
@exec{nmake win-cs} on Windows with Visual Studio) builds a variant
of Racket that runs on Chez Scheme. By default, the executables for
the Racket CS variant all have a @litchar{cs} or @litchar{CS}
suffix, and they coexist with a Racket BC build by keeping
Expand Down Expand Up @@ -247,7 +245,7 @@ Instead of using the top-level makefile, you can go into
which gives you more configuration options.

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

Minimal Racket does not require additional native libraries to run,
Expand All @@ -263,7 +261,7 @@ minimal-Racket libraries. See the documentation for @exec{raco setup}
for information on the options.

For cross compilation, add configuration options to
@exec{CONFIGURE_ARGS_qq="@nonterm{options}"} as described in the
@exec{CONFIGURE_ARGS="@nonterm{options}"} as described in the
@filepath{README.txt} of @filepath{racket/src}, but also add a
@exec{PLAIN_RACKET=...} argument for the top-level makefile to specify
the same executable as in an @exec{--enable-racket=...} for
Expand Down
7 changes: 6 additions & 1 deletion pkgs/racket-doc/scribblings/reference/startup.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ flags:

@itemize[

@item{@FlagFirst{Z} : The argument following this flag is ignored.
This flag can be handy in some impoverished scripting environments
to replace or cancel another command-line argument.}

@item{@FlagFirst{-} : No argument following this flag is itself used
as a flag.}

Expand Down Expand Up @@ -462,7 +466,8 @@ Extra arguments following the last option are available from the
@indexed-racket[current-command-line-arguments] parameter.

@history[#:changed "6.90.0.17" @elem{Added @Flag{O}/@DFlag{stdout}.}
#:changed "7.1.0.5" @elem{Added @Flag{M}/@DFlag{compile-any}.}]
#:changed "7.1.0.5" @elem{Added @Flag{M}/@DFlag{compile-any}.}
#:changed "7.8.0.6" @elem{Added @Flag{Z}.}]

@; ----------------------------------------------------------------------

Expand Down
22 changes: 16 additions & 6 deletions racket/src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,26 @@ local/Makefile:

# Install (common) ----------------------------------------

# Intended for configuration by an external makefile that drives this one:
SELF_ROOT_CONFIG_FLAG = -Z
SELF_ROOT_CONFIG_DIR = ../../../build/config
SELF_ROOT_CONFIG = $(SELF_ROOT_CONFIG_FLAG) $(SELF_ROOT_CONFIG_DIR)

INST_CONFIG = -X @DIRCVTPRE@"$(DESTDIR)$(collectsdir)"@DIRCVTPOST@ -G @DIRCVTPRE@"$(DESTDIR)$(configdir)"@DIRCVTPOST@
SETUP_RACKET_FLAGS = $(INST_CONFIG) $(SETUP_MACHINE_FLAGS) $(SELF_RACKET_FLAGS) @INSTALL_SETUP_RACKET_FLAGS@
SETUP_RACKET_FLAGS = $(INST_CONFIG) $(SETUP_MACHINE_FLAGS) $(SELF_ROOT_CONFIG) @INSTALL_SETUP_RACKET_FLAGS@
SETUP_SETUP_FLAGS = @INSTALL_SETUP_FLAGS@ $(PLT_SETUP_OPTIONS) $(PLT_ISO)
SETUP_ARGS = $(SETUP_RACKET_FLAGS) -N "raco" -l- setup $(SETUP_SETUP_FLAGS)

# Needed for non-GNU makes:
PROPAGATE_VARIABLES = SELF_ROOT_CONFIG_FLAG="$(SELF_ROOT_CONFIG_FLAG)" \
PLT_SETUP_OPTIONS="$(PLT_SETUP_OPTIONS)" \
SETUP_MACHINE_FLAGS="$(SETUP_MACHINE_FLAGS)"

install:
$(MAKE) install-@MAIN_MAKE_TARGET@
$(MAKE) install-@MAIN_MAKE_TARGET@ $(PROPAGATE_VARIABLES)

install-racket-variant:
$(MAKE) install-@MAIN_VARIANT@
$(MAKE) install-@MAIN_VARIANT@ $(PROPAGATE_VARIABLES)

plain-install:
if [ "$(DESTDIR)" != "" ]; then \
Expand Down Expand Up @@ -264,17 +274,17 @@ install-cs-common:
$(MAKE) install-common-first
cd cs/c; $(MAKE) plain-install
$(MAKE) install-common-middle MIDDLE_POST_COLLECTS=install-no-post-collects
cd cs/c; $(MAKE) $(CS_SETUP_INSTALL_TARGET)
cd cs/c; $(MAKE) $(CS_SETUP_INSTALL_TARGET) $(PROPAGATE_VARIABLES)
$(MAKE) install-common-last

install-racketcs:
$(MAKE) install-cs-common
$(MAKE) install-cs-common $(PROPAGATE_VARIABLES)

plain-install-racketcs:
$(MAKE) install-cs-common CS_SETUP_INSTALL_TARGET=no-setup-install

install-cs:
$(MAKE) install-racketcs
$(MAKE) install-racketcs $(PROPAGATE_VARIABLES)

plain-install-cs:
$(MAKE) plain-install-racketcs
Expand Down
22 changes: 16 additions & 6 deletions racket/src/cs/c/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -409,22 +409,32 @@ repack-no-install-libs:
# ----------------------------------------
# Install

install@NOT_MINGW@:
$(MAKE) plain-install
$(MAKE) setup-install

# RUN_RACKET typically redirects to RUN_THIS_RACKET, but it can also
# redirect to a compatible existing Racket executable (e.g., for
# cross-compilation)
RUN_THIS_RACKET = $(DESTDIR)$(bindir)/racket$(CS_INSTALLED)

# Intended for configuration by an external makefile that drives this one:
SELF_ROOT_CONFIG_FLAG = -Z
SELF_ROOT_CONFIG_DIR = ../../../../../build/config
SELF_ROOT_CONFIG = $(SELF_ROOT_CONFIG_FLAG) $(SELF_ROOT_CONFIG_DIR)

INST_CONFIG = -X "$(DESTDIR)$(collectsdir)" -G "$(DESTDIR)$(configdir)"
SETUP_RACKET_FLAGS = $(INST_CONFIG) $(SETUP_MACHINE_FLAGS) $(SELF_RACKET_FLAGS) @INSTALL_SETUP_RACKET_FLAGS@
SETUP_RACKET_FLAGS = $(INST_CONFIG) $(SETUP_MACHINE_FLAGS) $(SELF_ROOT_CONFIG) @INSTALL_SETUP_RACKET_FLAGS@
SETUP_SETUP_FLAGS = @INSTALL_SETUP_FLAGS@ $(PLT_SETUP_OPTIONS) $(PLT_ISO)
SETUP_ARGS = $(SETUP_RACKET_FLAGS) -N "raco" -l- setup $(SETUP_SETUP_FLAGS)

# Needed for non-GNU makes:
PROPAGATE_VARIABLES = SELF_ROOT_CONFIG_FLAG="$(SELF_ROOT_CONFIG_FLAG)" \
PLT_SETUP_OPTIONS="$(PLT_SETUP_OPTIONS)" \
SETUP_MACHINE_FLAGS="$(SETUP_MACHINE_FLAGS)"

install@NOT_MINGW@:
$(MAKE) plain-install
$(MAKE) setup-install $(PROPAGATE_VARIABLES)

setup-install:
@RUN_RACKET@ $(SELF_RACKET_FLAGS) $(SETUP_ARGS)
@RUN_RACKET@ $(SELF_ROOT_CONFIG) $(SETUP_ARGS)

no-setup-install:
echo done
Expand Down
2 changes: 1 addition & 1 deletion racket/src/cs/c/configure
Original file line number Diff line number Diff line change
Expand Up @@ -4890,10 +4890,10 @@ if test "${enable_racket}" != "" ; then
# Racket used only for generating Chez Scheme boot files
if test "${CROSS_MODE}" = "cross" ; then
RACKET="${enable_racket}"
SETUP_BOOT_MODE=--chain
else
BOOTFILE_RACKET="${enable_racket}"
fi
SETUP_BOOT_MODE=--chain
fi

if test "${enable_compress}" != "no" ; then
Expand Down
2 changes: 1 addition & 1 deletion racket/src/cs/c/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,10 @@ if test "${enable_racket}" != "" ; then
# Racket used only for generating Chez Scheme boot files
if test "${CROSS_MODE}" = "cross" ; then
RACKET="${enable_racket}"
SETUP_BOOT_MODE=--chain
else
BOOTFILE_RACKET="${enable_racket}"
fi
SETUP_BOOT_MODE=--chain
fi

if test "${enable_compress}" != "no" ; then
Expand Down
3 changes: 3 additions & 0 deletions racket/src/cs/main.sps
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,9 @@
(flags-loop null (see saw 'non-config))]
[("-j" "--no-jit")
(loop (cdr args))]
[("-Z")
(let-values ([(ignored rest-args) (next-arg "argument to ignore" arg within-arg args)])
(flags-loop rest-args saw))]
[("-h" "--help")
(show-help)
(exit)]
Expand Down
Loading

0 comments on commit 1d9db6e

Please sign in to comment.