make3_80-sh - Executes commands written for GNU make V3.80
make3_80-sh [options] -- -c command
make3_80-sh -H
In order to comply with POSIX GNU make V3.81 introduced a change in how backslash-newline combinations in commands are handled. Whereas up to GNU make V3.80 backslash-newlines are removed from a command line, GNU make V3.81 preserves backslash-newlines giving them to the shell.
If you have a Makefile written for GNU make <= V3.80 then this may contain backslash-newlines which are unexcpected when executed by GNU make V3.81.
Consider the following example:
ok: echo first ; \ echo second
In V3.80 the shell sees
echo first ; echo second
In V3.81 the shell sees
echo first ; \ echo second
This example is not a problem because the shell interprets the backslash-newline correctly.
In the next example, however, the semantic of the command is changed:
fail: echo 'first\n\ second'
In V3.80 the shell sees
echo 'first\nsecond'
In V3.81 the shell sees
echo 'first\n\ second'
Because the backslash-newline is part of a quoted string the shell takes it literally and adds another line to the output.
This effect is heavy for longer perl scripts because they see the backslash-newlines and cannot interpret them correctly. This affects older Makefiles which may be hard to do.
make3_80-sh is a drop-in replacement solving this problem. Just put it in the SHELL variable of make and continue to use your Makefiles written for GNU make <= V3.80 with GNU make >= V3.81.
Apart from the solving the problem with old Makefiles make3_80-sh also
works as a migration aid. You can mix commands written for GNU make <= V3.80
with commands written for GNU make >= V3.81. To preserve backslash-newlines
as V3.81 does just put the string 3.81
somewhere before the first
backslash-newline.
An example for a shell command:
for3_81: : "This command is written for GNU make V3.81" ; \ do_something_useful
Or for a Perl command:
for3_81: perl -e '"This command is written for GNU make V3.81" ; # \ do_something_useful
When executed under GNU make <= V3.80 the backslash-newlines are removed probably modifying the intended semantic (see BUGS). Thus when make3_80-sh encounters a marked line and finds no backslash-newlines it emits a warning.
See also option -m/--migrate for more migration options.
This is not really an option but the way make hands the command down to the shell. It must appear last on the command line and in exactly this form.
Give hints for migrating a Makefile written for GNU make <= V3.80 to GNU make >= V3.81. migration-mode may have one of the following values:
quiet
Don't give any migration hints.
warn
If make3_80-sh notices backslash-newline in a command which is not marked by
3.81
in the first line a warning is generated on stderr.
This is a hint that this command probably needs to be migrated to V3.81.
error
Works as warn
but exits with an error probably stopping the calling make.
info
Warn about commands with a 3.81
in the first line.
This is a tool to finish a migration and helps to find places where the marker is which should be removed.
Defaults to quiet
.
Shell to execute. shell is split at whitespace. This way options may be given. There is no way to quote such whitespace.
Defaults to /bin/sh.
Operate verbose. This is mainly for debugging purposes.
Generate the man page for this program on standard output.
If an unknown option such as -. is given, a short usage message is generated.
A typical migration of Makefiles from GNU make <= V3.80 to GNU make >= V3.81 may work like this.
In the Makefile written for GNU make <= V3.80 define SHELL like this
SHELL = make3_80-sh --
If you have a setting for SHELL already use this
SHELL = make3_80-sh --shell 'OLD' --
replacing OLD with the old setting.
With this setting the Makefile should work with GNU make >= V3.81 giving you time for a migration.
When you run the Makefile set the environment variable
MAKE3_80_SH_OPTIONS to --migrate warn
. With this you get an idea of where
you need to migrate commands.
Adapt the commands in your Makefile to work with GNU make >= V3.81. Add a
first line containing 3.81
to all migrated commands.
Set the environment variable MAKE3_80_SH_OPTIONS to --migrate error
and
run your Makefile. Repeat the migration until everything works as expected.
Remove the setting of SHELL in your Makefile or reset it to the old value if you had a setting before.
Until this point Makefile should run with both GNU make <= V3.80 and GNU make >= V3.81.
MAKE3_80_SH_OPTIONS
Contains more command line options which are prepended before the --.
Backslash quotes the next character. Whitespace is used for parsing the value of the variable unless it is quoted.
GNU make <= V3.80 treated backslash-newline very special. In particular the
treatment differed according to the value of SHELL. If SHELL explicitly
or implicitly had a value of /bin/sh
whitespace following the
backslash-newline has been preserved under some conditions. Under other
conditions such trailing whitespace has been replaced by a single blank. If
SHELL had another value such trailing whitespace has always been replaced by
a single blank.
If you set SHELL to make3_80-sh then such trailing whitespace is always replaced by a single blank - although this was not intended. Since effectively this information is lost when make3_80-sh gets control there is no way to solve this problem.
However, if -s/--shell is given with a value different from /bin/sh
then
the V3.80 behavior is emulated.
make
Stefan Merten <stefan@merten-home.de>
This program is licensed under the terms of the GPL. See
http://www.gnu.org/licenses/gpl.txt
See
http://www.merten-home.de/FreeSoftware/make3_80-sh/