xref: /netbsd-src/usr.sbin/crash/Makefile (revision 53d1339bf7f9c7367b35a9e1ebe693f9b047a47b)
1#	$NetBSD: Makefile,v 1.46 2021/04/13 08:55:06 mrg Exp $
2
3PROG=		crash
4MAN=		crash.8
5RUMPKERNEL=	yes	# XXX: Avoid -mcmodel=kernel
6
7CWARNFLAGS.clang+=	-Wno-format
8
9LDADD+=	-lutil -lkvm -ledit -lterminfo
10DPADD+=	${LIBUTIL} ${LIBKVM} ${LIBEDIT} ${LIBTERMINFO}
11
12.include <bsd.own.mk>
13
14# some ddb kernel components need limited modifications.  for now,
15# punt if not noted as implemented here.
16.if    ${MACHINE} == "amd64" \
17    || ${MACHINE} == "hppa" \
18    || ${MACHINE} == "i386" \
19    || ${MACHINE} == "sparc" \
20    || ${MACHINE} == "sparc64" \
21    || ${MACHINE_CPU} == "arm" \
22    || ${MACHINE_CPU} == "aarch64" \
23    || ${MACHINE_CPU} == "mips" \
24    || ${MACHINE_ARCH} == "m68k"
25SRCS+=	db_trace.c
26.if ${MACHINE_CPU} == "mips"
27SRCS+=	db_interface.c mips_stacktrace.c
28CPPFLAGS+=	-DDDB
29.elif ${MACHINE_ARCH} != "m68k"
30SRCS+=	db_machdep.c
31.endif
32REALCRASH=yes
33.else
34REALCRASH=no
35.endif
36
37.if ${REALCRASH} != "no"	# {
38
39S=		${.CURDIR}/../../sys
40
41CPPFLAGS+=	-I${.CURDIR} -I${.OBJDIR} -I${S} -fno-strict-aliasing
42CPPFLAGS+=	-DDDB_VERBOSE_HELP -DDB_MAX_LINE=10000000 -D_KMEMUSER
43CPPFLAGS+=	-UDB_MACHINE_COMMANDS
44
45# ddb files from kernel
46.PATH:	$S/ddb
47SRCS+=	db_command.c db_lwp.c db_proc.c db_xxx.c db_cpu.c
48SRCS+=  db_autoconf.c
49SRCS+=	db_access.c db_elf.c db_examine.c
50SRCS+=	db_expr.c db_lex.c db_output.c db_print.c
51SRCS+=	db_sym.c db_variables.c db_write_cmd.c
52
53.PATH:	${S}/arch/${MACHINE}/${MACHINE}
54.PATH:	${S}/arch/${MACHINE_ARCH}/${MACHINE_ARCH}
55SRCS+=	db_disasm.c
56
57.PATH:  $S/kern
58SRCS+=	kern_timeout.c
59CPPFLAGS.kern_timeout.c += -DCRASH -DDDB
60
61CPPFLAGS +=-DLOCKDEBUG
62SRCS += subr_lockdebug.c
63CPPFLAGS.subr_lockdebug.c += -DCRASH -DDDB
64
65CPPFLAGS+=	-I${S}/arch
66
67. if    ${MACHINE} == "amd64" \
68     || ${MACHINE} == "i386"
69MACHINE_FAMILY = x86
70. elif  ${MACHINE} == "sparc64"
71MACHINE_FAMILY = sparc
72. else
73MACHINE_FAMILY = ${MACHINE_CPU}
74. endif
75
76.if ${MACHINE_CPU} == "arm"
77.PATH:	${S}/arch/arm/arm32
78SRCS+=disassem.c cpufunc_asm.S
79.endif
80.if ${MACHINE_CPU} == "aarch64"
81SRCS+=disasm.c
82.endif
83
84.PATH:	${S}/arch/${MACHINE_FAMILY}/${MACHINE_FAMILY}
85
86# crash main source
87SRCS+=	crash.c
88
89# arch.c
90.PATH:	${.CURDIR}/arch
91. if (exists(${.CURDIR}/arch/${MACHINE_FAMILY}.c))
92SRCS+=	${MACHINE_FAMILY}.c
93. else
94SRCS+=	generic.c
95. endif
96
97COPTS.db_output.c += -Wno-format-nonliteral
98
99.if ${MKREPRO} == "yes"
100.       if ${MKREPRO_TIMESTAMP:U0} != 0
101NVFLAGS+=-r ${MKREPRO_TIMESTAMP}
102.       else
103NVFLAGS+=-R
104.       endif
105.endif
106
107# vers.c
108SRCS+=	vers.c
109vers.c:	${S}/conf/newvers.sh ${_NETBSD_VERSION_DEPENDS}
110	${HOST_SH} ${S}/conf/newvers.sh ${NVFLAGS} -n -m ${MACHINE} -i CRASH
111CLEANFILES+=	vers.c version
112
113.else				# } {
114
115SRCS+=	unsupported.c
116
117.endif				# }
118
119.if  ${MACHINE} == "sparc" \
120    || ${MACHINE} == "sparc64"
121COPTS.kern_timeout.c += -Wno-stack-protector
122.endif
123
124.include "../../compat/exec.mk"
125
126COPTS.db_command.c+=	${GCC_NO_CAST_FUNCTION_TYPE}
127
128COPTS+=		-fcommon
129
130.include <bsd.prog.mk>
131.include <bsd.klinks.mk>
132