1 1.6 christos # $NetBSD: Makefile,v 1.6 2018/04/14 17:53:18 christos Exp $ 2 1.1 christos 3 1.2 christos CPPFLAGS+= -I${.CURDIR}/arch/${BINUTILS_MACHINE_ARCH} \ 4 1.2 christos -I${DIST}/ld \ 5 1.2 christos -DDEFAULT_EMULATION=\"${G_EMUL}\" \ 6 1.2 christos -DSCRIPTDIR=\"${SCRIPTSDIR}\" \ 7 1.2 christos -DTARGET=\"${G_target_alias}\" \ 8 1.2 christos -DBINDIR=\"/usr/bin\" \ 9 1.2 christos -DTOOLBINDIR=\"/usr/bin\" \ 10 1.4 christos -DENABLE_PLUGINS \ 11 1.4 christos -DELF_LIST_OPTIONS=TRUE \ 12 1.4 christos -DELF_SHLIB_LIST_OPTIONS=TRUE \ 13 1.4 christos -DELF_PLT_UNWIND_LIST_OPTIONS=TRUE 14 1.1 christos 15 1.1 christos .include "${.CURDIR}/../common/Makefile.inc" 16 1.1 christos .include "${.CURDIR}/arch/${BINUTILS_MACHINE_ARCH}/defs.mk" 17 1.1 christos 18 1.1 christos SCRIPTSDIR= /usr/libdata 19 1.1 christos 20 1.1 christos PROG= ld 21 1.1 christos SRCS= ${G_OFILES:.o=.c} 22 1.1 christos 23 1.1 christos COPTS.ldgram.c = -Wno-stack-protector 24 1.1 christos 25 1.1 christos PROGDPLIBS+= bfd ${TOP}/${BFDSUBDIR}/libbfd 26 1.1 christos PROGDPLIBS+= iberty ${TOP}/${BFDSUBDIR}/libiberty 27 1.1 christos 28 1.1 christos TEXINFO= ${G_TEXINFOS} 29 1.1 christos COMMONOBJDIR!= cd ${TOP}/usr.bin/common && ${PRINTOBJDIR} 30 1.1 christos INFOFLAGS= -I${COMMONOBJDIR} -I${DIST}/ld -I${DIST}/bfd/doc -I${DIST}/libiberty 31 1.1 christos 32 1.1 christos FILESDIR= ${SCRIPTSDIR}/ldscripts 33 1.1 christos 34 1.1 christos .PATH: ${COMMONOBJDIR} ${DIST}/ld ${DIST}/ld/emulparams \ 35 1.1 christos ${DIST}/ld/emultempl ${DIST}/ld/scripttempl ldscripts 36 1.1 christos 37 1.1 christos BUILDSYMLINKS+= ${G_STRINGIFY} stringify.sed 38 1.1 christos BUILDSYMLINKS+= gen-doc.texi configdoc.texi 39 1.1 christos 40 1.1 christos ${PROG}.info: configdoc.texi bfdver.texi 41 1.1 christos 42 1.1 christos .for f in ${G_EMULATION_OFILES:S/^e//:R} 43 1.1 christos .if exists(.depend.${f}) && !(make(clean) || make(cleandir)) 44 1.1 christos .include ".depend.${f}" 45 1.1 christos .endif 46 1.1 christos 47 1.1 christos .depend.${f}: ${f}.sh 48 1.1 christos ${_MKTARGET_CREATE} 49 1.1 christos (srcdir=${DIST}/ld EMULATION_NAME=$f . ${>:M*.sh} && \ 50 1.1 christos if [ x"$$TEMPLATE_NAME" != x ]; then \ 51 1.1 christos temp_name=$$TEMPLATE_NAME.em; \ 52 1.1 christos else \ 53 1.1 christos temp_name=; \ 54 1.1 christos fi; \ 55 1.1 christos if [ x"$$SCRIPT_NAME" != x ]; then \ 56 1.1 christos script=$$SCRIPT_NAME.sc; \ 57 1.1 christos else \ 58 1.1 christos script=; \ 59 1.1 christos fi; \ 60 1.1 christos echo "e${f}.c: $$temp_name $$script" \ 61 1.1 christos ) >$@ 62 1.1 christos 63 1.1 christos DPSRCS+= .depend.${f} e${f}.c 64 1.1 christos CLEANFILES+= .depend.${f} e${f}.c 65 1.1 christos 66 1.1 christos # XXX super hack 67 1.1 christos . if (${BINUTILS_MACHINE_ARCH} == "x86_64" && \ 68 1.1 christos ("${f}" == "elf_i386" || "${f}" == "i386nbsd")) 69 1.1 christos EMUL_LIB_PATH.${f}=/usr/lib/i386 70 1.1 christos . elif (${BINUTILS_MACHINE_ARCH} == "sparc64" && \ 71 1.1 christos ("${f}" == "elf32_sparc" || "${f}" == "sparcnbsd")) 72 1.1 christos EMUL_LIB_PATH.${f}=/usr/lib/sparc 73 1.4 christos . elif !empty(BINUTILS_MACHINE_ARCH:Mmips64*) 74 1.1 christos . if "${f}" == "elf32ltsmip" || "${f}" == "elf32btsmip" 75 1.1 christos EMUL_LIB_PATH.${f}:=/usr/lib/o32 76 1.1 christos . elif "${f}" == "elf64ltsmip" || "${f}" == "elf64btsmip" 77 1.1 christos EMUL_LIB_PATH.${f}:=/usr/lib/64 78 1.1 christos . else 79 1.1 christos EMUL_LIB_PATH.${f}=/usr/lib 80 1.1 christos . endif 81 1.1 christos . else 82 1.1 christos EMUL_LIB_PATH.${f}=/usr/lib 83 1.1 christos . endif 84 1.1 christos 85 1.1 christos e${f}.c: ${DIST}/ld/genscripts.sh ${.CURDIR}/Makefile stringify.sed 86 1.1 christos ${_MKTARGET_CREATE} 87 1.1 christos unset MACHINE || true; \ 88 1.1 christos LIB_PATH=${EMUL_LIB_PATH.${f}} NATIVE=yes \ 89 1.4 christos ${HOST_SH} ${DIST}/ld/genscripts.sh ${DIST}/ld \ 90 1.4 christos ${LIBDIR} "/usr" "/usr/bin" \ 91 1.1 christos ${G_target_alias} ${G_target_alias} ${G_target_alias} \ 92 1.4 christos ${G_EMUL} ${LIBDIR} yes ${G_enable_initfini_array} \ 93 1.4 christos ${f} "${G_target_alias}" 94 1.1 christos 95 1.4 christos . if ${BINUTILS_MACHINE_ARCH} == "x86_64" || \ 96 1.4 christos ${BINUTILS_MACHINE_ARCH} == "sparc64" || \ 97 1.4 christos !empty(BINUTILS_MACHINE_ARCH:Maarch64*) || \ 98 1.4 christos !empty(BINUTILS_MACHINE_ARCH:Mearm*) || \ 99 1.4 christos !empty(BINUTILS_MACHINE_ARCH:Marm*) || \ 100 1.4 christos !empty(BINUTILS_MACHINE_ARCH:Mmips64*) 101 1.4 christos . for e in x xbn xc xd xdc xdw xn xr xs xsc xsw xu xw 102 1.4 christos . if exists(ldscripts/${f}.${e}) 103 1.4 christos FILES+= ${f}.${e} 104 1.4 christos . endif 105 1.4 christos . endfor 106 1.4 christos . endif 107 1.1 christos .endfor 108 1.1 christos 109 1.1 christos .include <bsd.prog.mk> 110 1.1 christos .include <bsd.info.mk> 111 1.1 christos .include <bsd.subdir.mk> 112 1.1 christos 113 1.1 christos # Make sure we use the pre-generated C files 114 1.1 christos .l.c .y.c .y.h: 115 1.1 christos @true 116 1.1 christos 117 1.1 christos cleandir: __cleanldscripts 118 1.1 christos __cleanldscripts: 119 1.1 christos -rm -rf ldscripts tmpdir 120 1.1 christos 121 1.1 christos LDADD+= -lintl -lz 122 1.1 christos DPADD+= ${LIBINTL} ${LIBZ} 123