1dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectLOCAL_PATH:= $(call my-dir)
25054c0db7075c5565c476f74ec0a995e9b756660Elliott Hughes
3fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes
45054c0db7075c5565c476f74ec0a995e9b756660Elliott Hughescommon_cflags := \
53294ad163fa4086809831f3e960421511693ae20Andreas Gampe    -Werror -Wno-unused-parameter -Wno-unused-const-variable \
6fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    -I$(LOCAL_PATH)/upstream-netbsd/include/ \
75054c0db7075c5565c476f74ec0a995e9b756660Elliott Hughes    -include bsd-compatibility.h \
85054c0db7075c5565c476f74ec0a995e9b756660Elliott Hughes
9fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes
10fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughesinclude $(CLEAR_VARS)
11fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott HughesLOCAL_SRC_FILES := \
12fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    upstream-netbsd/bin/dd/args.c \
13fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    upstream-netbsd/bin/dd/conv.c \
14fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    upstream-netbsd/bin/dd/dd.c \
15fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    upstream-netbsd/bin/dd/dd_hostops.c \
16fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    upstream-netbsd/bin/dd/misc.c \
17d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/bin/dd/position.c \
18d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/lib/libc/gen/getbsize.c \
19d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/lib/libc/gen/humanize_number.c \
20d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/lib/libc/stdlib/strsuftoll.c \
21d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/lib/libc/string/swab.c \
22d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/lib/libutil/raise_default_signal.c
23fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott HughesLOCAL_CFLAGS += $(common_cflags) -Dmain=dd_main -DNO_CONV
24fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott HughesLOCAL_MODULE := libtoolbox_dd
25fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughesinclude $(BUILD_STATIC_LIBRARY)
26fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes
27fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes
28fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughesinclude $(CLEAR_VARS)
29fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes
30fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott HughesBSD_TOOLS := \
31fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    dd \
32dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
33fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott HughesOUR_TOOLS := \
34fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    getevent \
35fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    iftop \
36fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    ioctl \
37fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    log \
38fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    nandread \
39fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    newfs_msdos \
40fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    ps \
410c0ab6bb066a40c781fcd3268db5e6c4d70ffcf6Elliott Hughes    prlimit \
42fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    sendevent \
43fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    start \
44fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    stop \
45fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    top \
468290d1083ec7eee3f32265012f5d6be2774c4afcStephen Smalley
47fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott HughesALL_TOOLS = $(BSD_TOOLS) $(OUR_TOOLS)
4857df14c654a968e5b85d508cbd0871632011cb0eJeff Sharkey
4957df14c654a968e5b85d508cbd0871632011cb0eJeff SharkeyLOCAL_SRC_FILES := \
506e83c3d76d02cd922620526c446cf5840e042706Elliott Hughes    start_stop.cpp \
51fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott Hughes    toolbox.c \
52d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    $(patsubst %,%.c,$(OUR_TOOLS)) \
53dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
545054c0db7075c5565c476f74ec0a995e9b756660Elliott HughesLOCAL_CFLAGS += $(common_cflags)
556e83c3d76d02cd922620526c446cf5840e042706Elliott HughesLOCAL_CONLYFLAGS += -std=gnu99
56ccecf1425412beb2bc3bb38d470293fdc244d6f1Elliott Hughes
57b83c09812f30d36285cacdf5cf824c56c267f8e5Kenny RootLOCAL_SHARED_LIBRARIES := \
587fc47129cf6a25b01b551816ac58ff3f53320123Elliott Hughes    libcutils \
597fc47129cf6a25b01b551816ac58ff3f53320123Elliott Hughes    libselinux \
607fc47129cf6a25b01b551816ac58ff3f53320123Elliott Hughes
61fd4c6b0a3a25921a9fe24691a695d715aecb6afeElliott HughesLOCAL_WHOLE_STATIC_LIBRARIES := $(patsubst %,libtoolbox_%,$(BSD_TOOLS))
625054c0db7075c5565c476f74ec0a995e9b756660Elliott Hughes
6357df14c654a968e5b85d508cbd0871632011cb0eJeff SharkeyLOCAL_MODULE := toolbox
64dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
657d45be0e4aa034e7184464b9535d8a822110d58fYing Wang# Install the symlinks.
667d45be0e4aa034e7184464b9535d8a822110d58fYing WangLOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf toolbox $(TARGET_OUT)/bin/$(t);)
677d45be0e4aa034e7184464b9535d8a822110d58fYing Wang
68dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project# Including this will define $(intermediates).
69dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#
70dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectinclude $(BUILD_EXECUTABLE)
71dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
72dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project$(LOCAL_PATH)/toolbox.c: $(intermediates)/tools.h
73dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
74dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectTOOLS_H := $(intermediates)/tools.h
7557df14c654a968e5b85d508cbd0871632011cb0eJeff Sharkey$(TOOLS_H): PRIVATE_TOOLS := $(ALL_TOOLS)
76dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project$(TOOLS_H): PRIVATE_CUSTOM_TOOL = echo "/* file generated automatically */" > $@ ; for t in $(PRIVATE_TOOLS) ; do echo "TOOL($$t)" >> $@ ; done
77dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project$(TOOLS_H): $(LOCAL_PATH)/Android.mk
78dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project$(TOOLS_H):
79dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project	$(transform-generated-source)
80dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
81c7f3c5c10cbe633683888a7e14a5fa436a2b32a6Elliott Hughes$(LOCAL_PATH)/getevent.c: $(intermediates)/input.h-labels.h
82c7f3c5c10cbe633683888a7e14a5fa436a2b32a6Elliott Hughes
83b71e8970034f2e37231ce11a44f4488ae7892be4Elliott HughesUAPI_INPUT_EVENT_CODES_H := bionic/libc/kernel/uapi/linux/input-event-codes.h
84c7f3c5c10cbe633683888a7e14a5fa436a2b32a6Elliott HughesINPUT_H_LABELS_H := $(intermediates)/input.h-labels.h
85c7f3c5c10cbe633683888a7e14a5fa436a2b32a6Elliott Hughes$(INPUT_H_LABELS_H): PRIVATE_LOCAL_PATH := $(LOCAL_PATH)
86b71e8970034f2e37231ce11a44f4488ae7892be4Elliott Hughes# The PRIVATE_CUSTOM_TOOL line uses = to evaluate the output path late.
87b71e8970034f2e37231ce11a44f4488ae7892be4Elliott Hughes# We copy the input path so it can't be accidentally modified later.
88b71e8970034f2e37231ce11a44f4488ae7892be4Elliott Hughes$(INPUT_H_LABELS_H): PRIVATE_UAPI_INPUT_EVENT_CODES_H := $(UAPI_INPUT_EVENT_CODES_H)
89b71e8970034f2e37231ce11a44f4488ae7892be4Elliott Hughes$(INPUT_H_LABELS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_LOCAL_PATH)/generate-input.h-labels.py $(PRIVATE_UAPI_INPUT_EVENT_CODES_H) > $@
90b71e8970034f2e37231ce11a44f4488ae7892be4Elliott Hughes# The dependency line though gets evaluated now, so the PRIVATE_ copy doesn't exist yet,
91b71e8970034f2e37231ce11a44f4488ae7892be4Elliott Hughes# and the original can't yet have been modified, so this is both sufficient and necessary.
92b71e8970034f2e37231ce11a44f4488ae7892be4Elliott Hughes$(INPUT_H_LABELS_H): $(LOCAL_PATH)/Android.mk $(LOCAL_PATH)/generate-input.h-labels.py $(UAPI_INPUT_EVENT_CODES_H)
93c7f3c5c10cbe633683888a7e14a5fa436a2b32a6Elliott Hughes$(INPUT_H_LABELS_H):
94c7f3c5c10cbe633683888a7e14a5fa436a2b32a6Elliott Hughes	$(transform-generated-source)
95660e750b122b546760ade1a792248fc1d2c09b1bElliott Hughes
96660e750b122b546760ade1a792248fc1d2c09b1bElliott Hughes# We only want 'r' on userdebug and eng builds.
97660e750b122b546760ade1a792248fc1d2c09b1bElliott Hughesinclude $(CLEAR_VARS)
98660e750b122b546760ade1a792248fc1d2c09b1bElliott HughesLOCAL_SRC_FILES := r.c
99660e750b122b546760ade1a792248fc1d2c09b1bElliott HughesLOCAL_CFLAGS += $(common_cflags)
100660e750b122b546760ade1a792248fc1d2c09b1bElliott HughesLOCAL_MODULE := r
101660e750b122b546760ade1a792248fc1d2c09b1bElliott HughesLOCAL_MODULE_TAGS := debug
102660e750b122b546760ade1a792248fc1d2c09b1bElliott Hughesinclude $(BUILD_EXECUTABLE)
103d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes
104d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes
105d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes# We build BSD grep separately, so it can provide egrep and fgrep too.
106d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughesinclude $(CLEAR_VARS)
107d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott HughesLOCAL_SRC_FILES := \
108d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/usr.bin/grep/fastgrep.c \
109d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/usr.bin/grep/file.c \
110d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/usr.bin/grep/grep.c \
111d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/usr.bin/grep/queue.c \
112d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughes    upstream-netbsd/usr.bin/grep/util.c
113d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott HughesLOCAL_CFLAGS += $(common_cflags)
114d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott HughesLOCAL_MODULE := grep
115d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott HughesLOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,egrep fgrep,ln -sf grep $(TARGET_OUT)/bin/$(t);)
116d20218e05dfd54620999f1fd9cb7aaa91a296be5Elliott Hughesinclude $(BUILD_EXECUTABLE)
117