xref: /freebsd/usr.bin/truss/Makefile (revision 39ee7a7a6bdd1557b1c3532abf60d139798ac88b)
1# $FreeBSD$
2
3NO_WERROR=
4PROG=	truss
5SRCS=	main.c setup.c syscalls.c ioctl.c
6
7.PATH:	${.CURDIR:H}/kdump
8SRCS+=	utrace.c
9
10CFLAGS+= -I${.CURDIR} -I. -I${.CURDIR}/../../sys
11CLEANFILES= ioctl.c
12
13ioctl.c: ${.CURDIR}/../kdump/mkioctls
14	env MACHINE=${MACHINE} CPP="${CPP}" \
15		/bin/sh ${.CURDIR}/../kdump/mkioctls return ${DESTDIR}${INCLUDEDIR} > ${.TARGET}
16
17# Define where to generate syscalls for each ABI.
18ABI_SYSPATH.freebsd=		sys/kern
19ABI_SYSPATH.freebsd32=		sys/compat/freebsd32
20ABI_SYSPATH.cloudabi64=		sys/compat/cloudabi64
21ABI_SYSPATH.i386-linux=		sys/i386/linux
22ABI_SYSPATH.amd64-linux32=	sys/amd64/linux32
23
24ABIS+=		freebsd
25# Each ABI is expected to have an ABI.c, MACHINE_ARCH-ABI.c or
26# MACHINE_CPUARCH-ABI.c file that will be used to map the syscall arguments.
27.if ${MACHINE_CPUARCH} == "i386"
28ABIS+=		i386-linux
29.endif
30.if ${MACHINE_CPUARCH} == "amd64"
31ABIS+=		amd64-linux32
32ABIS+=		freebsd32
33ABIS+=		cloudabi64
34.endif
35.if ${MACHINE_ARCH} == "powerpc64"
36ABIS+=		freebsd32
37.endif
38
39.for abi in ${ABIS}
40# Find the right file to handle this ABI.
41abi_src=
42ABI_SRCS=	${abi}.c ${MACHINE_ARCH}-${abi}.c ${MACHINE_CPUARCH}-${abi}.c
43.for f in ${ABI_SRCS}
44.if exists(${.CURDIR}/${f}) && empty(abi_src)
45abi_src=	${f}
46.endif
47.endfor
48SRCS:=		${SRCS} ${abi_src} ${abi}_syscalls.h
49CLEANFILES+=	${abi}_syscalls.conf ${abi}_syscalls.master ${abi}_syscalls.h
50${abi}_syscalls.conf: ${.CURDIR}/makesyscallsconf.sh
51	/bin/sh ${.CURDIR}/makesyscallsconf.sh ${abi} ${.TARGET}
52
53${abi}_syscalls.master:	${.CURDIR:H:H}/${ABI_SYSPATH.${abi}}/syscalls.master
54	cp -f ${.ALLSRC} ${.TARGET}
55
56${abi}_syscalls.h:	${abi}_syscalls.master ${abi}_syscalls.conf \
57			${.CURDIR:H:H}/sys/kern/makesyscalls.sh
58	/bin/sh ${.CURDIR:H:H}/sys/kern/makesyscalls.sh \
59	    ${abi}_syscalls.master ${abi}_syscalls.conf
60# Eliminate compiler warning about non-static global.
61	sed -i '' '/^const char \*/s/^/static /' ${.TARGET}.tmp
62	mv ${.TARGET}.tmp ${.TARGET}
63.endfor
64
65.include <bsd.prog.mk>
66