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.
52 lib/interestingtimes.c \
60 toys/android/getenforce.c \
61 toys/android/getprop.c \
62 toys/android/load_policy.c \
64 toys/android/restorecon.c \
65 toys/android/runcon.c \
66 toys/android/sendevent.c \
67 toys/android/setenforce.c \
68 toys/android/setprop.c \
69 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 \
111 toys/other/makedevs.c \
112 toys/other/mkswap.c \
113 toys/other/modinfo.c \
114 toys/other/mountpoint.c \
115 toys/other/nbd_client.c \
116 toys/other/partprobe.c \
117 toys/other/pivot_root.c \
119 toys/other/printenv.c \
121 toys/other/readlink.c \
122 toys/other/realpath.c \
125 toys/other/setsid.c \
127 toys/other/swapoff.c \
128 toys/other/swapon.c \
129 toys/other/sysctl.c \
131 toys/other/taskset.c \
132 toys/other/timeout.c \
133 toys/other/truncate.c \
134 toys/other/uptime.c \
135 toys/other/usleep.c \
136 toys/other/vconfig.c \
137 toys/other/vmstat.c \
142 toys/pending/diff.c \
143 toys/pending/expr.c \
144 toys/pending/getfattr.c \
145 toys/pending/gzip.c \
146 toys/pending/lsof.c \
147 toys/pending/modprobe.c \
148 toys/pending/more.c \
149 toys/pending/setfattr.c \
152 toys/pending/traceroute.c \
153 toys/posix/basename.c \
166 toys/posix/dirname.c \
170 toys/posix/expand.c \
181 toys/posix/mkfifo.c \
188 toys/posix/printf.c \
191 toys/posix/renice.c \
198 toys/posix/strings.c \
205 toys/posix/ulimit.c \
208 toys/posix/uudecode.c \
209 toys/posix/uuencode.c \
216 -Wno-char-subscripts \
217 -Wno-gnu-variable-sized-type-not-at-end \
218 -Wno-missing-field-initializers \
220 -Wno-string-plus-int \
222 -Wno-unused-parameter \
224 -ffunction-sections -fdata-sections \
225 -fno-asynchronous-unwind-tables \
227 toybox_upstream_version := $(shell sed 's/#define.*TOYBOX_VERSION.*"\(.*\)"/\1/p;d' $(LOCAL_PATH)/main.c)
229 toybox_version := $(toybox_upstream_version)-android-$(BUILD_NUMBER_FROM_FILE)
231 toybox_libraries := liblog libselinux libcutils libcrypto libz
233 common_CFLAGS += -DTOYBOX_VERSION=\"$(toybox_version)\"
235 # not usable on Android?: freeramdisk fsfreeze install makedevs nbd-client
236 # partprobe pivot_root pwdx rev rfkill vconfig
237 # currently prefer BSD system/core/toolbox: dd
238 # currently prefer BSD external/netcat: nc netcat
239 # currently prefer external/efs2progs: blkid chattr lsattr
393 ############################################
395 ############################################
397 include $(CLEAR_VARS)
398 LOCAL_MODULE := toybox
399 LOCAL_SRC_FILES := $(common_SRC_FILES)
400 LOCAL_CFLAGS := $(common_CFLAGS)
401 LOCAL_SHARED_LIBRARIES := $(toybox_libraries)
402 # This doesn't actually prevent us from dragging in libc++ at runtime
403 # because libnetd_client.so is C++.
404 LOCAL_CXX_STL := none
405 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf toybox $(TARGET_OUT)/bin/$(t);)
406 include $(BUILD_EXECUTABLE)
408 ############################################
409 # static version to be installed in /vendor
410 ############################################
412 ifeq ($(PRODUCT_FULL_TREBLE),true)
413 include $(CLEAR_VARS)
414 LOCAL_MODULE := toybox_vendor
415 LOCAL_VENDOR_MODULE := true
416 LOCAL_SRC_FILES := $(common_SRC_FILES)
417 LOCAL_CFLAGS := $(common_CFLAGS)
418 LOCAL_STATIC_LIBRARIES := $(toybox_libraries)
419 # libc++_static is needed by static liblog
420 LOCAL_CXX_STL := libc++_static
421 LOCAL_MODULE_TAGS := optional
422 LOCAL_FORCE_STATIC_EXECUTABLE := true
423 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf ${LOCAL_MODULE} $(TARGET_OUT_VENDOR_EXECUTABLES)/$(t);)
424 include $(BUILD_EXECUTABLE)
427 ############################################
428 # static version to be installed in recovery
429 ############################################
431 include $(CLEAR_VARS)
432 LOCAL_MODULE := toybox_static
433 LOCAL_SRC_FILES := $(common_SRC_FILES)
434 LOCAL_CFLAGS := $(common_CFLAGS)
435 LOCAL_STATIC_LIBRARIES := $(toybox_libraries)
436 # libc++_static is needed by static liblog
437 LOCAL_CXX_STL := libc++_static
438 LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
439 LOCAL_FORCE_STATIC_EXECUTABLE := true
440 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf ${LOCAL_MODULE} $(LOCAL_MODULE_PATH)/$(t);)
441 include $(BUILD_EXECUTABLE)