1#	$NetBSD: Makefile,v 1.27 2023/10/07 12:15:50 rin Exp $
2
3NOLINKLIB=	# defined
4NOLINT=		# defined
5NOMAN=		# defined
6NOPROFILE=	# defined
7NOCLANGERROR=	# defined
8
9.include <bsd.init.mk>
10
11# If the platform does not support shared libraries, we need to supply
12# *something* for BFD-using programs to link against.  Also provide an
13# empty libinstall target so that libbfd.a does not get installed.
14.if ${MKPIC} == "no"
15MKLINKLIB=	yes
16libinstall:	# do nothing
17.endif
18
19LIB=		bfd
20
21BFD_MACHINE_ARCH?=	${MACHINE_ARCH:C/armv[4-7]/arm/}
22
23DEFS_MK=${.CURDIR}/arch/${BFD_MACHINE_ARCH}/defs.mk
24# XXX: Fix me
25BINDIR=/usr/bin
26BINDIR=/usr/lib
27
28.if exists(${DEFS_MK})
29.include "${DEFS_MK}"
30
31SHLIB_MAJOR=	18
32SHLIB_MINOR=	0
33
34LIBDPLIBS+=	z	${.CURDIR}/../../../../../lib/libz
35
36GCPPFLAGS=	${G_archdefs} ${G_DEFS} ${G_INCLUDES} ${G_TDEFAULTS}
37GCPPFLAGS+=	${G_HAVEVECS}
38
39CPPFLAGS+=	-I${.CURDIR}/arch/${BFD_MACHINE_ARCH} -I${DIST}/include -I. \
40		-I${DIST}/bfd ${GCPPFLAGS:M-D*} ${GCPPFLAGS:M-I*:N-I.*} \
41		-DDEBUGDIR=\"${DEBUGDIR}\" -DLIBDIR=\"${LIBDIR}\" \
42		-DBINDIR=\"${BINDIR}\"
43
44COPTS.pei-x86_64.c+=	-Wno-stack-protector
45COPTS.elfxx-mips.c+=	-Wno-stack-protector
46COPTS.elf.c+=		${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 10:? -Wno-overflow :}
47
48GSRCS=		${G_libbfd_la_OBJECTS:libbfd.lo=lib_bfd.lo} \
49		${G_libbfd_la_DEPENDENCIES:M*.lo}
50SRCS=		${GSRCS:.lo=.c}
51
52DPSRCS+=	elf32-target.h elf64-target.h targmatch.h \
53		elf32-aarch64.c elf64-aarch64.c \
54		elf32-ia64.c elf64-ia64.c \
55		elf32-riscv.c elf64-riscv.c \
56		peigen.c pepigen.c \
57		pex64igen.c
58CLEANFILES+=	elf32-target.h elf64-target.h targmatch.h \
59		elf32-aarch64.c elf64-aarch64.c \
60		elf32-ia64.c elf64-ia64.c \
61		elf32-riscv.c elf64-riscv.c \
62		peigen.c pepigen.c \
63		pex64igen.c
64
65TEXINFO=	bfd.texinfo
66INFOFLAGS=	-I${DIST}/bfd/doc
67
68.PATH: ${DIST}/bfd ${DIST}/bfd/doc
69
70.include <bsd.lib.mk>
71.include <bsd.info.mk>
72
73${OBJS} ${SOBJS}: elf32-target.h elf64-target.h
74targets.o targets.pico: targmatch.h Makefile
75.else
76.include <bsd.prog.mk> # do nothing
77.endif
78
79targmatch.h: config.bfd targmatch.sed
80	${_MKTARGET_CREATE}
81	${TOOL_SED} -f ${.ALLSRC:M*.sed} ${.ALLSRC:M*.bfd} >$@
82
83elf32-target.h: elfxx-target.h
84	${_MKTARGET_CREATE}
85	${TOOL_SED} -e s/NN/32/g < $> > $@
86
87elf64-target.h: elfxx-target.h
88	${_MKTARGET_CREATE}
89	${TOOL_SED} -e s/NN/64/g < $> > $@
90
91elf32-aarch64.c: elfnn-aarch64.c
92	${_MKTARGET_CREATE}
93	${TOOL_SED} -e s/NN/32/g < $> > $@
94
95elf64-aarch64.c: elfnn-aarch64.c
96	${_MKTARGET_CREATE}
97	${TOOL_SED} -e s/NN/64/g < $> > $@
98
99elf32-ia64.c: elfnn-ia64.c
100	${_MKTARGET_CREATE}
101	${TOOL_SED} -e s/NN/32/g < $> > $@
102
103elf64-ia64.c: elfnn-ia64.c
104	${_MKTARGET_CREATE}
105	${TOOL_SED} -e s/NN/64/g < $> > $@
106
107elf32-riscv.c: elfnn-riscv.c
108	${_MKTARGET_CREATE}
109	${TOOL_SED} -e s/NN/32/g < $> > $@
110
111elf64-riscv.c: elfnn-riscv.c
112	${_MKTARGET_CREATE}
113	${TOOL_SED} -e s/NN/64/g < $> > $@
114
115peigen.c: peXXigen.c
116	${_MKTARGET_CREATE}
117	${TOOL_SED} -e s/XX/pe/g < $> > $@
118
119pepigen.c: peXXigen.c
120	${_MKTARGET_CREATE}
121	${TOOL_SED} -e s/XX/pep/g < $> > $@
122
123pex64igen.c: peXXigen.c
124	${_MKTARGET_CREATE}
125	${TOOL_SED} -e s/XX/pex64/g < $> > $@
126
127pe-aarch64igen.c: peXXigen.c
128	${_MKTARGET_CREATE}
129	${TOOL_SED} -e s/XX/peAArch64/g < $> > $@
130