blob: 77df4d43a19079ee75de543da3f51346d94b0e36 [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 \
42 notify \
43 printenv \
44 ps \
45 readlink \
46 renice \
47 restorecon \
48 rm \
49 rmdir \
50 rmmod \
51 route \
52 runcon \
53 schedtop \
54 sendevent \
55 setenforce \
56 setprop \
57 setsebool \
58 sleep \
59 smd \
60 start \
61 stop \
62 swapoff \
63 swapon \
64 sync \
65 top \
66 touch \
67 umount \
Mike Lockwooda699d622010-04-09 15:27:16 -040068 uptime \
Arve Hjønnevåg7c953d02009-09-17 17:30:55 -070069 vmstat \
Elliott Hughes7fc47122014-06-07 21:53:04 -070070 watchprops \
71 wipe \
Stephen Smalley8290d102012-01-13 08:53:56 -050072
Erik Gillingb76f0ff2011-04-28 14:23:26 -070073ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
74TOOLS += r
75endif
76
Jeff Sharkey57df14c2012-07-13 16:25:33 -070077ALL_TOOLS = $(TOOLS)
78ALL_TOOLS += \
Jeff Sharkey3e8b1582012-07-13 16:37:13 -070079 cp \
80 grep
Jeff Sharkey57df14c2012-07-13 16:25:33 -070081
82LOCAL_SRC_FILES := \
Elliott Hughes0b024672014-02-28 16:48:49 -080083 cp/cp.c \
84 cp/utils.c \
David 'Digit' Turnera8d1afb2011-01-06 08:39:44 +010085 dynarray.c \
Elliott Hughes0b024672014-02-28 16:48:49 -080086 grep/fastgrep.c \
87 grep/file.c \
88 grep/grep.c \
89 grep/queue.c \
90 grep/util.c \
Jeff Sharkey57df14c2012-07-13 16:25:33 -070091 $(patsubst %,%.c,$(TOOLS)) \
Elliott Hughes0b024672014-02-28 16:48:49 -080092 toolbox.c \
93 uid_from_user.c \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080094
Elliott Hughes0b024672014-02-28 16:48:49 -080095LOCAL_CFLAGS += \
Elliott Hughes5922d3b2014-04-18 16:53:04 -070096 -std=gnu99 \
Mark Salyzynaa907762014-05-08 09:31:43 -070097 -Werror -Wno-unused-parameter \
Elliott Hughes3f6b63e2014-02-28 17:25:17 -080098 -include bsd-compatibility.h \
Elliott Hughesccecf142014-01-16 10:53:11 -080099
Elliott Hughes7fc47122014-06-07 21:53:04 -0700100LOCAL_C_INCLUDES += external/openssl/include
101
Kenny Rootb83c0982012-10-10 11:26:33 -0700102LOCAL_SHARED_LIBRARIES := \
Elliott Hughes7fc47122014-06-07 21:53:04 -0700103 libcrypto \
104 libcutils \
105 libselinux \
106
107# libusbhost is only used by lsusb, and that isn't usually included in toolbox.
108# The linker strips out all the unused library code in the normal case.
109LOCAL_STATIC_LIBRARIES := \
110 libusbhost \
Stephen Smalley8290d102012-01-13 08:53:56 -0500111
Jeff Sharkey57df14c2012-07-13 16:25:33 -0700112LOCAL_MODULE := toolbox
Elliott Hughes7fc47122014-06-07 21:53:04 -0700113LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800114
115# Including this will define $(intermediates).
116#
117include $(BUILD_EXECUTABLE)
118
119$(LOCAL_PATH)/toolbox.c: $(intermediates)/tools.h
120
121TOOLS_H := $(intermediates)/tools.h
Jeff Sharkey57df14c2012-07-13 16:25:33 -0700122$(TOOLS_H): PRIVATE_TOOLS := $(ALL_TOOLS)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800123$(TOOLS_H): PRIVATE_CUSTOM_TOOL = echo "/* file generated automatically */" > $@ ; for t in $(PRIVATE_TOOLS) ; do echo "TOOL($$t)" >> $@ ; done
124$(TOOLS_H): $(LOCAL_PATH)/Android.mk
125$(TOOLS_H):
126 $(transform-generated-source)
127
128# Make #!/system/bin/toolbox launchers for each tool.
129#
Jeff Sharkey57df14c2012-07-13 16:25:33 -0700130SYMLINKS := $(addprefix $(TARGET_OUT)/bin/,$(ALL_TOOLS))
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800131$(SYMLINKS): TOOLBOX_BINARY := $(LOCAL_MODULE)
132$(SYMLINKS): $(LOCAL_INSTALLED_MODULE) $(LOCAL_PATH)/Android.mk
133 @echo "Symlink: $@ -> $(TOOLBOX_BINARY)"
134 @mkdir -p $(dir $@)
135 @rm -rf $@
136 $(hide) ln -sf $(TOOLBOX_BINARY) $@
137
138ALL_DEFAULT_INSTALLED_MODULES += $(SYMLINKS)
139
140# We need this so that the installed files could be picked up based on the
141# local module name
142ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
143 $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(SYMLINKS)