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)
20 # To sync with upstream:
24 # git remote add toybox https://github.com/landley/toybox.git
26 # git merge toybox/master
28 # # Regenerate generated files.
31 # # Make any necessary Android.mk changes and rebuild.
35 # ./run-tests-on-android.sh
36 # # Run a single test.
37 # ./run-tests-on-android.sh wc
40 # git commit -a --amend
41 # git push aosp HEAD:refs/for/master # Push to gerrit for review.
42 # git push aosp HEAD:master # Push directly, avoiding gerrit.
49 # Edit .config to enable the toy you want to add.
50 # make clean && make # Regenerate the generated files.
51 # # Edit LOCAL_SRC_FILES below to add the toy.
52 # # If you just want to use it as "toybox x" rather than "x", you can stop now.
53 # # If you want this toy to have a symbolic link in /system/bin, add the toy to ALL_TOOLS.
60 lib/interestingtimes.c \
68 toys/android/getenforce.c \
69 toys/android/getprop.c \
70 toys/android/load_policy.c \
72 toys/android/restorecon.c \
73 toys/android/runcon.c \
74 toys/android/sendevent.c \
75 toys/android/setenforce.c \
76 toys/android/setprop.c \
77 toys/android/start.c \
98 toys/other/blockdev.c \
100 toys/other/chroot.c \
103 toys/other/dos2unix.c \
104 toys/other/fallocate.c \
107 toys/other/freeramdisk.c \
108 toys/other/fsfreeze.c \
110 toys/other/hwclock.c \
111 toys/other/inotifyd.c \
112 toys/other/insmod.c \
113 toys/other/ionice.c \
114 toys/other/losetup.c \
115 toys/other/lsattr.c \
119 toys/other/makedevs.c \
120 toys/other/mkswap.c \
121 toys/other/modinfo.c \
122 toys/other/mountpoint.c \
123 toys/other/nbd_client.c \
124 toys/other/partprobe.c \
125 toys/other/pivot_root.c \
127 toys/other/printenv.c \
129 toys/other/readlink.c \
130 toys/other/realpath.c \
133 toys/other/setsid.c \
135 toys/other/swapoff.c \
136 toys/other/swapon.c \
137 toys/other/sysctl.c \
139 toys/other/taskset.c \
140 toys/other/timeout.c \
141 toys/other/truncate.c \
142 toys/other/uptime.c \
143 toys/other/usleep.c \
144 toys/other/vconfig.c \
145 toys/other/vmstat.c \
150 toys/pending/diff.c \
151 toys/pending/expr.c \
152 toys/pending/getfattr.c \
153 toys/pending/gzip.c \
154 toys/pending/lsof.c \
155 toys/pending/modprobe.c \
156 toys/pending/more.c \
157 toys/pending/setfattr.c \
160 toys/pending/traceroute.c \
161 toys/posix/basename.c \
174 toys/posix/dirname.c \
178 toys/posix/expand.c \
189 toys/posix/mkfifo.c \
196 toys/posix/printf.c \
199 toys/posix/renice.c \
206 toys/posix/strings.c \
213 toys/posix/ulimit.c \
216 toys/posix/uudecode.c \
217 toys/posix/uuencode.c \
224 -Wno-char-subscripts \
225 -Wno-gnu-variable-sized-type-not-at-end \
226 -Wno-missing-field-initializers \
228 -Wno-string-plus-int \
230 -Wno-unused-parameter \
232 -ffunction-sections -fdata-sections \
233 -fno-asynchronous-unwind-tables \
235 toybox_upstream_version := $(shell sed 's/#define.*TOYBOX_VERSION.*"\(.*\)"/\1/p;d' $(LOCAL_PATH)/main.c)
237 toybox_version := $(toybox_upstream_version)-android
239 toybox_libraries := liblog libselinux libcutils libcrypto libz
241 common_CFLAGS += -DTOYBOX_VERSION=\"$(toybox_version)\"
243 # not usable on Android?: freeramdisk fsfreeze install makedevs nbd-client
244 # partprobe pivot_root pwdx rev rfkill vconfig
245 # currently prefer BSD system/core/toolbox: dd
246 # currently prefer BSD external/netcat: nc netcat
247 # currently prefer external/efs2progs: blkid chattr lsattr
401 ############################################
403 ############################################
405 include $(CLEAR_VARS)
406 LOCAL_MODULE := toybox
407 LOCAL_SRC_FILES := $(common_SRC_FILES)
408 LOCAL_CFLAGS := $(common_CFLAGS)
409 LOCAL_SHARED_LIBRARIES := $(toybox_libraries)
410 # This doesn't actually prevent us from dragging in libc++ at runtime
411 # because libnetd_client.so is C++.
412 LOCAL_CXX_STL := none
413 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf toybox $(TARGET_OUT)/bin/$(t);)
414 include $(BUILD_EXECUTABLE)
416 ############################################
418 ############################################
420 include $(CLEAR_VARS)
421 LOCAL_MODULE := toybox_vendor
422 LOCAL_VENDOR_MODULE := true
423 LOCAL_SRC_FILES := $(common_SRC_FILES)
424 LOCAL_CFLAGS := $(common_CFLAGS)
425 LOCAL_STATIC_LIBRARIES := libcutils libcrypto libz
426 LOCAL_SHARED_LIBRARIES := libselinux_vendor liblog
427 LOCAL_MODULE_TAGS := optional
428 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf ${LOCAL_MODULE} $(TARGET_OUT_VENDOR_EXECUTABLES)/$(t);)
429 include $(BUILD_EXECUTABLE)
431 ############################################
432 # static version to be installed in recovery
433 ############################################
435 include $(CLEAR_VARS)
436 LOCAL_MODULE := toybox_static
437 LOCAL_SRC_FILES := $(common_SRC_FILES)
438 LOCAL_CFLAGS := $(common_CFLAGS)
439 LOCAL_STATIC_LIBRARIES := $(toybox_libraries)
440 # libc++_static is needed by static liblog
441 LOCAL_CXX_STL := libc++_static
442 LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
443 LOCAL_FORCE_STATIC_EXECUTABLE := true
444 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf ${LOCAL_MODULE} $(LOCAL_MODULE_PATH)/$(t);)
445 include $(BUILD_EXECUTABLE)