• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1LOCAL_PATH:= $(call my-dir)
2
3
4common_cflags := \
5    -Werror -Wno-unused-parameter -Wno-unused-const-variable \
6    -I$(LOCAL_PATH)/upstream-netbsd/include/ \
7    -include bsd-compatibility.h \
8
9
10include $(CLEAR_VARS)
11LOCAL_SRC_FILES := \
12    upstream-netbsd/bin/dd/args.c \
13    upstream-netbsd/bin/dd/conv.c \
14    upstream-netbsd/bin/dd/dd.c \
15    upstream-netbsd/bin/dd/dd_hostops.c \
16    upstream-netbsd/bin/dd/misc.c \
17    upstream-netbsd/bin/dd/position.c \
18    upstream-netbsd/lib/libc/gen/getbsize.c \
19    upstream-netbsd/lib/libc/gen/humanize_number.c \
20    upstream-netbsd/lib/libc/stdlib/strsuftoll.c \
21    upstream-netbsd/lib/libc/string/swab.c \
22    upstream-netbsd/lib/libutil/raise_default_signal.c
23LOCAL_CFLAGS += $(common_cflags) -Dmain=dd_main -DNO_CONV
24LOCAL_MODULE := libtoolbox_dd
25include $(BUILD_STATIC_LIBRARY)
26
27
28include $(CLEAR_VARS)
29
30BSD_TOOLS := \
31    dd \
32
33OUR_TOOLS := \
34    getevent \
35    iftop \
36    ioctl \
37    log \
38    nandread \
39    newfs_msdos \
40    ps \
41    prlimit \
42    sendevent \
43    start \
44    stop \
45    top \
46
47ALL_TOOLS = $(BSD_TOOLS) $(OUR_TOOLS)
48
49LOCAL_SRC_FILES := \
50    start_stop.cpp \
51    toolbox.c \
52    $(patsubst %,%.c,$(OUR_TOOLS)) \
53
54LOCAL_CFLAGS += $(common_cflags)
55LOCAL_CONLYFLAGS += -std=gnu99
56
57LOCAL_SHARED_LIBRARIES := \
58    libcutils \
59    libselinux \
60
61LOCAL_WHOLE_STATIC_LIBRARIES := $(patsubst %,libtoolbox_%,$(BSD_TOOLS))
62
63LOCAL_MODULE := toolbox
64
65# Install the symlinks.
66LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf toolbox $(TARGET_OUT)/bin/$(t);)
67
68# Including this will define $(intermediates).
69#
70include $(BUILD_EXECUTABLE)
71
72$(LOCAL_PATH)/toolbox.c: $(intermediates)/tools.h
73
74TOOLS_H := $(intermediates)/tools.h
75$(TOOLS_H): PRIVATE_TOOLS := $(ALL_TOOLS)
76$(TOOLS_H): PRIVATE_CUSTOM_TOOL = echo "/* file generated automatically */" > $@ ; for t in $(PRIVATE_TOOLS) ; do echo "TOOL($$t)" >> $@ ; done
77$(TOOLS_H): $(LOCAL_PATH)/Android.mk
78$(TOOLS_H):
79	$(transform-generated-source)
80
81$(LOCAL_PATH)/getevent.c: $(intermediates)/input.h-labels.h
82
83UAPI_INPUT_EVENT_CODES_H := bionic/libc/kernel/uapi/linux/input-event-codes.h
84INPUT_H_LABELS_H := $(intermediates)/input.h-labels.h
85$(INPUT_H_LABELS_H): PRIVATE_LOCAL_PATH := $(LOCAL_PATH)
86# The PRIVATE_CUSTOM_TOOL line uses = to evaluate the output path late.
87# We copy the input path so it can't be accidentally modified later.
88$(INPUT_H_LABELS_H): PRIVATE_UAPI_INPUT_EVENT_CODES_H := $(UAPI_INPUT_EVENT_CODES_H)
89$(INPUT_H_LABELS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_LOCAL_PATH)/generate-input.h-labels.py $(PRIVATE_UAPI_INPUT_EVENT_CODES_H) > $@
90# The dependency line though gets evaluated now, so the PRIVATE_ copy doesn't exist yet,
91# and the original can't yet have been modified, so this is both sufficient and necessary.
92$(INPUT_H_LABELS_H): $(LOCAL_PATH)/Android.mk $(LOCAL_PATH)/generate-input.h-labels.py $(UAPI_INPUT_EVENT_CODES_H)
93$(INPUT_H_LABELS_H):
94	$(transform-generated-source)
95
96# We only want 'r' on userdebug and eng builds.
97include $(CLEAR_VARS)
98LOCAL_SRC_FILES := r.c
99LOCAL_CFLAGS += $(common_cflags)
100LOCAL_MODULE := r
101LOCAL_MODULE_TAGS := debug
102include $(BUILD_EXECUTABLE)
103
104
105# We build BSD grep separately, so it can provide egrep and fgrep too.
106include $(CLEAR_VARS)
107LOCAL_SRC_FILES := \
108    upstream-netbsd/usr.bin/grep/fastgrep.c \
109    upstream-netbsd/usr.bin/grep/file.c \
110    upstream-netbsd/usr.bin/grep/grep.c \
111    upstream-netbsd/usr.bin/grep/queue.c \
112    upstream-netbsd/usr.bin/grep/util.c
113LOCAL_CFLAGS += $(common_cflags)
114LOCAL_MODULE := grep
115LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,egrep fgrep,ln -sf grep $(TARGET_OUT)/bin/$(t);)
116include $(BUILD_EXECUTABLE)
117