Android.mk revision e3764ccdc1fc3cde5a679539c58c825ed54293ee
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#  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
36#
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
47include $(CLEAR_VARS)
48
49LOCAL_SRC_FILES := \
50    lib/args.c \
51    lib/dirtree.c \
52    lib/getmountlist.c \
53    lib/help.c \
54    lib/interestingtimes.c \
55    lib/lib.c \
56    lib/llist.c \
57    lib/net.c \
58    lib/portability.c \
59    lib/xwrap.c \
60    main.c \
61    toys/android/getenforce.c \
62    toys/android/getprop.c \
63    toys/android/load_policy.c \
64    toys/android/restorecon.c \
65    toys/android/runcon.c \
66    toys/android/setenforce.c \
67    toys/android/setprop.c \
68    toys/lsb/dmesg.c \
69    toys/lsb/hostname.c \
70    toys/lsb/killall.c \
71    toys/lsb/md5sum.c \
72    toys/lsb/mknod.c \
73    toys/lsb/mktemp.c \
74    toys/lsb/mount.c \
75    toys/lsb/pidof.c \
76    toys/lsb/seq.c \
77    toys/lsb/sync.c \
78    toys/lsb/umount.c \
79    toys/other/acpi.c \
80    toys/other/base64.c \
81    toys/other/blkid.c \
82    toys/other/blockdev.c \
83    toys/other/bzcat.c \
84    toys/other/chcon.c \
85    toys/other/chroot.c \
86    toys/other/clear.c \
87    toys/other/dos2unix.c \
88    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/ionice.c \
97    toys/other/losetup.c \
98    toys/other/lsattr.c \
99    toys/other/lsmod.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 \
107    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 \
112    toys/other/readlink.c \
113    toys/other/realpath.c \
114    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 \
127    toys/other/usleep.c \
128    toys/other/vconfig.c \
129    toys/other/vmstat.c \
130    toys/other/which.c \
131    toys/other/xxd.c \
132    toys/other/yes.c \
133    toys/pending/dd.c \
134    toys/pending/expr.c \
135    toys/pending/hwclock.c \
136    toys/pending/more.c \
137    toys/pending/pgrep.c \
138    toys/pending/netstat.c \
139    toys/pending/route.c \
140    toys/pending/tar.c \
141    toys/pending/top.c \
142    toys/pending/tr.c \
143    toys/pending/traceroute.c \
144    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 \
153    toys/posix/cpio.c \
154    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 \
168    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 \
178    toys/posix/printf.c \
179    toys/posix/pwd.c \
180    toys/posix/renice.c \
181    toys/posix/rm.c \
182    toys/posix/rmdir.c \
183    toys/posix/sed.c \
184    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 \
196    toys/posix/wc.c \
197    toys/posix/xargs.c \
198
199LOCAL_CFLAGS += \
200    -std=c99 \
201    -Os \
202    -Wno-char-subscripts \
203    -Wno-sign-compare \
204    -Wno-string-plus-int \
205    -Wno-uninitialized \
206    -Wno-unused-parameter \
207    -funsigned-char \
208    -ffunction-sections -fdata-sections \
209    -fno-asynchronous-unwind-tables \
210
211toybox_version := $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)-android
212LOCAL_CFLAGS += -DTOYBOX_VERSION='"$(toybox_version)"'
213
214LOCAL_CLANG := true
215
216LOCAL_SHARED_LIBRARIES := libcutils libselinux
217
218# This doesn't actually prevent us from dragging in libc++ at runtime
219# because libnetd_client.so is C++.
220LOCAL_CXX_STL := none
221
222LOCAL_MODULE := toybox
223
224# dupes: dd df du ls renice
225# useless?: freeramdisk fsfreeze install makedevs mkfifo nbd-client
226#           partprobe pivot_root pwdx rev rfkill switch_root tty vconfig
227# prefer BSD netcat instead?: nc netcat
228# prefer efs2progs instead?: blkid chattr lsattr
229
230ALL_TOOLS := \
231    acpi \
232    basename \
233    blockdev \
234    bzcat \
235    cal \
236    cat \
237    chcon \
238    chgrp \
239    chmod \
240    chown \
241    chroot \
242    cksum \
243    clear \
244    comm \
245    cmp \
246    cp \
247    cpio \
248    cut \
249    date \
250    dirname \
251    dmesg \
252    dos2unix \
253    echo \
254    env \
255    expand \
256    expr \
257    fallocate \
258    false \
259    find \
260    free \
261    getenforce \
262    getprop \
263    groups \
264    head \
265    hostname \
266    hwclock \
267    id \
268    ifconfig \
269    inotifyd \
270    insmod \
271    kill \
272    killall \
273    load_policy \
274    ln \
275    logname \
276    losetup \
277    lsmod \
278    lsusb \
279    md5sum \
280    mkdir \
281    mknod \
282    mkswap \
283    mktemp \
284    modinfo \
285    more \
286    mount \
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    tty \
338    umount \
339    uname \
340    uniq \
341    unix2dos \
342    usleep \
343    vmstat \
344    wc \
345    which \
346    whoami \
347    xargs \
348    yes \
349
350# Install the symlinks.
351LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf toybox $(TARGET_OUT)/bin/$(t);)
352
353include $(BUILD_EXECUTABLE)
354