3 # Grab default values for $CFLAGS and such.
7 [ -z "$PREFIX" ] && PREFIX="/usr/toybox"
9 # Parse command line arguments.
14 # Create symlinks instead of hardlinks?
15 [ "$1" == "--symlink" ] && LINK_TYPE="-s"
18 [ "$1" == "--uninstall" ] && UNINSTALL=Uninstall
20 # Delete destination command if it exists?
21 [ "$1" == "--force" ] && DO_FORCE="-f"
23 # Use {,usr}/{bin,sbin} paths instead of all files in one directory?
24 [ "$1" == "--long" ] && LONG_PATH="bin/"
29 echo "Compile instlist..."
31 $DEBUG $HOSTCC -I . scripts/install.c -o generated/instlist || exit 1
32 COMMANDS="$(generated/instlist $LONG_PATH)"
34 echo "${UNINSTALL:-Install} commands..."
38 if [ -z "$UNINSTALL" ]
40 mkdir -p "${PREFIX}/${LONG_PATH}" &&
41 rm -f "${PREFIX}/${LONG_PATH}/toybox" &&
42 cp toybox ${PREFIX}/${LONG_PATH} || exit 1
44 rm -f "${PREFIX}/${LONG_PATH}/toybox" 2>/dev/null
46 cd "$PREFIX" || exit 1
48 # Make links to toybox
54 # Figure out target of link
56 if [ -z "$LONG_PATH" ]
60 # Create subdirectory for command to go in (if necessary)
62 DOTPATH="$(dirname "$i")"/
63 if [ -z "$UNINSTALL" ]
65 mkdir -p "$DOTPATH" || exit 1
68 if [ -z "$LINK_TYPE" ]
72 if [ "$DOTPATH" != "$LONG_PATH" ]
74 # For symlinks we need ../../bin style relative paths
75 DOTPATH="$(echo $DOTPATH | sed -e 's@[^/]*/@../@g')"$LONG_PATH
83 if [ -z "$UNINSTALL" ]
85 ln $DO_FORCE $LINK_TYPE ${DOTPATH}toybox $i || EXIT=1