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 .
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/sysctl.c \
149 toys/other/taskset.c \
150 toys/other/timeout.c \
151 toys/other/truncate.c \
152 toys/other/uptime.c \
153 toys/other/usleep.c \
154 toys/other/vconfig.c \
155 toys/other/vmstat.c \
161 toys/pending/diff.c \
162 toys/pending/expr.c \
163 toys/pending/fdisk.c \
164 toys/pending/file.c \
165 toys/pending/ftpget.c \
166 toys/pending/host.c \
167 toys/pending/lsof.c \
168 toys/pending/more.c \
169 toys/pending/netstat.c \
170 toys/pending/resize.c \
171 toys/pending/route.c \
173 toys/pending/telnet.c \
174 toys/pending/test.c \
176 toys/pending/traceroute.c \
177 toys/pending/watch.c \
178 toys/pending/xzcat.c \
179 toys/posix/basename.c \
192 toys/posix/dirname.c \
196 toys/posix/expand.c \
206 toys/posix/mkfifo.c \
213 toys/posix/printf.c \
216 toys/posix/renice.c \
223 toys/posix/strings.c \
230 toys/posix/ulimit.c \
236 LOCAL_CFLAGS := $(common_cflags)
239 LOCAL_STATIC_LIBRARIES := libselinux
241 # This doesn't actually prevent us from dragging in libc++ at runtime
242 # because libnetd_client.so is C++.
243 LOCAL_CXX_STL := none
245 LOCAL_C_INCLUDES += bionic/libc/dns/include
247 LOCAL_MODULE := libtoybox
249 include $(BUILD_STATIC_LIBRARY)
252 # Host binary to enumerate the toys
253 include $(CLEAR_VARS)
254 LOCAL_SRC_FILES := scripts/install.c
255 LOCAL_MODULE_TAGS := optional
256 LOCAL_CFLAGS := $(common_cflags)
258 LOCAL_MODULE := toybox-instlist
259 include $(BUILD_HOST_EXECUTABLE)
262 include $(CLEAR_VARS)
263 LOCAL_SRC_FILES := main.c
264 LOCAL_STATIC_LIBRARIES := libtoybox
265 LOCAL_SHARED_LIBRARIES := libcutils libselinux
266 LOCAL_CFLAGS := $(common_cflags)
267 LOCAL_CXX_STL := none
269 LOCAL_MODULE := toybox
271 # for dumping the list of toys
272 TOYBOX_INSTLIST := $(HOST_OUT_EXECUTABLES)/toybox-instlist
273 LOCAL_ADDITIONAL_DEPENDENCIES := toybox_links
275 # we still want a link for ls/ps, but the toolbox version needs to
276 # stick around for compatibility reasons, for now.
277 TOYS_FOR_XBIN := ls ps
279 # skip links for these toys in the system image, they already have
280 # a full-blown counterpart. we still want them for the recovery
282 TOYS_WITHOUT_LINKS := blkid traceroute6
284 include $(BUILD_EXECUTABLE)
286 toybox_links: $(TOYBOX_INSTLIST)
287 toybox_links: TOYBOX_BINARY := $(TARGET_OUT)/bin/toybox
289 @echo -e ${CL_CYN}"Generate Toybox links:"${CL_RST} $$($(TOYBOX_INSTLIST))
290 @mkdir -p $(TARGET_OUT_EXECUTABLES) $(TARGET_OUT_OPTIONAL_EXECUTABLES)
291 $(hide) $(TOYBOX_INSTLIST) | grep -vFx -f <(tr ' ' '\n' <<< '$(TOYS_FOR_XBIN) $(TOYS_WITHOUT_LINKS)') | xargs -I'{}' ln -sf toybox '$(TARGET_OUT_EXECUTABLES)/{}'
292 $(hide) tr ' ' '\n' <<< '$(TOYS_FOR_XBIN)' | xargs -I'{}' ln -sf ../bin/toybox '$(TARGET_OUT_OPTIONAL_EXECUTABLES)/{}'
295 # This is used by the recovery system
296 include $(CLEAR_VARS)
297 LOCAL_SRC_FILES := main.c
298 LOCAL_WHOLE_STATIC_LIBRARIES := libselinux libtoybox
299 LOCAL_CFLAGS := $(common_cflags)
300 LOCAL_CFLAGS += -Dmain=toybox_driver
301 LOCAL_CXX_STL := none
303 LOCAL_MODULE := libtoybox_driver
304 include $(BUILD_STATIC_LIBRARY)
306 # static executable for use in limited environments
307 include $(CLEAR_VARS)
308 LOCAL_SRC_FILES := main.c
309 LOCAL_CFLAGS := $(common_cflags)
310 LOCAL_CXX_STL := none
312 LOCAL_UNSTRIPPED_PATH := $(PRODUCT_OUT)/symbols/utilities
313 LOCAL_MODULE := toybox_static
314 LOCAL_MODULE_CLASS := UTILITY_EXECUTABLES
315 LOCAL_MODULE_PATH := $(PRODUCT_OUT)/utilities
316 LOCAL_MODULE_TAGS := optional
317 LOCAL_MODULE_STEM := toybox
318 LOCAL_PACK_MODULE_RELOCATIONS := false
319 LOCAL_STATIC_LIBRARIES := libc libtoybox libcutils libselinux libmincrypt liblog
320 LOCAL_FORCE_STATIC_EXECUTABLE := true
321 include $(BUILD_EXECUTABLE)