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#  repo sync .
24#  repo start merge .
25#  git merge aosp/upstream-master --no-ff # resolve any conflicts
26#  ./configure && make
27#  mm -j32
28#  # (Make any necessary Android.mk changes and test the new strace.)
29#  # Beware the .gitignore files --- xlat especially.
30#  git commit -a --amend
31#
32
33# We don't currently have a good solution for the 'configure' side of things.
34# You can get a list of the HAVE_* variables in use and manually go through it:
35#
36#   find . -name "*.[ch]" | xargs grep HAVE_ | sed 's/.*\(HAVE_[A-Z0-9_]*\).*/\1/p' | grep -v HAVE_DECL_ | sort | uniq -d
37
38# -------------------------------------------------------------------------
39
40include $(CLEAR_VARS)
41
42strace_version := $(shell grep strace $(LOCAL_PATH)/debian/changelog | \
43                          head -1 | cut -d " " -f 2)
44
45LOCAL_SRC_FILES := \
46    access.c \
47    affinity.c \
48    aio.c \
49    bjm.c \
50    block.c \
51    bpf.c \
52    btrfs.c \
53    cacheflush.c \
54    capability.c \
55    chdir.c \
56    chmod.c \
57    clone.c \
58    copy_file_range.c \
59    count.c \
60    desc.c \
61    dirent.c \
62    dirent64.c \
63    epoll.c \
64    evdev.c \
65    eventfd.c \
66    execve.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    fetch_struct_mmsghdr.c \
75    fetch_struct_msghdr.c \
76    fetch_struct_stat.c \
77    fetch_struct_stat64.c \
78    fetch_struct_statfs.c \
79    file_handle.c \
80    file_ioctl.c \
81    flock.c \
82    fstatfs.c \
83    fstatfs64.c \
84    fs_x_ioctl.c \
85    futex.c \
86    getcpu.c \
87    getcwd.c \
88    getrandom.c \
89    get_robust_list.c \
90    hdio.c \
91    hostname.c \
92    inotify.c \
93    io.c \
94    ioctl.c \
95    ioperm.c \
96    iopl.c \
97    ioprio.c \
98    ipc.c \
99    ipc_msg.c \
100    ipc_msgctl.c \
101    ipc_sem.c \
102    ipc_shm.c \
103    ipc_shmctl.c \
104    kcmp.c \
105    kexec.c \
106    keyctl.c \
107    ldt.c \
108    link.c \
109    lookup_dcookie.c \
110    loop.c \
111    lseek.c \
112    mem.c \
113    membarrier.c \
114    memfd_create.c \
115    mknod.c \
116    mmsghdr.c \
117    mount.c \
118    mq.c \
119    msghdr.c \
120    mtd.c \
121    net.c \
122    netlink.c \
123    numa.c \
124    oldstat.c \
125    open.c \
126    pathtrace.c \
127    perf.c \
128    personality.c \
129    pkeys.c \
130    poll.c \
131    prctl.c \
132    print_dev_t.c \
133    print_mq_attr.c \
134    print_msgbuf.c \
135    print_sigevent.c \
136    print_statfs.c \
137    print_struct_stat.c \
138    print_time.c \
139    print_timespec.c \
140    print_timeval.c \
141    print_timex.c \
142    printmode.c \
143    printrusage.c \
144    printsiginfo.c \
145    process.c \
146    process_vm.c \
147    ptp.c \
148    qualify.c \
149    quota.c \
150    readahead.c \
151    readlink.c \
152    reboot.c \
153    renameat.c \
154    resource.c \
155    rtc.c \
156    sched.c \
157    scsi.c \
158    seccomp.c \
159    sendfile.c \
160    sg_io_v3.c \
161    sg_io_v4.c \
162    sigaltstack.c \
163    signal.c \
164    signalfd.c \
165    sigreturn.c \
166    sock.c \
167    sockaddr.c \
168    socketcall.c \
169    socketutils.c \
170    sram_alloc.c \
171    stat.c \
172    stat64.c \
173    statfs.c \
174    statfs64.c \
175    strace.c \
176    swapon.c \
177    sync_file_range.c \
178    sync_file_range2.c \
179    syscall.c \
180    sysctl.c \
181    sysinfo.c \
182    syslog.c \
183    sysmips.c \
184    term.c \
185    time.c \
186    times.c \
187    truncate.c \
188    ubi.c \
189    uid16.c \
190    uid.c \
191    umask.c \
192    umount.c \
193    uname.c \
194    upeek.c \
195    upoke.c \
196    userfaultfd.c \
197    ustat.c \
198    util.c \
199    utime.c \
200    utimes.c \
201    v4l2.c \
202    wait.c \
203    xattr.c \
204    xmalloc.c \
205
206LOCAL_CFLAGS := \
207    -DGETGROUPS_T=gid_t \
208    \
209    -UHAVE_ASM_CACHECTL_H \
210    -DHAVE_ASM_SIGCONTEXT_H=1 \
211    -DHAVE_BLKGETSIZE64=1 \
212    -UHAVE_BLUETOOTH_BLUETOOTH_H \
213    -DHAVE___BUILTIN_POPCOUNT=1 \
214    -DHAVE_DIRENT_H=1 \
215    -DHAVE_DLADDR=1 \
216    -DHAVE_ELF_H=1 \
217    -DHAVE_FOPEN64=1 \
218    -DHAVE_FORK=1 \
219    -DHAVE_FSTATAT=1 \
220    -DHAVE_FTRUNCATE=1 \
221    -DHAVE_FUTIMENS=1 \
222    -DHAVE_IF_INDEXTONAME=1 \
223    -DHAVE_INET_NTOP=1 \
224    -DHAVE_INET_PTON=1 \
225    -DHAVE_INTTYPES_H=1 \
226    -DHAVE_LINUX_BPF_H=1 \
227    -DHAVE_LINUX_BSG_H=1 \
228    -DHAVE_LINUX_BTRFS_H=1 \
229    -DHAVE_LINUX_FALLOC_H=1 \
230    -DHAVE_LINUX_FILTER_H=1 \
231    -DHAVE_LINUX_FUTEX_H=1 \
232    -DHAVE_LINUX_ICMP_H=1 \
233    -DHAVE_LINUX_IF_PACKET_H=1 \
234    -DHAVE_LINUX_INPUT_H=1 \
235    -DHAVE_LINUX_IN6_H=1 \
236    -DHAVE_LINUX_IPC_H=1 \
237    -DHAVE_LINUX_MQUEUE=1 \
238    -DHAVE_LINUX_MSG_H=1 \
239    -DHAVE_LINUX_NETLINK_H=1 \
240    -DHAVE_LINUX_PERF_EVENT_H=1 \
241    -DHAVE_LINUX_SEM_H=1 \
242    -DHAVE_LINUX_SHM_H=1 \
243    -DHAVE_LITTLE_ENDIAN_LONG_LONG=1 \
244    -DHAVE_LONG_LONG=1 \
245    -DHAVE_NETINET_TCP_H=1 \
246    -DHAVE_NETINET_UDP_H=1 \
247    -DHAVE_POLL_H=1 \
248    -DHAVE_PRCTL=1 \
249    -DHAVE_PWRITEV=1 \
250    -DHAVE_SENDMSG=1 \
251    -DHAVE_SIGACTION=1 \
252    -DHAVE_SIG_ATOMIC_T=1 \
253    -DHAVE_SIGINFO_T=1 \
254    -DHAVE_SIGINFO_T_SI_OVERRUN=1 \
255    -DHAVE_SIGINFO_T_SI_SYSCALL=1 \
256    -DHAVE_SIGINFO_T_SI_TIMERID=1 \
257    -DHAVE_STATFS64=1 \
258    -DHAVE_STDBOOL_H=1 \
259    -DHAVE_STRERROR=1 \
260    -DHAVE_STRUCT_BTRFS_IOCTL_DEFRAG_RANGE_ARGS_START=1 \
261    -DHAVE_STRUCT_BTRFS_IOCTL_FEATURE_FLAGS_COMPAT_FLAGS=1 \
262    -DHAVE_STRUCT_FLOCK=1 \
263    -DHAVE_STRUCT_FLOCK64=1 \
264    -DHAVE_STRUCT_MMSGHDR=1 \
265    -DHAVE_STRUCT_MSGHDR_MSG_CONTROL=1 \
266    -DHAVE_STRUCT_SIGCONTEXT=1 \
267    -DHAVE_STRUCT_SIGEVENT__SIGEV_UN__PAD=1 \
268    -DHAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID=1 \
269    -DHAVE_STRUCT_STATFS64=1 \
270    -UHAVE_STRUCT_STAT_ST_ACLCNT \
271    -DHAVE_STRUCT_STAT_ST_BLKSIZE=1 \
272    -DHAVE_STRUCT_STAT_ST_BLOCKS=1 \
273    -UHAVE_STRUCT_STAT_ST_FLAGS \
274    -UHAVE_STRUCT_STAT_ST_FSTYPE \
275    -UHAVE_STRUCT_STAT_ST_GEN \
276    -UHAVE_STRUCT_STAT_ST_LEVEL \
277    -DHAVE_STRUCT_STAT_ST_RDEV=1 \
278    -DHAVE_STRUCT_SYSINFO_FREEHIGH=1 \
279    -DHAVE_STRUCT_SYSINFO_MEM_UNIT=1 \
280    -DHAVE_STRUCT_SYSINFO_TOTALHIGH=1 \
281    -DHAVE_STRUCT_UTSNAME_DOMAINNAME=1 \
282    -DHAVE_SYS_EPOLL_H=1 \
283    -DHAVE_SYS_IOCTL_H=1 \
284    -DHAVE_SYS_POLL_H=1 \
285    -DHAVE_SYS_REG_H=1 \
286    -DHAVE_SYS_VFS_H=1 \
287    -DHAVE_SYS_XATTR_H=1 \
288    -DHAVE_UNISTD_H=1 \
289    -DHAVE_UTIMENSAT=1 \
290    \
291    -DMAJOR_IN_SYSMACROS \
292    -DPACKAGE_NAME='"strace"' \
293    -DPACKAGE_URL='"https://strace.io"' \
294    -DPACKAGE_VERSION='"$(strace_version)"' \
295    -DSIZEOF_KERNEL_LONG_T=SIZEOF_LONG \
296    -DSIZEOF_OFF_T=SIZEOF_LONG \
297    -DSIZEOF_LONG_LONG=8 \
298    -DSTDC_HEADERS=1 \
299    -DSTRACE_KNOWS_ONLY_EABI=1 \
300    -D_LFS64_LARGEFILE=1 \
301
302LOCAL_CFLAGS += -D_GNU_SOURCE=1 -D_POSIX_SOURCE=1
303
304LOCAL_CFLAGS += -fno-strict-aliasing
305
306LOCAL_CFLAGS_32 += -DSIZEOF_LONG=4 -DSIZEOF_RLIM_T=4 -DHAVE_STRUCT_STAT64=1
307LOCAL_CFLAGS_64 += -DSIZEOF_LONG=8 -DSIZEOF_RLIM_T=8
308
309LOCAL_CFLAGS_arm += -DARM=1
310LOCAL_CFLAGS_arm += -DHAVE_STRUCT___OLD_KERNEL_STAT=1
311
312LOCAL_CFLAGS_arm64 += -DAARCH64=1
313
314LOCAL_CFLAGS_mips += -DMIPS=1 -DLINUX_MIPSO32=1
315LOCAL_CFLAGS_mips += -DHAVE_ASM_SYSMIPS_H=1
316
317LOCAL_CFLAGS_mips64 += -DMIPS=1 -DLINUX_MIPSN64=1
318LOCAL_CFLAGS_mips64 += -DHAVE_ASM_SYSMIPS_H=1
319
320LOCAL_CFLAGS_x86 += -DI386=1
321LOCAL_CFLAGS_x86 += -DHAVE_STRUCT___OLD_KERNEL_STAT=1
322
323LOCAL_CFLAGS_x86_64 += -DX86_64=1
324
325LOCAL_CFLAGS += \
326    -Wall \
327    -Wwrite-strings \
328    -Wsign-compare \
329    -Wno-missing-field-initializers \
330    -Wno-pointer-arith \
331    -Wno-unused-parameter \
332    -Wno-sign-compare \
333
334LOCAL_C_INCLUDES_arm := $(LOCAL_PATH)/linux/arm $(LOCAL_PATH)/linux
335LOCAL_C_INCLUDES_arm64 := $(LOCAL_PATH)/linux/aarch64 $(LOCAL_PATH)/linux
336LOCAL_C_INCLUDES_mips := $(LOCAL_PATH)/linux/mips $(LOCAL_PATH)/linux
337LOCAL_C_INCLUDES_mips64 := $(LOCAL_PATH)/linux/mips $(LOCAL_PATH)/linux
338LOCAL_C_INCLUDES_x86 := $(LOCAL_PATH)/linux/i386 $(LOCAL_PATH)/linux
339LOCAL_C_INCLUDES_x86_64 := $(LOCAL_PATH)/linux/x86_64 $(LOCAL_PATH)/linux
340
341LOCAL_CLANG := true
342
343LOCAL_MODULE := strace
344
345LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
346
347LOCAL_MODULE_TAGS := debug
348
349LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
350
351include $(BUILD_EXECUTABLE)
352