1 LOCAL_PATH:= $(call my-dir) 2 include $(CLEAR_VARS) 3 4 TOOLS := \ 5 ls \ 6 mount \ 7 cat \ 8 ps \ 9 kill \ 10 ln \ 11 insmod \ 12 rmmod \ 13 lsmod \ 14 ifconfig \ 15 setconsole \ 16 rm \ 17 mkdir \ 18 rmdir \ 19 reboot \ 20 getevent \ 21 sendevent \ 22 date \ 23 wipe \ 24 sync \ 25 umount \ 26 start \ 27 stop \ 28 notify \ 29 cmp \ 30 dmesg \ 31 route \ 32 hd \ 33 dd \ 34 df \ 35 getprop \ 36 setprop \ 37 watchprops \ 38 log \ 39 sleep \ 40 renice \ 41 printenv \ 42 smd \ 43 chmod \ 44 chown \ 45 newfs_msdos \ 46 netstat \ 47 ioctl \ 48 mv \ 49 schedtop \ 50 top \ 51 iftop \ 52 id \ 53 uptime \ 54 vmstat \ 55 nandread \ 56 ionice \ 57 touch \ 58 lsof \ 59 du \ 60 md5 \ 61 clear \ 62 getenforce \ 63 setenforce \ 64 chcon \ 65 restorecon \ 66 runcon \ 67 getsebool \ 68 setsebool \ 69 load_policy 70 71 ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT))) 72 TOOLS += r 73 endif 74 75 ALL_TOOLS = $(TOOLS) 76 ALL_TOOLS += \ 77 cp \ 78 grep 79 80 LOCAL_SRC_FILES := \ 81 dynarray.c \ 82 toolbox.c \ 83 $(patsubst %,%.c,$(TOOLS)) \ 84 cp/cp.c cp/utils.c \ 85 grep/grep.c grep/fastgrep.c grep/file.c grep/queue.c grep/util.c 86 87 LOCAL_C_INCLUDES := bionic/libc/bionic 88 89 LOCAL_SHARED_LIBRARIES := \ 90 libcutils \ 91 liblog \ 92 libc \ 93 libusbhost \ 94 libselinux 95 96 LOCAL_MODULE := toolbox 97 98 # Including this will define $(intermediates). 99 # 100 include $(BUILD_EXECUTABLE) 101 102 $(LOCAL_PATH)/toolbox.c: $(intermediates)/tools.h 103 104 TOOLS_H := $(intermediates)/tools.h 105 $(TOOLS_H): PRIVATE_TOOLS := $(ALL_TOOLS) 106 $(TOOLS_H): PRIVATE_CUSTOM_TOOL = echo "/* file generated automatically */" > $@ ; for t in $(PRIVATE_TOOLS) ; do echo "TOOL($$t)" >> $@ ; done 107 $(TOOLS_H): $(LOCAL_PATH)/Android.mk 108 $(TOOLS_H): 109 $(transform-generated-source) 110 111 # Make #!/system/bin/toolbox launchers for each tool. 112 # 113 SYMLINKS := $(addprefix $(TARGET_OUT)/bin/,$(ALL_TOOLS)) 114 $(SYMLINKS): TOOLBOX_BINARY := $(LOCAL_MODULE) 115 $(SYMLINKS): $(LOCAL_INSTALLED_MODULE) $(LOCAL_PATH)/Android.mk 116 @echo "Symlink: $@ -> $(TOOLBOX_BINARY)" 117 @mkdir -p $(dir $@) 118 @rm -rf $@ 119 $(hide) ln -sf $(TOOLBOX_BINARY) $@ 120 121 ALL_DEFAULT_INSTALLED_MODULES += $(SYMLINKS) 122 123 # We need this so that the installed files could be picked up based on the 124 # local module name 125 ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \ 126 $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(SYMLINKS) 127