| LOCAL_PATH:= $(call my-dir) |
| include $(CLEAR_VARS) |
| |
| TOOLS := \ |
| ls \ |
| mount \ |
| cat \ |
| ps \ |
| kill \ |
| ln \ |
| insmod \ |
| rmmod \ |
| lsmod \ |
| ifconfig \ |
| setconsole \ |
| rm \ |
| mkdir \ |
| rmdir \ |
| reboot \ |
| getevent \ |
| sendevent \ |
| date \ |
| sync \ |
| umount \ |
| notify \ |
| cmp \ |
| dmesg \ |
| route \ |
| hd \ |
| dd \ |
| df \ |
| sleep \ |
| renice \ |
| printenv \ |
| smd \ |
| chmod \ |
| chown \ |
| netstat \ |
| ioctl \ |
| mv \ |
| schedtop \ |
| top \ |
| iftop \ |
| id \ |
| vmstat \ |
| lsof \ |
| daemon \ |
| devmem \ |
| mknod |
| |
| LOCAL_SRC_FILES:= \ |
| toolbox.c \ |
| $(patsubst %,%.c,$(TOOLS)) |
| |
| LOCAL_MODULE:= toolbox |
| |
| all: ${LOCAL_MODULE} symlinks symlinks.list |
| |
| symlinks: $(SYMLINKS) |
| for i in $(TOOLS); do ln -sf $(TOOLBOX_BINARY) $$i; done |
| |
| symlinks.list: |
| rm -f $@ $@.new |
| for i in $(TOOLS); do echo $$i; done >$@.new |
| mv $@.new $@ |
| |
| install: symlinks |
| cp -P $(LOCAL_MODULE) $(TOOLS) $(TARGET_OUT) |
| |
| CC ?= gcc |
| |
| # Directory where object files should be placed |
| TARGET_OUT ?= . |
| |
| TOOLS_H := ${TARGET_OUT}/tools.h |
| $(TOOLS_H): |
| echo "/* file generated automatically */" > $@ ; for t in $(TOOLS) ; do echo "TOOL($$t)" >> $@ ; done |
| |
| $(TARGET_OUT)/%.o: %.c |
| $(CC) $(CFLAGS) $(DEFINES) -I${TARGET_OUT} -c -o $@ $< |
| |
| OBJFILES := $(patsubst %.c,$(TARGET_OUT)/%.o,$(LOCAL_SRC_FILES)) |
| DEFINES := -g -DNO_ANDROID_HEADERS |
| LIBRARIES := -lpthread $(LDFLAGS) |
| |
| toolbox: $(TOOLS_H) $(OBJFILES) |
| $(CC) -o $(TARGET_OUT)/$(LOCAL_MODULE) $(DEFINES) $(OBJFILES) $(LIBRARIES) |
| |
| clean: |
| rm $(TARGET_OUT)/*.o $(TARGET_OUT)/$(LOCAL_MODULE) $(TOOLS_H) \ |
| symlinks.list |
| |
| # Make #!/system/bin/toolbox launchers for each tool. |
| # |
| SYMLINKS := $(addprefix $(TARGET_OUT)/bin/,$(TOOLS)) |
| TOOLBOX_BINARY := $(LOCAL_MODULE) |
| $(SYMLINKS): |
| @echo "Symlink: $@ -> $(TOOLBOX_BINARY)" |
| @mkdir -p $(dir $@) |
| @rm -rf $@ |
| @ln -sf $(TOOLBOX_BINARY) $@ |