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 awk 'match($$0, /TOYBOX_VERSION.*"(.*)"/, ary) {print ary[1]}' $(LOCAL_PATH)/main.c)
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 .
60 # # (Select the toy you want to add.)
61 # make clean && make # Regenerate the generated files.
62 # # Edit LOCAL_SRC_FILES below to add the toy.
63 # # If you just want to use it as "toybox x" rather than "x", you can stop now.
64 # # If you want this toy to have a symbolic link in /system/bin, add the toy to ALL_TOOLS.
73 lib/interestingtimes.c \
82 toys/android/getenforce.c \
83 toys/android/getprop.c \
84 toys/android/load_policy.c \
85 toys/android/restorecon.c \
86 toys/android/runcon.c \
87 toys/android/setenforce.c \
88 toys/android/setprop.c \
101 toys/other/base64.c \
103 toys/other/blockdev.c \
106 toys/other/chroot.c \
108 toys/other/dos2unix.c \
109 toys/other/fallocate.c \
112 toys/other/freeramdisk.c \
113 toys/other/fsfreeze.c \
115 toys/other/hwclock.c \
116 toys/other/ifconfig.c \
117 toys/other/inotifyd.c \
118 toys/other/insmod.c \
119 toys/other/ionice.c \
120 toys/other/losetup.c \
121 toys/other/lsattr.c \
125 toys/other/makedevs.c \
126 toys/other/mkswap.c \
127 toys/other/modinfo.c \
128 toys/other/mountpoint.c \
129 toys/other/nbd_client.c \
130 toys/other/netcat.c \
131 toys/other/partprobe.c \
132 toys/other/pivot_root.c \
134 toys/other/printenv.c \
136 toys/other/readahead.c \
137 toys/other/readlink.c \
138 toys/other/realpath.c \
141 toys/other/rfkill.c \
143 toys/other/setsid.c \
145 toys/other/swapoff.c \
146 toys/other/swapon.c \
147 toys/other/switch_root.c \
148 toys/other/sysctl.c \
150 toys/other/taskset.c \
151 toys/other/timeout.c \
152 toys/other/truncate.c \
153 toys/other/uptime.c \
154 toys/other/usleep.c \
155 toys/other/vconfig.c \
156 toys/other/vmstat.c \
162 toys/pending/diff.c \
163 toys/pending/expr.c \
164 toys/pending/fdisk.c \
165 toys/pending/file.c \
166 toys/pending/ftpget.c \
167 toys/pending/host.c \
168 toys/pending/lsof.c \
169 toys/pending/more.c \
170 toys/pending/netstat.c \
171 toys/pending/resize.c \
172 toys/pending/route.c \
174 toys/pending/telnet.c \
175 toys/pending/test.c \
177 toys/pending/traceroute.c \
178 toys/pending/watch.c \
179 toys/pending/xzcat.c \
180 toys/posix/basename.c \
193 toys/posix/dirname.c \
197 toys/posix/expand.c \
207 toys/posix/mkfifo.c \
214 toys/posix/printf.c \
217 toys/posix/renice.c \
224 toys/posix/strings.c \
231 toys/posix/ulimit.c \
237 LOCAL_CFLAGS := $(common_cflags)
240 # This doesn't actually prevent us from dragging in libc++ at runtime
241 # because libnetd_client.so is C++.
242 LOCAL_CXX_STL := none
244 LOCAL_C_INCLUDES += bionic/libc/dns/include
246 LOCAL_MODULE := libtoybox
248 include $(BUILD_STATIC_LIBRARY)
251 # Host binary to enumerate the toys
252 include $(CLEAR_VARS)
253 LOCAL_SRC_FILES := scripts/install.c
254 LOCAL_MODULE_TAGS := optional
255 LOCAL_CFLAGS := $(common_cflags)
257 LOCAL_MODULE := toybox-instlist
258 include $(BUILD_HOST_EXECUTABLE)
261 include $(CLEAR_VARS)
262 LOCAL_SRC_FILES := main.c
263 LOCAL_STATIC_LIBRARIES := libtoybox
264 LOCAL_SHARED_LIBRARIES := libcutils libselinux
265 LOCAL_CFLAGS := $(common_cflags)
266 LOCAL_CXX_STL := none
268 LOCAL_MODULE := toybox
270 # for dumping the list of toys
271 TOYBOX_INSTLIST := $(HOST_OUT_EXECUTABLES)/toybox-instlist
272 LOCAL_ADDITIONAL_DEPENDENCIES := toybox_links
274 # we still want a link for ls/ps, but the toolbox version needs to
275 # stick around for compatibility reasons, for now.
276 TOYS_FOR_XBIN := ls ps
278 # skip links for these toys in the system image, they already have
279 # a full-blown counterpart. we still want them for the recovery
281 TOYS_WITHOUT_LINKS := blkid
283 include $(BUILD_EXECUTABLE)
285 toybox_links: $(TOYBOX_INSTLIST) toybox
286 toybox_links: TOY_LIST=$(shell $(TOYBOX_INSTLIST))
287 toybox_links: TOYBOX_BINARY := $(TARGET_OUT)/bin/toybox
289 @echo -e ${CL_CYN}"Generate Toybox links:"${CL_RST} $(TOY_LIST)
290 @mkdir -p $(TARGET_OUT)/bin
291 @mkdir -p $(TARGET_OUT)/xbin
292 $(hide) $(foreach t,$(filter-out $(TOYS_FOR_XBIN) $(TOYS_WITHOUT_LINKS),$(TOY_LIST)),ln -sf toybox $(TARGET_OUT_EXECUTABLES)/$(t);)
293 $(hide) $(foreach t,$(TOYS_FOR_XBIN),ln -sf /system/bin/toybox $(TARGET_OUT_OPTIONAL_EXECUTABLES)/$(t);)
296 # This is used by the recovery system
297 include $(CLEAR_VARS)
298 LOCAL_SRC_FILES := main.c
299 LOCAL_WHOLE_STATIC_LIBRARIES := libtoybox
300 LOCAL_CFLAGS := $(common_cflags)
301 LOCAL_CFLAGS += -Dmain=toybox_driver
302 LOCAL_CXX_STL := none
304 LOCAL_MODULE := libtoybox_driver
305 include $(BUILD_STATIC_LIBRARY)
307 # static executable for use in limited environments
308 include $(CLEAR_VARS)
309 LOCAL_SRC_FILES := main.c
310 LOCAL_CFLAGS := $(common_cflags)
311 LOCAL_CXX_STL := none
313 LOCAL_UNSTRIPPED_PATH := $(PRODUCT_OUT)/symbols/utilities
314 LOCAL_MODULE := toybox_static
315 LOCAL_MODULE_CLASS := UTILITY_EXECUTABLES
316 LOCAL_MODULE_PATH := $(PRODUCT_OUT)/utilities
317 LOCAL_MODULE_TAGS := optional
318 LOCAL_MODULE_STEM := toybox
319 LOCAL_STATIC_LIBRARIES := libc libtoybox libcutils libselinux libmincrypt
320 LOCAL_FORCE_STATIC_EXECUTABLE := true
321 include $(BUILD_EXECUTABLE)