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/load_policy.c \
71 toys/android/restorecon.c \
72 toys/android/runcon.c \
73 toys/android/sendevent.c \
74 toys/android/setenforce.c \
75 toys/android/setprop.c \
76 toys/android/start.c \
97 toys/other/blockdev.c \
102 toys/other/dos2unix.c \
103 toys/other/fallocate.c \
106 toys/other/freeramdisk.c \
107 toys/other/fsfreeze.c \
109 toys/other/hwclock.c \
110 toys/other/inotifyd.c \
111 toys/other/insmod.c \
112 toys/other/ionice.c \
113 toys/other/losetup.c \
114 toys/other/lsattr.c \
118 toys/other/makedevs.c \
119 toys/other/mkswap.c \
120 toys/other/modinfo.c \
121 toys/other/mountpoint.c \
122 toys/other/nbd_client.c \
123 toys/other/partprobe.c \
124 toys/other/pivot_root.c \
126 toys/other/printenv.c \
128 toys/other/readlink.c \
129 toys/other/realpath.c \
132 toys/other/setfattr.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 \
153 toys/pending/getfattr.c \
154 toys/pending/gzip.c \
155 toys/pending/lsof.c \
156 toys/pending/modprobe.c \
157 toys/pending/more.c \
158 toys/pending/stty.c \
161 toys/pending/traceroute.c \
162 toys/posix/basename.c \
175 toys/posix/dirname.c \
179 toys/posix/expand.c \
190 toys/posix/mkfifo.c \
197 toys/posix/printf.c \
200 toys/posix/renice.c \
207 toys/posix/strings.c \
214 toys/posix/ulimit.c \
217 toys/posix/uudecode.c \
218 toys/posix/uuencode.c \
226 -Wno-char-subscripts \
227 -Wno-gnu-variable-sized-type-not-at-end \
228 -Wno-missing-field-initializers \
230 -Wno-string-plus-int \
232 -Wno-unused-parameter \
234 -ffunction-sections -fdata-sections \
235 -fno-asynchronous-unwind-tables \
237 toybox_libraries := liblog libselinux libcutils libcrypto libz
239 common_CFLAGS += -DTOYBOX_VENDOR=\"-android\"
241 # not usable on Android?: freeramdisk fsfreeze install makedevs nbd-client
242 # partprobe pivot_root pwdx rev rfkill vconfig
243 # currently prefer BSD system/core/toolbox: dd
244 # currently prefer BSD external/netcat: nc netcat
245 # currently prefer external/efs2progs: blkid chattr lsattr
400 ############################################
402 ############################################
404 include $(CLEAR_VARS)
405 LOCAL_MODULE := toybox
406 LOCAL_SRC_FILES := $(common_SRC_FILES)
407 LOCAL_CFLAGS := $(common_CFLAGS)
408 LOCAL_SHARED_LIBRARIES := $(toybox_libraries)
409 # This doesn't actually prevent us from dragging in libc++ at runtime
410 # because libnetd_client.so is C++.
411 LOCAL_CXX_STL := none
412 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf toybox $(TARGET_OUT)/bin/$(t);)
413 include $(BUILD_EXECUTABLE)
415 ############################################
417 ############################################
419 include $(CLEAR_VARS)
420 LOCAL_MODULE := toybox_vendor
421 LOCAL_VENDOR_MODULE := true
422 LOCAL_SRC_FILES := $(common_SRC_FILES)
423 LOCAL_CFLAGS := $(common_CFLAGS)
424 LOCAL_STATIC_LIBRARIES := libcutils libcrypto libz
425 LOCAL_SHARED_LIBRARIES := libselinux liblog
426 LOCAL_MODULE_TAGS := optional
427 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf ${LOCAL_MODULE} $(TARGET_OUT_VENDOR_EXECUTABLES)/$(t);)
428 include $(BUILD_EXECUTABLE)
430 ############################################
431 # static version to be installed in recovery
432 ############################################
434 include $(CLEAR_VARS)
435 LOCAL_MODULE := toybox_static
436 LOCAL_SRC_FILES := $(common_SRC_FILES)
437 LOCAL_CFLAGS := $(common_CFLAGS)
438 LOCAL_STATIC_LIBRARIES := $(toybox_libraries)
439 # libc++_static is needed by static liblog
440 LOCAL_CXX_STL := libc++_static
441 LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
442 LOCAL_FORCE_STATIC_EXECUTABLE := true
443 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf ${LOCAL_MODULE} $(LOCAL_MODULE_PATH)/$(t);)
444 include $(BUILD_EXECUTABLE)