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 -Wno-char-subscripts \
25 -Wno-string-plus-int \
27 -Wno-unused-parameter \
29 -ffunction-sections -fdata-sections \
30 -fno-asynchronous-unwind-tables \
32 toybox_version := $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)-android
33 common_cflags += -DTOYBOX_VERSION='"$(toybox_version)"'
39 # git remote add toybox https://github.com/landley/toybox.git
41 # git merge toybox/master
43 # # (Make any necessary Android.mk changes and test the new toybox.)
45 # git push aosp HEAD:refs/for/master # Push to gerrit for review.
46 # git push aosp HEAD:master # Push directly, avoiding gerrit.
48 # # Now commit any necessary Android.mk changes like normal:
49 # repo start post-sync .
58 # # (Select the toy you want to add.)
59 # make clean && make # Regenerate the generated files.
60 # # Edit LOCAL_SRC_FILES below to add the toy.
61 # # If you just want to use it as "toybox x" rather than "x", you can stop now.
62 # # If you want this toy to have a symbolic link in /system/bin, add the toy to ALL_TOOLS.
71 lib/interestingtimes.c \
80 toys/android/getenforce.c \
81 toys/android/getprop.c \
82 toys/android/load_policy.c \
83 toys/android/restorecon.c \
84 toys/android/runcon.c \
85 toys/android/setenforce.c \
86 toys/android/setprop.c \
101 toys/other/blockdev.c \
104 toys/other/chroot.c \
106 toys/other/dos2unix.c \
107 toys/other/fallocate.c \
110 toys/other/freeramdisk.c \
111 toys/other/fsfreeze.c \
113 toys/other/hwclock.c \
114 toys/other/ifconfig.c \
115 toys/other/inotifyd.c \
116 toys/other/insmod.c \
117 toys/other/ionice.c \
118 toys/other/losetup.c \
119 toys/other/lsattr.c \
122 toys/other/makedevs.c \
123 toys/other/mkswap.c \
124 toys/other/modinfo.c \
125 toys/other/mountpoint.c \
126 toys/other/nbd_client.c \
127 toys/other/netcat.c \
128 toys/other/partprobe.c \
129 toys/other/pivot_root.c \
131 toys/other/printenv.c \
133 toys/other/readahead.c \
134 toys/other/readlink.c \
135 toys/other/realpath.c \
138 toys/other/rfkill.c \
140 toys/other/setsid.c \
142 toys/other/swapoff.c \
143 toys/other/swapon.c \
144 toys/other/switch_root.c \
145 toys/other/sysctl.c \
147 toys/other/taskset.c \
148 toys/other/timeout.c \
149 toys/other/truncate.c \
150 toys/other/uptime.c \
151 toys/other/usleep.c \
152 toys/other/vconfig.c \
153 toys/other/vmstat.c \
159 toys/pending/diff.c \
160 toys/pending/expr.c \
161 toys/pending/fdisk.c \
162 toys/pending/ftpget.c \
163 toys/pending/host.c \
164 toys/pending/lsof.c \
165 toys/pending/more.c \
166 toys/pending/netstat.c \
167 toys/pending/resize.c \
168 toys/pending/route.c \
170 toys/pending/telnet.c \
171 toys/pending/test.c \
173 toys/pending/traceroute.c \
174 toys/pending/watch.c \
175 toys/pending/xzcat.c \
176 toys/posix/basename.c \
189 toys/posix/dirname.c \
193 toys/posix/expand.c \
203 toys/posix/mkfifo.c \
210 toys/posix/printf.c \
213 toys/posix/renice.c \
220 toys/posix/strings.c \
232 LOCAL_CFLAGS := $(common_cflags)
235 # This doesn't actually prevent us from dragging in libc++ at runtime
236 # because libnetd_client.so is C++.
237 LOCAL_CXX_STL := none
239 LOCAL_C_INCLUDES += bionic/libc/dns/include
241 LOCAL_MODULE := libtoybox
243 include $(BUILD_STATIC_LIBRARY)
246 # Host binary to enumerate the toys
247 include $(CLEAR_VARS)
248 LOCAL_SRC_FILES := scripts/install.c
249 LOCAL_MODULE_TAGS := optional
250 LOCAL_CFLAGS := $(common_cflags)
252 LOCAL_MODULE := toybox-instlist
253 include $(BUILD_HOST_EXECUTABLE)
256 include $(CLEAR_VARS)
257 LOCAL_SRC_FILES := main.c
258 LOCAL_STATIC_LIBRARIES := libtoybox
259 LOCAL_SHARED_LIBRARIES := libcutils libselinux
260 LOCAL_CFLAGS := $(common_cflags)
261 LOCAL_CXX_STL := none
263 LOCAL_MODULE := toybox
265 # for dumping the list of toys
266 TOYBOX_INSTLIST := $(HOST_OUT_EXECUTABLES)/toybox-instlist
267 LOCAL_ADDITIONAL_DEPENDENCIES := toybox_links
269 # we still want a link for ls/ps, but the toolbox version needs to
270 # stick around for compatibility reasons, for now.
271 TOYS_FOR_XBIN := ls ps
273 # skip links for these toys in the system image, they already have
274 # a full-blown counterpart. we still want them for the recovery
276 TOYS_WITHOUT_LINKS := blkid
278 include $(BUILD_EXECUTABLE)
280 toybox_links: $(TOYBOX_INSTLIST) toybox
281 toybox_links: TOY_LIST=$(shell $(TOYBOX_INSTLIST))
282 toybox_links: TOYBOX_BINARY := $(TARGET_OUT)/bin/toybox
284 @echo -e ${CL_CYN}"Generate Toybox links:"${CL_RST} $(TOY_LIST)
285 @mkdir -p $(TARGET_OUT)/bin
286 @mkdir -p $(TARGET_OUT)/xbin
287 $(hide) $(foreach t,$(filter-out $(TOYS_FOR_XBIN) $(TOYS_WITHOUT_LINKS),$(TOY_LIST)),ln -sf toybox $(TARGET_OUT_EXECUTABLES)/$(t);)
288 $(hide) $(foreach t,$(TOYS_FOR_XBIN),ln -sf /system/bin/toybox $(TARGET_OUT_OPTIONAL_EXECUTABLES)/$(t);)
291 # This is used by the recovery system
292 include $(CLEAR_VARS)
293 LOCAL_SRC_FILES := main.c
294 LOCAL_WHOLE_STATIC_LIBRARIES := libtoybox
295 LOCAL_CFLAGS := $(common_cflags)
296 LOCAL_CFLAGS += -Dmain=toybox_driver
297 LOCAL_CXX_STL := none
299 LOCAL_MODULE := libtoybox_driver
300 include $(BUILD_STATIC_LIBRARY)
302 # static executable for use in limited environments
303 include $(CLEAR_VARS)
304 LOCAL_SRC_FILES := main.c
305 LOCAL_CFLAGS := $(common_cflags)
306 LOCAL_CXX_STL := none
308 LOCAL_UNSTRIPPED_PATH := $(PRODUCT_OUT)/symbols/utilities
309 LOCAL_MODULE := toybox_static
310 LOCAL_MODULE_CLASS := UTILITY_EXECUTABLES
311 LOCAL_MODULE_PATH := $(PRODUCT_OUT)/utilities
312 LOCAL_MODULE_TAGS := optional
313 LOCAL_MODULE_STEM := toybox
314 LOCAL_STATIC_LIBRARIES := libc libtoybox libcutils libselinux libmincrypt
315 LOCAL_FORCE_STATIC_EXECUTABLE := true
316 include $(BUILD_EXECUTABLE)