aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2019-01-19 16:58:04 -0600
committerRob Landley <rob@landley.net>2019-01-19 16:58:04 -0600
commit84ef9083fbb8435031b0f0ff8ac03324ce2d0e6f (patch)
tree6e166523b5c2508837f3ba63392198418baa77ad /scripts
parent81207825c50fa9a4ec1475024543f830dee247fd (diff)
downloadtoybox-84ef9083fbb8435031b0f0ff8ac03324ce2d0e6f.tar.gz
Factor out scripts/portability.sh and have genconfig.sh use it to find sed/gsed.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/genconfig.sh7
-rwxr-xr-xscripts/make.sh13
-rw-r--r--scripts/portability.sh6
3 files changed, 15 insertions, 11 deletions
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