blob: 578245127b8036734e1ccd951ce75367dce9b909 [file] [log] [blame]
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -08001#
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
Elliott Hughesa67bfec2015-04-05 10:14:19 -070023# git remote add toybox https://github.com/landley/toybox.git
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -080024# git fetch toybox
25# git merge toybox/master
26# mm -j32
27# # (Make any necessary Android.mk changes and test the new toybox.)
28# git push aosp HEAD:master # Push directly, avoiding gerrit.
29# git push aosp HEAD:refs/for/master # Push to gerrit.
30#
31# # Now commit any necessary Android.mk changes like normal:
32# repo start post-sync .
33# git commit -a
34
35
Elliott Hughes361d6ab2015-03-13 14:49:52 -070036#
37# To add a toy:
38#
39
40# make menuconfig
41# # (Select the toy you want to add.)
42# make clean && make # Regenerate the generated files.
43# # Edit LOCAL_SRC_FILES below to add the toy.
44# # If you just want to use it as "toybox x" rather than "x", you can stop now.
45# # If you want this toy to have a symbolic link in /system/bin, add the toy to ALL_TOOLS.
46
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -080047include $(CLEAR_VARS)
48
49LOCAL_SRC_FILES := \
50 lib/args.c \
51 lib/dirtree.c \
52 lib/getmountlist.c \
53 lib/help.c \
54 lib/lib.c \
55 lib/llist.c \
56 lib/net.c \
57 lib/portability.c \
58 lib/xwrap.c \
59 main.c \
Elliott Hughes0e6551a2015-03-28 12:49:31 -070060 toys/android/getenforce.c \
Elliott Hughes85cda1a2015-04-08 10:53:59 -070061 toys/android/getprop.c \
Elliott Hughes0e6551a2015-03-28 12:49:31 -070062 toys/android/load_policy.c \
Elliott Hughese0953ac2015-04-07 14:51:26 -070063 toys/android/restorecon.c \
Elliott Hughescfbb8c12015-03-23 17:53:47 -070064 toys/android/runcon.c \
Elliott Hughes0e6551a2015-03-28 12:49:31 -070065 toys/android/setenforce.c \
Elliott Hughes4b39d132015-04-07 17:42:12 -070066 toys/android/setprop.c \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -080067 toys/lsb/dmesg.c \
68 toys/lsb/hostname.c \
69 toys/lsb/killall.c \
70 toys/lsb/md5sum.c \
71 toys/lsb/mknod.c \
72 toys/lsb/mktemp.c \
73 toys/lsb/mount.c \
74 toys/lsb/pidof.c \
75 toys/lsb/seq.c \
76 toys/lsb/sync.c \
77 toys/lsb/umount.c \
78 toys/other/acpi.c \
Elliott Hughes14862232014-12-18 17:55:47 -080079 toys/other/base64.c \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -080080 toys/other/blkid.c \
81 toys/other/blockdev.c \
82 toys/other/bzcat.c \
Elliott Hughesbf65a2e2015-02-09 12:14:46 -080083 toys/other/chcon.c \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -080084 toys/other/chroot.c \
85 toys/other/chvt.c \
86 toys/other/clear.c \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -080087 toys/other/dos2unix.c \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -080088 toys/other/fallocate.c \
89 toys/other/free.c \
90 toys/other/freeramdisk.c \
91 toys/other/fsfreeze.c \
92 toys/other/help.c \
93 toys/other/ifconfig.c \
94 toys/other/inotifyd.c \
95 toys/other/insmod.c \
96 toys/other/losetup.c \
97 toys/other/lsattr.c \
98 toys/other/lsmod.c \
99 toys/other/lspci.c \
100 toys/other/lsusb.c \
101 toys/other/makedevs.c \
102 toys/other/mkswap.c \
103 toys/other/modinfo.c \
104 toys/other/mountpoint.c \
105 toys/other/nbd_client.c \
106 toys/other/netcat.c \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800107 toys/other/partprobe.c \
108 toys/other/pivot_root.c \
109 toys/other/pmap.c \
110 toys/other/printenv.c \
111 toys/other/pwdx.c \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800112 toys/other/readlink.c \
113 toys/other/realpath.c \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800114 toys/other/rev.c \
115 toys/other/rfkill.c \
116 toys/other/rmmod.c \
117 toys/other/setsid.c \
118 toys/other/stat.c \
119 toys/other/swapoff.c \
120 toys/other/swapon.c \
121 toys/other/switch_root.c \
122 toys/other/sysctl.c \
123 toys/other/tac.c \
124 toys/other/taskset.c \
125 toys/other/timeout.c \
126 toys/other/truncate.c \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800127 toys/other/usleep.c \
128 toys/other/vconfig.c \
129 toys/other/vmstat.c \
130 toys/other/which.c \
131 toys/other/yes.c \
Elliott Hughes3c3e83a2014-12-16 20:18:05 -0800132 toys/pending/dd.c \
Elliott Hughes88db4122015-02-18 17:32:09 -0800133 toys/pending/expr.c \
Elliott Hughes9aaeff32015-01-14 12:26:10 -0800134 toys/pending/hwclock.c \
Elliott Hughes53a43da2014-12-11 17:05:54 -0800135 toys/pending/more.c \
Elliott Hughes5d2ad232015-03-19 22:52:46 -0700136 toys/pending/pgrep.c \
Elliott Hughes3c3e83a2014-12-16 20:18:05 -0800137 toys/pending/ps.c \
138 toys/pending/netstat.c \
139 toys/pending/route.c \
Elliott Hughes88db4122015-02-18 17:32:09 -0800140 toys/pending/tar.c \
Elliott Hughes3c3e83a2014-12-16 20:18:05 -0800141 toys/pending/top.c \
Elliott Hughes347e42b2015-01-13 18:45:44 -0800142 toys/pending/tr.c \
Elliott Hughes3c3e83a2014-12-16 20:18:05 -0800143 toys/pending/traceroute.c \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800144 toys/posix/basename.c \
145 toys/posix/cal.c \
146 toys/posix/cat.c \
147 toys/posix/chgrp.c \
148 toys/posix/chmod.c \
149 toys/posix/cksum.c \
150 toys/posix/cmp.c \
151 toys/posix/comm.c \
152 toys/posix/cp.c \
Elliott Hughesbfa8d062015-02-05 10:02:55 -0800153 toys/posix/cpio.c \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800154 toys/posix/cut.c \
155 toys/posix/date.c \
156 toys/posix/df.c \
157 toys/posix/dirname.c \
158 toys/posix/du.c \
159 toys/posix/echo.c \
160 toys/posix/env.c \
161 toys/posix/expand.c \
162 toys/posix/false.c \
163 toys/posix/find.c \
164 toys/posix/grep.c \
165 toys/posix/head.c \
166 toys/posix/id.c \
167 toys/posix/kill.c \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800168 toys/posix/ln.c \
169 toys/posix/ls.c \
170 toys/posix/mkdir.c \
171 toys/posix/mkfifo.c \
172 toys/posix/nice.c \
173 toys/posix/nl.c \
174 toys/posix/nohup.c \
175 toys/posix/od.c \
176 toys/posix/paste.c \
177 toys/posix/patch.c \
Elliott Hughes0e6551a2015-03-28 12:49:31 -0700178 toys/posix/printf.c \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800179 toys/posix/pwd.c \
180 toys/posix/renice.c \
181 toys/posix/rm.c \
182 toys/posix/rmdir.c \
Elliott Hughes347e42b2015-01-13 18:45:44 -0800183 toys/posix/sed.c \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800184 toys/posix/sleep.c \
185 toys/posix/sort.c \
186 toys/posix/split.c \
187 toys/posix/strings.c \
188 toys/posix/tail.c \
189 toys/posix/tee.c \
190 toys/posix/time.c \
191 toys/posix/touch.c \
192 toys/posix/true.c \
193 toys/posix/tty.c \
194 toys/posix/uname.c \
195 toys/posix/uniq.c \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800196 toys/posix/wc.c \
197 toys/posix/xargs.c \
198
199LOCAL_CFLAGS += \
Elliott Hughes4b39d132015-04-07 17:42:12 -0700200 -std=c99 \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800201 -Os \
202 -Wno-char-subscripts \
203 -Wno-sign-compare \
Elliott Hughes0e6551a2015-03-28 12:49:31 -0700204 -Wno-string-plus-int \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800205 -Wno-uninitialized \
206 -Wno-unused-parameter \
Elliott Hughesd3533982015-01-15 15:04:19 -0800207 -funsigned-char \
208 -ffunction-sections -fdata-sections \
209 -fno-asynchronous-unwind-tables \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800210
Elliott Hughes4b39d132015-04-07 17:42:12 -0700211LOCAL_CLANG := true
212
213LOCAL_SHARED_LIBRARIES := libcutils libselinux
Elliott Hughes76115632014-12-16 09:14:47 -0800214
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800215LOCAL_MODULE := toybox
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800216
Elliott Hughescc6fc172015-04-02 21:27:05 -0700217# dupes: dd df du ls mount renice
Elliott Hughes79984b42015-02-09 12:16:39 -0800218# useless?: chvt freeramdisk fsfreeze install makedevs mkfifo nbd-client
Elliott Hughesbf65a2e2015-02-09 12:14:46 -0800219# partprobe pivot_root pwdx rev rfkill switch_root tty vconfig
Elliott Hughes5eec03a2015-02-09 14:09:49 -0800220# prefer BSD netcat instead?: nc netcat
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800221# prefer efs2progs instead?: blkid chattr lsattr
222
223ALL_TOOLS := \
224 acpi \
225 basename \
226 blockdev \
227 bzcat \
228 cal \
Elliott Hughes1e0e5ea2015-01-14 10:40:22 -0800229 cat \
Elliott Hughes76115632014-12-16 09:14:47 -0800230 chcon \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800231 chgrp \
Elliott Hughes5c7cca02014-12-11 12:12:59 -0800232 chmod \
Elliott Hughes6ee70fc2015-01-15 13:41:34 -0800233 chown \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800234 chroot \
235 cksum \
Elliott Hughes03275a82014-11-22 22:56:47 -0800236 clear \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800237 comm \
Elliott Hughesd3533982015-01-15 15:04:19 -0800238 cmp \
Elliott Hughes6b4d05c2014-12-16 16:15:47 -0800239 cp \
Elliott Hughesbfa8d062015-02-05 10:02:55 -0800240 cpio \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800241 cut \
Elliott Hughes9aaeff32015-01-14 12:26:10 -0800242 date \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800243 dirname \
Elliott Hughesc99e20b2014-11-26 11:38:43 -0800244 dmesg \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800245 dos2unix \
246 echo \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800247 env \
248 expand \
Elliott Hughes88db4122015-02-18 17:32:09 -0800249 expr \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800250 fallocate \
Elliott Hughes03275a82014-11-22 22:56:47 -0800251 false \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800252 find \
253 free \
Elliott Hughes9250c952014-12-24 11:29:44 -0800254 getenforce \
Elliott Hughes85cda1a2015-04-08 10:53:59 -0700255 getprop \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800256 groups \
257 head \
258 hostname \
Elliott Hughes9aaeff32015-01-14 12:26:10 -0800259 hwclock \
Elliott Hughesc8fa5ee2015-01-16 19:27:31 -0800260 id \
Elliott Hughes4f060a32015-01-14 11:07:28 -0800261 ifconfig \
Elliott Hughes123aecf2015-01-14 11:00:47 -0800262 inotifyd \
Elliott Hughes6a646ef2014-11-24 11:41:35 -0800263 insmod \
Elliott Hughes95211ea2014-12-04 20:09:44 -0800264 kill \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800265 killall \
Elliott Hughes0e6551a2015-03-28 12:49:31 -0700266 load_policy \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800267 ln \
268 logname \
269 losetup \
Elliott Hughes6a646ef2014-11-24 11:41:35 -0800270 lsmod \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800271 lspci \
272 lsusb \
273 md5sum \
Elliott Hughesd13bf6a2014-12-16 15:17:17 -0800274 mkdir \
Elliott Hughes0a0435c2014-12-11 18:34:09 -0800275 mknod \
Elliott Hughes620bc1a2014-11-24 16:12:40 -0800276 mkswap \
Elliott Hughes79984b42015-02-09 12:16:39 -0800277 mktemp \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800278 modinfo \
Elliott Hughes53a43da2014-12-11 17:05:54 -0800279 more \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800280 mountpoint \
Elliott Hughesdbcacc62014-12-16 19:18:43 -0800281 mv \
Elliott Hughes5f9893b2014-12-23 09:12:18 -0800282 netstat \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800283 nice \
284 nl \
Elliott Hughes9f989412014-11-25 17:00:40 -0800285 nohup \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800286 od \
287 paste \
288 patch \
Elliott Hughes5d2ad232015-03-19 22:52:46 -0700289 pgrep \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800290 pidof \
Elliott Hughes5d2ad232015-03-19 22:52:46 -0700291 pkill \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800292 pmap \
Elliott Hughes68e18cd2014-11-24 15:36:51 -0800293 printenv \
Elliott Hughes0e6551a2015-03-28 12:49:31 -0700294 printf \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800295 pwd \
Elliott Hughes8f7bc7a2014-11-26 15:21:03 -0800296 readlink \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800297 realpath \
Elliott Hughese0953ac2015-04-07 14:51:26 -0700298 restorecon \
Elliott Hughesf5275f92014-12-16 16:22:32 -0800299 rm \
Elliott Hughesd4a6d662014-12-16 15:26:53 -0800300 rmdir \
Elliott Hughes6a646ef2014-11-24 11:41:35 -0800301 rmmod \
Elliott Hughes84974ec2015-03-30 11:25:18 -0700302 route \
Elliott Hughescfbb8c12015-03-23 17:53:47 -0700303 runcon \
Elliott Hughes347e42b2015-01-13 18:45:44 -0800304 sed \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800305 seq \
Elliott Hughes9250c952014-12-24 11:29:44 -0800306 setenforce \
Elliott Hughes176eae92015-04-07 20:36:38 -0700307 setprop \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800308 setsid \
309 sha1sum \
Elliott Hughes62cf8d62014-11-24 15:23:04 -0800310 sleep \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800311 sort \
312 split \
313 stat \
314 strings \
Elliott Hughes620bc1a2014-11-24 16:12:40 -0800315 swapoff \
316 swapon \
Elliott Hughes85368282014-11-24 14:53:36 -0800317 sync \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800318 sysctl \
319 tac \
320 tail \
Elliott Hughes88db4122015-02-18 17:32:09 -0800321 tar \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800322 taskset \
323 tee \
324 time \
325 timeout \
Elliott Hughes5eec03a2015-02-09 14:09:49 -0800326 touch \
Elliott Hughes347e42b2015-01-13 18:45:44 -0800327 tr \
Elliott Hughes03275a82014-11-22 22:56:47 -0800328 true \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800329 truncate \
Elliott Hughescc6fc172015-04-02 21:27:05 -0700330 umount \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800331 uname \
332 uniq \
333 unix2dos \
Elliott Hughes10bd49e2014-11-21 14:53:43 -0800334 usleep \
Elliott Hughes20800602014-11-25 17:25:05 -0800335 vmstat \
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800336 wc \
337 which \
338 whoami \
339 xargs \
340 yes \
341
Ying Wang331b22d2014-11-24 12:42:09 -0800342# Install the symlinks.
343LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf toybox $(TARGET_OUT)/bin/$(t);)
Elliott Hughesd8d2d3c2014-11-20 10:39:27 -0800344
Ying Wang331b22d2014-11-24 12:42:09 -0800345include $(BUILD_EXECUTABLE)