blob: 8151fd1aa7cbc99ff5efadebbbbe6ec0dd036350 [file] [log] [blame]
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
LOCAL_SRC_FILES:= \
toolbox.c \
$(patsubst %,%.c,$(TOOLS))
LOCAL_MODULE:= toolbox
all: ${LOCAL_MODULE} symlinks
symlinks: $(SYMLINKS)
for i in $(TOOLS); do ln -sf $(TOOLBOX_BINARY) $$i; done
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) $(DEFINES) -I${TARGET_OUT} -c -o $@ $<
OBJFILES := $(patsubst %.c,$(TARGET_OUT)/%.o,$(LOCAL_SRC_FILES))
DEFINES := -g -DNO_ANDROID_HEADERS
LIBRARIES := -lpthread
toolbox: $(TOOLS_H) $(OBJFILES)
$(CC) -o $(TARGET_OUT)/$(LOCAL_MODULE) $(DEFINES) $(OBJFILES) $(LIBRARIES)
clean:
rm $(TARGET_OUT)/*.o $(TARGET_OUT)/$(LOCAL_MODULE) $(TOOLS_H)
# 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) $@