Subject: Guile 2.2.3 fails to install with BSD sed

From: Ryan Schmidt <[email-masked]>
Date: Thu, 28 Jun 2018 15:14:56 -0500

Guile 2.2.3 fails to install when BSD sed was found by the configure script. It works fine if GNU sed was found.

The error we see is:

sed: -i may not be used with stdin

This problem was reported to MacPorts here:

https://trac.macports.org/ticket/56748

The problem was introduced in this commit:

This problem was introduced in http://git.savannah.gnu.org/cgit/guile.git/commit/libguile/Makefile.am?id=81d2e352663bc5f80734312fec90f250b1fbe2e4

The problem is happening in libguile/Makefile.am which says:

INSTANTIATE =                                                                   \
  $(SED) -e 's,[@]pkgdatadir[@],$(pkgdatadir),g'                                \
         -e 's,[@]pkglibdir[@],$(pkglibdir),g'                                  \
         -e 's,[@]GUILE_EFFECTIVE_VERSION[@],$(GUILE_EFFECTIVE_VERSION),g'      \
         -i

This usage of the -i flag (without an argument) is only compatible with GNU sed. BSD sed requires an argument.

Unfortunately I don't know of a way to specify that there should be no backup file made that is compatible with both GNU and BSD sed. BSD sed requires a space between the flag and the argument if the argument is the empty string, like this: "-i ''"; "-i" and "-i''" are considered errors. Conversely, GNU sed requires "-i" or "-i''"; "-i ''" is an error. The only solution I know of is to specify a nonempty backup file suffix, which will cause a backup file to be created, e.g. "-i.bak".

If you want to be truly portable, I'm told you have to avoid the -i flag entirely, because it's not in POSIX.