3.5.23 ‘makefile-script’ - create makefile script
Usage: (makefile-script text)
This function will take ordinary shell script text and reformat it
so that it will work properly inside of a makefile shell script.
Not every shell construct can be supported; the intent is to have
most ordinary scripts work without much, if any, alteration.
The following transformations are performed on the source text:
-
Trailing whitespace on each line is stripped.
-
Except for the last line, the string, " ; \\" is appended to the end of
every line that does not end with certain special characters or keywords.
Note that this will mutilate multi-line quoted strings, but
make
renders it impossible to use multi-line constructs anyway.
-
If the line ends with a backslash, it is left alone.
-
If the line ends with a semi-colon, conjunction operator, pipe (vertical
bar) or one of the keywords "then", "else" or "in", then a space and a
backslash is added, but no semi-colon.
-
The dollar sign character is doubled, unless it immediately precedes an
opening parenthesis or the single character make macros ’*’, ’<’, ’@’,
’?’ or ’%’. Other single character make macros that do not have enclosing
parentheses will fail. For shell usage of the "$@", "$?" and "$*"
macros, you must enclose them with curly braces, e.g., "${?}".
The ksh construct
$(<command>)
will not work. Though some
make
s accept ${var}
constructs, this function will
assume it is for shell interpretation and double the dollar character.
You must use $(var)
for all make
substitutions.
-
Double dollar signs are replaced by four before the next character
is examined.
-
Every line is prefixed with a tab, unless the first line
already starts with a tab.
-
The newline character on the last line, if present, is suppressed.
-
Blank lines are stripped.
-
Lines starting with "@ifdef", "@ifndef", "@else" and "@endif" are
presumed to be autoconf "sed" expression tags. These lines will be
emitted as-is, with no tab prefix and no line splicing backslash.
These lines can then be processed at configure time with
AC_CONFIG_FILES
sed expressions, similar to:
| sed "/^@ifdef foo/d;/^@endif foo/d;/^@ifndef foo/,/^@endif foo/d"
|
This function is intended to be used approximately as follows:
| $(TARGET) : $(DEPENDENCIES)
<+ (out-push-new) +>
....mostly arbitrary shell script text....
<+ (makefile-script (out-pop #t)) +>
|
Arguments:
text - the text of the script
This document was generated by Bruce Korb on August 21, 2015 using texi2html 1.82.