Home | History | Annotate | Download | only in toolbox
      1 LOCAL_PATH:= $(call my-dir)
      2 include $(CLEAR_VARS)
      3 
      4 TOOLS := \
      5 	ls \
      6 	mount \
      7 	cat \
      8 	ps \
      9 	kill \
     10 	ln \
     11 	insmod \
     12 	rmmod \
     13 	lsmod \
     14 	ifconfig \
     15 	setconsole \
     16 	rm \
     17 	mkdir \
     18 	rmdir \
     19 	reboot \
     20 	getevent \
     21 	sendevent \
     22 	date \
     23 	wipe \
     24 	sync \
     25 	umount \
     26 	start \
     27 	stop \
     28 	notify \
     29 	cmp \
     30 	dmesg \
     31 	route \
     32 	hd \
     33 	dd \
     34 	df \
     35 	getprop \
     36 	setprop \
     37 	watchprops \
     38 	log \
     39 	sleep \
     40 	renice \
     41 	printenv \
     42 	smd \
     43 	chmod \
     44 	chown \
     45 	newfs_msdos \
     46 	netstat \
     47 	ioctl \
     48 	mv \
     49 	schedtop \
     50 	top \
     51 	iftop \
     52 	id \
     53 	uptime \
     54 	vmstat \
     55 	nandread \
     56 	ionice \
     57 	touch \
     58 	lsof \
     59 	du \
     60 	md5
     61 
     62 ifeq ($(HAVE_SELINUX),true)
     63 
     64 TOOLS += \
     65 	getenforce \
     66 	setenforce \
     67 	chcon \
     68 	restorecon \
     69 	runcon \
     70 	getsebool \
     71 	setsebool \
     72 	load_policy
     73 
     74 endif
     75 
     76 
     77 ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
     78 TOOLS += r
     79 endif
     80 
     81 ALL_TOOLS = $(TOOLS)
     82 ALL_TOOLS += \
     83 	cp \
     84 	grep
     85 
     86 LOCAL_SRC_FILES := \
     87 	dynarray.c \
     88 	toolbox.c \
     89 	$(patsubst %,%.c,$(TOOLS)) \
     90 	cp/cp.c cp/utils.c \
     91 	grep/grep.c grep/fastgrep.c grep/file.c grep/queue.c grep/util.c
     92 
     93 LOCAL_SHARED_LIBRARIES := libcutils libc libusbhost
     94 
     95 LOCAL_C_INCLUDES := bionic/libc/bionic
     96 
     97 ifeq ($(HAVE_SELINUX),true)
     98 
     99 LOCAL_CFLAGS += -DHAVE_SELINUX
    100 LOCAL_SHARED_LIBRARIES += libselinux
    101 LOCAL_C_INCLUDES += external/libselinux/include
    102 
    103 endif
    104 
    105 LOCAL_MODULE := toolbox
    106 
    107 # Including this will define $(intermediates).
    108 #
    109 include $(BUILD_EXECUTABLE)
    110 
    111 $(LOCAL_PATH)/toolbox.c: $(intermediates)/tools.h
    112 
    113 TOOLS_H := $(intermediates)/tools.h
    114 $(TOOLS_H): PRIVATE_TOOLS := $(ALL_TOOLS)
    115 $(TOOLS_H): PRIVATE_CUSTOM_TOOL = echo "/* file generated automatically */" > $@ ; for t in $(PRIVATE_TOOLS) ; do echo "TOOL($$t)" >> $@ ; done
    116 $(TOOLS_H): $(LOCAL_PATH)/Android.mk
    117 $(TOOLS_H):
    118 	$(transform-generated-source)
    119 
    120 # Make #!/system/bin/toolbox launchers for each tool.
    121 #
    122 SYMLINKS := $(addprefix $(TARGET_OUT)/bin/,$(ALL_TOOLS))
    123 $(SYMLINKS): TOOLBOX_BINARY := $(LOCAL_MODULE)
    124 $(SYMLINKS): $(LOCAL_INSTALLED_MODULE) $(LOCAL_PATH)/Android.mk
    125 	@echo "Symlink: $@ -> $(TOOLBOX_BINARY)"
    126 	@mkdir -p $(dir $@)
    127 	@rm -rf $@
    128 	$(hide) ln -sf $(TOOLBOX_BINARY) $@
    129 
    130 ALL_DEFAULT_INSTALLED_MODULES += $(SYMLINKS)
    131 
    132 # We need this so that the installed files could be picked up based on the
    133 # local module name
    134 ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
    135     $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(SYMLINKS)
    136