OSDN Git Service

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