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    bpf.c \
54    cacheflush.c \
55    capability.c \
56    chdir.c \
57    chmod.c \
58    clone.c \
59    count.c \
60    desc.c \
61    dirent.c \
62    dirent64.c \
63    epoll.c \
64    eventfd.c \
65    execve.c \
66    exit.c \
67    fadvise.c \
68    fallocate.c \
69    fanotify.c \
70    fchownat.c \
71    fcntl.c \
72    fetch_seccomp_fprog.c \
73    fetch_struct_flock.c \
74    file.c \
75    file_handle.c \
76    flock.c \
77    futex.c \
78    getcpu.c \
79    getcwd.c \
80    getrandom.c \
81    get_robust_list.c \
82    hostname.c \
83    inotify.c \
84    io.c \
85    ioctl.c \
86    ioperm.c \
87    iopl.c \
88    ioprio.c \
89    ipc_msg.c \
90    ipc_msgctl.c \
91    ipc_sem.c \
92    ipc_shm.c \
93    ipc_shmctl.c \
94    kcmp.c \
95    kexec.c \
96    keyctl.c \
97    ldt.c \
98    link.c \
99    lookup_dcookie.c \
100    loop.c \
101    lseek.c \
102    mem.c \
103    membarrier.c \
104    memfd_create.c \
105    mknod.c \
106    mount.c \
107    mq.c \
108    mtd.c \
109    net.c \
110    open.c \
111    pathtrace.c \
112    perf.c \
113    personality.c \
114    poll.c \
115    prctl.c \
116    print_mq_attr.c \
117    print_msgbuf.c \
118    print_sigevent.c \
119    print_time.c \
120    print_timex.c \
121    printmode.c \
122    printrusage.c \
123    printsiginfo.c \
124    process.c \
125    process_vm.c \
126    ptp.c \
127    quota.c \
128    readahead.c \
129    readlink.c \
130    reboot.c \
131    renameat.c \
132    resource.c \
133    rtc.c \
134    sched.c \
135    scsi.c \
136    seccomp.c \
137    sendfile.c \
138    sigaltstack.c \
139    signal.c \
140    signalfd.c \
141    sigreturn.c \
142    sock.c \
143    socketutils.c \
144    sram_alloc.c \
145    statfs.c \
146    strace.c \
147    swapon.c \
148    sync_file_range.c \
149    syscall.c \
150    sysctl.c \
151    sysinfo.c \
152    syslog.c \
153    sysmips.c \
154    term.c \
155    time.c \
156    times.c \
157    truncate.c \
158    uid16.c \
159    uid.c \
160    umask.c \
161    umount.c \
162    uname.c \
163    userfaultfd.c \
164    util.c \
165    utime.c \
166    utimes.c \
167    v4l2.c \
168    vsprintf.c \
169    wait.c \
170    xattr.c \
171    xmalloc.c \
172
173LOCAL_SHARED_LIBRARIES :=
174
175LOCAL_CFLAGS := \
176    -DGETGROUPS_T=gid_t \
177    -DHAVE_ASM_SIGCONTEXT_H=1 \
178    -DHAVE_DECL_PTRACE_EVENT_FORK=1 \
179    -DHAVE_DECL_PTRACE_EVENT_VFORK=1 \
180    -DHAVE_DECL_PTRACE_EVENT_CLONE=1 \
181    -DHAVE_DECL_PTRACE_EVENT_EXEC=1 \
182    -DHAVE_DECL_PTRACE_EVENT_VFORK_DONE=1 \
183    -DHAVE_DECL_PTRACE_EVENT_EXIT=1 \
184    -DHAVE_DECL_PTRACE_GETEVENTMSG=1 \
185    -DHAVE_DECL_PTRACE_GETSIGINFO=1 \
186    -DHAVE_DECL_PTRACE_O_TRACECLONE=1 \
187    -DHAVE_DECL_PTRACE_O_TRACEEXEC=1 \
188    -DHAVE_DECL_PTRACE_O_TRACEEXIT=1 \
189    -DHAVE_DECL_PTRACE_O_TRACEFORK=1 \
190    -DHAVE_DECL_PTRACE_O_TRACESYSGOOD=1 \
191    -DHAVE_DECL_PTRACE_O_TRACEVFORK=1 \
192    -DHAVE_DECL_PTRACE_SETOPTIONS=1 \
193    -UHAVE_DECL_IO_CMD_PWRITE \
194    -UHAVE_DECL_IO_CMD_PWRITEV \
195    -UHAVE_DECL_LO_FLAGS_AUTOCLEAR \
196    -UHAVE_DECL_LO_FLAGS_PARTSCAN \
197    -DHAVE_DECL_SYS_ERRLIST=1 \
198    -DHAVE_ELF_H=1 \
199    -DHAVE_FOPEN64=1 \
200    -DHAVE_FORK=1 \
201    -DHAVE_IF_INDEXTONAME=1 \
202    -DHAVE_INET_NTOP=1 \
203    -DHAVE_LINUX_CAPABILITY_H=1 \
204    -DHAVE_LINUX_FALLOC_H=1 \
205    -DHAVE_LINUX_FILTER_H=1 \
206    -DHAVE_LINUX_FUTEX_H=1 \
207    -DHAVE_LINUX_ICMP_H=1 \
208    -DHAVE_LINUX_IF_PACKET_H=1 \
209    -DHAVE_LINUX_IN6_H=1 \
210    -DHAVE_LINUX_IPC_H=1 \
211    -DHAVE_LINUX_MQUEUE=1 \
212    -DHAVE_LINUX_MSG_H=1 \
213    -DHAVE_LINUX_NETLINK_H=1 \
214    -DHAVE_LINUX_PERF_EVENT_H=1 \
215    -DHAVE_LINUX_SEM_H=1 \
216    -DHAVE_LINUX_SHM_H=1 \
217    -DHAVE_LITTLE_ENDIAN_LONG_LONG=1 \
218    -DHAVE_LONG_LONG=1 \
219    -DHAVE_NETINET_TCP_H=1 \
220    -DHAVE_NETINET_UDP_H=1 \
221    -DHAVE_POLL_H=1 \
222    -DHAVE_PRCTL=1 \
223    -DHAVE_PWRITEV=1 \
224    -DHAVE_SENDMSG=1 \
225    -DHAVE_SIGACTION=1 \
226    -DHAVE_SIG_ATOMIC_T=1 \
227    -DHAVE_SIGINFO_T=1 \
228    -DHAVE_SIGINFO_T_SI_OVERRUN=1 \
229    -DHAVE_SIGINFO_T_SI_SYSCALL=1 \
230    -DHAVE_SIGINFO_T_SI_TIMERID=1 \
231    -UHAVE_STAT64 \
232    -DHAVE_STATFS64=1 \
233    -DHAVE_STDBOOL_H=1 \
234    -DHAVE_STRERROR=1 \
235    -DHAVE_STRUCT_FLOCK=1 \
236    -DHAVE_STRUCT_FLOCK64=1 \
237    -DHAVE_STRUCT_MMSGHDR=1 \
238    -DHAVE_STRUCT_MSGHDR_MSG_CONTROL=1 \
239    -DHAVE_STRUCT_SIGCONTEXT=1 \
240    -DHAVE_STRUCT_SIGEVENT__SIGEV_UN__PAD=1 \
241    -DHAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID=1 \
242    -DHAVE_STRUCT_STATFS64=1 \
243    -UHAVE_STRUCT_STAT_ST_ACLCNT \
244    -DHAVE_STRUCT_STAT_ST_BLKSIZE=1 \
245    -DHAVE_STRUCT_STAT_ST_BLOCKS=1 \
246    -UHAVE_STRUCT_STAT_ST_FLAGS \
247    -UHAVE_STRUCT_STAT_ST_FSTYPE \
248    -UHAVE_STRUCT_STAT_ST_GEN \
249    -UHAVE_STRUCT_STAT_ST_LEVEL \
250    -DHAVE_STRUCT_STAT_ST_RDEV=1 \
251    -DHAVE_STRUCT_SYSINFO_FREEHIGH=1 \
252    -DHAVE_STRUCT_SYSINFO_MEM_UNIT=1 \
253    -DHAVE_STRUCT_SYSINFO_TOTALHIGH=1 \
254    -DHAVE_STRUCT_UTSNAME_DOMAINNAME=1 \
255    -DHAVE_SYS_EPOLL_H=1 \
256    -DHAVE_SYS_IOCTL_H=1 \
257    -DHAVE_SYS_POLL_H=1 \
258    -DHAVE_SYS_REG_H=1 \
259    -DHAVE_SYS_VFS_H=1 \
260    -DHAVE_SYS_XATTR_H=1 \
261    -DMAJOR_IN_SYSMACROS \
262    -DPACKAGE_NAME='"strace"' \
263    -DVERSION='"$(strace_version)"' \
264    -DSIZEOF_OFF_T=SIZEOF_LONG \
265    -DSIZEOF_LONG_LONG=8 \
266    -DSTDC_HEADERS=1 \
267    -DSTRACE_KNOWS_ONLY_EABI=1 \
268    -D_LFS64_LARGEFILE=1 \
269
270LOCAL_CFLAGS += -D_GNU_SOURCE=1 -D_POSIX_SOURCE=1
271
272LOCAL_CFLAGS += -fno-strict-aliasing
273
274LOCAL_CFLAGS_32 += -DSIZEOF_LONG=4 -DSIZEOF_RLIM_T=4 -DHAVE_STAT64=1
275LOCAL_CFLAGS_64 += -DSIZEOF_LONG=8 -DSIZEOF_RLIM_T=8
276
277LOCAL_CFLAGS_arm += -DARM=1
278LOCAL_CFLAGS_arm += -DHAVE_STRUCT___OLD_KERNEL_STAT=1
279
280LOCAL_CFLAGS_arm64 += -DAARCH64=1
281
282LOCAL_CFLAGS_mips += -DMIPS=1 -DLINUX_MIPSO32=1
283LOCAL_CFLAGS_mips += -DHAVE_ASM_SYSMIPS_H=1
284
285LOCAL_CFLAGS_mips64 += -DMIPS=1 -DLINUX_MIPSN64=1
286LOCAL_CFLAGS_mips64 += -DHAVE_ASM_SYSMIPS_H=1
287
288LOCAL_CFLAGS_x86 += -DI386=1
289LOCAL_CFLAGS_x86 += -DHAVE_STRUCT___OLD_KERNEL_STAT=1
290
291LOCAL_CFLAGS_x86_64 += -DX86_64=1
292
293LOCAL_CFLAGS += \
294    -Wall \
295    -Wwrite-strings \
296    -Wsign-compare \
297    -Wno-missing-field-initializers \
298    -Wno-unused-parameter \
299    -Wno-sign-compare \
300
301LOCAL_C_INCLUDES_arm := $(LOCAL_PATH)/linux/arm $(LOCAL_PATH)/linux
302LOCAL_C_INCLUDES_arm64 := $(LOCAL_PATH)/linux/aarch64 $(LOCAL_PATH)/linux
303LOCAL_C_INCLUDES_mips := $(LOCAL_PATH)/linux/mips $(LOCAL_PATH)/linux
304LOCAL_C_INCLUDES_mips64 := $(LOCAL_PATH)/linux/mips $(LOCAL_PATH)/linux
305LOCAL_C_INCLUDES_x86 := $(LOCAL_PATH)/linux/i386 $(LOCAL_PATH)/linux
306LOCAL_C_INCLUDES_x86_64 := $(LOCAL_PATH)/linux/x86_64 $(LOCAL_PATH)/linux
307
308LOCAL_CLANG := true
309
310LOCAL_MODULE := strace
311
312LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
313
314LOCAL_MODULE_TAGS := debug
315
316LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
317
318include $(BUILD_EXECUTABLE)
319