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)
22 -Wno-char-subscripts \
24 -Wno-string-plus-int \
26 -Wno-unused-parameter \
28 -ffunction-sections -fdata-sections \
29 -fno-asynchronous-unwind-tables \
31 toybox_upstream_version := $(shell grep -o 'TOYBOX_VERSION.*\".*\"' $(LOCAL_PATH)/main.c | cut -d'"' -f2)
32 toybox_sha := $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)
34 toybox_version := $(toybox_upstream_version)-$(toybox_sha)-android
35 common_cflags += -DTOYBOX_VERSION='"$(toybox_version)"'
41 # git remote add toybox https://github.com/landley/toybox.git
43 # git merge toybox/master
45 # # (Make any necessary Android.mk changes and test the new toybox.)
47 # git push aosp HEAD:refs/for/master # Push to gerrit for review.
48 # git push aosp HEAD:master # Push directly, avoiding gerrit.
50 # # Now commit any necessary Android.mk changes like normal:
51 # repo start post-sync .
59 # Edit .config to enable the toy you want to add.
60 # make clean && make # Regenerate the generated files.
61 # # Edit LOCAL_SRC_FILES below to add the toy.
62 # # If you just want to use it as "toybox x" rather than "x", you can stop now.
63 # # If you want this toy to have a symbolic link in /system/bin, add the toy to ALL_TOOLS.
72 lib/interestingtimes.c \
81 toys/android/getenforce.c \
82 toys/android/getprop.c \
83 toys/android/load_policy.c \
85 toys/android/restorecon.c \
86 toys/android/runcon.c \
87 toys/android/sendevent.c \
88 toys/android/setenforce.c \
89 toys/android/setprop.c \
90 toys/android/start.c \
102 toys/net/ifconfig.c \
108 toys/other/base64.c \
110 toys/other/blockdev.c \
113 toys/other/chroot.c \
115 toys/other/dos2unix.c \
116 toys/other/fallocate.c \
119 toys/other/freeramdisk.c \
120 toys/other/fsfreeze.c \
122 toys/other/hwclock.c \
123 toys/other/inotifyd.c \
124 toys/other/insmod.c \
125 toys/other/ionice.c \
126 toys/other/losetup.c \
127 toys/other/lsattr.c \
131 toys/other/makedevs.c \
132 toys/other/mkswap.c \
133 toys/other/modinfo.c \
134 toys/other/mountpoint.c \
135 toys/other/nbd_client.c \
136 toys/other/partprobe.c \
137 toys/other/pivot_root.c \
139 toys/other/printenv.c \
141 toys/other/readahead.c \
142 toys/other/readlink.c \
143 toys/other/realpath.c \
147 toys/other/setfattr.c \
148 toys/other/setsid.c \
150 toys/other/swapoff.c \
151 toys/other/swapon.c \
152 toys/other/sysctl.c \
154 toys/other/taskset.c \
155 toys/other/timeout.c \
156 toys/other/truncate.c \
157 toys/other/uptime.c \
158 toys/other/usleep.c \
159 toys/other/vconfig.c \
160 toys/other/vmstat.c \
165 toys/pending/chrt.c \
167 toys/pending/diff.c \
168 toys/pending/expr.c \
169 toys/pending/fdisk.c \
170 toys/pending/ftpget.c \
171 toys/pending/getfattr.c \
172 toys/pending/host.c \
173 toys/pending/lsof.c \
174 toys/pending/more.c \
175 toys/pending/resize.c \
176 toys/pending/route.c \
178 toys/pending/telnet.c \
179 toys/pending/test.c \
181 toys/pending/traceroute.c \
182 toys/pending/watch.c \
183 toys/pending/xzcat.c \
184 toys/posix/basename.c \
197 toys/posix/dirname.c \
201 toys/posix/expand.c \
212 toys/posix/mkfifo.c \
219 toys/posix/printf.c \
222 toys/posix/renice.c \
229 toys/posix/strings.c \
236 toys/posix/ulimit.c \
242 LOCAL_CFLAGS := $(common_cflags)
245 LOCAL_STATIC_LIBRARIES := libselinux libcrypto_static
247 # This doesn't actually prevent us from dragging in libc++ at runtime
248 # because libnetd_client.so is C++.
249 LOCAL_CXX_STL := none
251 LOCAL_C_INCLUDES += bionic/libc/dns/include
253 LOCAL_MODULE := libtoybox
255 include $(BUILD_STATIC_LIBRARY)
258 # Host binary to enumerate the toys
259 include $(CLEAR_VARS)
260 LOCAL_SRC_FILES := scripts/install.c
261 LOCAL_MODULE_TAGS := optional
262 LOCAL_CFLAGS := $(common_cflags)
264 LOCAL_MODULE := toybox-instlist
265 include $(BUILD_HOST_EXECUTABLE)
268 include $(CLEAR_VARS)
269 LOCAL_SRC_FILES := main.c
270 LOCAL_STATIC_LIBRARIES := libtoybox
271 LOCAL_SHARED_LIBRARIES := libcutils libselinux libcrypto
272 LOCAL_CFLAGS := $(common_cflags)
273 LOCAL_CXX_STL := none
275 LOCAL_MODULE := toybox
277 # for dumping the list of toys
278 TOYBOX_INSTLIST := $(HOST_OUT_EXECUTABLES)/toybox-instlist
279 LOCAL_ADDITIONAL_DEPENDENCIES := toybox_links
281 # we still want a link for ps, but the toolbox version needs to
282 # stick around for compatibility reasons, for now.
285 # skip links for these toys in the system image, they already have
286 # a full-blown counterpart. we still want them for the recovery
288 TOYS_WITHOUT_LINKS := blkid traceroute6
290 include $(BUILD_EXECUTABLE)
292 toybox_links: $(TOYBOX_INSTLIST)
293 toybox_links: TOYBOX_BINARY := $(TARGET_OUT)/bin/toybox
295 @echo -e ${CL_CYN}"Generate Toybox links:"${CL_RST} $$($(TOYBOX_INSTLIST))
296 @mkdir -p $(TARGET_OUT_EXECUTABLES) $(TARGET_OUT_OPTIONAL_EXECUTABLES)
297 $(hide) $(TOYBOX_INSTLIST) | grep -vFx -f <(tr ' ' '\n' <<< '$(TOYS_FOR_XBIN) $(TOYS_WITHOUT_LINKS)') | xargs -I'{}' ln -sf toybox '$(TARGET_OUT_EXECUTABLES)/{}'
298 $(hide) tr ' ' '\n' <<< '$(TOYS_FOR_XBIN)' | xargs -I'{}' ln -sf ../bin/toybox '$(TARGET_OUT_OPTIONAL_EXECUTABLES)/{}'
301 # This is used by the recovery system
302 include $(CLEAR_VARS)
303 LOCAL_SRC_FILES := main.c
304 LOCAL_WHOLE_STATIC_LIBRARIES := libselinux libtoybox
305 LOCAL_CFLAGS := $(common_cflags)
306 LOCAL_CFLAGS += -Dmain=toybox_driver
307 LOCAL_CXX_STL := none
309 LOCAL_MODULE := libtoybox_driver
310 include $(BUILD_STATIC_LIBRARY)
312 # static executable for use in limited environments
313 include $(CLEAR_VARS)
314 LOCAL_SRC_FILES := main.c
315 LOCAL_CFLAGS := $(common_cflags)
316 LOCAL_CXX_STL := none
318 LOCAL_UNSTRIPPED_PATH := $(PRODUCT_OUT)/symbols/utilities
319 LOCAL_MODULE := toybox_static
320 LOCAL_MODULE_CLASS := UTILITY_EXECUTABLES
321 LOCAL_MODULE_PATH := $(PRODUCT_OUT)/utilities
322 LOCAL_MODULE_TAGS := optional
323 LOCAL_MODULE_STEM := toybox
324 LOCAL_PACK_MODULE_RELOCATIONS := false
325 LOCAL_STATIC_LIBRARIES := libc libtoybox libcutils libselinux libcrypto_static liblog
326 LOCAL_FORCE_STATIC_EXECUTABLE := true
327 include $(BUILD_EXECUTABLE)