-
Notifications
You must be signed in to change notification settings - Fork 0
/
Android.mk
321 lines (293 loc) · 8.72 KB
/
Android.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
#
# Copyright (C) 2014 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LOCAL_PATH := $(call my-dir)
common_cflags += \
-std=c99 \
-Os \
-Wno-char-subscripts \
-Wno-sign-compare \
-Wno-string-plus-int \
-Wno-uninitialized \
-Wno-unused-parameter \
-funsigned-char \
-ffunction-sections -fdata-sections \
-fno-asynchronous-unwind-tables \
toybox_upstream_version := $(shell awk 'match($$0, /TOYBOX_VERSION.*"(.*)"/, ary) {print ary[1]}' $(LOCAL_PATH)/main.c)
toybox_sha := $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)
toybox_version := $(toybox_upstream_version)-$(toybox_sha)-android
common_cflags += -DTOYBOX_VERSION='"$(toybox_version)"'
#
# To update:
#
# git remote add toybox https://github.com/landley/toybox.git
# git fetch toybox
# git merge toybox/master
# mm -j32
# # (Make any necessary Android.mk changes and test the new toybox.)
# repo upload .
# git push aosp HEAD:refs/for/master # Push to gerrit for review.
# git push aosp HEAD:master # Push directly, avoiding gerrit.
#
# # Now commit any necessary Android.mk changes like normal:
# repo start post-sync .
# git commit -a
#
# To add a toy:
#
# make menuconfig
# # (Select the toy you want to add.)
# make clean && make # Regenerate the generated files.
# # Edit LOCAL_SRC_FILES below to add the toy.
# # If you just want to use it as "toybox x" rather than "x", you can stop now.
# # If you want this toy to have a symbolic link in /system/bin, add the toy to ALL_TOOLS.
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
lib/args.c \
lib/dirtree.c \
lib/getmountlist.c \
lib/help.c \
lib/interestingtimes.c \
lib/lib.c \
lib/linestack.c \
lib/llist.c \
lib/net.c \
lib/password.c \
lib/portability.c \
lib/xwrap.c \
main.c \
toys/android/getenforce.c \
toys/android/getprop.c \
toys/android/load_policy.c \
toys/android/restorecon.c \
toys/android/runcon.c \
toys/android/setenforce.c \
toys/android/setprop.c \
toys/lsb/dmesg.c \
toys/lsb/hostname.c \
toys/lsb/killall.c \
toys/lsb/md5sum.c \
toys/lsb/mknod.c \
toys/lsb/mktemp.c \
toys/lsb/mount.c \
toys/lsb/pidof.c \
toys/lsb/seq.c \
toys/lsb/sync.c \
toys/lsb/umount.c \
toys/other/acpi.c \
toys/other/base64.c \
toys/other/blkid.c \
toys/other/blockdev.c \
toys/other/bzcat.c \
toys/other/chcon.c \
toys/other/chroot.c \
toys/other/clear.c \
toys/other/dos2unix.c \
toys/other/fallocate.c \
toys/other/flock.c \
toys/other/free.c \
toys/other/freeramdisk.c \
toys/other/fsfreeze.c \
toys/other/help.c \
toys/other/hwclock.c \
toys/other/ifconfig.c \
toys/other/inotifyd.c \
toys/other/insmod.c \
toys/other/ionice.c \
toys/other/losetup.c \
toys/other/lsattr.c \
toys/other/lsmod.c \
toys/other/lspci.c \
toys/other/lsusb.c \
toys/other/makedevs.c \
toys/other/mkswap.c \
toys/other/modinfo.c \
toys/other/mountpoint.c \
toys/other/nbd_client.c \
toys/other/netcat.c \
toys/other/partprobe.c \
toys/other/pivot_root.c \
toys/other/pmap.c \
toys/other/printenv.c \
toys/other/pwdx.c \
toys/other/readahead.c \
toys/other/readlink.c \
toys/other/realpath.c \
toys/other/reset.c \
toys/other/rev.c \
toys/other/rfkill.c \
toys/other/rmmod.c \
toys/other/setsid.c \
toys/other/stat.c \
toys/other/swapoff.c \
toys/other/swapon.c \
toys/other/switch_root.c \
toys/other/sysctl.c \
toys/other/tac.c \
toys/other/taskset.c \
toys/other/timeout.c \
toys/other/truncate.c \
toys/other/uptime.c \
toys/other/usleep.c \
toys/other/vconfig.c \
toys/other/vmstat.c \
toys/other/which.c \
toys/other/xxd.c \
toys/other/yes.c \
toys/pending/arp.c \
toys/pending/dd.c \
toys/pending/diff.c \
toys/pending/expr.c \
toys/pending/fdisk.c \
toys/pending/file.c \
toys/pending/ftpget.c \
toys/pending/host.c \
toys/pending/lsof.c \
toys/pending/more.c \
toys/pending/netstat.c \
toys/pending/resize.c \
toys/pending/route.c \
toys/pending/tar.c \
toys/pending/telnet.c \
toys/pending/test.c \
toys/pending/tr.c \
toys/pending/traceroute.c \
toys/pending/watch.c \
toys/pending/xzcat.c \
toys/posix/basename.c \
toys/posix/cal.c \
toys/posix/cat.c \
toys/posix/chgrp.c \
toys/posix/chmod.c \
toys/posix/cksum.c \
toys/posix/cmp.c \
toys/posix/comm.c \
toys/posix/cp.c \
toys/posix/cpio.c \
toys/posix/cut.c \
toys/posix/date.c \
toys/posix/df.c \
toys/posix/dirname.c \
toys/posix/du.c \
toys/posix/echo.c \
toys/posix/env.c \
toys/posix/expand.c \
toys/posix/false.c \
toys/posix/find.c \
toys/posix/grep.c \
toys/posix/head.c \
toys/posix/id.c \
toys/posix/kill.c \
toys/posix/ln.c \
toys/posix/ls.c \
toys/posix/mkdir.c \
toys/posix/mkfifo.c \
toys/posix/nice.c \
toys/posix/nl.c \
toys/posix/nohup.c \
toys/posix/od.c \
toys/posix/paste.c \
toys/posix/patch.c \
toys/posix/printf.c \
toys/posix/ps.c \
toys/posix/pwd.c \
toys/posix/renice.c \
toys/posix/rm.c \
toys/posix/rmdir.c \
toys/posix/sed.c \
toys/posix/sleep.c \
toys/posix/sort.c \
toys/posix/split.c \
toys/posix/strings.c \
toys/posix/tail.c \
toys/posix/tee.c \
toys/posix/time.c \
toys/posix/touch.c \
toys/posix/true.c \
toys/posix/tty.c \
toys/posix/ulimit.c \
toys/posix/uname.c \
toys/posix/uniq.c \
toys/posix/wc.c \
toys/posix/xargs.c
LOCAL_CFLAGS := $(common_cflags)
LOCAL_CLANG := true
# This doesn't actually prevent us from dragging in libc++ at runtime
# because libnetd_client.so is C++.
LOCAL_CXX_STL := none
LOCAL_C_INCLUDES += bionic/libc/dns/include
LOCAL_MODULE := libtoybox
include $(BUILD_STATIC_LIBRARY)
# Host binary to enumerate the toys
include $(CLEAR_VARS)
LOCAL_SRC_FILES := scripts/install.c
LOCAL_MODULE_TAGS := optional
LOCAL_CFLAGS := $(common_cflags)
LOCAL_CLANG := true
LOCAL_MODULE := toybox-instlist
include $(BUILD_HOST_EXECUTABLE)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := main.c
LOCAL_STATIC_LIBRARIES := libtoybox
LOCAL_SHARED_LIBRARIES := libcutils libselinux
LOCAL_CFLAGS := $(common_cflags)
LOCAL_CXX_STL := none
LOCAL_CLANG := true
LOCAL_MODULE := toybox
# for dumping the list of toys
TOYBOX_INSTLIST := $(HOST_OUT_EXECUTABLES)/toybox-instlist
LOCAL_ADDITIONAL_DEPENDENCIES := toybox_links
# we still want a link for ls/ps, but the toolbox version needs to
# stick around for compatibility reasons, for now.
TOYS_FOR_XBIN := ls ps
# skip links for these toys in the system image, they already have
# a full-blown counterpart. we still want them for the recovery
# image though.
TOYS_WITHOUT_LINKS := blkid
include $(BUILD_EXECUTABLE)
toybox_links: $(TOYBOX_INSTLIST) toybox
toybox_links: TOY_LIST=$(shell $(TOYBOX_INSTLIST))
toybox_links: TOYBOX_BINARY := $(TARGET_OUT)/bin/toybox
toybox_links:
@echo -e ${CL_CYN}"Generate Toybox links:"${CL_RST} $(TOY_LIST)
@mkdir -p $(TARGET_OUT)/bin
@mkdir -p $(TARGET_OUT)/xbin
$(hide) $(foreach t,$(filter-out $(TOYS_FOR_XBIN) $(TOYS_WITHOUT_LINKS),$(TOY_LIST)),ln -sf toybox $(TARGET_OUT_EXECUTABLES)/$(t);)
$(hide) $(foreach t,$(TOYS_FOR_XBIN),ln -sf /system/bin/toybox $(TARGET_OUT_OPTIONAL_EXECUTABLES)/$(t);)
# This is used by the recovery system
include $(CLEAR_VARS)
LOCAL_SRC_FILES := main.c
LOCAL_WHOLE_STATIC_LIBRARIES := libtoybox
LOCAL_CFLAGS := $(common_cflags)
LOCAL_CFLAGS += -Dmain=toybox_driver
LOCAL_CXX_STL := none
LOCAL_CLANG := true
LOCAL_MODULE := libtoybox_driver
include $(BUILD_STATIC_LIBRARY)
# static executable for use in limited environments
include $(CLEAR_VARS)
LOCAL_SRC_FILES := main.c
LOCAL_CFLAGS := $(common_cflags)
LOCAL_CXX_STL := none
LOCAL_CLANG := true
LOCAL_UNSTRIPPED_PATH := $(PRODUCT_OUT)/symbols/utilities
LOCAL_MODULE := toybox_static
LOCAL_MODULE_CLASS := UTILITY_EXECUTABLES
LOCAL_MODULE_PATH := $(PRODUCT_OUT)/utilities
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_STEM := toybox
LOCAL_STATIC_LIBRARIES := libc libtoybox libcutils libselinux libmincrypt
LOCAL_FORCE_STATIC_EXECUTABLE := true
include $(BUILD_EXECUTABLE)