OSDN Git Service

Merge tag 'android-8.1.0_r1' into oreo-x86
[android-x86/external-toybox.git] / Android.mk
1 #
2 # Copyright (C) 2014 The Android Open Source Project
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16
17 LOCAL_PATH := $(call my-dir)
18
19 #
20 # To update:
21 #
22
23 #  git remote add toybox https://github.com/landley/toybox.git
24 #  git fetch toybox
25 #  git merge toybox/master
26 #  mm -j32
27 #  # (Make any necessary Android.mk changes and test the new toybox.)
28 #  repo upload .
29 #  git push aosp HEAD:refs/for/master  # Push to gerrit for review.
30 #  git push aosp HEAD:master  # Push directly, avoiding gerrit.
31 #
32 #  # Now commit any necessary Android.mk changes like normal:
33 #  repo start post-sync .
34 #  git commit -a
35
36
37 #
38 # To add a toy:
39 #
40
41 #  Edit .config to enable the toy you want to add.
42 #  make clean && make  # Regenerate the generated files.
43 #  # Edit LOCAL_SRC_FILES below to add the toy.
44 #  # If you just want to use it as "toybox x" rather than "x", you can stop now.
45 #  # If you want this toy to have a symbolic link in /system/bin, add the toy to ALL_TOOLS.
46
47 common_SRC_FILES := \
48     lib/args.c \
49     lib/dirtree.c \
50     lib/getmountlist.c \
51     lib/help.c \
52     lib/interestingtimes.c \
53     lib/lib.c \
54     lib/linestack.c \
55     lib/llist.c \
56     lib/net.c \
57     lib/portability.c \
58     lib/xwrap.c \
59     main.c \
60     toys/android/getenforce.c \
61     toys/android/getprop.c \
62     toys/android/load_policy.c \
63     toys/android/log.c \
64     toys/android/restorecon.c \
65     toys/android/runcon.c \
66     toys/android/sendevent.c \
67     toys/android/setenforce.c \
68     toys/android/setprop.c \
69     toys/android/start.c \
70     toys/lsb/dmesg.c \
71     toys/lsb/hostname.c \
72     toys/lsb/killall.c \
73     toys/lsb/md5sum.c \
74     toys/lsb/mknod.c \
75     toys/lsb/mktemp.c \
76     toys/lsb/mount.c \
77     toys/lsb/pidof.c \
78     toys/lsb/seq.c \
79     toys/lsb/sync.c \
80     toys/lsb/umount.c \
81     toys/net/ifconfig.c \
82     toys/net/microcom.c \
83     toys/net/netcat.c \
84     toys/net/netstat.c \
85     toys/net/rfkill.c \
86     toys/net/tunctl.c \
87     toys/other/acpi.c \
88     toys/other/base64.c \
89     toys/other/blkid.c \
90     toys/other/blockdev.c \
91     toys/other/chcon.c \
92     toys/other/chroot.c \
93     toys/other/chrt.c \
94     toys/other/clear.c \
95     toys/other/dos2unix.c \
96     toys/other/fallocate.c \
97     toys/other/flock.c \
98     toys/other/free.c \
99     toys/other/freeramdisk.c \
100     toys/other/fsfreeze.c \
101     toys/other/help.c \
102     toys/other/hwclock.c \
103     toys/other/inotifyd.c \
104     toys/other/insmod.c \
105     toys/other/ionice.c \
106     toys/other/losetup.c \
107     toys/other/lsattr.c \
108     toys/other/lsmod.c \
109     toys/other/lspci.c \
110     toys/other/lsusb.c \
111     toys/other/makedevs.c \
112     toys/other/mkswap.c \
113     toys/other/modinfo.c \
114     toys/other/mountpoint.c \
115     toys/other/nbd_client.c \
116     toys/other/partprobe.c \
117     toys/other/pivot_root.c \
118     toys/other/pmap.c \
119     toys/other/printenv.c \
120     toys/other/pwdx.c \
121     toys/other/readlink.c \
122     toys/other/realpath.c \
123     toys/other/rev.c \
124     toys/other/rmmod.c \
125     toys/other/setsid.c \
126     toys/other/stat.c \
127     toys/other/swapoff.c \
128     toys/other/swapon.c \
129     toys/other/sysctl.c \
130     toys/other/tac.c \
131     toys/other/taskset.c \
132     toys/other/timeout.c \
133     toys/other/truncate.c \
134     toys/other/uptime.c \
135     toys/other/usleep.c \
136     toys/other/vconfig.c \
137     toys/other/vmstat.c \
138     toys/other/which.c \
139     toys/other/xxd.c \
140     toys/other/yes.c \
141     toys/pending/dd.c \
142     toys/pending/diff.c \
143     toys/pending/expr.c \
144     toys/pending/getfattr.c \
145     toys/pending/gzip.c \
146     toys/pending/lsof.c \
147     toys/pending/modprobe.c \
148     toys/pending/more.c \
149     toys/pending/setfattr.c \
150     toys/pending/tar.c \
151     toys/pending/tr.c \
152     toys/pending/traceroute.c \
153     toys/posix/basename.c \
154     toys/posix/cal.c \
155     toys/posix/cat.c \
156     toys/posix/chgrp.c \
157     toys/posix/chmod.c \
158     toys/posix/cksum.c \
159     toys/posix/cmp.c \
160     toys/posix/comm.c \
161     toys/posix/cp.c \
162     toys/posix/cpio.c \
163     toys/posix/cut.c \
164     toys/posix/date.c \
165     toys/posix/df.c \
166     toys/posix/dirname.c \
167     toys/posix/du.c \
168     toys/posix/echo.c \
169     toys/posix/env.c \
170     toys/posix/expand.c \
171     toys/posix/false.c \
172     toys/posix/file.c \
173     toys/posix/find.c \
174     toys/posix/grep.c \
175     toys/posix/head.c \
176     toys/posix/id.c \
177     toys/posix/kill.c \
178     toys/posix/ln.c \
179     toys/posix/ls.c \
180     toys/posix/mkdir.c \
181     toys/posix/mkfifo.c \
182     toys/posix/nice.c \
183     toys/posix/nl.c \
184     toys/posix/nohup.c \
185     toys/posix/od.c \
186     toys/posix/paste.c \
187     toys/posix/patch.c \
188     toys/posix/printf.c \
189     toys/posix/ps.c \
190     toys/posix/pwd.c \
191     toys/posix/renice.c \
192     toys/posix/rm.c \
193     toys/posix/rmdir.c \
194     toys/posix/sed.c \
195     toys/posix/sleep.c \
196     toys/posix/sort.c \
197     toys/posix/split.c \
198     toys/posix/strings.c \
199     toys/posix/tail.c \
200     toys/posix/tee.c \
201     toys/posix/time.c \
202     toys/posix/touch.c \
203     toys/posix/true.c \
204     toys/posix/tty.c \
205     toys/posix/ulimit.c \
206     toys/posix/uname.c \
207     toys/posix/uniq.c \
208     toys/posix/uudecode.c \
209     toys/posix/uuencode.c \
210     toys/posix/wc.c \
211     toys/posix/xargs.c \
212
213 common_CFLAGS := \
214     -std=c99 \
215     -Os \
216     -Wno-char-subscripts \
217     -Wno-gnu-variable-sized-type-not-at-end \
218     -Wno-missing-field-initializers \
219     -Wno-sign-compare \
220     -Wno-string-plus-int \
221     -Wno-uninitialized \
222     -Wno-unused-parameter \
223     -funsigned-char \
224     -ffunction-sections -fdata-sections \
225     -fno-asynchronous-unwind-tables \
226
227 toybox_upstream_version := $(shell sed 's/#define.*TOYBOX_VERSION.*"\(.*\)"/\1/p;d' $(LOCAL_PATH)/main.c)
228
229 toybox_version := $(toybox_upstream_version)-android
230
231 toybox_libraries := liblog libselinux libcutils libcrypto libz
232
233 common_CFLAGS += -DTOYBOX_VERSION=\"$(toybox_version)\"
234
235 # not usable on Android?: freeramdisk fsfreeze install makedevs nbd-client
236 #                         partprobe pivot_root pwdx rev rfkill vconfig
237 # currently prefer BSD system/core/toolbox: dd
238 # currently prefer BSD external/netcat: nc netcat
239 # currently prefer external/efs2progs: blkid chattr lsattr
240
241 ALL_TOOLS := \
242     acpi \
243     base64 \
244     basename \
245     blockdev \
246     cal \
247     cat \
248     chcon \
249     chgrp \
250     chmod \
251     chown \
252     chroot \
253     chrt \
254     cksum \
255     clear \
256     comm \
257     cmp \
258     cp \
259     cpio \
260     cut \
261     date \
262     df \
263     diff \
264     dirname \
265     dmesg \
266     dos2unix \
267     du \
268     echo \
269     env \
270     expand \
271     expr \
272     fallocate \
273     false \
274     file \
275     find \
276     flock \
277     free \
278     getenforce \
279     getprop \
280     groups \
281     gunzip \
282     gzip \
283     head \
284     hostname \
285     hwclock \
286     id \
287     ifconfig \
288     inotifyd \
289     insmod \
290     ionice \
291     iorenice \
292     kill \
293     killall \
294     load_policy \
295     ln \
296     log \
297     logname \
298     losetup \
299     ls \
300     lsmod \
301     lsof \
302     lspci \
303     lsusb \
304     md5sum \
305     mkdir \
306     mkfifo \
307     mknod \
308     mkswap \
309     mktemp \
310     microcom \
311     modinfo \
312     modprobe \
313     more \
314     mount \
315     mountpoint \
316     mv \
317     netstat \
318     nice \
319     nl \
320     nohup \
321     od \
322     paste \
323     patch \
324     pgrep \
325     pidof \
326     pkill \
327     pmap \
328     printenv \
329     printf \
330     ps \
331     pwd \
332     readlink \
333     realpath \
334     renice \
335     restorecon \
336     rm \
337     rmdir \
338     rmmod \
339     runcon \
340     sed \
341     sendevent \
342     seq \
343     setenforce \
344     setprop \
345     setsid \
346     sha1sum \
347     sha224sum \
348     sha256sum \
349     sha384sum \
350     sha512sum \
351     sleep \
352     sort \
353     split \
354     start \
355     stat \
356     stop \
357     strings \
358     swapoff \
359     swapon \
360     sync \
361     sysctl \
362     tac \
363     tail \
364     tar \
365     taskset \
366     tee \
367     time \
368     timeout \
369     top \
370     touch \
371     tr \
372     true \
373     truncate \
374     tty \
375     ulimit \
376     umount \
377     uname \
378     uniq \
379     unix2dos \
380     uptime \
381     usleep \
382     uudecode \
383     uuencode \
384     vmstat \
385     wc \
386     which \
387     whoami \
388     xargs \
389     xxd \
390     yes \
391     zcat \
392
393 ############################################
394 # toybox for /system
395 ############################################
396
397 include $(CLEAR_VARS)
398 LOCAL_MODULE := toybox
399 LOCAL_SRC_FILES := $(common_SRC_FILES)
400 LOCAL_CFLAGS := $(common_CFLAGS)
401 LOCAL_SHARED_LIBRARIES := $(toybox_libraries)
402 # This doesn't actually prevent us from dragging in libc++ at runtime
403 # because libnetd_client.so is C++.
404 LOCAL_CXX_STL := none
405 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf toybox $(TARGET_OUT)/bin/$(t);)
406 include $(BUILD_EXECUTABLE)
407
408 ############################################
409 # toybox for /vendor
410 ############################################
411
412 include $(CLEAR_VARS)
413 LOCAL_MODULE := toybox_vendor
414 LOCAL_VENDOR_MODULE := true
415 LOCAL_SRC_FILES := $(common_SRC_FILES)
416 LOCAL_CFLAGS := $(common_CFLAGS)
417 LOCAL_STATIC_LIBRARIES := libcutils libcrypto libz
418 LOCAL_SHARED_LIBRARIES := libselinux_vendor liblog
419 LOCAL_MODULE_TAGS := optional
420 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf ${LOCAL_MODULE} $(TARGET_OUT_VENDOR_EXECUTABLES)/$(t);)
421 include $(BUILD_EXECUTABLE)
422
423 ############################################
424 # static version to be installed in recovery
425 ############################################
426
427 include $(CLEAR_VARS)
428 LOCAL_MODULE := toybox_static
429 LOCAL_SRC_FILES := $(common_SRC_FILES)
430 LOCAL_CFLAGS := $(common_CFLAGS)
431 LOCAL_STATIC_LIBRARIES := $(toybox_libraries)
432 # libc++_static is needed by static liblog
433 LOCAL_CXX_STL := libc++_static
434 LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
435 LOCAL_FORCE_STATIC_EXECUTABLE := true
436 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf ${LOCAL_MODULE} $(LOCAL_MODULE_PATH)/$(t);)
437 include $(BUILD_EXECUTABLE)