blob: c53f17da535e27500941e3f48f034633deca2a01 [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 \
Sujith Ramakrishnan032d4e22014-01-14 16:57:22 -080036 mknod \
Elliott Hughes7fc47122014-06-07 21:53:04 -070037 mkswap \
38 mount \
39 mv \
40 nandread \
41 netstat \
42 newfs_msdos \
Glenn Kasten38e5f072013-09-23 15:10:12 -070043 nohup \
Elliott Hughes7fc47122014-06-07 21:53:04 -070044 notify \
45 printenv \
46 ps \
47 readlink \
48 renice \
49 restorecon \
50 rm \
51 rmdir \
52 rmmod \
53 route \
54 runcon \
55 schedtop \
56 sendevent \
57 setenforce \
58 setprop \
59 setsebool \
60 sleep \
61 smd \
62 start \
63 stop \
64 swapoff \
65 swapon \
66 sync \
67 top \
68 touch \
69 umount \
Mike Lockwooda699d622010-04-09 15:27:16 -040070 uptime \
Arve Hjønnevåg7c953d02009-09-17 17:30:55 -070071 vmstat \
Elliott Hughes7fc47122014-06-07 21:53:04 -070072 watchprops \
73 wipe \
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
Elliott Hughes0b024672014-02-28 16:48:49 -080097LOCAL_CFLAGS += \
Elliott Hughes5922d3b2014-04-18 16:53:04 -070098 -std=gnu99 \
Mark Salyzynaa907762014-05-08 09:31:43 -070099 -Werror -Wno-unused-parameter \
Elliott Hughes3f6b63e2014-02-28 17:25:17 -0800100 -include bsd-compatibility.h \
Elliott Hughesccecf142014-01-16 10:53:11 -0800101
Elliott Hughes7fc47122014-06-07 21:53:04 -0700102LOCAL_C_INCLUDES += external/openssl/include
103
Kenny Rootb83c0982012-10-10 11:26:33 -0700104LOCAL_SHARED_LIBRARIES := \
Elliott Hughes7fc47122014-06-07 21:53:04 -0700105 libcrypto \
106 libcutils \
107 libselinux \
108
109# libusbhost is only used by lsusb, and that isn't usually included in toolbox.
110# The linker strips out all the unused library code in the normal case.
111LOCAL_STATIC_LIBRARIES := \
112 libusbhost \
Stephen Smalley8290d102012-01-13 08:53:56 -0500113
Jeff Sharkey57df14c2012-07-13 16:25:33 -0700114LOCAL_MODULE := toolbox
Elliott Hughes7fc47122014-06-07 21:53:04 -0700115LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800116
117# Including this will define $(intermediates).
118#
119include $(BUILD_EXECUTABLE)
120
121$(LOCAL_PATH)/toolbox.c: $(intermediates)/tools.h
122
123TOOLS_H := $(intermediates)/tools.h
Jeff Sharkey57df14c2012-07-13 16:25:33 -0700124$(TOOLS_H): PRIVATE_TOOLS := $(ALL_TOOLS)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800125$(TOOLS_H): PRIVATE_CUSTOM_TOOL = echo "/* file generated automatically */" > $@ ; for t in $(PRIVATE_TOOLS) ; do echo "TOOL($$t)" >> $@ ; done
126$(TOOLS_H): $(LOCAL_PATH)/Android.mk
127$(TOOLS_H):
128 $(transform-generated-source)
129
130# Make #!/system/bin/toolbox launchers for each tool.
131#
Jeff Sharkey57df14c2012-07-13 16:25:33 -0700132SYMLINKS := $(addprefix $(TARGET_OUT)/bin/,$(ALL_TOOLS))
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800133$(SYMLINKS): TOOLBOX_BINARY := $(LOCAL_MODULE)
134$(SYMLINKS): $(LOCAL_INSTALLED_MODULE) $(LOCAL_PATH)/Android.mk
135 @echo "Symlink: $@ -> $(TOOLBOX_BINARY)"
136 @mkdir -p $(dir $@)
137 @rm -rf $@
138 $(hide) ln -sf $(TOOLBOX_BINARY) $@
139
140ALL_DEFAULT_INSTALLED_MODULES += $(SYMLINKS)
141
142# We need this so that the installed files could be picked up based on the
143# local module name
144ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
145 $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(SYMLINKS)