blob: 9b9a5117ddab23e2e042616f546046e6ef10f19f [file] [log] [blame]
Denton Gentry1f912cf2011-06-12 05:08:41 -07001LOCAL_PATH:= $(call my-dir)
2include $(CLEAR_VARS)
3
4TOOLS := \
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 \
Denton Gentry1f912cf2011-06-12 05:08:41 -070023 sync \
24 umount \
Denton Gentry1f912cf2011-06-12 05:08:41 -070025 notify \
26 cmp \
27 dmesg \
28 route \
29 hd \
30 dd \
31 df \
Denton Gentry1f912cf2011-06-12 05:08:41 -070032 sleep \
33 renice \
34 printenv \
35 smd \
36 chmod \
37 chown \
Denton Gentry1f912cf2011-06-12 05:08:41 -070038 netstat \
39 ioctl \
40 mv \
41 schedtop \
42 top \
43 iftop \
44 id \
Denton Gentry1f912cf2011-06-12 05:08:41 -070045 vmstat \
Denton Gentry1f912cf2011-06-12 05:08:41 -070046 lsof
47
48LOCAL_SRC_FILES:= \
49 toolbox.c \
50 $(patsubst %,%.c,$(TOOLS))
51
52LOCAL_MODULE:= toolbox
53
54all: ${LOCAL_MODULE}
55
56CC ?= gcc
57
58# Directory where object files should be placed
59TARGET_OUT ?= .
60
61TOOLS_H := ${TARGET_OUT}/tools.h
62$(TOOLS_H):
63 echo "/* file generated automatically */" > $@ ; for t in $(PRIVATE_TOOLS) ; do echo "TOOL($$t)" >> $@ ; done
64
65$(TARGET_OUT)/%.o: %.c
66 $(CC) $(DEFINES) -I${TARGET_OUT} -c -o $@ $<
67
68OBJFILES := $(patsubst %.c,$(TARGET_OUT)/%.o,$(LOCAL_SRC_FILES))
Denton Gentry6b61a3f2011-06-12 05:33:33 -070069DEFINES := -DNO_ANDROID_HEADERS
Denton Gentry1f912cf2011-06-12 05:08:41 -070070
Denton Gentryc60b92c2011-06-12 05:19:58 -070071toolbox: $(TOOLS_H) $(OBJFILES)
Denton Gentry6b61a3f2011-06-12 05:33:33 -070072 $(CC) -o $(TARGET_OUT)/$(TARGET) $(DEFINES) $(OBJFILES) $(LIBRARIES)
Denton Gentry1f912cf2011-06-12 05:08:41 -070073
74# Make #!/system/bin/toolbox launchers for each tool.
75#
76SYMLINKS := $(addprefix $(TARGET_OUT)/bin/,$(TOOLS))
77$(SYMLINKS): TOOLBOX_BINARY := $(LOCAL_MODULE)
78$(SYMLINKS):
79 @echo "Symlink: $@ -> $(TOOLBOX_BINARY)"
80 @mkdir -p $(dir $@)
81 @rm -rf $@
82 $(hide) ln -sf $(TOOLBOX_BINARY) $@