1#
2# Copyright (C) 2006 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
17LOCAL_PATH := $(call my-dir)
18
19#
20# To update:
21#
22
23#  git remote add strace git://git.code.sf.net/p/strace/code
24#  git fetch strace
25#  git merge strace/master
26#  mm -j32
27#  # (Make any necessary Android.mk changes and test the new strace.)
28#  git push aosp HEAD:master  # Push directly, avoiding gerrit.
29#  git push aosp HEAD:refs/for/master  # Push to gerrit.
30#
31#  # Now commit any necessary Android.mk changes like normal:
32#  repo start post-sync .
33#  git commit -a
34#
35
36# We don't currently have a good solution for the 'configure' side of things.
37# You can get a list of the HAVE_* variables in use and manually go through it:
38#
39#   find . -name "*.[ch]" | xargs grep HAVE_ | sed 's/.*\(HAVE_[A-Z0-9_]*\).*/\1/p' | sort | uniq -d
40
41# -------------------------------------------------------------------------
42
43include $(CLEAR_VARS)
44
45strace_version := $(shell grep Version $(LOCAL_PATH)/strace.spec | cut -d " " -f 2)
46
47LOCAL_SRC_FILES := \
48    access.c \
49    affinity.c \
50    aio.c \
51    bjm.c \
52    block.c \
53    cacheflush.c \
54    capability.c \
55    chdir.c \
56    chmod.c \
57    clone.c \
58    count.c \
59    desc.c \
60    dirent.c \
61    execve.c \
62    exit.c \
63    fadvise.c \
64    fallocate.c \
65    fanotify.c \
66    fchownat.c \
67    file.c \
68    futex.c \
69    getcpu.c \
70    getcwd.c \
71    getrandom.c \
72    get_robust_list.c \
73    hostname.c \
74    inotify.c \
75    io.c \
76    ioctl.c \
77    ioprio.c \
78    ipc.c \
79    kexec.c \
80    keyctl.c \
81    ldt.c \
82    link.c \
83    loop.c \
84    lseek.c \
85    mem.c \
86    mknod.c \
87    mount.c \
88    mtd.c \
89    net.c \
90    open.c \
91    pathtrace.c \
92    personality.c \
93    prctl.c \
94    printmode.c \
95    printsiginfo.c \
96    process.c \
97    process_vm.c \
98    ptp.c \
99    quota.c \
100    readahead.c \
101    readlink.c \
102    reboot.c \
103    renameat.c \
104    resource.c \
105    sched.c \
106    scsi.c \
107    seccomp.c \
108    sigaltstack.c \
109    signal.c \
110    sigreturn.c \
111    sock.c \
112    socketutils.c \
113    sram_alloc.c \
114    statfs.c \
115    strace.c \
116    stream.c \
117    swapon.c \
118    sync_file_range.c \
119    syscall.c \
120    sysctl.c \
121    sysinfo.c \
122    syslog.c \
123    sysmips.c \
124    term.c \
125    time.c \
126    truncate.c \
127    uid16.c \
128    uid.c \
129    umask.c \
130    umount.c \
131    uname.c \
132    util.c \
133    utime.c \
134    utimes.c \
135    v4l2.c \
136    vsprintf.c \
137    wait.c \
138    xattr.c \
139
140LOCAL_SHARED_LIBRARIES :=
141
142LOCAL_CFLAGS := \
143    -DGETGROUPS_T=gid_t \
144    -DHAVE_ASM_SIGCONTEXT_H=1 \
145    -DHAVE_DECL_PTRACE_EVENT_FORK=1 \
146    -DHAVE_DECL_PTRACE_EVENT_VFORK=1 \
147    -DHAVE_DECL_PTRACE_EVENT_CLONE=1 \
148    -DHAVE_DECL_PTRACE_EVENT_EXEC=1 \
149    -DHAVE_DECL_PTRACE_EVENT_VFORK_DONE=1 \
150    -DHAVE_DECL_PTRACE_EVENT_EXIT=1 \
151    -DHAVE_DECL_PTRACE_GETEVENTMSG=1 \
152    -DHAVE_DECL_PTRACE_GETSIGINFO=1 \
153    -DHAVE_DECL_PTRACE_O_TRACECLONE=1 \
154    -DHAVE_DECL_PTRACE_O_TRACEEXEC=1 \
155    -DHAVE_DECL_PTRACE_O_TRACEEXIT=1 \
156    -DHAVE_DECL_PTRACE_O_TRACEFORK=1 \
157    -DHAVE_DECL_PTRACE_O_TRACESYSGOOD=1 \
158    -DHAVE_DECL_PTRACE_O_TRACEVFORK=1 \
159    -DHAVE_DECL_PTRACE_SETOPTIONS=1 \
160    -UHAVE_DECL_IO_CMD_PWRITE \
161    -UHAVE_DECL_IO_CMD_PWRITEV \
162    -UHAVE_DECL_LO_FLAGS_AUTOCLEAR \
163    -UHAVE_DECL_LO_FLAGS_PARTSCAN \
164    -DHAVE_DECL_SYS_ERRLIST=1 \
165    -DHAVE_ELF_H=1 \
166    -DHAVE_FOPEN64=1 \
167    -DHAVE_FORK=1 \
168    -DHAVE_IF_INDEXTONAME=1 \
169    -DHAVE_INET_NTOP=1 \
170    -DHAVE_LINUX_CAPABILITY_H=1 \
171    -DHAVE_LINUX_FALLOC_H=1 \
172    -DHAVE_LINUX_FILTER_H=1 \
173    -DHAVE_LINUX_FUTEX_H=1 \
174    -DHAVE_LINUX_ICMP_H=1 \
175    -DHAVE_LINUX_IF_PACKET_H=1 \
176    -DHAVE_LINUX_IN6_H=1 \
177    -DHAVE_LINUX_NETLINK_H=1 \
178    -DHAVE_LINUX_PERF_EVENT_H=1 \
179    -DHAVE_LITTLE_ENDIAN_LONG_LONG=1 \
180    -DHAVE_LONG_LONG=1 \
181    -DHAVE_NETINET_TCP_H=1 \
182    -DHAVE_NETINET_UDP_H=1 \
183    -DHAVE_POLL_H=1 \
184    -DHAVE_PRCTL=1 \
185    -DHAVE_PWRITEV=1 \
186    -DHAVE_SENDMSG=1 \
187    -DHAVE_SIGACTION=1 \
188    -DHAVE_SIG_ATOMIC_T=1 \
189    -DHAVE_SIGINFO_T=1 \
190    -DHAVE_SIGINFO_T_SI_OVERRUN=1 \
191    -DHAVE_SIGINFO_T_SI_SYSCALL=1 \
192    -DHAVE_SIGINFO_T_SI_TIMERID=1 \
193    -UHAVE_STAT64 \
194    -DHAVE_STATFS64=1 \
195    -DHAVE_STDBOOL_H=1 \
196    -DHAVE_STRERROR=1 \
197    -DHAVE_STRUCT_FLOCK64=1 \
198    -DHAVE_STRUCT_MMSGHDR=1 \
199    -DHAVE_STRUCT_MSGHDR_MSG_CONTROL=1 \
200    -DHAVE_STRUCT_SIGCONTEXT=1 \
201    -DHAVE_STRUCT_SIGEVENT__SIGEV_UN__PAD=1 \
202    -DHAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID=1 \
203    -DHAVE_STRUCT_STATFS64=1 \
204    -DHAVE_STRUCT_STAT_ST_ACLCNT=0 \
205    -DHAVE_STRUCT_STAT_ST_BLKSIZE=1 \
206    -DHAVE_STRUCT_STAT_ST_BLOCKS=1 \
207    -DHAVE_STRUCT_STAT_ST_FLAGS=0 \
208    -DHAVE_STRUCT_STAT_ST_FSTYPE=0 \
209    -DHAVE_STRUCT_STAT_ST_GEN=0 \
210    -DHAVE_STRUCT_STAT_ST_LEVEL=0 \
211    -DHAVE_STRUCT_STAT_ST_RDEV=1 \
212    -DHAVE_STRUCT_SYSINFO_FREEHIGH=1 \
213    -DHAVE_STRUCT_SYSINFO_MEM_UNIT=1 \
214    -DHAVE_STRUCT_SYSINFO_TOTALHIGH=1 \
215    -DHAVE_STRUCT_UTSNAME_DOMAINNAME=1 \
216    -DHAVE_SYS_EPOLL_H=1 \
217    -DHAVE_SYS_IOCTL_H=1 \
218    -DHAVE_SYS_POLL_H=1 \
219    -DHAVE_SYS_REG_H=1 \
220    -DHAVE_SYS_VFS_H=1 \
221    -DHAVE_SYS_XATTR_H=1 \
222    -DMAJOR_IN_SYSMACROS \
223    -DPACKAGE_NAME='"strace"' \
224    -DVERSION='"$(strace_version)"' \
225    -DSIZEOF_OFF_T=SIZEOF_LONG \
226    -DSIZEOF_LONG_LONG=8 \
227    -DSTDC_HEADERS=1 \
228    -DSTRACE_KNOWS_ONLY_EABI=1 \
229    -D_LFS64_LARGEFILE=1 \
230
231LOCAL_CFLAGS += -D_GNU_SOURCE=1 -D_POSIX_SOURCE=1
232
233LOCAL_CFLAGS_32 += -DSIZEOF_LONG=4 -DSIZEOF_RLIM_T=4 -DHAVE_STAT64=1
234LOCAL_CFLAGS_64 += -DSIZEOF_LONG=8 -DSIZEOF_RLIM_T=8
235
236LOCAL_CFLAGS_arm += -DARM=1
237LOCAL_CFLAGS_arm += -DHAVE_STRUCT___OLD_KERNEL_STAT=1
238
239LOCAL_CFLAGS_arm64 += -DAARCH64=1
240
241LOCAL_CFLAGS_mips += -DMIPS=1 -DLINUX_MIPSO32=1
242LOCAL_CFLAGS_mips += -DHAVE_ASM_SYSMIPS_H=1
243
244LOCAL_CFLAGS_mips64 += -DMIPS=1 -DLINUX_MIPSN64=1
245LOCAL_CFLAGS_mips64 += -DHAVE_ASM_SYSMIPS_H=1
246
247LOCAL_CFLAGS_x86 += -DI386=1
248LOCAL_CFLAGS_x86 += -DHAVE_STRUCT___OLD_KERNEL_STAT=1
249
250LOCAL_CFLAGS_x86_64 += -DX86_64=1
251
252LOCAL_CFLAGS += \
253    -Wall \
254    -Wwrite-strings \
255    -Wsign-compare \
256    -Wno-missing-field-initializers \
257    -Wno-unused-parameter \
258    -Wno-sign-compare \
259
260LOCAL_C_INCLUDES_arm := $(LOCAL_PATH)/linux/arm $(LOCAL_PATH)/linux
261LOCAL_C_INCLUDES_arm64 := $(LOCAL_PATH)/linux/aarch64 $(LOCAL_PATH)/linux
262LOCAL_C_INCLUDES_mips := $(LOCAL_PATH)/linux/mips $(LOCAL_PATH)/linux
263LOCAL_C_INCLUDES_mips64 := $(LOCAL_PATH)/linux/mips $(LOCAL_PATH)/linux
264LOCAL_C_INCLUDES_x86 := $(LOCAL_PATH)/linux/i386 $(LOCAL_PATH)/linux
265LOCAL_C_INCLUDES_x86_64 := $(LOCAL_PATH)/linux/x86_64 $(LOCAL_PATH)/linux
266
267LOCAL_MODULE := strace
268
269LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
270
271LOCAL_MODULE_TAGS := debug
272
273LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
274
275include $(BUILD_EXECUTABLE)
276
277
278# -------------------------------------------------------------------------
279
280# TODO: this is currently broken; the checked in ioctlent*.h files are from the 4.10 release.
281
282.PHONY: update-ioctls
283update-ioctls:
284	# Build the generated .h files needed by ioctlsort from the current bionic uapi headers.
285	cd external/strace; ./linux/ioctlent.sh ../../bionic/libc/kernel/uapi/
286	# Build the ioctlsort tool.
287	ONE_SHOT_MAKEFILE=external/strace/Android.mk make -f build/core/main.mk $(HOST_OUT_EXECUTABLES)/ioctlsort
288	# Remove the generated .h files now we've built ioctlsort.
289	rm external/strace/ioctls.h external/strace/ioctldefs.h
290	# Run the ioctlsort tool to generate the one file we do want to check in.
291	ioctlsort | tr -d '\r' | sed 's/^\([[:space:]]*{\)"[^"]\+",[[:space:]]*/\1/' | sort -u -k2,2 -k1,1 > external/strace/linux/ioctlent.h
292	# Rebuild strace with the new "ioctlent.h".
293	ONE_SHOT_MAKEFILE=external/strace/Android.mk make -f build/core/main.mk $(TARGET_OUT_OPTIONAL_EXECUTABLES)/strace
294
295# We don't build ioctlsort unless really necessary, because we don't check
296# in the temporary files needed to build it. This tool is only necessary
297# when updating strace's list of ioctls.
298ifneq (,$(filter $(HOST_OUT_EXECUTABLES)/ioctlsort,$(MAKECMDGOALS)))
299include $(CLEAR_VARS)
300LOCAL_SRC_FILES := ioctlsort.c
301# As long as ashmem isn't in glibc, we need the bionic header.
302# Unfortunately, it uses __u32 without pulling in a definition, so we need asm/types.h too.
303LOCAL_CFLAGS += -include asm/types.h -include bionic/libc/kernel/uapi/linux/ashmem.h
304LOCAL_CFLAGS += -Wno-unused-parameter
305LOCAL_MODULE := ioctlsort
306LOCAL_MODULE_TAGS := optional
307LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
308include $(BUILD_HOST_EXECUTABLE)
309endif
310
311# -------------------------------------------------------------------------
312