2 # Copyright (C) 2014 The Android Open Source Project
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 LOCAL_PATH := $(call my-dir)
23 # git remote add toybox https://github.com/landley/toybox.git
25 # git merge toybox/master
27 # # (Make any necessary Android.mk changes and test the new toybox.)
29 # git push aosp HEAD:refs/for/master # Push to gerrit for review.
30 # git push aosp HEAD:master # Push directly, avoiding gerrit.
32 # # Now commit any necessary Android.mk changes like normal:
33 # repo start post-sync .
41 # Edit .config to enable 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.
54 lib/interestingtimes.c \
62 toys/android/getenforce.c \
63 toys/android/getprop.c \
64 toys/android/load_policy.c \
66 toys/android/restorecon.c \
67 toys/android/runcon.c \
68 toys/android/sendevent.c \
69 toys/android/setenforce.c \
70 toys/android/setprop.c \
71 toys/android/start.c \
90 toys/other/blockdev.c \
95 toys/other/dos2unix.c \
96 toys/other/fallocate.c \
99 toys/other/freeramdisk.c \
100 toys/other/fsfreeze.c \
102 toys/other/hwclock.c \
103 toys/other/inotifyd.c \
104 toys/other/insmod.c \
105 toys/other/ionice.c \
106 toys/other/losetup.c \
107 toys/other/lsattr.c \
110 toys/other/makedevs.c \
111 toys/other/mkswap.c \
112 toys/other/modinfo.c \
113 toys/other/mountpoint.c \
114 toys/other/nbd_client.c \
115 toys/other/partprobe.c \
116 toys/other/pivot_root.c \
118 toys/other/printenv.c \
120 toys/other/readlink.c \
121 toys/other/realpath.c \
124 toys/other/setsid.c \
126 toys/other/swapoff.c \
127 toys/other/swapon.c \
128 toys/other/sysctl.c \
130 toys/other/taskset.c \
131 toys/other/timeout.c \
132 toys/other/truncate.c \
133 toys/other/uptime.c \
134 toys/other/usleep.c \
135 toys/other/vconfig.c \
136 toys/other/vmstat.c \
141 toys/pending/expr.c \
142 toys/pending/lsof.c \
143 toys/pending/more.c \
146 toys/pending/traceroute.c \
147 toys/posix/basename.c \
160 toys/posix/dirname.c \
164 toys/posix/expand.c \
175 toys/posix/mkfifo.c \
182 toys/posix/printf.c \
185 toys/posix/renice.c \
192 toys/posix/strings.c \
199 toys/posix/ulimit.c \
208 -Wno-char-subscripts \
210 -Wno-string-plus-int \
212 -Wno-unused-parameter \
214 -ffunction-sections -fdata-sections \
215 -fno-asynchronous-unwind-tables \
217 toybox_upstream_version := $(shell awk 'match($$0, /TOYBOX_VERSION.*"(.*)"/, ary) {print ary[1]}' $(LOCAL_PATH)/main.c)
218 toybox_sha := $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)
220 toybox_version := $(toybox_upstream_version)-$(toybox_sha)-android
221 LOCAL_CFLAGS += -DTOYBOX_VERSION='"$(toybox_version)"'
225 LOCAL_SHARED_LIBRARIES := libcutils libselinux libcrypto
227 # This doesn't actually prevent us from dragging in libc++ at runtime
228 # because libnetd_client.so is C++.
229 LOCAL_CXX_STL := none
231 LOCAL_MODULE := toybox
234 # useless?: freeramdisk fsfreeze install makedevs mkfifo nbd-client
235 # partprobe pivot_root pwdx rev rfkill vconfig
236 # prefer BSD netcat instead?: nc netcat
237 # prefer efs2progs instead?: blkid chattr lsattr
377 # Install the symlinks.
378 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf toybox $(TARGET_OUT)/bin/$(t);)
380 include $(BUILD_EXECUTABLE)