3 # Grab default values for $CFLAGS and such.
7 # Parse command line arguments.
9 [ -z "$PREFIX" ] && PREFIX="."
14 # Create symlinks instead of hardlinks?
16 [ "$1" == "--symlink" ] && LINK_TYPE="-s"
20 [ "$1" == "--uninstall" ] && UNINSTALL=1
22 # Delete destination command if it exists?
24 [ "$1" == "--force" ] && DO_FORCE="-f"
26 # Use {,usr}/{bin,sbin} paths instead of all files in one directory?
28 if [ "$1" == "--long" ]
36 echo "Compile instlist..."
38 $DEBUG $HOSTCC $CCFLAGS -I . scripts/install.c -o instlist || exit 1
39 COMMANDS="$(./instlist $LONG_PATH)"
41 echo "Install commands..."
45 if [ -z "$UNINSTALL" ]
47 mkdir -p ${PREFIX}/${LONG_PATH} || exit 1
48 cp toybox ${PREFIX}/${LONG_PATH} || exit 1
50 rm "${PREFIX}/${LONG_PATH}/toybox" 2>/dev/null
51 rmdir "${PREFIX}/${LONG_PATH}" 2>/dev/null
55 # Make links to toybox
59 # Figure out target of link
61 if [ -z "$LONG_PATH" ]
65 # Create subdirectory for command to go in (if necessary)
67 DOTPATH="$(echo $i | sed 's@\(.*/\).*@\1@')"
68 if [ -z "$UNINSTALL" ]
70 mkdir -p "$DOTPATH" || exit 1
72 rmdir "$DOTPATH" 2>/dev/null
75 if [ -z "$LINK_TYPE" ]
79 if [ "$DOTPATH" != "$LONG_PATH" ]
81 DOTPATH="$(echo $DOTPATH | sed -e 's@[^/]*/@../@g')"$LONG_PATH
89 [ -z "$UNINSTALL" ] &&
90 ln $DO_FORCE $LINK_TYPE ${DOTPATH}toybox $i ||