Ethan Yonker | c798c9c | 2015-10-09 11:15:26 -0500 | [diff] [blame] | 1 | # |
| 2 | # Copyright (C) 2014 The Android Open Source Project |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | |
| 17 | ifneq ($(wildcard external/toybox/Android.mk),) |
| 18 | |
| 19 | ifeq ($(TW_USE_TOOLBOX), true) |
| 20 | |
| 21 | LOCAL_PATH := external/toybox |
| 22 | |
| 23 | # |
| 24 | # To update: |
| 25 | # |
| 26 | |
| 27 | # git remote add toybox https://github.com/landley/toybox.git |
| 28 | # git fetch toybox |
| 29 | # git merge toybox/master |
| 30 | # mm -j32 |
| 31 | # # (Make any necessary Android.mk changes and test the new toybox.) |
| 32 | # git push aosp HEAD:master # Push directly, avoiding gerrit. |
| 33 | # git push aosp HEAD:refs/for/master # Push to gerrit. |
| 34 | # |
| 35 | # # Now commit any necessary Android.mk changes like normal: |
| 36 | # repo start post-sync . |
| 37 | # git commit -a |
| 38 | |
| 39 | |
| 40 | # |
| 41 | # To add a toy: |
| 42 | # |
| 43 | |
| 44 | # make menuconfig |
| 45 | # # (Select the toy you want to add.) |
| 46 | # make clean && make # Regenerate the generated files. |
| 47 | # # Edit LOCAL_SRC_FILES below to add the toy. |
| 48 | # # If you just want to use it as "toybox x" rather than "x", you can stop now. |
| 49 | # # If you want this toy to have a symbolic link in /system/bin, add the toy to ALL_TOOLS. |
| 50 | |
| 51 | include $(CLEAR_VARS) |
| 52 | |
| 53 | LOCAL_SRC_FILES := \ |
| 54 | lib/args.c \ |
| 55 | lib/dirtree.c \ |
| 56 | lib/getmountlist.c \ |
| 57 | lib/help.c \ |
| 58 | lib/interestingtimes.c \ |
| 59 | lib/lib.c \ |
| 60 | lib/llist.c \ |
| 61 | lib/net.c \ |
| 62 | lib/portability.c \ |
| 63 | lib/xwrap.c \ |
| 64 | main.c \ |
| 65 | toys/android/getenforce.c \ |
| 66 | toys/android/getprop.c \ |
| 67 | toys/android/load_policy.c \ |
| 68 | toys/android/restorecon.c \ |
| 69 | toys/android/runcon.c \ |
| 70 | toys/android/setenforce.c \ |
| 71 | toys/android/setprop.c \ |
| 72 | toys/lsb/dmesg.c \ |
| 73 | toys/lsb/hostname.c \ |
| 74 | toys/lsb/killall.c \ |
| 75 | toys/lsb/md5sum.c \ |
| 76 | toys/lsb/mknod.c \ |
| 77 | toys/lsb/mktemp.c \ |
| 78 | toys/lsb/mount.c \ |
| 79 | toys/lsb/pidof.c \ |
| 80 | toys/lsb/seq.c \ |
| 81 | toys/lsb/sync.c \ |
| 82 | toys/lsb/umount.c \ |
| 83 | toys/other/acpi.c \ |
| 84 | toys/other/base64.c \ |
| 85 | toys/other/blkid.c \ |
| 86 | toys/other/blockdev.c \ |
| 87 | toys/other/bzcat.c \ |
| 88 | toys/other/chcon.c \ |
| 89 | toys/other/chroot.c \ |
| 90 | toys/other/clear.c \ |
| 91 | toys/other/dos2unix.c \ |
| 92 | toys/other/fallocate.c \ |
| 93 | toys/other/free.c \ |
| 94 | toys/other/freeramdisk.c \ |
| 95 | toys/other/fsfreeze.c \ |
| 96 | toys/other/help.c \ |
| 97 | toys/other/ifconfig.c \ |
| 98 | toys/other/inotifyd.c \ |
| 99 | toys/other/insmod.c \ |
| 100 | toys/other/losetup.c \ |
| 101 | toys/other/lsattr.c \ |
| 102 | toys/other/lsmod.c \ |
| 103 | toys/other/lsusb.c \ |
| 104 | toys/other/makedevs.c \ |
| 105 | toys/other/mkswap.c \ |
| 106 | toys/other/modinfo.c \ |
| 107 | toys/other/mountpoint.c \ |
| 108 | toys/other/nbd_client.c \ |
| 109 | toys/other/netcat.c \ |
| 110 | toys/other/partprobe.c \ |
| 111 | toys/other/pivot_root.c \ |
| 112 | toys/other/pmap.c \ |
| 113 | toys/other/printenv.c \ |
| 114 | toys/other/pwdx.c \ |
| 115 | toys/other/readlink.c \ |
| 116 | toys/other/realpath.c \ |
| 117 | toys/other/rev.c \ |
| 118 | toys/other/rfkill.c \ |
| 119 | toys/other/rmmod.c \ |
| 120 | toys/other/setsid.c \ |
| 121 | toys/other/stat.c \ |
| 122 | toys/other/swapoff.c \ |
| 123 | toys/other/swapon.c \ |
| 124 | toys/other/switch_root.c \ |
| 125 | toys/other/sysctl.c \ |
| 126 | toys/other/tac.c \ |
| 127 | toys/other/taskset.c \ |
| 128 | toys/other/timeout.c \ |
| 129 | toys/other/truncate.c \ |
| 130 | toys/other/usleep.c \ |
| 131 | toys/other/vconfig.c \ |
| 132 | toys/other/vmstat.c \ |
| 133 | toys/other/which.c \ |
| 134 | toys/other/yes.c \ |
| 135 | toys/pending/dd.c \ |
| 136 | toys/pending/expr.c \ |
| 137 | toys/pending/hwclock.c \ |
| 138 | toys/pending/more.c \ |
| 139 | toys/pending/pgrep.c \ |
| 140 | toys/pending/netstat.c \ |
| 141 | toys/pending/route.c \ |
| 142 | toys/pending/tar.c \ |
| 143 | toys/pending/top.c \ |
| 144 | toys/pending/tr.c \ |
| 145 | toys/pending/traceroute.c \ |
| 146 | toys/posix/basename.c \ |
| 147 | toys/posix/cal.c \ |
| 148 | toys/posix/cat.c \ |
| 149 | toys/posix/chgrp.c \ |
| 150 | toys/posix/chmod.c \ |
| 151 | toys/posix/cksum.c \ |
| 152 | toys/posix/cmp.c \ |
| 153 | toys/posix/comm.c \ |
| 154 | toys/posix/cp.c \ |
| 155 | toys/posix/cpio.c \ |
| 156 | toys/posix/cut.c \ |
| 157 | toys/posix/date.c \ |
| 158 | toys/posix/df.c \ |
| 159 | toys/posix/dirname.c \ |
| 160 | toys/posix/du.c \ |
| 161 | toys/posix/echo.c \ |
| 162 | toys/posix/env.c \ |
| 163 | toys/posix/expand.c \ |
| 164 | toys/posix/false.c \ |
| 165 | toys/posix/find.c \ |
| 166 | toys/posix/grep.c \ |
| 167 | toys/posix/head.c \ |
| 168 | toys/posix/id.c \ |
| 169 | toys/posix/kill.c \ |
| 170 | toys/posix/ln.c \ |
| 171 | toys/posix/ls.c \ |
| 172 | toys/posix/mkdir.c \ |
| 173 | toys/posix/mkfifo.c \ |
| 174 | toys/posix/nice.c \ |
| 175 | toys/posix/nl.c \ |
| 176 | toys/posix/nohup.c \ |
| 177 | toys/posix/od.c \ |
| 178 | toys/posix/paste.c \ |
| 179 | toys/posix/patch.c \ |
| 180 | toys/posix/printf.c \ |
| 181 | toys/posix/pwd.c \ |
| 182 | toys/posix/renice.c \ |
| 183 | toys/posix/rm.c \ |
| 184 | toys/posix/rmdir.c \ |
| 185 | toys/posix/sed.c \ |
| 186 | toys/posix/sleep.c \ |
| 187 | toys/posix/sort.c \ |
| 188 | toys/posix/split.c \ |
| 189 | toys/posix/strings.c \ |
| 190 | toys/posix/tail.c \ |
| 191 | toys/posix/tee.c \ |
| 192 | toys/posix/time.c \ |
| 193 | toys/posix/touch.c \ |
| 194 | toys/posix/true.c \ |
| 195 | toys/posix/tty.c \ |
| 196 | toys/posix/uname.c \ |
| 197 | toys/posix/uniq.c \ |
| 198 | toys/posix/wc.c \ |
| 199 | toys/posix/xargs.c \ |
| 200 | |
| 201 | LOCAL_CFLAGS += \ |
| 202 | -std=c99 \ |
| 203 | -Os \ |
| 204 | -Wno-char-subscripts \ |
| 205 | -Wno-sign-compare \ |
| 206 | -Wno-string-plus-int \ |
| 207 | -Wno-uninitialized \ |
| 208 | -Wno-unused-parameter \ |
| 209 | -funsigned-char \ |
| 210 | -ffunction-sections -fdata-sections \ |
| 211 | -fno-asynchronous-unwind-tables \ |
| 212 | |
| 213 | toybox_version := $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)-android |
| 214 | LOCAL_CFLAGS += -DTOYBOX_VERSION='"$(toybox_version)"' |
| 215 | |
| 216 | LOCAL_CLANG := true |
| 217 | |
| 218 | LOCAL_SHARED_LIBRARIES := libcutils libselinux |
| 219 | |
| 220 | LOCAL_MODULE := toybox_recovery |
| 221 | LOCAL_MODULE_STEM := toybox |
| 222 | LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin |
| 223 | LOCAL_MODULE_TAGS := optional |
| 224 | |
| 225 | # dupes: dd df du ls mount renice |
| 226 | # useless?: freeramdisk fsfreeze install makedevs mkfifo nbd-client |
| 227 | # partprobe pivot_root pwdx rev rfkill switch_root tty vconfig |
| 228 | # prefer BSD netcat instead?: nc netcat |
| 229 | # prefer efs2progs instead?: blkid chattr lsattr |
| 230 | |
| 231 | ALL_TOOLS := \ |
| 232 | acpi \ |
| 233 | basename \ |
| 234 | blkid \ |
| 235 | blockdev \ |
| 236 | bzcat \ |
| 237 | cal \ |
| 238 | cat \ |
| 239 | chcon \ |
| 240 | chgrp \ |
| 241 | chmod \ |
| 242 | chown \ |
| 243 | chroot \ |
| 244 | cksum \ |
| 245 | clear \ |
| 246 | comm \ |
| 247 | cmp \ |
| 248 | cp \ |
| 249 | cpio \ |
| 250 | cut \ |
| 251 | date \ |
| 252 | dirname \ |
| 253 | dmesg \ |
| 254 | dos2unix \ |
| 255 | echo \ |
| 256 | env \ |
| 257 | expand \ |
| 258 | expr \ |
| 259 | fallocate \ |
| 260 | false \ |
| 261 | find \ |
| 262 | free \ |
| 263 | getenforce \ |
| 264 | getprop \ |
| 265 | groups \ |
| 266 | head \ |
| 267 | hostname \ |
| 268 | hwclock \ |
| 269 | id \ |
| 270 | ifconfig \ |
| 271 | inotifyd \ |
| 272 | insmod \ |
| 273 | kill \ |
| 274 | load_policy \ |
| 275 | ln \ |
| 276 | logname \ |
| 277 | losetup \ |
| 278 | lsmod \ |
| 279 | lsusb \ |
| 280 | md5sum \ |
| 281 | mkdir \ |
| 282 | mknod \ |
| 283 | mkswap \ |
| 284 | mktemp \ |
| 285 | modinfo \ |
| 286 | more \ |
| 287 | mountpoint \ |
| 288 | mv \ |
| 289 | netstat \ |
| 290 | nice \ |
| 291 | nl \ |
| 292 | nohup \ |
| 293 | od \ |
| 294 | paste \ |
| 295 | patch \ |
| 296 | pgrep \ |
| 297 | pidof \ |
| 298 | pkill \ |
| 299 | pmap \ |
| 300 | printenv \ |
| 301 | printf \ |
| 302 | pwd \ |
| 303 | readlink \ |
| 304 | realpath \ |
| 305 | restorecon \ |
| 306 | rm \ |
| 307 | rmdir \ |
| 308 | rmmod \ |
| 309 | route \ |
| 310 | runcon \ |
| 311 | sed \ |
| 312 | seq \ |
| 313 | setenforce \ |
| 314 | setprop \ |
| 315 | setsid \ |
| 316 | sha1sum \ |
| 317 | sleep \ |
| 318 | sort \ |
| 319 | split \ |
| 320 | stat \ |
| 321 | strings \ |
| 322 | swapoff \ |
| 323 | swapon \ |
| 324 | sync \ |
| 325 | sysctl \ |
| 326 | tac \ |
| 327 | tail \ |
| 328 | tar \ |
| 329 | taskset \ |
| 330 | tee \ |
| 331 | time \ |
| 332 | timeout \ |
| 333 | touch \ |
| 334 | tr \ |
| 335 | true \ |
| 336 | truncate \ |
| 337 | umount \ |
| 338 | uname \ |
| 339 | uniq \ |
| 340 | unix2dos \ |
| 341 | usleep \ |
| 342 | vmstat \ |
| 343 | wc \ |
| 344 | which \ |
| 345 | whoami \ |
| 346 | xargs \ |
| 347 | yes \ |
| 348 | |
| 349 | # Install the symlinks. |
| 350 | LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf toybox $(TARGET_RECOVERY_ROOT_OUT)/sbin/$(t);) |
| 351 | |
| 352 | include $(BUILD_EXECUTABLE) |
| 353 | |
| 354 | # Make /sbin/toolbox launchers for each tool |
| 355 | SYMLINKS := $(addprefix $(TARGET_RECOVERY_ROOT_OUT)/sbin/,$(ALL_TOOLS)) |
| 356 | $(SYMLINKS): TOYBOX_BINARY := $(LOCAL_MODULE_STEM) |
| 357 | $(SYMLINKS): $(LOCAL_INSTALLED_MODULE) $(LOCAL_PATH)/Android.mk |
| 358 | @echo "Symlink: $@ -> $(TOYBOX_BINARY)" |
| 359 | @mkdir -p $(dir $@) |
| 360 | @rm -rf $@ |
| 361 | $(hide) ln -sf $(TOYBOX_BINARY) $@ |
| 362 | |
| 363 | include $(CLEAR_VARS) |
| 364 | LOCAL_MODULE := toybox_symlinks |
| 365 | LOCAL_MODULE_TAGS := optional |
| 366 | LOCAL_ADDITIONAL_DEPENDENCIES := $(SYMLINKS) |
| 367 | include $(BUILD_PHONY_PACKAGE) |
| 368 | |
| 369 | endif |
| 370 | |
| 371 | endif |