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