OSDN Git Service

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