blob: 6943d38a64e6249cb77299c2a7ead695bc58be8f [file] [log] [blame]
Elliott Hughes858a5c72014-02-28 15:58:12 -08001#
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#
The Android Open Source Project34d6eab2009-03-03 19:30:45 -080016
Elliott Hughes858a5c72014-02-28 15:58:12 -080017LOCAL_PATH := $(call my-dir)
Elliott Hughes7c538322014-02-28 10:32:04 -080018
Elliott Hughes4e779b42014-05-07 09:10:38 -070019#
20# To update:
21#
22
Elliott Hughes60b6d902014-06-06 22:42:41 -070023# git remote add strace git://git.code.sf.net/p/strace/code
Elliott Hughes4e779b42014-05-07 09:10:38 -070024# git fetch strace
25# git merge strace/master
26# mm -j32
27# # (Make any necessary Android.mk changes and test the new strace.)
Elliott Hughes60b6d902014-06-06 22:42:41 -070028# git push aosp HEAD:master # Push directly, avoiding gerrit.
29# git push aosp HEAD:refs/for/master # Push to gerrit.
Elliott Hughes4e779b42014-05-07 09:10:38 -070030#
31# # Now commit any necessary Android.mk changes like normal:
32# repo start post-sync .
33# git commit -a
34#
35
Elliott Hughes9e25f2c2014-10-03 11:01:13 -070036# 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
Elliott Hughes7c538322014-02-28 10:32:04 -080041# -------------------------------------------------------------------------
42
The Android Open Source Project34d6eab2009-03-03 19:30:45 -080043include $(CLEAR_VARS)
44
Elliott Hughes15fc6a22014-01-09 10:30:06 -080045strace_version := $(shell grep Version $(LOCAL_PATH)/strace.spec | cut -d " " -f 2)
The Android Open Source Project34d6eab2009-03-03 19:30:45 -080046
Elliott Hughesbb0c2d52014-01-07 17:34:14 -080047LOCAL_SRC_FILES := \
Elliott Hughescaca6ee2015-01-06 12:18:17 -080048 access.c \
49 affinity.c \
Elliott Hughes5dec78d2014-02-26 15:56:23 -080050 aio.c \
Elliott Hughesbb0c2d52014-01-07 17:34:14 -080051 bjm.c \
52 block.c \
Elliott Hughescaca6ee2015-01-06 12:18:17 -080053 cacheflush.c \
54 capability.c \
55 chdir.c \
56 chmod.c \
57 clone.c \
Elliott Hughesbb0c2d52014-01-07 17:34:14 -080058 count.c \
59 desc.c \
Elliott Hughes1f72dc72014-09-22 10:04:17 -070060 dirent.c \
Elliott Hughescaca6ee2015-01-06 12:18:17 -080061 execve.c \
62 exit.c \
63 fadvise.c \
64 fallocate.c \
Elliott Hughes5dec78d2014-02-26 15:56:23 -080065 fanotify.c \
Elliott Hughescaca6ee2015-01-06 12:18:17 -080066 fchownat.c \
Elliott Hughesbb0c2d52014-01-07 17:34:14 -080067 file.c \
Elliott Hughescaca6ee2015-01-06 12:18:17 -080068 futex.c \
69 getcpu.c \
70 getcwd.c \
71 get_robust_list.c \
72 hostname.c \
Elliott Hughes5dec78d2014-02-26 15:56:23 -080073 inotify.c \
Elliott Hughesbb0c2d52014-01-07 17:34:14 -080074 io.c \
75 ioctl.c \
Elliott Hughes5dec78d2014-02-26 15:56:23 -080076 ioprio.c \
Elliott Hughesbb0c2d52014-01-07 17:34:14 -080077 ipc.c \
Elliott Hughes5dec78d2014-02-26 15:56:23 -080078 kexec.c \
79 keyctl.c \
Elliott Hughes51505672014-04-10 11:06:16 -070080 ldt.c \
Elliott Hughescaca6ee2015-01-06 12:18:17 -080081 link.c \
Elliott Hughesbb0c2d52014-01-07 17:34:14 -080082 loop.c \
Elliott Hughescaca6ee2015-01-06 12:18:17 -080083 lseek.c \
Elliott Hughesbb0c2d52014-01-07 17:34:14 -080084 mem.c \
Elliott Hughescaca6ee2015-01-06 12:18:17 -080085 mknod.c \
86 mount.c \
Elliott Hughesbb0c2d52014-01-07 17:34:14 -080087 mtd.c \
88 net.c \
Elliott Hughescaca6ee2015-01-06 12:18:17 -080089 open.c \
Elliott Hughesbb0c2d52014-01-07 17:34:14 -080090 pathtrace.c \
Elliott Hughescaca6ee2015-01-06 12:18:17 -080091 personality.c \
92 prctl.c \
93 printmode.c \
Elliott Hughesbb0c2d52014-01-07 17:34:14 -080094 process.c \
Elliott Hughescaca6ee2015-01-06 12:18:17 -080095 process_vm.c \
Elliott Hughes5dec78d2014-02-26 15:56:23 -080096 ptp.c \
Elliott Hughesbb0c2d52014-01-07 17:34:14 -080097 quota.c \
Elliott Hughescaca6ee2015-01-06 12:18:17 -080098 readahead.c \
99 readlink.c \
Elliott Hughes5dec78d2014-02-26 15:56:23 -0800100 reboot.c \
Elliott Hughescaca6ee2015-01-06 12:18:17 -0800101 renameat.c \
Elliott Hughesbb0c2d52014-01-07 17:34:14 -0800102 resource.c \
Elliott Hughescaca6ee2015-01-06 12:18:17 -0800103 sched.c \
Elliott Hughes5dec78d2014-02-26 15:56:23 -0800104 scsi.c \
Elliott Hughesbb0c2d52014-01-07 17:34:14 -0800105 signal.c \
106 sock.c \
Elliott Hughes1f72dc72014-09-22 10:04:17 -0700107 socketutils.c \
Elliott Hughescaca6ee2015-01-06 12:18:17 -0800108 sram_alloc.c \
Elliott Hughes1f72dc72014-09-22 10:04:17 -0700109 statfs.c \
Elliott Hughesbb0c2d52014-01-07 17:34:14 -0800110 strace.c \
111 stream.c \
Elliott Hughescaca6ee2015-01-06 12:18:17 -0800112 swapon.c \
113 sync_file_range.c \
Elliott Hughesbb0c2d52014-01-07 17:34:14 -0800114 syscall.c \
Elliott Hughescaca6ee2015-01-06 12:18:17 -0800115 sysctl.c \
Elliott Hughes5a9d3b92014-10-03 09:50:14 -0700116 sysinfo.c \
Elliott Hughescaca6ee2015-01-06 12:18:17 -0800117 syslog.c \
118 sysmips.c \
Elliott Hughesbb0c2d52014-01-07 17:34:14 -0800119 term.c \
120 time.c \
Elliott Hughescaca6ee2015-01-06 12:18:17 -0800121 truncate.c \
122 uid16.c \
123 uid.c \
124 umask.c \
125 umount.c \
126 uname.c \
Elliott Hughesbb0c2d52014-01-07 17:34:14 -0800127 util.c \
Elliott Hughescaca6ee2015-01-06 12:18:17 -0800128 utime.c \
129 utimes.c \
130 v4l2.c \
Elliott Hughes5dec78d2014-02-26 15:56:23 -0800131 vsprintf.c \
Elliott Hughescaca6ee2015-01-06 12:18:17 -0800132 wait.c \
133 xattr.c \
The Android Open Source Project34d6eab2009-03-03 19:30:45 -0800134
135LOCAL_SHARED_LIBRARIES :=
136
Elliott Hughes15fc6a22014-01-09 10:30:06 -0800137LOCAL_CFLAGS := \
138 -DGETGROUPS_T=gid_t \
139 -DHAVE_ASM_SIGCONTEXT_H=1 \
140 -DHAVE_DECL_PTRACE_EVENT_FORK=1 \
141 -DHAVE_DECL_PTRACE_EVENT_VFORK=1 \
142 -DHAVE_DECL_PTRACE_EVENT_CLONE=1 \
143 -DHAVE_DECL_PTRACE_EVENT_EXEC=1 \
144 -DHAVE_DECL_PTRACE_EVENT_VFORK_DONE=1 \
145 -DHAVE_DECL_PTRACE_EVENT_EXIT=1 \
146 -DHAVE_DECL_PTRACE_GETEVENTMSG=1 \
147 -DHAVE_DECL_PTRACE_GETSIGINFO=1 \
148 -DHAVE_DECL_PTRACE_O_TRACECLONE=1 \
149 -DHAVE_DECL_PTRACE_O_TRACEEXEC=1 \
150 -DHAVE_DECL_PTRACE_O_TRACEEXIT=1 \
151 -DHAVE_DECL_PTRACE_O_TRACEFORK=1 \
152 -DHAVE_DECL_PTRACE_O_TRACESYSGOOD=1 \
153 -DHAVE_DECL_PTRACE_O_TRACEVFORK=1 \
154 -DHAVE_DECL_PTRACE_SETOPTIONS=1 \
155 -UHAVE_DECL_IO_CMD_PWRITE \
156 -UHAVE_DECL_IO_CMD_PWRITEV \
157 -UHAVE_DECL_LO_FLAGS_AUTOCLEAR \
158 -UHAVE_DECL_LO_FLAGS_PARTSCAN \
159 -DHAVE_DECL_SYS_ERRLIST=1 \
Elliott Hughesa7f55552014-01-09 16:07:59 -0800160 -DHAVE_ELF_H=1 \
Elliott Hughes9e25f2c2014-10-03 11:01:13 -0700161 -DHAVE_FOPEN64=1 \
Elliott Hughes15fc6a22014-01-09 10:30:06 -0800162 -DHAVE_FORK=1 \
163 -DHAVE_IF_INDEXTONAME=1 \
164 -DHAVE_INET_NTOP=1 \
165 -DHAVE_LINUX_CAPABILITY_H=1 \
Elliott Hughescaca6ee2015-01-06 12:18:17 -0800166 -DHAVE_LINUX_FALLOC_H=1 \
Elliott Hughes9e25f2c2014-10-03 11:01:13 -0700167 -DHAVE_LINUX_FUTEX_H=1 \
Elliott Hughes15fc6a22014-01-09 10:30:06 -0800168 -DHAVE_LINUX_ICMP_H=1 \
169 -DHAVE_LINUX_IF_PACKET_H=1 \
170 -DHAVE_LINUX_IN6_H=1 \
171 -DHAVE_LINUX_NETLINK_H=1 \
Elliott Hughes9e25f2c2014-10-03 11:01:13 -0700172 -DHAVE_LINUX_PERF_EVENT_H=1 \
Elliott Hughes15fc6a22014-01-09 10:30:06 -0800173 -DHAVE_LITTLE_ENDIAN_LONG_LONG=1 \
174 -DHAVE_LONG_LONG=1 \
175 -DHAVE_NETINET_TCP_H=1 \
176 -DHAVE_NETINET_UDP_H=1 \
177 -DHAVE_POLL_H=1 \
178 -DHAVE_PRCTL=1 \
Elliott Hughes9e25f2c2014-10-03 11:01:13 -0700179 -DHAVE_PWRITEV=1 \
Elliott Hughes15fc6a22014-01-09 10:30:06 -0800180 -DHAVE_SENDMSG=1 \
181 -DHAVE_SIGACTION=1 \
Elliott Hughes15fc6a22014-01-09 10:30:06 -0800182 -DHAVE_SIG_ATOMIC_T=1 \
Elliott Hughes9e25f2c2014-10-03 11:01:13 -0700183 -DHAVE_SIGINFO_T=1 \
184 -DHAVE_SIGINFO_T_SI_SYSCALL=1 \
Elliott Hughesad8fa132014-10-03 11:56:40 -0700185 -UHAVE_STAT64 \
Elliott Hughes15fc6a22014-01-09 10:30:06 -0800186 -DHAVE_STATFS64=1 \
187 -DHAVE_STDBOOL_H=1 \
188 -DHAVE_STRERROR=1 \
Elliott Hughes5dec78d2014-02-26 15:56:23 -0800189 -DHAVE_STRUCT_FLOCK64=1 \
Elliott Hughescaca6ee2015-01-06 12:18:17 -0800190 -DHAVE_STRUCT_MMSGHDR=1 \
Elliott Hughes15fc6a22014-01-09 10:30:06 -0800191 -DHAVE_STRUCT_MSGHDR_MSG_CONTROL=1 \
Elliott Hughes4e779b42014-05-07 09:10:38 -0700192 -DHAVE_STRUCT_SIGCONTEXT=1 \
193 -DHAVE_STRUCT_SIGEVENT__SIGEV_UN__PAD=1 \
Elliott Hughes15fc6a22014-01-09 10:30:06 -0800194 -DHAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID=1 \
Elliott Hughes9e25f2c2014-10-03 11:01:13 -0700195 -DHAVE_STRUCT_STAT_ST_ACLCNT=0 \
Elliott Hughes15fc6a22014-01-09 10:30:06 -0800196 -DHAVE_STRUCT_STAT_ST_BLKSIZE=1 \
197 -DHAVE_STRUCT_STAT_ST_BLOCKS=1 \
Elliott Hughes9e25f2c2014-10-03 11:01:13 -0700198 -DHAVE_STRUCT_STAT_ST_FLAGS=0 \
199 -DHAVE_STRUCT_STAT_ST_FSTYPE=0 \
200 -DHAVE_STRUCT_STAT_ST_GEN=0 \
201 -DHAVE_STRUCT_STAT_ST_LEVEL=0 \
Elliott Hughes15fc6a22014-01-09 10:30:06 -0800202 -DHAVE_STRUCT_STAT_ST_RDEV=1 \
Elliott Hughes37be67d2014-10-03 09:58:58 -0700203 -DHAVE_STRUCT_SYSINFO_FREEHIGH=1 \
204 -DHAVE_STRUCT_SYSINFO_MEM_UNIT=1 \
205 -DHAVE_STRUCT_SYSINFO_TOTALHIGH=1 \
Elliott Hughes9e25f2c2014-10-03 11:01:13 -0700206 -DHAVE_STRUCT_UTSNAME_DOMAINNAME=1 \
Elliott Hughes15fc6a22014-01-09 10:30:06 -0800207 -DHAVE_SYS_EPOLL_H=1 \
208 -DHAVE_SYS_IOCTL_H=1 \
209 -DHAVE_SYS_POLL_H=1 \
210 -DHAVE_SYS_REG_H=1 \
211 -DHAVE_SYS_VFS_H=1 \
212 -DMAJOR_IN_SYSMACROS \
213 -DPACKAGE_NAME='"strace"' \
214 -DVERSION='"$(strace_version)"' \
Elliott Hughes556f9ae2014-03-03 16:08:32 -0800215 -DSIZEOF_OFF_T=SIZEOF_LONG \
Elliott Hughes15fc6a22014-01-09 10:30:06 -0800216 -DSIZEOF_LONG_LONG=8 \
217 -DSTDC_HEADERS=1 \
Elliott Hughes5dec78d2014-02-26 15:56:23 -0800218 -DSTRACE_KNOWS_ONLY_EABI=1 \
Elliott Hughes15fc6a22014-01-09 10:30:06 -0800219 -D_LFS64_LARGEFILE=1 \
220
221LOCAL_CFLAGS += -D_GNU_SOURCE=1 -D_POSIX_SOURCE=1
Elliott Hughesbb0c2d52014-01-07 17:34:14 -0800222
Elliott Hughes4ce18c82014-04-09 19:23:30 -0700223LOCAL_CFLAGS_32 += -DSIZEOF_LONG=4 -DSIZEOF_RLIM_T=4 -DHAVE_STAT64=1
Colin Crossd6b039c2014-01-29 18:09:48 -0800224LOCAL_CFLAGS_64 += -DSIZEOF_LONG=8 -DSIZEOF_RLIM_T=8
Jeff Brownf76f96e2012-03-02 16:23:23 -0800225
Colin Crossd6b039c2014-01-29 18:09:48 -0800226LOCAL_CFLAGS_arm += -DARM=1
227LOCAL_CFLAGS_arm += -DHAVE_STRUCT___OLD_KERNEL_STAT=1
228
229LOCAL_CFLAGS_arm64 += -DAARCH64=1
230
231LOCAL_CFLAGS_mips += -DMIPS=1
232LOCAL_CFLAGS_mips += -DHAVE_ASM_SYSMIPS_H=1
233
Raghu Gandham55776012014-08-29 12:20:30 -0700234LOCAL_CFLAGS_mips64 += -DMIPS=1
235LOCAL_CFLAGS_mips64 += -DHAVE_ASM_SYSMIPS_H=1
236
Colin Crossd6b039c2014-01-29 18:09:48 -0800237LOCAL_CFLAGS_x86 += -DI386=1
238LOCAL_CFLAGS_x86 += -DHAVE_STRUCT___OLD_KERNEL_STAT=1
239
Elliott Hughes4ce18c82014-04-09 19:23:30 -0700240LOCAL_CFLAGS_x86_64 += -DX86_64=1
Lorenzo Colittia0b125c2009-08-20 15:06:43 -0700241
Elliott Hughesbb0c2d52014-01-07 17:34:14 -0800242LOCAL_CFLAGS += \
Elliott Hughes10bd42d2014-01-08 16:34:09 -0800243 -Wall \
Elliott Hughes1f72dc72014-09-22 10:04:17 -0700244 -Wwrite-strings \
245 -Wsign-compare \
Elliott Hughesbb0c2d52014-01-07 17:34:14 -0800246 -Wno-missing-field-initializers \
247 -Wno-unused-parameter \
248 -Wno-sign-compare \
Jeff Brownf76f96e2012-03-02 16:23:23 -0800249
The Android Open Source Project34d6eab2009-03-03 19:30:45 -0800250LOCAL_C_INCLUDES := \
Elliott Hughes15fc6a22014-01-09 10:30:06 -0800251 $(LOCAL_PATH)/linux
The Android Open Source Project34d6eab2009-03-03 19:30:45 -0800252
Colin Crossd6b039c2014-01-29 18:09:48 -0800253LOCAL_C_INCLUDES_arm := $(LOCAL_PATH)/linux/arm
254LOCAL_C_INCLUDES_arm64 := $(LOCAL_PATH)/linux/aarch64
255LOCAL_C_INCLUDES_mips := $(LOCAL_PATH)/linux/mips
Duane Sand2cafa722014-05-20 12:57:09 -0700256LOCAL_C_INCLUDES_mips64 := $(LOCAL_PATH)/linux/mips
Colin Crossd6b039c2014-01-29 18:09:48 -0800257LOCAL_C_INCLUDES_x86 := $(LOCAL_PATH)/linux/i386
258LOCAL_C_INCLUDES_x86_64 := $(LOCAL_PATH)/linux/x86_64
259
The Android Open Source Project34d6eab2009-03-03 19:30:45 -0800260LOCAL_MODULE := strace
261
262LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
263
264LOCAL_MODULE_TAGS := debug
265
Elliott Hughesbb0c2d52014-01-07 17:34:14 -0800266LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
267
The Android Open Source Project34d6eab2009-03-03 19:30:45 -0800268include $(BUILD_EXECUTABLE)
Elliott Hughes7c538322014-02-28 10:32:04 -0800269
Elliott Hughes858a5c72014-02-28 15:58:12 -0800270
Elliott Hughes7c538322014-02-28 10:32:04 -0800271# -------------------------------------------------------------------------
272
273.PHONY: update-ioctls
274update-ioctls:
275 # Build the generated .h files needed by ioctlsort from the current bionic uapi headers.
276 cd external/strace; ./linux/ioctlent.sh ../../bionic/libc/kernel/uapi/
277 # Build the ioctlsort tool.
278 ONE_SHOT_MAKEFILE=external/strace/Android.mk make -f build/core/main.mk $(TARGET_OUT_EXECUTABLES)/ioctlsort
279 # Remove the generated .h files now we've built ioctlsort.
280 rm external/strace/ioctls.h external/strace/ioctldefs.h
281 # Run the ioctlsort tool on the target to generate the one file we do want to check in.
282 adb sync
Elliott Hughescaca6ee2015-01-06 12:18:17 -0800283 adb shell ioctlsort | tr -d '\r' | sed 's/^\([[:space:]]*{\)"[^"]\+",[[:space:]]*/\1/' | sort -u -k2,2 -k1,1 > external/strace/linux/ioctlent.h
Elliott Hughes7c538322014-02-28 10:32:04 -0800284 # Rebuild strace with the new "ioctlent.h".
285 ONE_SHOT_MAKEFILE=external/strace/Android.mk make -f build/core/main.mk
286
287# We don't build ioctlsort unless really necessary, because we don't check
288# in the temporary files needed to build it. This tool is only necessary
289# when updating strace's list of ioctls.
Elliott Hughes16488d52014-06-06 22:58:11 -0700290ifneq (,$(filter $(TARGET_OUT_EXECUTABLES)/ioctlsort,$(MAKECMDGOALS)))
Elliott Hughes7c538322014-02-28 10:32:04 -0800291include $(CLEAR_VARS)
Elliott Hughescaca6ee2015-01-06 12:18:17 -0800292LOCAL_SRC_FILES := ioctlsort.c
Elliott Hughes7c538322014-02-28 10:32:04 -0800293LOCAL_CFLAGS += -include asm/types.h -include linux/ashmem.h
294LOCAL_CFLAGS += -Wno-unused-parameter
295LOCAL_MODULE := ioctlsort
296LOCAL_MODULE_TAGS := optional
297LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
298include $(BUILD_EXECUTABLE)
299endif
300
301# -------------------------------------------------------------------------
302
Elliott Hughes858a5c72014-02-28 15:58:12 -0800303include $(LOCAL_PATH)/test/Android.mk