From 84ef9083fbb8435031b0f0ff8ac03324ce2d0e6f Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 19 Jan 2019 16:58:04 -0600 Subject: Factor out scripts/portability.sh and have genconfig.sh use it to find sed/gsed. --- scripts/genconfig.sh | 7 ++++--- scripts/make.sh | 13 +++++-------- scripts/portability.sh | 6 ++++++ 3 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 scripts/portability.sh (limited to 'scripts') diff --git a/scripts/genconfig.sh b/scripts/genconfig.sh index 3887b077..c4940dfd 100755 --- a/scripts/genconfig.sh +++ b/scripts/genconfig.sh @@ -6,6 +6,7 @@ mkdir -p generated source configure +source scripts/portability.sh probecc() { @@ -129,7 +130,7 @@ genconfig() do # Grab the config block for Config.in echo "# $i" - sed -n '/^\*\//q;/^config [A-Z]/,$p' $i || return 1 + $SED -n '/^\*\//q;/^config [A-Z]/,$p' $i || return 1 echo done @@ -144,7 +145,7 @@ genconfig > generated/Config.in || rm generated/Config.in toys() { grep 'TOY(.*)' "$@" | grep -v TOYFLAG_NOFORK | grep -v "0))" | \ - sed -En 's/([^:]*):.*(OLD|NEW)TOY\( *([a-zA-Z][^,]*) *,.*/\1:\3/p' + $SED -En 's/([^:]*):.*(OLD|NEW)TOY\( *([a-zA-Z][^,]*) *,.*/\1:\3/p' } WORKING= @@ -163,5 +164,5 @@ done && echo -e "clean::\n\trm -f $WORKING $PENDING" && echo -e "list:\n\t@echo $(echo $WORKING | tr ' ' '\n' | sort | xargs)" && echo -e "list_pending:\n\t@echo $(echo $PENDING | tr ' ' '\n' | sort | xargs)" && -echo -e ".PHONY: $WORKING $PENDING" | sed 's/ \([^ ]\)/ test_\1/g' +echo -e ".PHONY: $WORKING $PENDING" | $SED 's/ \([^ ]\)/ test_\1/g' ) > .singlemake diff --git a/scripts/make.sh b/scripts/make.sh index 45d6f1ca..388af651 100755 --- a/scripts/make.sh +++ b/scripts/make.sh @@ -6,6 +6,7 @@ export LANG=c export LC_ALL=C set -o pipefail source ./configure +source scripts/portability.sh [ ! -z "$CROSS_COMPILE" ] && [ ! -e "$CROSS_COMPILE"cc ] && echo "missing ${CROSS_COMPILE}cc" && exit 1 @@ -15,12 +16,7 @@ source ./configure UNSTRIPPED="generated/unstripped/$(basename "$OUTNAME")" # Try to keep one more cc invocation going than we have processors -[ -z "$CPUS" ] && CPUS=$(($(nproc)+1)) - -if [ -z "$SED" ] -then - [ ! -z "$(which gsed 2>/dev/null)" ] && SED=gsed || SED=sed -fi +[ -z "$CPUS" ] && CPUS=$(($(nproc 2>/dev/null)+1)) # Respond to V= by echoing command lines as well as running them DOTPROG= @@ -102,7 +98,7 @@ genbuildsh() } if ! cmp -s <(genbuildsh 2>/dev/null | head -n 6 ; echo LINK="'"$LDOPTIMIZE $LDFLAGS) \ - <(head -n 7 generated/build.sh 2>/dev/null | sed '7s/ -o .*//') + <(head -n 7 generated/build.sh 2>/dev/null | $SED '7s/ -o .*//') then echo -n "Library probe" @@ -135,7 +131,8 @@ then # This long and roundabout sed invocation is to make old versions of sed # happy. New ones have '\n' so can replace one line with two without all - # the branches and tedious mucking about with hold space. + # the branches and tedious mucking about with hyperspace. + # TODO: clean this up to use modern stuff. $SED -n \ -e 's/^# CONFIG_\(.*\) is not set.*/\1/' \ diff --git a/scripts/portability.sh b/scripts/portability.sh new file mode 100644 index 00000000..fddd84ec --- /dev/null +++ b/scripts/portability.sh @@ -0,0 +1,6 @@ +# sourced to find alternate names for things + +if [ -z "$SED" ] +then + [ ! -z "$(which gsed 2>/dev/null)" ] && SED=gsed || SED=sed +fi -- cgit v1.2.3