[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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:

  1. Trailing whitespace on each line is stripped.
  2. 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.
  3. If the line ends with a backslash, it is left alone.
  4. 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.
  5. 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 makes 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.
  6. Double dollar signs are replaced by four before the next character is examined.
  7. Every line is prefixed with a tab, unless the first line already starts with a tab.
  8. The newline character on the last line, if present, is suppressed.
  9. Blank lines are stripped.
  10. 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:

<+ (out-push-new) +>
....mostly arbitrary shell script text....
<+ (makefile-script (out-pop #t)) +>

text - the text of the script

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Bruce Korb on August 21, 2015 using texi2html 1.82.