OSDN Git Service

Switch to toybox gzip/gunzip/zcat. am: 429b7a378b
[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/hostname.c \
71     toys/lsb/killall.c \
72     toys/lsb/md5sum.c \
73     toys/lsb/mknod.c \
74     toys/lsb/mktemp.c \
75     toys/lsb/mount.c \
76     toys/lsb/pidof.c \
77     toys/lsb/seq.c \
78     toys/lsb/sync.c \
79     toys/lsb/umount.c \
80     toys/net/ifconfig.c \
81     toys/net/microcom.c \
82     toys/net/netcat.c \
83     toys/net/netstat.c \
84     toys/net/rfkill.c \
85     toys/net/tunctl.c \
86     toys/other/acpi.c \
87     toys/other/base64.c \
88     toys/other/blkid.c \
89     toys/other/blockdev.c \
90     toys/other/chcon.c \
91     toys/other/chroot.c \
92     toys/other/clear.c \
93     toys/other/dos2unix.c \
94     toys/other/fallocate.c \
95     toys/other/flock.c \
96     toys/other/free.c \
97     toys/other/freeramdisk.c \
98     toys/other/fsfreeze.c \
99     toys/other/help.c \
100     toys/other/hwclock.c \
101     toys/other/inotifyd.c \
102     toys/other/insmod.c \
103     toys/other/ionice.c \
104     toys/other/losetup.c \
105     toys/other/lsattr.c \
106     toys/other/lsmod.c \
107     toys/other/lsusb.c \
108     toys/other/makedevs.c \
109     toys/other/mkswap.c \
110     toys/other/modinfo.c \
111     toys/other/mountpoint.c \
112     toys/other/nbd_client.c \
113     toys/other/partprobe.c \
114     toys/other/pivot_root.c \
115     toys/other/pmap.c \
116     toys/other/printenv.c \
117     toys/other/pwdx.c \
118     toys/other/readlink.c \
119     toys/other/realpath.c \
120     toys/other/rev.c \
121     toys/other/rmmod.c \
122     toys/other/setsid.c \
123     toys/other/stat.c \
124     toys/other/swapoff.c \
125     toys/other/swapon.c \
126     toys/other/sysctl.c \
127     toys/other/tac.c \
128     toys/other/taskset.c \
129     toys/other/timeout.c \
130     toys/other/truncate.c \
131     toys/other/uptime.c \
132     toys/other/usleep.c \
133     toys/other/vconfig.c \
134     toys/other/vmstat.c \
135     toys/other/which.c \
136     toys/other/xxd.c \
137     toys/other/yes.c \
138     toys/pending/chrt.c \
139     toys/pending/dd.c \
140     toys/pending/diff.c \
141     toys/pending/dmesg.c \
142     toys/pending/expr.c \
143     toys/pending/getfattr.c \
144     toys/pending/gzip.c \
145     toys/pending/lsof.c \
146     toys/pending/modprobe.c \
147     toys/pending/more.c \
148     toys/pending/setfattr.c \
149     toys/pending/tar.c \
150     toys/pending/tr.c \
151     toys/pending/traceroute.c \
152     toys/posix/basename.c \
153     toys/posix/cal.c \
154     toys/posix/cat.c \
155     toys/posix/chgrp.c \
156     toys/posix/chmod.c \
157     toys/posix/cksum.c \
158     toys/posix/cmp.c \
159     toys/posix/comm.c \
160     toys/posix/cp.c \
161     toys/posix/cpio.c \
162     toys/posix/cut.c \
163     toys/posix/date.c \
164     toys/posix/df.c \
165     toys/posix/dirname.c \
166     toys/posix/du.c \
167     toys/posix/echo.c \
168     toys/posix/env.c \
169     toys/posix/expand.c \
170     toys/posix/false.c \
171     toys/posix/file.c \
172     toys/posix/find.c \
173     toys/posix/grep.c \
174     toys/posix/head.c \
175     toys/posix/id.c \
176     toys/posix/kill.c \
177     toys/posix/ln.c \
178     toys/posix/ls.c \
179     toys/posix/mkdir.c \
180     toys/posix/mkfifo.c \
181     toys/posix/nice.c \
182     toys/posix/nl.c \
183     toys/posix/nohup.c \
184     toys/posix/od.c \
185     toys/posix/paste.c \
186     toys/posix/patch.c \
187     toys/posix/printf.c \
188     toys/posix/ps.c \
189     toys/posix/pwd.c \
190     toys/posix/renice.c \
191     toys/posix/rm.c \
192     toys/posix/rmdir.c \
193     toys/posix/sed.c \
194     toys/posix/sleep.c \
195     toys/posix/sort.c \
196     toys/posix/split.c \
197     toys/posix/strings.c \
198     toys/posix/tail.c \
199     toys/posix/tee.c \
200     toys/posix/time.c \
201     toys/posix/touch.c \
202     toys/posix/true.c \
203     toys/posix/tty.c \
204     toys/posix/ulimit.c \
205     toys/posix/uname.c \
206     toys/posix/uniq.c \
207     toys/posix/uudecode.c \
208     toys/posix/uuencode.c \
209     toys/posix/wc.c \
210     toys/posix/xargs.c \
211
212 common_CFLAGS := \
213     -std=c99 \
214     -Os \
215     -Wno-char-subscripts \
216     -Wno-sign-compare \
217     -Wno-string-plus-int \
218     -Wno-uninitialized \
219     -Wno-unused-parameter \
220     -funsigned-char \
221     -ffunction-sections -fdata-sections \
222     -fno-asynchronous-unwind-tables \
223
224 toybox_upstream_version := $(shell awk 'match($$0, /TOYBOX_VERSION.*"(.*)"/, ary) {print ary[1]}' $(LOCAL_PATH)/main.c)
225 toybox_sha := $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)
226
227 toybox_version := $(toybox_upstream_version)-$(toybox_sha)-android
228
229 toybox_libraries := liblog libselinux libcutils libcrypto libz
230
231 common_CFLAGS += -DTOYBOX_VERSION='"$(toybox_version)"'
232
233 # not usable on Android?: freeramdisk fsfreeze install makedevs nbd-client
234 #                         partprobe pivot_root pwdx rev rfkill vconfig
235 # currently prefer BSD system/core/toolbox: dd
236 # currently prefer BSD external/netcat: nc netcat
237 # currently prefer external/efs2progs: blkid chattr lsattr
238
239 ALL_TOOLS := \
240     acpi \
241     base64 \
242     basename \
243     blockdev \
244     cal \
245     cat \
246     chcon \
247     chgrp \
248     chmod \
249     chown \
250     chroot \
251     chrt \
252     cksum \
253     clear \
254     comm \
255     cmp \
256     cp \
257     cpio \
258     cut \
259     date \
260     df \
261     diff \
262     dirname \
263     dmesg \
264     dos2unix \
265     du \
266     echo \
267     env \
268     expand \
269     expr \
270     fallocate \
271     false \
272     file \
273     find \
274     flock \
275     free \
276     getenforce \
277     getprop \
278     groups \
279     gunzip \
280     gzip \
281     head \
282     hostname \
283     hwclock \
284     id \
285     ifconfig \
286     inotifyd \
287     insmod \
288     ionice \
289     iorenice \
290     kill \
291     killall \
292     load_policy \
293     ln \
294     log \
295     logname \
296     losetup \
297     ls \
298     lsmod \
299     lsof \
300     lsusb \
301     md5sum \
302     mkdir \
303     mkfifo \
304     mknod \
305     mkswap \
306     mktemp \
307     microcom \
308     modinfo \
309     modprobe \
310     more \
311     mount \
312     mountpoint \
313     mv \
314     netstat \
315     nice \
316     nl \
317     nohup \
318     od \
319     paste \
320     patch \
321     pgrep \
322     pidof \
323     pkill \
324     pmap \
325     printenv \
326     printf \
327     ps \
328     pwd \
329     readlink \
330     realpath \
331     renice \
332     restorecon \
333     rm \
334     rmdir \
335     rmmod \
336     runcon \
337     sed \
338     sendevent \
339     seq \
340     setenforce \
341     setprop \
342     setsid \
343     sha1sum \
344     sha224sum \
345     sha256sum \
346     sha384sum \
347     sha512sum \
348     sleep \
349     sort \
350     split \
351     start \
352     stat \
353     stop \
354     strings \
355     swapoff \
356     swapon \
357     sync \
358     sysctl \
359     tac \
360     tail \
361     tar \
362     taskset \
363     tee \
364     time \
365     timeout \
366     top \
367     touch \
368     tr \
369     true \
370     truncate \
371     tty \
372     ulimit \
373     umount \
374     uname \
375     uniq \
376     unix2dos \
377     uptime \
378     usleep \
379     uudecode \
380     uuencode \
381     vmstat \
382     wc \
383     which \
384     whoami \
385     xargs \
386     xxd \
387     yes \
388     zcat \
389
390 ############################################
391 # toybox for /system
392 ############################################
393
394 include $(CLEAR_VARS)
395 LOCAL_MODULE := toybox
396 LOCAL_SRC_FILES := $(common_SRC_FILES)
397 LOCAL_CFLAGS := $(common_CFLAGS)
398 LOCAL_SHARED_LIBRARIES := $(toybox_libraries)
399 # This doesn't actually prevent us from dragging in libc++ at runtime
400 # because libnetd_client.so is C++.
401 LOCAL_CXX_STL := none
402 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf toybox $(TARGET_OUT)/bin/$(t);)
403 include $(BUILD_EXECUTABLE)
404
405 ############################################
406 # static version to be installed in /vendor
407 ############################################
408
409 ifeq ($(PRODUCT_FULL_TREBLE),true)
410 include $(CLEAR_VARS)
411 LOCAL_MODULE := toybox_vendor
412 LOCAL_VENDOR_MODULE := true
413 LOCAL_SRC_FILES := $(common_SRC_FILES)
414 LOCAL_CFLAGS := $(common_CFLAGS)
415 LOCAL_STATIC_LIBRARIES := $(toybox_libraries)
416 # libc++_static is needed by static liblog
417 LOCAL_CXX_STL := libc++_static
418 LOCAL_MODULE_TAGS := optional
419 LOCAL_FORCE_STATIC_EXECUTABLE := true
420 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf ${LOCAL_MODULE} $(TARGET_OUT_VENDOR_EXECUTABLES)/$(t);)
421 include $(BUILD_EXECUTABLE)
422 endif
423
424 ############################################
425 # static version to be installed in recovery
426 ############################################
427
428 include $(CLEAR_VARS)
429 LOCAL_MODULE := toybox_static
430 LOCAL_SRC_FILES := $(common_SRC_FILES)
431 LOCAL_CFLAGS := $(common_CFLAGS)
432 LOCAL_STATIC_LIBRARIES := $(toybox_libraries)
433 # libc++_static is needed by static liblog
434 LOCAL_CXX_STL := libc++_static
435 LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
436 LOCAL_FORCE_STATIC_EXECUTABLE := true
437 # TODO: is there any reason to only have modprobe in recovery?
438 RECOVERY_TOOLS := modprobe
439 # Install the symlinks.
440 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(RECOVERY_TOOLS),ln -sf ${LOCAL_MODULE} $(LOCAL_MODULE_PATH)/$(t);)
441 include $(BUILD_EXECUTABLE)