OSDN Git Service

Fix cflags pollution from other projects
[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 common_cflags := \
20     -std=c99 \
21     -Os \
22     -Wno-char-subscripts \
23     -Wno-sign-compare \
24     -Wno-string-plus-int \
25     -Wno-uninitialized \
26     -Wno-unused-parameter \
27     -funsigned-char \
28     -ffunction-sections -fdata-sections \
29     -fno-asynchronous-unwind-tables \
30
31 toybox_upstream_version := $(shell awk 'match($$0, /TOYBOX_VERSION.*"(.*)"/, ary) {print ary[1]}' $(LOCAL_PATH)/main.c)
32 toybox_sha := $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)
33
34 toybox_version := $(toybox_upstream_version)-$(toybox_sha)-android
35 common_cflags += -DTOYBOX_VERSION='"$(toybox_version)"'
36
37 #
38 # To update:
39 #
40
41 #  git remote add toybox https://github.com/landley/toybox.git
42 #  git fetch toybox
43 #  git merge toybox/master
44 #  mm -j32
45 #  # (Make any necessary Android.mk changes and test the new toybox.)
46 #  repo upload .
47 #  git push aosp HEAD:refs/for/master  # Push to gerrit for review.
48 #  git push aosp HEAD:master  # Push directly, avoiding gerrit.
49 #
50 #  # Now commit any necessary Android.mk changes like normal:
51 #  repo start post-sync .
52 #  git commit -a
53
54
55 #
56 # To add a toy:
57 #
58
59 #  make menuconfig
60 #  # (Select the toy you want to add.)
61 #  make clean && make  # Regenerate the generated files.
62 #  # Edit LOCAL_SRC_FILES below to add the toy.
63 #  # If you just want to use it as "toybox x" rather than "x", you can stop now.
64 #  # If you want this toy to have a symbolic link in /system/bin, add the toy to ALL_TOOLS.
65
66 include $(CLEAR_VARS)
67
68 LOCAL_SRC_FILES := \
69     lib/args.c \
70     lib/dirtree.c \
71     lib/getmountlist.c \
72     lib/help.c \
73     lib/interestingtimes.c \
74     lib/lib.c \
75     lib/linestack.c \
76     lib/llist.c \
77     lib/net.c \
78     lib/password.c \
79     lib/portability.c \
80     lib/xwrap.c \
81     main.c \
82     toys/android/getenforce.c \
83     toys/android/getprop.c \
84     toys/android/load_policy.c \
85     toys/android/restorecon.c \
86     toys/android/runcon.c \
87     toys/android/setenforce.c \
88     toys/android/setprop.c \
89     toys/lsb/dmesg.c \
90     toys/lsb/hostname.c \
91     toys/lsb/killall.c \
92     toys/lsb/md5sum.c \
93     toys/lsb/mknod.c \
94     toys/lsb/mktemp.c \
95     toys/lsb/mount.c \
96     toys/lsb/pidof.c \
97     toys/lsb/seq.c \
98     toys/lsb/sync.c \
99     toys/lsb/umount.c \
100     toys/other/acpi.c \
101     toys/other/base64.c \
102     toys/other/blkid.c \
103     toys/other/blockdev.c \
104     toys/other/bzcat.c \
105     toys/other/chcon.c \
106     toys/other/chroot.c \
107     toys/other/clear.c \
108     toys/other/dos2unix.c \
109     toys/other/fallocate.c \
110     toys/other/flock.c \
111     toys/other/free.c \
112     toys/other/freeramdisk.c \
113     toys/other/fsfreeze.c \
114     toys/other/help.c \
115     toys/other/hwclock.c \
116     toys/other/ifconfig.c \
117     toys/other/inotifyd.c \
118     toys/other/insmod.c \
119     toys/other/ionice.c \
120     toys/other/losetup.c \
121     toys/other/lsattr.c \
122     toys/other/lsmod.c \
123     toys/other/lspci.c \
124     toys/other/lsusb.c \
125     toys/other/makedevs.c \
126     toys/other/mkswap.c \
127     toys/other/modinfo.c \
128     toys/other/mountpoint.c \
129     toys/other/nbd_client.c \
130     toys/other/netcat.c \
131     toys/other/partprobe.c \
132     toys/other/pivot_root.c \
133     toys/other/pmap.c \
134     toys/other/printenv.c \
135     toys/other/pwdx.c \
136     toys/other/readahead.c \
137     toys/other/readlink.c \
138     toys/other/realpath.c \
139     toys/other/reset.c \
140     toys/other/rev.c \
141     toys/other/rfkill.c \
142     toys/other/rmmod.c \
143     toys/other/setsid.c \
144     toys/other/stat.c \
145     toys/other/swapoff.c \
146     toys/other/swapon.c \
147     toys/other/switch_root.c \
148     toys/other/sysctl.c \
149     toys/other/tac.c \
150     toys/other/taskset.c \
151     toys/other/timeout.c \
152     toys/other/truncate.c \
153     toys/other/uptime.c \
154     toys/other/usleep.c \
155     toys/other/vconfig.c \
156     toys/other/vmstat.c \
157     toys/other/which.c \
158     toys/other/xxd.c \
159     toys/other/yes.c \
160     toys/pending/arp.c \
161     toys/pending/dd.c \
162     toys/pending/diff.c \
163     toys/pending/expr.c \
164     toys/pending/fdisk.c \
165     toys/pending/file.c \
166     toys/pending/ftpget.c \
167     toys/pending/host.c \
168     toys/pending/lsof.c \
169     toys/pending/more.c \
170     toys/pending/netstat.c \
171     toys/pending/resize.c \
172     toys/pending/route.c \
173     toys/pending/tar.c \
174     toys/pending/telnet.c \
175     toys/pending/test.c \
176     toys/pending/tr.c \
177     toys/pending/traceroute.c \
178     toys/pending/watch.c \
179     toys/pending/xzcat.c \
180     toys/posix/basename.c \
181     toys/posix/cal.c \
182     toys/posix/cat.c \
183     toys/posix/chgrp.c \
184     toys/posix/chmod.c \
185     toys/posix/cksum.c \
186     toys/posix/cmp.c \
187     toys/posix/comm.c \
188     toys/posix/cp.c \
189     toys/posix/cpio.c \
190     toys/posix/cut.c \
191     toys/posix/date.c \
192     toys/posix/df.c \
193     toys/posix/dirname.c \
194     toys/posix/du.c \
195     toys/posix/echo.c \
196     toys/posix/env.c \
197     toys/posix/expand.c \
198     toys/posix/false.c \
199     toys/posix/find.c \
200     toys/posix/grep.c \
201     toys/posix/head.c \
202     toys/posix/id.c \
203     toys/posix/kill.c \
204     toys/posix/ln.c \
205     toys/posix/ls.c \
206     toys/posix/mkdir.c \
207     toys/posix/mkfifo.c \
208     toys/posix/nice.c \
209     toys/posix/nl.c \
210     toys/posix/nohup.c \
211     toys/posix/od.c \
212     toys/posix/paste.c \
213     toys/posix/patch.c \
214     toys/posix/printf.c \
215     toys/posix/ps.c \
216     toys/posix/pwd.c \
217     toys/posix/renice.c \
218     toys/posix/rm.c \
219     toys/posix/rmdir.c \
220     toys/posix/sed.c \
221     toys/posix/sleep.c \
222     toys/posix/sort.c \
223     toys/posix/split.c \
224     toys/posix/strings.c \
225     toys/posix/tail.c \
226     toys/posix/tee.c \
227     toys/posix/time.c \
228     toys/posix/touch.c \
229     toys/posix/true.c \
230     toys/posix/tty.c \
231     toys/posix/ulimit.c \
232     toys/posix/uname.c \
233     toys/posix/uniq.c \
234     toys/posix/wc.c \
235     toys/posix/xargs.c
236
237 LOCAL_CFLAGS := $(common_cflags)
238 LOCAL_CLANG := true
239
240 # This doesn't actually prevent us from dragging in libc++ at runtime
241 # because libnetd_client.so is C++.
242 LOCAL_CXX_STL := none
243
244 LOCAL_C_INCLUDES += bionic/libc/dns/include
245
246 LOCAL_MODULE := libtoybox
247
248 include $(BUILD_STATIC_LIBRARY)
249
250
251 # Host binary to enumerate the toys
252 include $(CLEAR_VARS)
253 LOCAL_SRC_FILES := scripts/install.c
254 LOCAL_MODULE_TAGS := optional
255 LOCAL_CFLAGS := $(common_cflags)
256 LOCAL_CLANG := true
257 LOCAL_MODULE := toybox-instlist
258 include $(BUILD_HOST_EXECUTABLE)
259
260
261 include $(CLEAR_VARS)
262 LOCAL_SRC_FILES := main.c
263 LOCAL_STATIC_LIBRARIES := libtoybox
264 LOCAL_SHARED_LIBRARIES := libcutils libselinux
265 LOCAL_CFLAGS := $(common_cflags)
266 LOCAL_CXX_STL := none
267 LOCAL_CLANG := true
268 LOCAL_MODULE := toybox
269
270 # for dumping the list of toys
271 TOYBOX_INSTLIST := $(HOST_OUT_EXECUTABLES)/toybox-instlist
272 LOCAL_ADDITIONAL_DEPENDENCIES := toybox_links
273
274 # we still want a link for ls/ps, but the toolbox version needs to
275 # stick around for compatibility reasons, for now.
276 TOYS_FOR_XBIN := ls ps
277
278 # skip links for these toys in the system image, they already have
279 # a full-blown counterpart. we still want them for the recovery
280 # image though.
281 TOYS_WITHOUT_LINKS := blkid
282
283 include $(BUILD_EXECUTABLE)
284
285 toybox_links: $(TOYBOX_INSTLIST) toybox
286 toybox_links: TOY_LIST=$(shell $(TOYBOX_INSTLIST))
287 toybox_links: TOYBOX_BINARY := $(TARGET_OUT)/bin/toybox
288 toybox_links:
289         @echo -e ${CL_CYN}"Generate Toybox links:"${CL_RST} $(TOY_LIST)
290         @mkdir -p $(TARGET_OUT)/bin
291         @mkdir -p $(TARGET_OUT)/xbin
292         $(hide) $(foreach t,$(filter-out $(TOYS_FOR_XBIN) $(TOYS_WITHOUT_LINKS),$(TOY_LIST)),ln -sf toybox $(TARGET_OUT_EXECUTABLES)/$(t);)
293         $(hide) $(foreach t,$(TOYS_FOR_XBIN),ln -sf /system/bin/toybox $(TARGET_OUT_OPTIONAL_EXECUTABLES)/$(t);)
294
295
296 # This is used by the recovery system
297 include $(CLEAR_VARS)
298 LOCAL_SRC_FILES := main.c
299 LOCAL_WHOLE_STATIC_LIBRARIES := libtoybox
300 LOCAL_CFLAGS := $(common_cflags)
301 LOCAL_CFLAGS += -Dmain=toybox_driver
302 LOCAL_CXX_STL := none
303 LOCAL_CLANG := true
304 LOCAL_MODULE := libtoybox_driver
305 include $(BUILD_STATIC_LIBRARY)
306
307 # static executable for use in limited environments
308 include $(CLEAR_VARS)
309 LOCAL_SRC_FILES := main.c
310 LOCAL_CFLAGS := $(common_cflags)
311 LOCAL_CXX_STL := none
312 LOCAL_CLANG := true
313 LOCAL_UNSTRIPPED_PATH := $(PRODUCT_OUT)/symbols/utilities
314 LOCAL_MODULE := toybox_static
315 LOCAL_MODULE_CLASS := UTILITY_EXECUTABLES
316 LOCAL_MODULE_PATH := $(PRODUCT_OUT)/utilities
317 LOCAL_MODULE_TAGS := optional
318 LOCAL_MODULE_STEM := toybox
319 LOCAL_STATIC_LIBRARIES := libc libtoybox libcutils libselinux libmincrypt
320 LOCAL_FORCE_STATIC_EXECUTABLE := true
321 include $(BUILD_EXECUTABLE)