1LOCAL_PATH:= $(call my-dir) 2 3 4common_cflags := \ 5 -std=gnu99 \ 6 -Werror -Wno-unused-parameter \ 7 -I$(LOCAL_PATH)/upstream-netbsd/include/ \ 8 -include bsd-compatibility.h \ 9 10 11include $(CLEAR_VARS) 12LOCAL_SRC_FILES := upstream-netbsd/bin/cat/cat.c 13LOCAL_CFLAGS += $(common_cflags) -Dmain=cat_main 14LOCAL_MODULE := libtoolbox_cat 15LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk 16include $(BUILD_STATIC_LIBRARY) 17 18include $(CLEAR_VARS) 19LOCAL_SRC_FILES := upstream-netbsd/sbin/chown/chown.c 20LOCAL_CFLAGS += $(common_cflags) -Dmain=chown_main 21LOCAL_MODULE := libtoolbox_chown 22LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk 23include $(BUILD_STATIC_LIBRARY) 24 25include $(CLEAR_VARS) 26LOCAL_SRC_FILES := \ 27 upstream-netbsd/bin/cp/cp.c \ 28 upstream-netbsd/bin/cp/utils.c 29LOCAL_CFLAGS += $(common_cflags) -Dmain=cp_main 30LOCAL_MODULE := libtoolbox_cp 31LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk 32include $(BUILD_STATIC_LIBRARY) 33 34include $(CLEAR_VARS) 35LOCAL_SRC_FILES := \ 36 upstream-netbsd/bin/dd/args.c \ 37 upstream-netbsd/bin/dd/conv.c \ 38 upstream-netbsd/bin/dd/dd.c \ 39 upstream-netbsd/bin/dd/dd_hostops.c \ 40 upstream-netbsd/bin/dd/misc.c \ 41 upstream-netbsd/bin/dd/position.c 42LOCAL_CFLAGS += $(common_cflags) -Dmain=dd_main -DNO_CONV 43LOCAL_MODULE := libtoolbox_dd 44LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk 45include $(BUILD_STATIC_LIBRARY) 46 47include $(CLEAR_VARS) 48LOCAL_SRC_FILES := upstream-netbsd/usr.bin/du/du.c 49LOCAL_CFLAGS += $(common_cflags) -Dmain=du_main 50LOCAL_MODULE := libtoolbox_du 51LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk 52include $(BUILD_STATIC_LIBRARY) 53 54include $(CLEAR_VARS) 55LOCAL_SRC_FILES := \ 56 upstream-netbsd/usr.bin/grep/fastgrep.c \ 57 upstream-netbsd/usr.bin/grep/file.c \ 58 upstream-netbsd/usr.bin/grep/grep.c \ 59 upstream-netbsd/usr.bin/grep/queue.c \ 60 upstream-netbsd/usr.bin/grep/util.c 61LOCAL_CFLAGS += $(common_cflags) -Dmain=grep_main 62LOCAL_MODULE := libtoolbox_grep 63LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk 64include $(BUILD_STATIC_LIBRARY) 65 66include $(CLEAR_VARS) 67LOCAL_SRC_FILES := upstream-netbsd/bin/kill/kill.c 68LOCAL_CFLAGS += $(common_cflags) -Dmain=kill_main 69LOCAL_MODULE := libtoolbox_kill 70LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk 71include $(BUILD_STATIC_LIBRARY) 72 73include $(CLEAR_VARS) 74LOCAL_SRC_FILES := upstream-netbsd/bin/ln/ln.c 75LOCAL_CFLAGS += $(common_cflags) -Dmain=ln_main 76LOCAL_MODULE := libtoolbox_ln 77LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk 78include $(BUILD_STATIC_LIBRARY) 79 80include $(CLEAR_VARS) 81LOCAL_SRC_FILES := upstream-netbsd/bin/mv/mv.c 82LOCAL_CFLAGS += $(common_cflags) -Dmain=mv_main -D__SVR4 83LOCAL_MODULE := libtoolbox_mv 84LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk 85include $(BUILD_STATIC_LIBRARY) 86 87include $(CLEAR_VARS) 88LOCAL_SRC_FILES := upstream-netbsd/usr.bin/printenv/printenv.c 89LOCAL_CFLAGS += $(common_cflags) -Dmain=printenv_main 90LOCAL_MODULE := libtoolbox_printenv 91LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk 92include $(BUILD_STATIC_LIBRARY) 93 94include $(CLEAR_VARS) 95LOCAL_SRC_FILES := upstream-netbsd/bin/rm/rm.c 96LOCAL_CFLAGS += $(common_cflags) -Dmain=rm_main 97LOCAL_MODULE := libtoolbox_rm 98LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk 99include $(BUILD_STATIC_LIBRARY) 100 101include $(CLEAR_VARS) 102LOCAL_SRC_FILES := upstream-netbsd/bin/rmdir/rmdir.c 103LOCAL_CFLAGS += $(common_cflags) -Dmain=rmdir_main 104LOCAL_MODULE := libtoolbox_rmdir 105LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk 106include $(BUILD_STATIC_LIBRARY) 107 108include $(CLEAR_VARS) 109LOCAL_SRC_FILES := upstream-netbsd/bin/sleep/sleep.c 110LOCAL_CFLAGS += $(common_cflags) -Dmain=sleep_main 111LOCAL_MODULE := libtoolbox_sleep 112LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk 113include $(BUILD_STATIC_LIBRARY) 114 115include $(CLEAR_VARS) 116LOCAL_SRC_FILES := upstream-netbsd/bin/sync/sync.c 117LOCAL_CFLAGS += $(common_cflags) -Dmain=sync_main 118LOCAL_MODULE := libtoolbox_sync 119LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk 120include $(BUILD_STATIC_LIBRARY) 121 122 123include $(CLEAR_VARS) 124 125BSD_TOOLS := \ 126 cat \ 127 chown \ 128 cp \ 129 dd \ 130 du \ 131 grep \ 132 kill \ 133 ln \ 134 mv \ 135 printenv \ 136 rm \ 137 rmdir \ 138 sleep \ 139 sync \ 140 141OUR_TOOLS := \ 142 chcon \ 143 chmod \ 144 clear \ 145 cmp \ 146 date \ 147 df \ 148 dmesg \ 149 getenforce \ 150 getevent \ 151 getprop \ 152 getsebool \ 153 hd \ 154 id \ 155 ifconfig \ 156 iftop \ 157 insmod \ 158 ioctl \ 159 ionice \ 160 load_policy \ 161 log \ 162 ls \ 163 lsmod \ 164 lsof \ 165 md5 \ 166 mkdir \ 167 mknod \ 168 mkswap \ 169 mount \ 170 nandread \ 171 netstat \ 172 newfs_msdos \ 173 nohup \ 174 notify \ 175 ps \ 176 readlink \ 177 renice \ 178 restorecon \ 179 rmmod \ 180 route \ 181 runcon \ 182 schedtop \ 183 sendevent \ 184 setenforce \ 185 setprop \ 186 setsebool \ 187 smd \ 188 start \ 189 stop \ 190 swapoff \ 191 swapon \ 192 top \ 193 touch \ 194 umount \ 195 uptime \ 196 vmstat \ 197 watchprops \ 198 wipe \ 199 200ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT))) 201OUR_TOOLS += r 202endif 203 204ALL_TOOLS = $(BSD_TOOLS) $(OUR_TOOLS) 205 206LOCAL_SRC_FILES := \ 207 upstream-netbsd/lib/libc/gen/getbsize.c \ 208 upstream-netbsd/lib/libc/gen/humanize_number.c \ 209 upstream-netbsd/lib/libc/stdlib/strsuftoll.c \ 210 upstream-netbsd/lib/libc/string/swab.c \ 211 upstream-netbsd/lib/libutil/raise_default_signal.c \ 212 dynarray.c \ 213 pwcache.c \ 214 $(patsubst %,%.c,$(OUR_TOOLS)) \ 215 toolbox.c \ 216 217LOCAL_CFLAGS += $(common_cflags) 218 219LOCAL_C_INCLUDES += external/openssl/include 220 221LOCAL_SHARED_LIBRARIES := \ 222 libcrypto \ 223 libcutils \ 224 libselinux \ 225 226# libusbhost is only used by lsusb, and that isn't usually included in toolbox. 227# The linker strips out all the unused library code in the normal case. 228LOCAL_STATIC_LIBRARIES := \ 229 libusbhost \ 230 231LOCAL_WHOLE_STATIC_LIBRARIES := $(patsubst %,libtoolbox_%,$(BSD_TOOLS)) 232 233LOCAL_MODULE := toolbox 234LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk 235 236# Including this will define $(intermediates). 237# 238include $(BUILD_EXECUTABLE) 239 240$(LOCAL_PATH)/toolbox.c: $(intermediates)/tools.h 241 242TOOLS_H := $(intermediates)/tools.h 243$(TOOLS_H): PRIVATE_TOOLS := $(ALL_TOOLS) 244$(TOOLS_H): PRIVATE_CUSTOM_TOOL = echo "/* file generated automatically */" > $@ ; for t in $(PRIVATE_TOOLS) ; do echo "TOOL($$t)" >> $@ ; done 245$(TOOLS_H): $(LOCAL_PATH)/Android.mk 246$(TOOLS_H): 247 $(transform-generated-source) 248 249# Make #!/system/bin/toolbox launchers for each tool. 250# 251SYMLINKS := $(addprefix $(TARGET_OUT)/bin/,$(ALL_TOOLS)) 252$(SYMLINKS): TOOLBOX_BINARY := $(LOCAL_MODULE) 253$(SYMLINKS): $(LOCAL_INSTALLED_MODULE) $(LOCAL_PATH)/Android.mk 254 @echo "Symlink: $@ -> $(TOOLBOX_BINARY)" 255 @mkdir -p $(dir $@) 256 @rm -rf $@ 257 $(hide) ln -sf $(TOOLBOX_BINARY) $@ 258 259ALL_DEFAULT_INSTALLED_MODULES += $(SYMLINKS) 260 261# We need this so that the installed files could be picked up based on the 262# local module name 263ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \ 264 $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(SYMLINKS) 265