blob: 78adf1ec3c4d79ea204437e3986723178f27e2d3 [file] [log] [blame]
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08001LOCAL_PATH:= $(call my-dir)
2include $(CLEAR_VARS)
3
4TOOLS := \
5 ls \
6 mount \
7 cat \
8 ps \
9 kill \
10 ln \
11 insmod \
12 rmmod \
13 lsmod \
14 ifconfig \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080015 rm \
16 mkdir \
17 rmdir \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080018 getevent \
19 sendevent \
20 date \
21 wipe \
22 sync \
23 umount \
24 start \
25 stop \
26 notify \
27 cmp \
28 dmesg \
29 route \
30 hd \
31 dd \
32 df \
33 getprop \
34 setprop \
35 watchprops \
36 log \
37 sleep \
38 renice \
39 printenv \
40 smd \
41 chmod \
Dries Harnie2a743732010-01-18 17:44:33 +010042 chown \
San Mehat72eead42009-07-06 11:10:03 -070043 newfs_msdos \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080044 netstat \
45 ioctl \
46 mv \
47 schedtop \
48 top \
49 iftop \
50 id \
Mike Lockwooda699d622010-04-09 15:27:16 -040051 uptime \
Arve Hjønnevåg7c953d02009-09-17 17:30:55 -070052 vmstat \
San Mehat10d469b2010-02-25 14:02:55 -080053 nandread \
Kenny Root8b9b1052010-07-27 09:20:02 -070054 ionice \
Ken Sumrall795165b2011-04-05 20:46:30 -070055 touch \
Scott Andersond0455c92012-01-11 18:13:26 -080056 lsof \
Jeff Sharkey57df14c2012-07-13 16:25:33 -070057 du \
Michael Wright52abb4b2012-07-15 15:52:50 -070058 md5 \
Kenny Rootefb5e3c2012-10-16 18:00:29 -070059 clear \
Stephen Smalley8290d102012-01-13 08:53:56 -050060 getenforce \
61 setenforce \
62 chcon \
63 restorecon \
64 runcon \
65 getsebool \
66 setsebool \
Rom Lemarchand367297c2013-06-05 13:25:12 -070067 load_policy \
68 swapon \
69 swapoff \
Michael Wright9f50abd2013-08-19 15:56:34 -070070 mkswap \
Glenn Kasten3707e7f2013-09-23 15:10:12 -070071 readlink \
Sujith Ramakrishnan71bbbd12014-01-14 16:57:22 -080072 mknod \
Glenn Kasten3707e7f2013-09-23 15:10:12 -070073 nohup
Stephen Smalley8290d102012-01-13 08:53:56 -050074
Erik Gillingb76f0ff2011-04-28 14:23:26 -070075ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
76TOOLS += r
77endif
78
Jeff Sharkey57df14c2012-07-13 16:25:33 -070079ALL_TOOLS = $(TOOLS)
80ALL_TOOLS += \
Jeff Sharkey3e8b1582012-07-13 16:37:13 -070081 cp \
82 grep
Jeff Sharkey57df14c2012-07-13 16:25:33 -070083
84LOCAL_SRC_FILES := \
Elliott Hughes0b024672014-02-28 16:48:49 -080085 cp/cp.c \
86 cp/utils.c \
David 'Digit' Turnera8d1afb2011-01-06 08:39:44 +010087 dynarray.c \
Elliott Hughes0b024672014-02-28 16:48:49 -080088 grep/fastgrep.c \
89 grep/file.c \
90 grep/grep.c \
91 grep/queue.c \
92 grep/util.c \
Jeff Sharkey57df14c2012-07-13 16:25:33 -070093 $(patsubst %,%.c,$(TOOLS)) \
Elliott Hughes0b024672014-02-28 16:48:49 -080094 toolbox.c \
95 uid_from_user.c \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080096
Scott Andersond0455c92012-01-11 18:13:26 -080097LOCAL_C_INCLUDES := bionic/libc/bionic
98
Elliott Hughes0b024672014-02-28 16:48:49 -080099LOCAL_CFLAGS += \
Elliott Hughes5922d3b2014-04-18 16:53:04 -0700100 -std=gnu99 \
Mark Salyzynaa907762014-05-08 09:31:43 -0700101 -Werror -Wno-unused-parameter \
Elliott Hughes3f6b63e2014-02-28 17:25:17 -0800102 -include bsd-compatibility.h \
Elliott Hughesccecf142014-01-16 10:53:11 -0800103
Kenny Rootb83c0982012-10-10 11:26:33 -0700104LOCAL_SHARED_LIBRARIES := \
105 libcutils \
Ying Wang083b5cc2013-04-09 22:03:45 -0700106 liblog \
Kenny Rootb83c0982012-10-10 11:26:33 -0700107 libc \
108 libusbhost \
109 libselinux
Stephen Smalley8290d102012-01-13 08:53:56 -0500110
Jeff Sharkey57df14c2012-07-13 16:25:33 -0700111LOCAL_MODULE := toolbox
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800112
113# Including this will define $(intermediates).
114#
115include $(BUILD_EXECUTABLE)
116
117$(LOCAL_PATH)/toolbox.c: $(intermediates)/tools.h
118
119TOOLS_H := $(intermediates)/tools.h
Jeff Sharkey57df14c2012-07-13 16:25:33 -0700120$(TOOLS_H): PRIVATE_TOOLS := $(ALL_TOOLS)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800121$(TOOLS_H): PRIVATE_CUSTOM_TOOL = echo "/* file generated automatically */" > $@ ; for t in $(PRIVATE_TOOLS) ; do echo "TOOL($$t)" >> $@ ; done
122$(TOOLS_H): $(LOCAL_PATH)/Android.mk
123$(TOOLS_H):
124 $(transform-generated-source)
125
126# Make #!/system/bin/toolbox launchers for each tool.
127#
Jeff Sharkey57df14c2012-07-13 16:25:33 -0700128SYMLINKS := $(addprefix $(TARGET_OUT)/bin/,$(ALL_TOOLS))
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800129$(SYMLINKS): TOOLBOX_BINARY := $(LOCAL_MODULE)
130$(SYMLINKS): $(LOCAL_INSTALLED_MODULE) $(LOCAL_PATH)/Android.mk
131 @echo "Symlink: $@ -> $(TOOLBOX_BINARY)"
132 @mkdir -p $(dir $@)
133 @rm -rf $@
134 $(hide) ln -sf $(TOOLBOX_BINARY) $@
135
136ALL_DEFAULT_INSTALLED_MODULES += $(SYMLINKS)
137
138# We need this so that the installed files could be picked up based on the
139# local module name
140ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
141 $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(SYMLINKS)