blob: 053660ab1effbc8b99d22d520555cce27570343e [file] [log] [blame]
Dees Troy8d66f8b2013-10-08 14:04:55 +00001LOCAL_PATH:= system/core/toolbox/
2include $(CLEAR_VARS)
3
4TOOLS := \
5 start \
6 stop \
7 getprop \
8 setprop
9
Matt Mower81742fb2014-09-01 14:40:52 -050010# 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 Troy8d66f8b2013-10-08 14:04:55 +000012ifeq ($(TWHAVE_SELINUX), true)
Matt Mower81742fb2014-09-01 14:40:52 -050013 TOOLS_FOR_SELINUX := \
Dees Troy8d66f8b2013-10-08 14:04:55 +000014 ls \
15 getenforce \
16 setenforce \
17 chcon \
18 restorecon \
19 runcon \
20 getsebool \
21 setsebool \
22 load_policy
Matt Mower81742fb2014-09-01 14:40:52 -050023 TOOLS += $(filter-out $(RECOVERY_BUSYBOX_TOOLS), $(TOOLS_FOR_SELINUX))
Dees Troy8d66f8b2013-10-08 14:04:55 +000024endif
25
Ethan Yonker5c933692014-04-04 11:26:32 -050026ifeq ($(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
86endif
87
Dees Troy8d66f8b2013-10-08 14:04:55 +000088LOCAL_SRC_FILES := \
Dees Troy8d66f8b2013-10-08 14:04:55 +000089 toolbox.c \
90 $(patsubst %,%.c,$(TOOLS))
91
Dees Troybb4c0cb2013-11-02 20:25:14 +000092ifneq ($(wildcard system/core/toolbox/dynarray.c),)
93 LOCAL_SRC_FILES += dynarray.c
Dees Troy8d66f8b2013-10-08 14:04:55 +000094endif
95
Dees Troybb4c0cb2013-11-02 20:25:14 +000096# 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 Troy8d66f8b2013-10-08 14:04:55 +0000105LOCAL_C_INCLUDES := bionic/libc/bionic
106
107LOCAL_SHARED_LIBRARIES := \
108 libcutils \
109 liblog \
110 libc
111
112ifeq ($(TWHAVE_SELINUX), true)
113 LOCAL_SHARED_LIBRARIES += libselinux
114endif
115
116LOCAL_MODULE := toolbox_recovery
117LOCAL_MODULE_STEM := toolbox
118LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
119LOCAL_MODULE_TAGS := optional
120
121# Including this will define $(intermediates).
122#
123include $(BUILD_EXECUTABLE)
124
125$(LOCAL_PATH)/toolbox.c: $(intermediates)/tools.h
126
127TOOLS_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#
136SYMLINKS := $(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
144ALL_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
148ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
149 $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(SYMLINKS)