OSDN Git Service

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