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# -------------------------------------------------------------------------
37
38include $(CLEAR_VARS)
39
40strace_version := $(shell grep Version $(LOCAL_PATH)/strace.spec | cut -d " " -f 2)
41
42LOCAL_SRC_FILES := \
43    aio.c \
44    bjm.c \
45    block.c \
46    count.c \
47    desc.c \
48    fanotify.c \
49    file.c \
50    inotify.c \
51    io.c \
52    ioctl.c \
53    ioprio.c \
54    ipc.c \
55    kexec.c \
56    keyctl.c \
57    ldt.c \
58    loop.c \
59    mem.c \
60    mtd.c \
61    net.c \
62    pathtrace.c \
63    process.c \
64    ptp.c \
65    quota.c \
66    reboot.c \
67    resource.c \
68    scsi.c \
69    signal.c \
70    sock.c \
71    strace.c \
72    stream.c \
73    syscall.c \
74    system.c \
75    term.c \
76    time.c \
77    util.c \
78    vsprintf.c \
79
80LOCAL_SHARED_LIBRARIES :=
81
82LOCAL_CFLAGS := \
83    -DGETGROUPS_T=gid_t \
84    -DHAVE_ASM_SIGCONTEXT_H=1 \
85    -DHAVE_DECL_PTRACE_EVENT_FORK=1 \
86    -DHAVE_DECL_PTRACE_EVENT_VFORK=1 \
87    -DHAVE_DECL_PTRACE_EVENT_CLONE=1 \
88    -DHAVE_DECL_PTRACE_EVENT_EXEC=1 \
89    -DHAVE_DECL_PTRACE_EVENT_VFORK_DONE=1 \
90    -DHAVE_DECL_PTRACE_EVENT_EXIT=1 \
91    -DHAVE_DECL_PTRACE_GETEVENTMSG=1 \
92    -DHAVE_DECL_PTRACE_GETSIGINFO=1 \
93    -DHAVE_DECL_PTRACE_O_TRACECLONE=1 \
94    -DHAVE_DECL_PTRACE_O_TRACEEXEC=1 \
95    -DHAVE_DECL_PTRACE_O_TRACEEXIT=1 \
96    -DHAVE_DECL_PTRACE_O_TRACEFORK=1 \
97    -DHAVE_DECL_PTRACE_O_TRACESYSGOOD=1 \
98    -DHAVE_DECL_PTRACE_O_TRACEVFORK=1 \
99    -DHAVE_DECL_PTRACE_SETOPTIONS=1 \
100    -UHAVE_DECL_IO_CMD_PWRITE \
101    -UHAVE_DECL_IO_CMD_PWRITEV \
102    -UHAVE_DECL_LO_FLAGS_AUTOCLEAR \
103    -UHAVE_DECL_LO_FLAGS_PARTSCAN \
104    -DHAVE_DECL_SYS_ERRLIST=1 \
105    -DHAVE_ELF_H=1 \
106    -DHAVE_FORK=1 \
107    -DHAVE_IF_INDEXTONAME=1 \
108    -DHAVE_INET_NTOP=1 \
109    -DHAVE_LINUX_CAPABILITY_H=1 \
110    -DHAVE_LINUX_ICMP_H=1 \
111    -DHAVE_LINUX_IF_PACKET_H=1 \
112    -DHAVE_LINUX_IN6_H=1 \
113    -DHAVE_LINUX_NETLINK_H=1 \
114    -DHAVE_LITTLE_ENDIAN_LONG_LONG=1 \
115    -DHAVE_LONG_LONG=1 \
116    -DHAVE_NETINET_TCP_H=1 \
117    -DHAVE_NETINET_UDP_H=1 \
118    -DHAVE_POLL_H=1 \
119    -DHAVE_PRCTL=1 \
120    -DHAVE_SENDMSG=1 \
121    -DHAVE_SIGACTION=1 \
122    -DHAVE_SIGINFO_T=1 \
123    -DHAVE_SIG_ATOMIC_T=1 \
124    -DHAVE_STATFS64=1 \
125    -DHAVE_STDBOOL_H=1 \
126    -DHAVE_STRERROR=1 \
127    -DHAVE_STRUCT_FLOCK64=1 \
128    -DHAVE_STRUCT_MSGHDR_MSG_CONTROL=1 \
129    -DHAVE_STRUCT_SIGCONTEXT=1 \
130    -DHAVE_STRUCT_SIGEVENT__SIGEV_UN__PAD=1 \
131    -DHAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID=1 \
132    -DHAVE_STRUCT_STAT_ST_BLKSIZE=1 \
133    -DHAVE_STRUCT_STAT_ST_BLOCKS=1 \
134    -DHAVE_STRUCT_STAT_ST_RDEV=1 \
135    -DHAVE_STRUCT_USER_DESC=1 \
136    -DHAVE_SYS_EPOLL_H=1 \
137    -DHAVE_SYS_IOCTL_H=1 \
138    -DHAVE_SYS_POLL_H=1 \
139    -DHAVE_SYS_REG_H=1 \
140    -DHAVE_SYS_VFS_H=1 \
141    -DMAJOR_IN_SYSMACROS \
142    -DPACKAGE_NAME='"strace"' \
143    -DVERSION='"$(strace_version)"' \
144    -DSIZEOF_OFF_T=SIZEOF_LONG \
145    -DSIZEOF_LONG_LONG=8 \
146    -DSTDC_HEADERS=1 \
147    -DSTRACE_KNOWS_ONLY_EABI=1 \
148    -D_LFS64_LARGEFILE=1 \
149
150LOCAL_CFLAGS += -D_GNU_SOURCE=1 -D_POSIX_SOURCE=1
151
152LOCAL_CFLAGS_32 += -DSIZEOF_LONG=4 -DSIZEOF_RLIM_T=4 -DHAVE_STAT64=1
153LOCAL_CFLAGS_64 += -DSIZEOF_LONG=8 -DSIZEOF_RLIM_T=8
154
155LOCAL_CFLAGS_arm += -DARM=1
156LOCAL_CFLAGS_arm += -DHAVE_STRUCT___OLD_KERNEL_STAT=1
157
158LOCAL_CFLAGS_arm64 += -DAARCH64=1
159
160LOCAL_CFLAGS_mips += -DMIPS=1
161LOCAL_CFLAGS_mips += -DHAVE_ASM_SYSMIPS_H=1
162
163LOCAL_CFLAGS_x86 += -DI386=1
164LOCAL_CFLAGS_x86 += -DHAVE_STRUCT___OLD_KERNEL_STAT=1
165
166LOCAL_CFLAGS_x86_64 += -DX86_64=1
167
168LOCAL_CFLAGS += \
169    -Wall \
170    -Wno-missing-field-initializers \
171    -Wno-unused-parameter \
172    -Wno-sign-compare \
173
174LOCAL_C_INCLUDES := \
175    $(LOCAL_PATH)/linux
176
177LOCAL_C_INCLUDES_arm := $(LOCAL_PATH)/linux/arm
178LOCAL_C_INCLUDES_arm64 := $(LOCAL_PATH)/linux/aarch64
179LOCAL_C_INCLUDES_mips := $(LOCAL_PATH)/linux/mips
180LOCAL_C_INCLUDES_mips64 := $(LOCAL_PATH)/linux/mips
181LOCAL_C_INCLUDES_x86 := $(LOCAL_PATH)/linux/i386
182LOCAL_C_INCLUDES_x86_64 := $(LOCAL_PATH)/linux/x86_64
183
184LOCAL_MODULE := strace
185
186LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
187
188LOCAL_MODULE_TAGS := debug
189
190LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
191
192include $(BUILD_EXECUTABLE)
193
194
195# -------------------------------------------------------------------------
196
197.PHONY: update-ioctls
198update-ioctls:
199	# Build the generated .h files needed by ioctlsort from the current bionic uapi headers.
200	cd external/strace; ./linux/ioctlent.sh ../../bionic/libc/kernel/uapi/
201	# Build the ioctlsort tool.
202	ONE_SHOT_MAKEFILE=external/strace/Android.mk make -f build/core/main.mk $(TARGET_OUT_EXECUTABLES)/ioctlsort
203	# Remove the generated .h files now we've built ioctlsort.
204	rm external/strace/ioctls.h external/strace/ioctldefs.h
205	# Run the ioctlsort tool on the target to generate the one file we do want to check in.
206	adb sync
207	adb shell ioctlsort | tr -d '\r' > external/strace/linux/ioctlent.h
208	# Rebuild strace with the new "ioctlent.h".
209	ONE_SHOT_MAKEFILE=external/strace/Android.mk make -f build/core/main.mk
210
211# We don't build ioctlsort unless really necessary, because we don't check
212# in the temporary files needed to build it. This tool is only necessary
213# when updating strace's list of ioctls.
214ifneq (,$(filter $(TARGET_OUT_EXECUTABLES)/ioctlsort,$(MAKECMDGOALS)))
215include $(CLEAR_VARS)
216LOCAL_SRC_FILES := linux/ioctlsort.c
217LOCAL_CFLAGS += -include asm/types.h -include linux/ashmem.h
218LOCAL_CFLAGS += -Wno-unused-parameter
219LOCAL_MODULE := ioctlsort
220LOCAL_MODULE_TAGS := optional
221LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
222include $(BUILD_EXECUTABLE)
223endif
224
225# -------------------------------------------------------------------------
226
227include $(LOCAL_PATH)/test/Android.mk
228