Skip to content

Commit 23784a4

Browse files
committed
configure: set SED to gsed (MacOS et al) or sed (GNU).
We use some GNU sed features and it's easier to require gsed than fix them all (and keep noticing when they break). MacOS comes with gsed already! Signed-off-by: Rusty Russell <[email protected]>
1 parent 992771b commit 23784a4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

configure

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,24 @@ default_python()
8282
done
8383
}
8484

85+
# We want GNU sed, which, among other things, recognizes '\t'.
86+
# We don't want to get confused with some random program called gsed,
87+
# so we actually test.
88+
default_sed()
89+
{
90+
SED_BINS="gsed sed"
91+
for s in $SED_BINS; do
92+
if [ "$(which $s)" != "" ] ; then
93+
if [ "$(printf x | $s 's/x/\t/')" = " " ]; then
94+
echo "$s"
95+
return
96+
fi
97+
fi
98+
done
99+
echo "No valid sed found?" >&2
100+
exit 1
101+
}
102+
85103
# Takes PYTHON var
86104
default_pytest()
87105
{
@@ -184,6 +202,7 @@ set_defaults()
184202
fi
185203
echo CSANFLAGS = $CSANFLAGS
186204
PYTHON=${PYTHON-$(default_python)}
205+
SED=${SED-$(default_sed)}
187206
PYTEST=${PYTEST-$(default_pytest $PYTHON)}
188207
COPTFLAGS=${COPTFLAGS-$(default_coptflags "$DEBUGBUILD")}
189208
CONFIGURATOR_CC=${CONFIGURATOR_CC-$CC}
@@ -212,6 +231,7 @@ usage()
212231
echo " To override compile line for configurator itself"
213232
usage_with_default "PYTEST" "$PYTEST"
214233
usage_with_default "VALGRIND" "$VALGRIND"
234+
usage_with_default "SED" "$SED"
215235

216236
echo "Options include:"
217237
usage_with_default "--prefix=" "$PREFIX"
@@ -554,6 +574,7 @@ add_var SHA256SUM "$SHA256SUM"
554574
add_var FUZZING "$FUZZING"
555575
add_var RUST "$RUST"
556576
add_var PYTHON "$PYTHON"
577+
add_var SED "$SED"
557578

558579
# Hack to avoid sha256 name clash with libwally: will be fixed when that
559580
# becomes a standalone shared lib.

0 commit comments

Comments
 (0)