• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1LOCAL_PATH:= $(call my-dir)
2
3
4common_cflags := \
5    -std=gnu99 \
6    -Werror -Wno-unused-parameter \
7    -I$(LOCAL_PATH)/upstream-netbsd/include/ \
8    -include bsd-compatibility.h \
9
10
11include $(CLEAR_VARS)
12LOCAL_SRC_FILES := upstream-netbsd/bin/cat/cat.c
13LOCAL_CFLAGS += $(common_cflags) -Dmain=cat_main
14LOCAL_MODULE := libtoolbox_cat
15LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
16include $(BUILD_STATIC_LIBRARY)
17
18include $(CLEAR_VARS)
19LOCAL_SRC_FILES := upstream-netbsd/sbin/chown/chown.c
20LOCAL_CFLAGS += $(common_cflags) -Dmain=chown_main
21LOCAL_MODULE := libtoolbox_chown
22LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
23include $(BUILD_STATIC_LIBRARY)
24
25include $(CLEAR_VARS)
26LOCAL_SRC_FILES := \
27    upstream-netbsd/bin/cp/cp.c \
28    upstream-netbsd/bin/cp/utils.c
29LOCAL_CFLAGS += $(common_cflags) -Dmain=cp_main
30LOCAL_MODULE := libtoolbox_cp
31LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
32include $(BUILD_STATIC_LIBRARY)
33
34include $(CLEAR_VARS)
35LOCAL_SRC_FILES := \
36    upstream-netbsd/bin/dd/args.c \
37    upstream-netbsd/bin/dd/conv.c \
38    upstream-netbsd/bin/dd/dd.c \
39    upstream-netbsd/bin/dd/dd_hostops.c \
40    upstream-netbsd/bin/dd/misc.c \
41    upstream-netbsd/bin/dd/position.c
42LOCAL_CFLAGS += $(common_cflags) -Dmain=dd_main -DNO_CONV
43LOCAL_MODULE := libtoolbox_dd
44LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
45include $(BUILD_STATIC_LIBRARY)
46
47include $(CLEAR_VARS)
48LOCAL_SRC_FILES := upstream-netbsd/usr.bin/du/du.c
49LOCAL_CFLAGS += $(common_cflags) -Dmain=du_main
50LOCAL_MODULE := libtoolbox_du
51LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
52include $(BUILD_STATIC_LIBRARY)
53
54include $(CLEAR_VARS)
55LOCAL_SRC_FILES := \
56    upstream-netbsd/usr.bin/grep/fastgrep.c \
57    upstream-netbsd/usr.bin/grep/file.c \
58    upstream-netbsd/usr.bin/grep/grep.c \
59    upstream-netbsd/usr.bin/grep/queue.c \
60    upstream-netbsd/usr.bin/grep/util.c
61LOCAL_CFLAGS += $(common_cflags) -Dmain=grep_main
62LOCAL_MODULE := libtoolbox_grep
63LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
64include $(BUILD_STATIC_LIBRARY)
65
66include $(CLEAR_VARS)
67LOCAL_SRC_FILES := upstream-netbsd/bin/kill/kill.c
68LOCAL_CFLAGS += $(common_cflags) -Dmain=kill_main
69LOCAL_MODULE := libtoolbox_kill
70LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
71include $(BUILD_STATIC_LIBRARY)
72
73include $(CLEAR_VARS)
74LOCAL_SRC_FILES := upstream-netbsd/bin/ln/ln.c
75LOCAL_CFLAGS += $(common_cflags) -Dmain=ln_main
76LOCAL_MODULE := libtoolbox_ln
77LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
78include $(BUILD_STATIC_LIBRARY)
79
80include $(CLEAR_VARS)
81LOCAL_SRC_FILES := upstream-netbsd/bin/mv/mv.c
82LOCAL_CFLAGS += $(common_cflags) -Dmain=mv_main -D__SVR4
83LOCAL_MODULE := libtoolbox_mv
84LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
85include $(BUILD_STATIC_LIBRARY)
86
87include $(CLEAR_VARS)
88LOCAL_SRC_FILES := upstream-netbsd/usr.bin/printenv/printenv.c
89LOCAL_CFLAGS += $(common_cflags) -Dmain=printenv_main
90LOCAL_MODULE := libtoolbox_printenv
91LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
92include $(BUILD_STATIC_LIBRARY)
93
94include $(CLEAR_VARS)
95LOCAL_SRC_FILES := upstream-netbsd/bin/rm/rm.c
96LOCAL_CFLAGS += $(common_cflags) -Dmain=rm_main
97LOCAL_MODULE := libtoolbox_rm
98LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
99include $(BUILD_STATIC_LIBRARY)
100
101include $(CLEAR_VARS)
102LOCAL_SRC_FILES := upstream-netbsd/bin/rmdir/rmdir.c
103LOCAL_CFLAGS += $(common_cflags) -Dmain=rmdir_main
104LOCAL_MODULE := libtoolbox_rmdir
105LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
106include $(BUILD_STATIC_LIBRARY)
107
108include $(CLEAR_VARS)
109LOCAL_SRC_FILES := upstream-netbsd/bin/sleep/sleep.c
110LOCAL_CFLAGS += $(common_cflags) -Dmain=sleep_main
111LOCAL_MODULE := libtoolbox_sleep
112LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
113include $(BUILD_STATIC_LIBRARY)
114
115include $(CLEAR_VARS)
116LOCAL_SRC_FILES := upstream-netbsd/bin/sync/sync.c
117LOCAL_CFLAGS += $(common_cflags) -Dmain=sync_main
118LOCAL_MODULE := libtoolbox_sync
119LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
120include $(BUILD_STATIC_LIBRARY)
121
122
123include $(CLEAR_VARS)
124
125BSD_TOOLS := \
126    cat \
127    chown \
128    cp \
129    dd \
130    du \
131    grep \
132    kill \
133    ln \
134    mv \
135    printenv \
136    rm \
137    rmdir \
138    sleep \
139    sync \
140
141OUR_TOOLS := \
142    chcon \
143    chmod \
144    clear \
145    cmp \
146    date \
147    df \
148    dmesg \
149    getenforce \
150    getevent \
151    getprop \
152    getsebool \
153    hd \
154    id \
155    ifconfig \
156    iftop \
157    insmod \
158    ioctl \
159    ionice \
160    load_policy \
161    log \
162    ls \
163    lsmod \
164    lsof \
165    md5 \
166    mkdir \
167    mknod \
168    mkswap \
169    mount \
170    nandread \
171    netstat \
172    newfs_msdos \
173    nohup \
174    notify \
175    ps \
176    readlink \
177    renice \
178    restorecon \
179    prlimit \
180    rmmod \
181    route \
182    runcon \
183    schedtop \
184    sendevent \
185    setenforce \
186    setprop \
187    setsebool \
188    smd \
189    start \
190    stop \
191    swapoff \
192    swapon \
193    top \
194    touch \
195    umount \
196    uptime \
197    vmstat \
198    watchprops \
199    wipe \
200
201ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
202OUR_TOOLS += r
203endif
204
205ALL_TOOLS = $(BSD_TOOLS) $(OUR_TOOLS)
206
207LOCAL_SRC_FILES := \
208    upstream-netbsd/lib/libc/gen/getbsize.c \
209    upstream-netbsd/lib/libc/gen/humanize_number.c \
210    upstream-netbsd/lib/libc/stdlib/strsuftoll.c \
211    upstream-netbsd/lib/libc/string/swab.c \
212    upstream-netbsd/lib/libutil/raise_default_signal.c \
213    dynarray.c \
214    pwcache.c \
215    $(patsubst %,%.c,$(OUR_TOOLS)) \
216    toolbox.c \
217
218LOCAL_CFLAGS += $(common_cflags)
219
220LOCAL_C_INCLUDES += external/openssl/include
221
222LOCAL_SHARED_LIBRARIES := \
223    libcrypto \
224    libcutils \
225    libselinux \
226
227# libusbhost is only used by lsusb, and that isn't usually included in toolbox.
228# The linker strips out all the unused library code in the normal case.
229LOCAL_STATIC_LIBRARIES := \
230    libusbhost \
231
232LOCAL_WHOLE_STATIC_LIBRARIES := $(patsubst %,libtoolbox_%,$(BSD_TOOLS))
233
234LOCAL_MODULE := toolbox
235LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
236
237# Including this will define $(intermediates).
238#
239include $(BUILD_EXECUTABLE)
240
241$(LOCAL_PATH)/toolbox.c: $(intermediates)/tools.h
242
243TOOLS_H := $(intermediates)/tools.h
244$(TOOLS_H): PRIVATE_TOOLS := $(ALL_TOOLS)
245$(TOOLS_H): PRIVATE_CUSTOM_TOOL = echo "/* file generated automatically */" > $@ ; for t in $(PRIVATE_TOOLS) ; do echo "TOOL($$t)" >> $@ ; done
246$(TOOLS_H): $(LOCAL_PATH)/Android.mk
247$(TOOLS_H):
248	$(transform-generated-source)
249
250# Make #!/system/bin/toolbox launchers for each tool.
251#
252SYMLINKS := $(addprefix $(TARGET_OUT)/bin/,$(ALL_TOOLS))
253$(SYMLINKS): TOOLBOX_BINARY := $(LOCAL_MODULE)
254$(SYMLINKS): $(LOCAL_INSTALLED_MODULE) $(LOCAL_PATH)/Android.mk
255	@echo "Symlink: $@ -> $(TOOLBOX_BINARY)"
256	@mkdir -p $(dir $@)
257	@rm -rf $@
258	$(hide) ln -sf $(TOOLBOX_BINARY) $@
259
260ALL_DEFAULT_INSTALLED_MODULES += $(SYMLINKS)
261
262# We need this so that the installed files could be picked up based on the
263# local module name
264ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
265    $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(SYMLINKS)
266