OSDN Git Service

Merge remote-tracking branch 'toybox/master' into HEAD am: 3233e2f9c1 am: 5aa96f14c1...
[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/chrt.c \
93     toys/other/clear.c \
94     toys/other/dos2unix.c \
95     toys/other/fallocate.c \
96     toys/other/flock.c \
97     toys/other/free.c \
98     toys/other/freeramdisk.c \
99     toys/other/fsfreeze.c \
100     toys/other/help.c \
101     toys/other/hwclock.c \
102     toys/other/inotifyd.c \
103     toys/other/insmod.c \
104     toys/other/ionice.c \
105     toys/other/losetup.c \
106     toys/other/lsattr.c \
107     toys/other/lsmod.c \
108     toys/other/lsusb.c \
109     toys/other/makedevs.c \
110     toys/other/mkswap.c \
111     toys/other/modinfo.c \
112     toys/other/mountpoint.c \
113     toys/other/nbd_client.c \
114     toys/other/partprobe.c \
115     toys/other/pivot_root.c \
116     toys/other/pmap.c \
117     toys/other/printenv.c \
118     toys/other/pwdx.c \
119     toys/other/readlink.c \
120     toys/other/realpath.c \
121     toys/other/rev.c \
122     toys/other/rmmod.c \
123     toys/other/setsid.c \
124     toys/other/stat.c \
125     toys/other/swapoff.c \
126     toys/other/swapon.c \
127     toys/other/sysctl.c \
128     toys/other/tac.c \
129     toys/other/taskset.c \
130     toys/other/timeout.c \
131     toys/other/truncate.c \
132     toys/other/uptime.c \
133     toys/other/usleep.c \
134     toys/other/vconfig.c \
135     toys/other/vmstat.c \
136     toys/other/which.c \
137     toys/other/xxd.c \
138     toys/other/yes.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-gnu-variable-sized-type-not-at-end \
217     -Wno-missing-field-initializers \
218     -Wno-sign-compare \
219     -Wno-string-plus-int \
220     -Wno-uninitialized \
221     -Wno-unused-parameter \
222     -funsigned-char \
223     -ffunction-sections -fdata-sections \
224     -fno-asynchronous-unwind-tables \
225
226 toybox_upstream_version := $(shell sed 's/#define.*TOYBOX_VERSION.*"\(.*\)"/\1/p;d' $(LOCAL_PATH)/main.c)
227
228 toybox_version := $(toybox_upstream_version)-android-$(BUILD_NUMBER_FROM_FILE)
229
230 toybox_libraries := liblog libselinux libcutils libcrypto libz
231
232 common_CFLAGS += -DTOYBOX_VERSION=\"$(toybox_version)\"
233
234 # not usable on Android?: freeramdisk fsfreeze install makedevs nbd-client
235 #                         partprobe pivot_root pwdx rev rfkill vconfig
236 # currently prefer BSD system/core/toolbox: dd
237 # currently prefer BSD external/netcat: nc netcat
238 # currently prefer external/efs2progs: blkid chattr lsattr
239
240 ALL_TOOLS := \
241     acpi \
242     base64 \
243     basename \
244     blockdev \
245     cal \
246     cat \
247     chcon \
248     chgrp \
249     chmod \
250     chown \
251     chroot \
252     chrt \
253     cksum \
254     clear \
255     comm \
256     cmp \
257     cp \
258     cpio \
259     cut \
260     date \
261     df \
262     diff \
263     dirname \
264     dmesg \
265     dos2unix \
266     du \
267     echo \
268     env \
269     expand \
270     expr \
271     fallocate \
272     false \
273     file \
274     find \
275     flock \
276     free \
277     getenforce \
278     getprop \
279     groups \
280     gunzip \
281     gzip \
282     head \
283     hostname \
284     hwclock \
285     id \
286     ifconfig \
287     inotifyd \
288     insmod \
289     ionice \
290     iorenice \
291     kill \
292     killall \
293     load_policy \
294     ln \
295     log \
296     logname \
297     losetup \
298     ls \
299     lsmod \
300     lsof \
301     lsusb \
302     md5sum \
303     mkdir \
304     mkfifo \
305     mknod \
306     mkswap \
307     mktemp \
308     microcom \
309     modinfo \
310     modprobe \
311     more \
312     mount \
313     mountpoint \
314     mv \
315     netstat \
316     nice \
317     nl \
318     nohup \
319     od \
320     paste \
321     patch \
322     pgrep \
323     pidof \
324     pkill \
325     pmap \
326     printenv \
327     printf \
328     ps \
329     pwd \
330     readlink \
331     realpath \
332     renice \
333     restorecon \
334     rm \
335     rmdir \
336     rmmod \
337     runcon \
338     sed \
339     sendevent \
340     seq \
341     setenforce \
342     setprop \
343     setsid \
344     sha1sum \
345     sha224sum \
346     sha256sum \
347     sha384sum \
348     sha512sum \
349     sleep \
350     sort \
351     split \
352     start \
353     stat \
354     stop \
355     strings \
356     swapoff \
357     swapon \
358     sync \
359     sysctl \
360     tac \
361     tail \
362     tar \
363     taskset \
364     tee \
365     time \
366     timeout \
367     top \
368     touch \
369     tr \
370     true \
371     truncate \
372     tty \
373     ulimit \
374     umount \
375     uname \
376     uniq \
377     unix2dos \
378     uptime \
379     usleep \
380     uudecode \
381     uuencode \
382     vmstat \
383     wc \
384     which \
385     whoami \
386     xargs \
387     xxd \
388     yes \
389     zcat \
390
391 ############################################
392 # toybox for /system
393 ############################################
394
395 include $(CLEAR_VARS)
396 LOCAL_MODULE := toybox
397 LOCAL_SRC_FILES := $(common_SRC_FILES)
398 LOCAL_CFLAGS := $(common_CFLAGS)
399 LOCAL_SHARED_LIBRARIES := $(toybox_libraries)
400 # This doesn't actually prevent us from dragging in libc++ at runtime
401 # because libnetd_client.so is C++.
402 LOCAL_CXX_STL := none
403 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf toybox $(TARGET_OUT)/bin/$(t);)
404 include $(BUILD_EXECUTABLE)
405
406 ############################################
407 # static version to be installed in /vendor
408 ############################################
409
410 ifeq ($(PRODUCT_FULL_TREBLE),true)
411 include $(CLEAR_VARS)
412 LOCAL_MODULE := toybox_vendor
413 LOCAL_VENDOR_MODULE := true
414 LOCAL_SRC_FILES := $(common_SRC_FILES)
415 LOCAL_CFLAGS := $(common_CFLAGS)
416 LOCAL_STATIC_LIBRARIES := $(toybox_libraries)
417 # libc++_static is needed by static liblog
418 LOCAL_CXX_STL := libc++_static
419 LOCAL_MODULE_TAGS := optional
420 LOCAL_FORCE_STATIC_EXECUTABLE := true
421 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf ${LOCAL_MODULE} $(TARGET_OUT_VENDOR_EXECUTABLES)/$(t);)
422 include $(BUILD_EXECUTABLE)
423 endif
424
425 ############################################
426 # static version to be installed in recovery
427 ############################################
428
429 include $(CLEAR_VARS)
430 LOCAL_MODULE := toybox_static
431 LOCAL_SRC_FILES := $(common_SRC_FILES)
432 LOCAL_CFLAGS := $(common_CFLAGS)
433 LOCAL_STATIC_LIBRARIES := $(toybox_libraries)
434 # libc++_static is needed by static liblog
435 LOCAL_CXX_STL := libc++_static
436 LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
437 LOCAL_FORCE_STATIC_EXECUTABLE := true
438 LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf ${LOCAL_MODULE} $(LOCAL_MODULE_PATH)/$(t);)
439 include $(BUILD_EXECUTABLE)