blob: 73868976a0190a5c20d9632e7da682652d68dea1 [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
10ifeq ($(TWHAVE_SELINUX), true)
11 TOOLS += \
12 ls \
13 getenforce \
14 setenforce \
15 chcon \
16 restorecon \
17 runcon \
18 getsebool \
19 setsebool \
20 load_policy
21endif
22
Ethan Yonker5c933692014-04-04 11:26:32 -050023ifeq ($(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
83endif
84
Dees Troy8d66f8b2013-10-08 14:04:55 +000085LOCAL_SRC_FILES := \
Dees Troy8d66f8b2013-10-08 14:04:55 +000086 toolbox.c \
87 $(patsubst %,%.c,$(TOOLS))
88
Dees Troybb4c0cb2013-11-02 20:25:14 +000089ifneq ($(wildcard system/core/toolbox/dynarray.c),)
90 LOCAL_SRC_FILES += dynarray.c
Dees Troy8d66f8b2013-10-08 14:04:55 +000091endif
92
Dees Troybb4c0cb2013-11-02 20:25:14 +000093# 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 Troy8d66f8b2013-10-08 14:04:55 +0000102LOCAL_C_INCLUDES := bionic/libc/bionic
103
104LOCAL_SHARED_LIBRARIES := \
105 libcutils \
106 liblog \
107 libc
108
109ifeq ($(TWHAVE_SELINUX), true)
110 LOCAL_SHARED_LIBRARIES += libselinux
111endif
112
113LOCAL_MODULE := toolbox_recovery
114LOCAL_MODULE_STEM := toolbox
115LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
116LOCAL_MODULE_TAGS := optional
117
118# Including this will define $(intermediates).
119#
120include $(BUILD_EXECUTABLE)
121
122$(LOCAL_PATH)/toolbox.c: $(intermediates)/tools.h
123
124TOOLS_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#
133SYMLINKS := $(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
141ALL_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
145ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
146 $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(SYMLINKS)