OSDN Git Service

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