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/"
26 # Symlink host toolchain binaries to destination to create cross compile $PATH
27 [ "$1" == "--airlock" ] && AIRLOCK=1
32 echo "Compile instlist..."
34 NOBUILD=1 scripts/make.sh
35 $DEBUG $HOSTCC -I . scripts/install.c -o generated/instlist || exit 1
36 COMMANDS="$(generated/instlist $LONG_PATH)"
38 echo "${UNINSTALL:-Install} commands..."
42 if [ -z "$UNINSTALL" ]
44 mkdir -p "${PREFIX}/${LONG_PATH}" &&
45 rm -f "${PREFIX}/${LONG_PATH}/toybox" &&
46 cp toybox ${PREFIX}/${LONG_PATH} || exit 1
48 rm -f "${PREFIX}/${LONG_PATH}/toybox" 2>/dev/null
50 cd "$PREFIX" || exit 1
52 # Make links to toybox
58 # Figure out target of link
60 if [ -z "$LONG_PATH" ]
64 # Create subdirectory for command to go in (if necessary)
66 DOTPATH="$(dirname "$i")"/
67 if [ -z "$UNINSTALL" ]
69 mkdir -p "$DOTPATH" || exit 1
72 if [ -z "$LINK_TYPE" ]
76 if [ "$DOTPATH" != "$LONG_PATH" ]
78 # For symlinks we need ../../bin style relative paths
79 DOTPATH="$(echo $DOTPATH | sed -e 's@[^/]*/@../@g')"$LONG_PATH
87 if [ -z "$UNINSTALL" ]
89 ln $DO_FORCE $LINK_TYPE ${DOTPATH}toybox $i || EXIT=1
95 [ -z "$AIRLOCK" ] && exit 0
97 # --airlock creates a single directory you can point the $PATH to for cross
98 # compiling, which contains just toybox and symlinks to toolchain binaries.
100 # This not only means you're building with a known set of tools (insulated from
101 # variations in the host distro), but that everything else is NOT in your PATH
102 # and thus various configure stages won't find things on thie host that won't
103 # be there on the target (such as the distcc build noticing the host has
104 # python and deciding to #include Python.h).
106 # The following are commands toybox should provide, but doesn't yet.
107 # For now symlink the host version. This list must go away by 1.0.
109 PENDING="bunzip2 bzcat dd diff expr ftpd ftpget ftpput gunzip less ping route tar test tr vi wget zcat awk bzip2 fdisk gzip sh sha512sum unxz xzcat bc"
111 # "gcc" should go away for llvm, but some things still hardwire it
112 TOOLCHAIN="ar as nm cc make ld gcc objdump"
114 if [ ! -z "$AIRLOCK" ]
117 # Tools needed to build packages
118 for i in $TOOLCHAIN $PENDING $HOST_EXTRA
122 # Loop through each instance, populating fallback directories (used by
123 # things like distcc, which require multiple instances of the same binary
124 # in a known order in the $PATH).
128 which -a "$i" | while read j
130 if [ ! -e "$FALLBACK/$i" ]
132 mkdir -p "$FALLBACK" &&
133 ln -sf "$j" "$FALLBACK/$i" || exit 1
137 FALLBACK="$PREFIX/fallback-$X"
140 if [ ! -f "$PREFIX/$i" ]
142 echo "Toolchain component missing: $i" >&2
143 [ -z "$PEDANTIC" ] || EXIT=1