blob: 6bac5f52387a08c6b048e9864363e6aa1daac66d [file] [log] [blame]
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08001LOCAL_PATH:= $(call my-dir)
2include $(CLEAR_VARS)
3
4TOOLS := \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08005 cat \
Elliott Hughes7fc47122014-06-07 21:53:04 -07006 chcon \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08007 chmod \
Dries Harnie2a743732010-01-18 17:44:33 +01008 chown \
Elliott Hughes7fc47122014-06-07 21:53:04 -07009 clear \
10 cmp \
11 date \
12 dd \
13 df \
14 dmesg \
15 du \
16 getenforce \
17 getevent \
18 getprop \
19 getsebool \
20 hd \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080021 id \
Elliott Hughes7fc47122014-06-07 21:53:04 -070022 ifconfig \
23 iftop \
24 insmod \
25 ioctl \
26 ionice \
27 kill \
28 ln \
29 load_policy \
30 log \
31 ls \
32 lsmod \
33 lsof \
34 md5 \
35 mkdir \
36 mkswap \
37 mount \
38 mv \
39 nandread \
40 netstat \
41 newfs_msdos \
Glenn Kasten38e5f072013-09-23 15:10:12 -070042 nohup \
Elliott Hughes7fc47122014-06-07 21:53:04 -070043 notify \
44 printenv \
45 ps \
46 readlink \
47 renice \
48 restorecon \
49 rm \
50 rmdir \
51 rmmod \
52 route \
53 runcon \
54 schedtop \
55 sendevent \
56 setenforce \
57 setprop \
58 setsebool \
59 sleep \
60 smd \
61 start \
62 stop \
63 swapoff \
64 swapon \
65 sync \
66 top \
67 touch \
68 umount \
Mike Lockwooda699d622010-04-09 15:27:16 -040069 uptime \
Arve Hjønnevåg7c953d02009-09-17 17:30:55 -070070 vmstat \
Elliott Hughes7fc47122014-06-07 21:53:04 -070071 watchprops \
72 wipe \
Stephen Smalley8290d102012-01-13 08:53:56 -050073
Erik Gillingb76f0ff2011-04-28 14:23:26 -070074ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
75TOOLS += r
76endif
77
Jeff Sharkey57df14c2012-07-13 16:25:33 -070078ALL_TOOLS = $(TOOLS)
79ALL_TOOLS += \
Jeff Sharkey3e8b1582012-07-13 16:37:13 -070080 cp \
81 grep
Jeff Sharkey57df14c2012-07-13 16:25:33 -070082
83LOCAL_SRC_FILES := \
Elliott Hughes0b024672014-02-28 16:48:49 -080084 cp/cp.c \
85 cp/utils.c \
David 'Digit' Turnera8d1afb2011-01-06 08:39:44 +010086 dynarray.c \
Elliott Hughes0b024672014-02-28 16:48:49 -080087 grep/fastgrep.c \
88 grep/file.c \
89 grep/grep.c \
90 grep/queue.c \
91 grep/util.c \
Jeff Sharkey57df14c2012-07-13 16:25:33 -070092 $(patsubst %,%.c,$(TOOLS)) \
Elliott Hughes0b024672014-02-28 16:48:49 -080093 toolbox.c \
94 uid_from_user.c \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080095
Elliott Hughes0b024672014-02-28 16:48:49 -080096LOCAL_CFLAGS += \
Elliott Hughes5922d3b2014-04-18 16:53:04 -070097 -std=gnu99 \
Mark Salyzynaa907762014-05-08 09:31:43 -070098 -Werror -Wno-unused-parameter \
Elliott Hughes3f6b63e2014-02-28 17:25:17 -080099 -include bsd-compatibility.h \
Elliott Hughesccecf142014-01-16 10:53:11 -0800100
Elliott Hughes7fc47122014-06-07 21:53:04 -0700101LOCAL_C_INCLUDES += external/openssl/include
102
Kenny Rootb83c0982012-10-10 11:26:33 -0700103LOCAL_SHARED_LIBRARIES := \
Elliott Hughes7fc47122014-06-07 21:53:04 -0700104 libcrypto \
105 libcutils \
106 libselinux \
107
108# libusbhost is only used by lsusb, and that isn't usually included in toolbox.
109# The linker strips out all the unused library code in the normal case.
110LOCAL_STATIC_LIBRARIES := \
111 libusbhost \
Stephen Smalley8290d102012-01-13 08:53:56 -0500112
Jeff Sharkey57df14c2012-07-13 16:25:33 -0700113LOCAL_MODULE := toolbox
Elliott Hughes7fc47122014-06-07 21:53:04 -0700114LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800115
116# Including this will define $(intermediates).
117#
118include $(BUILD_EXECUTABLE)
119
120$(LOCAL_PATH)/toolbox.c: $(intermediates)/tools.h
121
122TOOLS_H := $(intermediates)/tools.h
Jeff Sharkey57df14c2012-07-13 16:25:33 -0700123$(TOOLS_H): PRIVATE_TOOLS := $(ALL_TOOLS)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800124$(TOOLS_H): PRIVATE_CUSTOM_TOOL = echo "/* file generated automatically */" > $@ ; for t in $(PRIVATE_TOOLS) ; do echo "TOOL($$t)" >> $@ ; done
125$(TOOLS_H): $(LOCAL_PATH)/Android.mk
126$(TOOLS_H):
127 $(transform-generated-source)
128
129# Make #!/system/bin/toolbox launchers for each tool.
130#
Jeff Sharkey57df14c2012-07-13 16:25:33 -0700131SYMLINKS := $(addprefix $(TARGET_OUT)/bin/,$(ALL_TOOLS))
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800132$(SYMLINKS): TOOLBOX_BINARY := $(LOCAL_MODULE)
133$(SYMLINKS): $(LOCAL_INSTALLED_MODULE) $(LOCAL_PATH)/Android.mk
134 @echo "Symlink: $@ -> $(TOOLBOX_BINARY)"
135 @mkdir -p $(dir $@)
136 @rm -rf $@
137 $(hide) ln -sf $(TOOLBOX_BINARY) $@
138
139ALL_DEFAULT_INSTALLED_MODULES += $(SYMLINKS)
140
141# We need this so that the installed files could be picked up based on the
142# local module name
143ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
144 $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(SYMLINKS)