1dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectLOCAL_PATH:= $(call my-dir)
25054c0db7075c5565c476f74ec0a995e9b756660Elliott Hughes
3fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes
45054c0db7075c5565c476f74ec0a995e9b756660Elliott Hughescommon_cflags := \
55054c0db7075c5565c476f74ec0a995e9b756660Elliott Hughes    -std=gnu99 \
65054c0db7075c5565c476f74ec0a995e9b756660Elliott Hughes    -Werror -Wno-unused-parameter \
7fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    -I$(LOCAL_PATH)/upstream-netbsd/include/ \
85054c0db7075c5565c476f74ec0a995e9b756660Elliott Hughes    -include bsd-compatibility.h \
95054c0db7075c5565c476f74ec0a995e9b756660Elliott Hughes
10fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes
11fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughesinclude $(CLEAR_VARS)
12fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott HughesLOCAL_SRC_FILES := \
13fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    upstream-netbsd/bin/dd/args.c \
14fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    upstream-netbsd/bin/dd/conv.c \
15fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    upstream-netbsd/bin/dd/dd.c \
16fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    upstream-netbsd/bin/dd/dd_hostops.c \
17fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    upstream-netbsd/bin/dd/misc.c \
18d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/bin/dd/position.c \
19d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/lib/libc/gen/getbsize.c \
20d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/lib/libc/gen/humanize_number.c \
21d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/lib/libc/stdlib/strsuftoll.c \
22d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/lib/libc/string/swab.c \
23d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/lib/libutil/raise_default_signal.c
24fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott HughesLOCAL_CFLAGS += $(common_cflags) -Dmain=dd_main -DNO_CONV
25fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott HughesLOCAL_MODULE := libtoolbox_dd
26fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughesinclude $(BUILD_STATIC_LIBRARY)
27fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes
28fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughesinclude $(CLEAR_VARS)
29fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott HughesLOCAL_SRC_FILES := upstream-netbsd/usr.bin/du/du.c
30fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott HughesLOCAL_CFLAGS += $(common_cflags) -Dmain=du_main
31fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott HughesLOCAL_MODULE := libtoolbox_du
32fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughesinclude $(BUILD_STATIC_LIBRARY)
33fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes
34fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes
35fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughesinclude $(CLEAR_VARS)
36fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes
37fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott HughesBSD_TOOLS := \
38fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    dd \
39fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    du \
40dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
41fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott HughesOUR_TOOLS := \
42fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    df \
43fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    getevent \
44fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    iftop \
45fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    ioctl \
46fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    ionice \
47fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    log \
484652fc6f08e9b03240980cdec42d66514fdc4a64Elliott Hughes    ls \
49fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    lsof \
50fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    mount \
51fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    nandread \
52fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    newfs_msdos \
53fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    ps \
540c0ab6bb066a40c781fcd3268db5e6c4d70ffcf6Elliott Hughes    prlimit \
55fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    renice \
56fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    sendevent \
57fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    start \
58fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    stop \
59fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    top \
60fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    uptime \
61fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    watchprops \
628290d1083ec7eee3f32265012f5d6be2774c4afcStephen Smalley
63fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott HughesALL_TOOLS = $(BSD_TOOLS) $(OUR_TOOLS)
6457df14c654a968e5b85d508cbd0871632011cb0eJeff Sharkey
6557df14c654a968e5b85d508cbd0871632011cb0eJeff SharkeyLOCAL_SRC_FILES := \
66fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    toolbox.c \
67d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    $(patsubst %,%.c,$(OUR_TOOLS)) \
68dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
695054c0db7075c5565c476f74ec0a995e9b756660Elliott HughesLOCAL_CFLAGS += $(common_cflags)
70ccecf1425412beb2bc3bb38d470293fdc244d6f1Elliott Hughes
71b83c09812f30d36285cacdf5cf824c56c267f8e5Kenny RootLOCAL_SHARED_LIBRARIES := \
727fc47129cf6a25b01b551816ac58ff3f53320123Elliott Hughes    libcutils \
737fc47129cf6a25b01b551816ac58ff3f53320123Elliott Hughes    libselinux \
747fc47129cf6a25b01b551816ac58ff3f53320123Elliott Hughes
75fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott HughesLOCAL_WHOLE_STATIC_LIBRARIES := $(patsubst %,libtoolbox_%,$(BSD_TOOLS))
765054c0db7075c5565c476f74ec0a995e9b756660Elliott Hughes
7757df14c654a968e5b85d508cbd0871632011cb0eJeff SharkeyLOCAL_MODULE := toolbox
78dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
797d45be0e4aa034e7184464b9535d8a822110d58fYing Wang# Install the symlinks.
807d45be0e4aa034e7184464b9535d8a822110d58fYing WangLOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf toolbox $(TARGET_OUT)/bin/$(t);)
817d45be0e4aa034e7184464b9535d8a822110d58fYing Wang
82dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project# Including this will define $(intermediates).
83dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#
84dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectinclude $(BUILD_EXECUTABLE)
85dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
86dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project$(LOCAL_PATH)/toolbox.c: $(intermediates)/tools.h
87dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
88dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectTOOLS_H := $(intermediates)/tools.h
8957df14c654a968e5b85d508cbd0871632011cb0eJeff Sharkey$(TOOLS_H): PRIVATE_TOOLS := $(ALL_TOOLS)
90dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project$(TOOLS_H): PRIVATE_CUSTOM_TOOL = echo "/* file generated automatically */" > $@ ; for t in $(PRIVATE_TOOLS) ; do echo "TOOL($$t)" >> $@ ; done
91dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project$(TOOLS_H): $(LOCAL_PATH)/Android.mk
92dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project$(TOOLS_H):
93dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project	$(transform-generated-source)
94dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
95c7f3c5c10cbe633683888a7e14a5fa436a2b32a6Elliott Hughes$(LOCAL_PATH)/getevent.c: $(intermediates)/input.h-labels.h
96c7f3c5c10cbe633683888a7e14a5fa436a2b32a6Elliott Hughes
97c7f3c5c10cbe633683888a7e14a5fa436a2b32a6Elliott HughesINPUT_H_LABELS_H := $(intermediates)/input.h-labels.h
98c7f3c5c10cbe633683888a7e14a5fa436a2b32a6Elliott Hughes$(INPUT_H_LABELS_H): PRIVATE_LOCAL_PATH := $(LOCAL_PATH)
99c7f3c5c10cbe633683888a7e14a5fa436a2b32a6Elliott Hughes$(INPUT_H_LABELS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_LOCAL_PATH)/generate-input.h-labels.py > $@
100c7f3c5c10cbe633683888a7e14a5fa436a2b32a6Elliott Hughes$(INPUT_H_LABELS_H): $(LOCAL_PATH)/Android.mk $(LOCAL_PATH)/generate-input.h-labels.py
101c7f3c5c10cbe633683888a7e14a5fa436a2b32a6Elliott Hughes$(INPUT_H_LABELS_H):
102c7f3c5c10cbe633683888a7e14a5fa436a2b32a6Elliott Hughes	$(transform-generated-source)
103660e750b122b546760ade1a792248fc1d2c09b1bElliott Hughes
104660e750b122b546760ade1a792248fc1d2c09b1bElliott Hughes# We only want 'r' on userdebug and eng builds.
105660e750b122b546760ade1a792248fc1d2c09b1bElliott Hughesinclude $(CLEAR_VARS)
106660e750b122b546760ade1a792248fc1d2c09b1bElliott HughesLOCAL_SRC_FILES := r.c
107660e750b122b546760ade1a792248fc1d2c09b1bElliott HughesLOCAL_CFLAGS += $(common_cflags)
108660e750b122b546760ade1a792248fc1d2c09b1bElliott HughesLOCAL_MODULE := r
109660e750b122b546760ade1a792248fc1d2c09b1bElliott HughesLOCAL_MODULE_TAGS := debug
110660e750b122b546760ade1a792248fc1d2c09b1bElliott Hughesinclude $(BUILD_EXECUTABLE)
111d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes
112d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes
113d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes# We build BSD grep separately, so it can provide egrep and fgrep too.
114d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughesinclude $(CLEAR_VARS)
115d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott HughesLOCAL_SRC_FILES := \
116d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/usr.bin/grep/fastgrep.c \
117d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/usr.bin/grep/file.c \
118d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/usr.bin/grep/grep.c \
119d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/usr.bin/grep/queue.c \
120d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/usr.bin/grep/util.c
121d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott HughesLOCAL_CFLAGS += $(common_cflags)
122d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott HughesLOCAL_MODULE := grep
123d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott HughesLOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,egrep fgrep,ln -sf grep $(TARGET_OUT)/bin/$(t);)
124d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughesinclude $(BUILD_EXECUTABLE)
125