aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile18
-rwxr-xr-xscripts/genconfig.sh16
-rwxr-xr-xscripts/install.sh45
-rwxr-xr-xscripts/make.sh15
-rwxr-xr-xscripts/single.sh4
-rw-r--r--www/code.html20
6 files changed, 64 insertions, 54 deletions
diff --git a/Makefile b/Makefile
index 40e95b1b..c7237405 100644
--- a/Makefile
+++ b/Makefile
@@ -15,11 +15,11 @@ KCONFIG_CONFIG ?= .config
toybox_stuff: $(KCONFIG_CONFIG) *.[ch] lib/*.[ch] toys/*.h toys/*/*.c scripts/*.sh
-toybox toybox_unstripped: toybox_stuff
+toybox generated/unstripped/toybox: toybox_stuff
scripts/make.sh
.PHONY: clean distclean baseline bloatcheck install install_flat \
- uinstall uninstall_flat test tests help toybox_stuff change \
+ uinstall uninstall_flat tests help toybox_stuff change \
list list_working list_pending
include kconfig/Makefile
@@ -31,11 +31,11 @@ generated/Config.in: toys/*/*.c scripts/genconfig.sh
scripts/genconfig.sh
# Development targets
-baseline: toybox_unstripped
- @cp toybox_unstripped toybox_old
+baseline: generated/unstripped/toybox
+ @cp generated/unstripped/toybox generated/unstripped/toybox_old
-bloatcheck: toybox_old toybox_unstripped
- @scripts/bloatcheck toybox_old toybox_unstripped
+bloatcheck: toybox_old generated/unstripped/toybox
+ @scripts/bloatcheck generated/unstripped/toybox_old generated/unstripped/toybox
install_flat:
scripts/install.sh --symlink --force
@@ -53,13 +53,11 @@ change:
scripts/change.sh
clean::
- rm -rf toybox toybox_unstripped generated change .singleconfig*
+ rm -rf toybox generated change .singleconfig*
distclean: clean
rm -f toybox_old .config* .singlemake
-test: tests
-
tests:
scripts/test.sh
@@ -71,7 +69,7 @@ help::
@echo ' baseline - Create toybox_old for use by bloatcheck.'
@echo ' bloatcheck - Report size differences between old and current versions'
@echo ' test_COMMAND - Run tests for COMMAND (test_ps, test_cat, etc.)'
- @echo ' test - Run test suite against all compiled commands.'
+ @echo ' tests - Run test suite against all compiled commands.'
@echo ' export TEST_HOST=1 to test host command, VERBOSE=1'
@echo ' to show diff, VERBOSE=fail to stop after first failure.'
@echo ' clean - Delete temporary files.'
diff --git a/scripts/genconfig.sh b/scripts/genconfig.sh
index 5e7d1df2..e9bb5141 100755
--- a/scripts/genconfig.sh
+++ b/scripts/genconfig.sh
@@ -146,12 +146,10 @@ do
[ "${FILE/pending//}" != "$FILE" ] &&
PENDING="$PENDING $NAME" ||
WORKING="$WORKING $NAME"
-done > .singlemake &&
-echo -e "clean::\n\trm -f $WORKING $PENDING" >> .singlemake &&
-echo -e "list:\n\t@echo $(echo $WORKING $PENDING | tr ' ' '\n' | sort | xargs)"\
- >> .singlemake &&
-echo -e "list_working:\n\t@echo $(echo $WORKING | tr ' ' '\n' | sort | xargs)" \
- >> .singlemake &&
-echo -e "list_pending:\n\t@echo $(echo $PENDING | tr ' ' '\n' | sort | xargs)" \
- >> .singlemake
-)
+done &&
+echo -e "clean::\n\trm -f $WORKING $PENDING" &&
+echo -e "list:\n\t@echo $(echo $WORKING $PENDING | tr ' ' '\n' | sort | xargs)" &&
+echo -e "list_working:\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'
+) > .singlemake
diff --git a/scripts/install.sh b/scripts/install.sh
index 8891a314..961341e6 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -4,31 +4,24 @@
source ./configure
-# Parse command line arguments.
+[ -z "$PREFIX" ] && PREFIX="/usr/toybox"
-[ -z "$PREFIX" ] && PREFIX="."
+# Parse command line arguments.
LONG_PATH=""
while [ ! -z "$1" ]
do
# Create symlinks instead of hardlinks?
-
[ "$1" == "--symlink" ] && LINK_TYPE="-s"
# Uninstall?
-
- [ "$1" == "--uninstall" ] && UNINSTALL=1
+ [ "$1" == "--uninstall" ] && UNINSTALL=Uninstall
# Delete destination command if it exists?
-
[ "$1" == "--force" ] && DO_FORCE="-f"
# Use {,usr}/{bin,sbin} paths instead of all files in one directory?
-
- if [ "$1" == "--long" ]
- then
- LONG_PATH="bin/"
- fi
+ [ "$1" == "--long" ] && LONG_PATH="bin/"
shift
done
@@ -38,22 +31,24 @@ echo "Compile instlist..."
$DEBUG $HOSTCC -I . scripts/install.c -o generated/instlist || exit 1
COMMANDS="$(generated/instlist $LONG_PATH)"
-echo "Install commands..."
+echo "${UNINSTALL:-Install} commands..."
# Copy toybox itself
if [ -z "$UNINSTALL" ]
then
- mkdir -p ${PREFIX}/${LONG_PATH} || exit 1
+ mkdir -p "${PREFIX}/${LONG_PATH}" &&
+ rm -f "${PREFIX}/${LONG_PATH}/toybox" &&
cp toybox ${PREFIX}/${LONG_PATH} || exit 1
else
- rm "${PREFIX}/${LONG_PATH}/toybox" 2>/dev/null
- rmdir "${PREFIX}/${LONG_PATH}" 2>/dev/null
+ rm -f "${PREFIX}/${LONG_PATH}/toybox" 2>/dev/null
fi
-cd "${PREFIX}"
+cd "$PREFIX" || exit 1
# Make links to toybox
+EXIT=0
+
for i in $COMMANDS
do
# Figure out target of link
@@ -64,20 +59,19 @@ do
else
# Create subdirectory for command to go in (if necessary)
- DOTPATH="$(echo $i | sed 's@\(.*/\).*@\1@')"
+ DOTPATH="$(dirname "$i")"/
if [ -z "$UNINSTALL" ]
then
mkdir -p "$DOTPATH" || exit 1
- else
- rmdir "$DOTPATH" 2>/dev/null
fi
if [ -z "$LINK_TYPE" ]
then
- dotpath="bin/"
+ DOTPATH="bin/"
else
if [ "$DOTPATH" != "$LONG_PATH" ]
then
+ # For symlinks we need ../../bin style relative paths
DOTPATH="$(echo $DOTPATH | sed -e 's@[^/]*/@../@g')"$LONG_PATH
else
DOTPATH=""
@@ -86,7 +80,12 @@ do
fi
# Create link
- [ -z "$UNINSTALL" ] &&
- ln $DO_FORCE $LINK_TYPE ${DOTPATH}toybox $i ||
- rm $i 2>/dev/null
+ if [ -z "$UNINSTALL" ]
+ then
+ ln $DO_FORCE $LINK_TYPE ${DOTPATH}toybox $i || EXIT=1
+ else
+ rm -f $i || EXIT=1
+ fi
done
+
+exit $EXIT
diff --git a/scripts/make.sh b/scripts/make.sh
index 8be4c3be..d3dc8eb9 100755
--- a/scripts/make.sh
+++ b/scripts/make.sh
@@ -7,7 +7,9 @@ export LC_ALL=C
set -o pipefail
source ./configure
-[ -z "$KCONFIG_CONFIG" ] && KCONFIG_CONFIG=".config"
+[ -z "$KCONFIG_CONFIG" ] && KCONFIG_CONFIG=.config
+[ -z "$OUTNAME" ] && OUTNAME=toybox
+UNSTRIPPED="generated/unstripped/$(basename "$OUTNAME")"
# Since each cc invocation is short, launch half again as many processes
# as we have processors so they don't exit faster than we can start them.
@@ -30,7 +32,7 @@ isnewer()
echo "Generate headers from toys/*/*.c..."
-mkdir -p generated
+mkdir -p generated/unstripped
if isnewer generated/Config.in toys
then
@@ -111,7 +113,7 @@ fi
# LINK needs optlibs.dat, above
-LINK="$(echo $LDOPTIMIZE $LDFLAGS -o toybox_unstripped -Wl,--as-needed $(cat generated/optlibs.dat))"
+LINK="$(echo $LDOPTIMIZE $LDFLAGS -o "$UNSTRIPPED" -Wl,--as-needed $(cat generated/optlibs.dat))"
genbuildsh > generated/build.sh && chmod +x generated/build.sh || exit 1
echo "Make generated/config.h from $KCONFIG_CONFIG."
@@ -293,9 +295,10 @@ done
[ $DONE -ne 0 ] && exit 1
do_loudly $BUILD $LFILES $LINK || exit 1
-if [ ! -z "$NOSTRIP" ] || ! do_loudly ${CROSS_COMPILE}strip toybox_unstripped -o toybox
+if [ ! -z "$NOSTRIP" ] ||
+ ! do_loudly ${CROSS_COMPILE}strip "$UNSTRIPPED" -o "$OUTNAME"
then
- echo "strip failed, using unstripped" && cp toybox_unstripped toybox ||
+ echo "strip failed, using unstripped" && cp "$UNSTRIPPED" "$OUTNAME" ||
exit 1
fi
@@ -303,6 +306,6 @@ fi
# its output the way SUSv4 suggests it do so. While we're at it, make sure
# we don't have the "w" bit set so things like bzip2's "cp -f" install don't
# overwrite our binary through the symlink.
-do_loudly chmod 555 toybox || exit 1
+do_loudly chmod 555 "$OUTNAME" || exit 1
echo
diff --git a/scripts/single.sh b/scripts/single.sh
index e3c9ebbd..cadb2fcd 100755
--- a/scripts/single.sh
+++ b/scripts/single.sh
@@ -38,6 +38,6 @@ do
echo "# CONFIG_TOYBOX is not set" >> "$KCONFIG_CONFIG" &&
grep "CONFIG_TOYBOX_" .config >> "$KCONFIG_CONFIG" &&
- make &&
- mv -f toybox $PREFIX$i || exit 1
+ rm -f "$PREFIX$i" &&
+ OUTNAME="$PREFIX$i" scripts/make.sh || exit 1
done
diff --git a/www/code.html b/www/code.html
index c133611c..c0566b4c 100644
--- a/www/code.html
+++ b/www/code.html
@@ -55,6 +55,13 @@ to the environment will take precedence.</p>
I.E. "what to build", and "configure" describes the build and installation
environment, I.E. "how to build it".)</p>
+<p>By default "make install" puts files in /usr/toybox. Adding this to the
+$PATH is up to you. The environment variable $PREFIX can change the
+install location, ala "PREFIX=/usr/local/bin make install".</p>
+
+<p>If you need an unstripped (debug) version of any of these binaries,
+look in generated/unstripped.</p>
+
<p><h1><a name="running"><a href="#running">Running a command</a></h1></p>
<h2>main</h2>
@@ -444,10 +451,15 @@ as specified by the options field off this command's toy_list entry. See
the get_optargs() description in lib/args.c for details.</p>
</li>
-<li><b>char toybuf[4096]</b> - a common scratch space buffer so
-commands don't need to allocate their own. Any command is free to use this,
-and it should never be directly referenced by functions in lib/ (although
-commands are free to pass toybuf in to a library function as an argument).</li>
+<li><b>char toybuf[4096]</b> - a common scratch space buffer guaranteed
+to start zeroed, so commands don't need to allocate/initialize their own.
+Any command is free to use this, and it should never be directly referenced
+by functions in lib/ (although commands are free to pass toybuf in to a
+library function as an argument).</li>
+
+<li><b>char libbuf[4096]</b> - like toybuf, but for use by common code in
+lib/*.c. Commands should never directly reference libbuf, and library
+could should nnever directly reference toybuf.</li>
</ul>
<p>The following functions are defined in main.c:</p>