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