Dees Troy | 8d66f8b | 2013-10-08 14:04:55 +0000 | [diff] [blame] | 1 | LOCAL_PATH:= system/core/toolbox/ |
| 2 | include $(CLEAR_VARS) |
| 3 | |
| 4 | TOOLS := \ |
| 5 | start \ |
| 6 | stop \ |
| 7 | getprop \ |
| 8 | setprop |
| 9 | |
| 10 | ifeq ($(TWHAVE_SELINUX), true) |
| 11 | TOOLS += \ |
| 12 | ls \ |
| 13 | getenforce \ |
| 14 | setenforce \ |
| 15 | chcon \ |
| 16 | restorecon \ |
| 17 | runcon \ |
| 18 | getsebool \ |
| 19 | setsebool \ |
| 20 | load_policy |
| 21 | endif |
| 22 | |
Ethan Yonker | 5c93369 | 2014-04-04 11:26:32 -0500 | [diff] [blame] | 23 | ifeq ($(TW_USE_TOOLBOX), true) |
| 24 | TOOLS += \ |
| 25 | mount \ |
| 26 | cat \ |
| 27 | ps \ |
| 28 | kill \ |
| 29 | ln \ |
| 30 | insmod \ |
| 31 | rmmod \ |
| 32 | lsmod \ |
| 33 | ifconfig \ |
| 34 | setconsole \ |
| 35 | rm \ |
| 36 | mkdir \ |
| 37 | rmdir \ |
| 38 | getevent \ |
| 39 | sendevent \ |
| 40 | date \ |
| 41 | wipe \ |
| 42 | sync \ |
| 43 | umount \ |
| 44 | notify \ |
| 45 | cmp \ |
| 46 | dmesg \ |
| 47 | route \ |
| 48 | hd \ |
| 49 | dd \ |
| 50 | df \ |
| 51 | watchprops \ |
| 52 | log \ |
| 53 | sleep \ |
| 54 | renice \ |
| 55 | printenv \ |
| 56 | smd \ |
| 57 | chmod \ |
| 58 | chown \ |
| 59 | newfs_msdos \ |
| 60 | netstat \ |
| 61 | ioctl \ |
| 62 | mv \ |
| 63 | schedtop \ |
| 64 | top \ |
| 65 | iftop \ |
| 66 | id \ |
| 67 | uptime \ |
| 68 | vmstat \ |
| 69 | nandread \ |
| 70 | ionice \ |
| 71 | touch \ |
| 72 | lsof \ |
| 73 | du \ |
| 74 | md5 \ |
| 75 | clear \ |
| 76 | swapon \ |
| 77 | swapoff \ |
| 78 | mkswap \ |
| 79 | readlink |
| 80 | ifneq ($(TWHAVE_SELINUX), true) |
| 81 | TOOLS += ls |
| 82 | endif |
| 83 | endif |
| 84 | |
Dees Troy | 8d66f8b | 2013-10-08 14:04:55 +0000 | [diff] [blame] | 85 | LOCAL_SRC_FILES := \ |
Dees Troy | 8d66f8b | 2013-10-08 14:04:55 +0000 | [diff] [blame] | 86 | toolbox.c \ |
| 87 | $(patsubst %,%.c,$(TOOLS)) |
| 88 | |
Dees Troy | bb4c0cb | 2013-11-02 20:25:14 +0000 | [diff] [blame] | 89 | ifneq ($(wildcard system/core/toolbox/dynarray.c),) |
| 90 | LOCAL_SRC_FILES += dynarray.c |
Dees Troy | 8d66f8b | 2013-10-08 14:04:55 +0000 | [diff] [blame] | 91 | endif |
| 92 | |
Dees Troy | bb4c0cb | 2013-11-02 20:25:14 +0000 | [diff] [blame] | 93 | # reboot.c was removed in 4.4 kitkat |
| 94 | #TOOLS += reboot |
| 95 | |
| 96 | #ifeq ($(BOARD_USES_BOOTMENU),true) |
| 97 | # LOCAL_SRC_FILES += ../../../external/bootmenu/libreboot/reboot.c |
| 98 | #else |
| 99 | # LOCAL_SRC_FILES += reboot.c |
| 100 | #endif |
| 101 | |
Dees Troy | 8d66f8b | 2013-10-08 14:04:55 +0000 | [diff] [blame] | 102 | LOCAL_C_INCLUDES := bionic/libc/bionic |
| 103 | |
| 104 | LOCAL_SHARED_LIBRARIES := \ |
| 105 | libcutils \ |
| 106 | liblog \ |
| 107 | libc |
| 108 | |
| 109 | ifeq ($(TWHAVE_SELINUX), true) |
| 110 | LOCAL_SHARED_LIBRARIES += libselinux |
| 111 | endif |
| 112 | |
| 113 | LOCAL_MODULE := toolbox_recovery |
| 114 | LOCAL_MODULE_STEM := toolbox |
| 115 | LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin |
| 116 | LOCAL_MODULE_TAGS := optional |
| 117 | |
| 118 | # Including this will define $(intermediates). |
| 119 | # |
| 120 | include $(BUILD_EXECUTABLE) |
| 121 | |
| 122 | $(LOCAL_PATH)/toolbox.c: $(intermediates)/tools.h |
| 123 | |
| 124 | TOOLS_H := $(intermediates)/tools.h |
| 125 | $(TOOLS_H): PRIVATE_TOOLS := $(TOOLS) |
| 126 | $(TOOLS_H): PRIVATE_CUSTOM_TOOL = echo "/* file generated automatically */" > $@ ; for t in $(PRIVATE_TOOLS) ; do echo "TOOL($$t)" >> $@ ; done |
| 127 | $(TOOLS_H): $(LOCAL_PATH)/Android.mk |
| 128 | $(TOOLS_H): |
| 129 | $(transform-generated-source) |
| 130 | |
| 131 | # Make #!/system/bin/toolbox launchers for each tool. |
| 132 | # |
| 133 | SYMLINKS := $(addprefix $(TARGET_RECOVERY_ROOT_OUT)/sbin/,$(TOOLS)) |
| 134 | $(SYMLINKS): TOOLBOX_BINARY := $(LOCAL_MODULE_STEM) |
| 135 | $(SYMLINKS): $(LOCAL_INSTALLED_MODULE) $(LOCAL_PATH)/Android.mk |
| 136 | @echo "Symlink: $@ -> $(TOOLBOX_BINARY)" |
| 137 | @mkdir -p $(dir $@) |
| 138 | @rm -rf $@ |
| 139 | $(hide) ln -sf $(TOOLBOX_BINARY) $@ |
| 140 | |
| 141 | ALL_DEFAULT_INSTALLED_MODULES += $(SYMLINKS) |
| 142 | |
| 143 | # We need this so that the installed files could be picked up based on the |
| 144 | # local module name |
| 145 | ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \ |
| 146 | $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(SYMLINKS) |