2013-07-18 21:58:13 +00:00
|
|
|
# $NetBSD: Makefile,v 1.121 2013/07/18 21:58:13 matt Exp $
|
2009-05-20 19:38:38 +00:00
|
|
|
#
|
|
|
|
# NOTE: when changing ld.so, ensure that ldd still compiles.
|
|
|
|
#
|
2009-03-16 02:24:55 +00:00
|
|
|
|
2009-05-19 20:44:52 +00:00
|
|
|
WARNS?=4
|
1996-12-16 20:37:55 +00:00
|
|
|
|
2013-05-03 15:52:31 +00:00
|
|
|
LDELFSO_MACHINE_ARCH?= ${MACHINE_ARCH}
|
|
|
|
|
2009-12-13 09:01:45 +00:00
|
|
|
# This needs to be before bsd.init.mk
|
|
|
|
.if defined(BSD_MK_COMPAT_FILE)
|
|
|
|
.include <${BSD_MK_COMPAT_FILE}>
|
|
|
|
.endif
|
|
|
|
|
2008-10-16 14:36:20 +00:00
|
|
|
# We are not building this with PIE
|
|
|
|
PIE_CFLAGS=
|
|
|
|
PIE_LDFLAGS=
|
remove almost all the ability to build netbsd with an a.out target.
we're ELF now, and there are many missing checks against OBJECT_FMT.
if we ever consider switching, the we can figure out what new ones
we need but for now it's just clutter.
this doesn't remove any of the support for exec_aout or any actually
required-for-boot a.out support, only the ability to build a netbsd
release in a.out format. ie, most of this code has been dead for
over a decade.
i've tested builds on vax, amd64, i386, mac68k, macppc, sparc, atari,
amiga, shark, cats, dreamcast, landisk, mmeye and x68k. this covers
the 5 MACHINE_ARCH's affected, and all the other arch code touched.
it also includes some actual run-time testing of sparc, i386 and
shark, and i performed binary comparison upon amiga and x68k as well.
some minor details relevant:
- move shlib.[ch] from ld.aout_so into ldconfig proper, and cut them
down to only the parts ldconfig needs
- remove various unused source files
- switch amiga bootblocks to using elf2bb.h instead of aout2bb.h
2010-07-06 05:59:50 +00:00
|
|
|
.include <bsd.init.mk> # for MKPIC definition
|
2012-08-23 21:21:14 +00:00
|
|
|
.include <bsd.shlib.mk> # for SHLINKINSTALLDIR definition
|
1998-02-23 10:09:31 +00:00
|
|
|
|
2008-10-26 07:11:54 +00:00
|
|
|
.if defined(LDELFSO_MACHINE_CPU) && !empty(LDELFSO_MACHINE_CPU) && \
|
|
|
|
exists(${.CURDIR}/arch/${LDELFSO_MACHINE_CPU})
|
|
|
|
ARCHSUBDIR= ${LDELFSO_MACHINE_CPU}
|
|
|
|
.else
|
2004-02-23 21:27:20 +00:00
|
|
|
ARCHSUBDIR= ${MACHINE_CPU}
|
2008-10-26 07:11:54 +00:00
|
|
|
.endif
|
2004-02-23 21:27:20 +00:00
|
|
|
M= ${.CURDIR}/arch/${ARCHSUBDIR}
|
1999-03-03 12:00:18 +00:00
|
|
|
|
2013-05-03 15:52:31 +00:00
|
|
|
.if ((${LDELFSO_MACHINE_ARCH} == "alpha") || \
|
2006-08-27 07:22:02 +00:00
|
|
|
(${MACHINE_CPU} == "arm") || \
|
2013-07-18 21:58:13 +00:00
|
|
|
(${LDELFSO_MACHINE_ARCH} == "coldfire") || \
|
2013-05-03 15:52:31 +00:00
|
|
|
(${LDELFSO_MACHINE_ARCH} == "hppa") || \
|
|
|
|
(${LDELFSO_MACHINE_ARCH} == "i386") || \
|
|
|
|
(${LDELFSO_MACHINE_ARCH} == "m68k") || \
|
2006-08-27 07:22:02 +00:00
|
|
|
(${MACHINE_CPU} == "mips") || \
|
2013-05-03 15:52:31 +00:00
|
|
|
(${LDELFSO_MACHINE_ARCH} == "powerpc") || \
|
2006-08-27 07:22:02 +00:00
|
|
|
(${MACHINE_CPU} == "sh3") || \
|
2013-05-03 15:52:31 +00:00
|
|
|
(${LDELFSO_MACHINE_ARCH} == "sparc") || \
|
|
|
|
(${LDELFSO_MACHINE_ARCH} == "sparc64") || \
|
|
|
|
(${LDELFSO_MACHINE_ARCH} == "x86_64") || \
|
|
|
|
(${LDELFSO_MACHINE_ARCH} == "vax")) && \
|
remove almost all the ability to build netbsd with an a.out target.
we're ELF now, and there are many missing checks against OBJECT_FMT.
if we ever consider switching, the we can figure out what new ones
we need but for now it's just clutter.
this doesn't remove any of the support for exec_aout or any actually
required-for-boot a.out support, only the ability to build a netbsd
release in a.out format. ie, most of this code has been dead for
over a decade.
i've tested builds on vax, amd64, i386, mac68k, macppc, sparc, atari,
amiga, shark, cats, dreamcast, landisk, mmeye and x68k. this covers
the 5 MACHINE_ARCH's affected, and all the other arch code touched.
it also includes some actual run-time testing of sparc, i386 and
shark, and i performed binary comparison upon amiga and x68k as well.
some minor details relevant:
- move shlib.[ch] from ld.aout_so into ldconfig proper, and cut them
down to only the parts ldconfig needs
- remove various unused source files
- switch amiga bootblocks to using elf2bb.h instead of aout2bb.h
2010-07-06 05:59:50 +00:00
|
|
|
${MKPIC} != "no"
|
1999-05-07 22:04:27 +00:00
|
|
|
|
2011-05-30 16:30:01 +00:00
|
|
|
LDFLAGS+= ${${ACTIVE_CC} == "clang":? -Wl,-Bsymbolic : -symbolic} \
|
|
|
|
-shared -nostartfiles -nodefaultlibs
|
2006-06-29 19:30:59 +00:00
|
|
|
LDFLAGS+= -Wl,-static
|
2011-01-16 02:36:05 +00:00
|
|
|
LDFLAGS+= -Wl,--warn-shared-textrel
|
|
|
|
|
2012-08-04 15:17:16 +00:00
|
|
|
COPTS+= -fvisibility=hidden
|
2004-02-22 01:39:43 +00:00
|
|
|
|
1997-10-22 05:45:08 +00:00
|
|
|
# Adds SRCS, CPPFLAGS, LDFLAGS, etc. Must go first so MD startup source
|
1996-12-16 20:37:55 +00:00
|
|
|
# is first.
|
1999-03-03 12:00:18 +00:00
|
|
|
.if exists($M/Makefile.inc)
|
|
|
|
.include "$M/Makefile.inc"
|
1997-04-10 17:39:20 +00:00
|
|
|
.endif
|
1996-12-16 20:37:55 +00:00
|
|
|
|
2009-12-13 09:31:47 +00:00
|
|
|
# Support compat ld.elf_so.
|
2009-12-13 08:25:20 +00:00
|
|
|
.if defined(MLIBDIR)
|
2009-12-13 09:31:47 +00:00
|
|
|
PROG= ld.elf_so-${MLIBDIR}
|
|
|
|
CPPFLAGS+= -DRTLD_ARCH_SUBDIR=\"${MLIBDIR}\"
|
2008-10-26 07:11:54 +00:00
|
|
|
.else
|
2009-12-13 09:31:47 +00:00
|
|
|
PROG= ld.elf_so
|
2008-10-26 07:11:54 +00:00
|
|
|
.endif
|
2002-01-04 19:08:04 +00:00
|
|
|
|
2009-12-13 09:31:47 +00:00
|
|
|
CLIBOBJ!= cd ${NETBSDSRCDIR}/lib/libc && ${PRINTOBJDIR}
|
|
|
|
|
2010-12-16 22:47:27 +00:00
|
|
|
SRCS+= rtld.c reloc.c symbol.c xmalloc.c xprintf.c debug.c \
|
2011-03-09 23:10:05 +00:00
|
|
|
map_object.c load.c search.c headers.c paths.c expand.c \
|
2012-03-15 00:16:07 +00:00
|
|
|
tls.c symver.c diagassert.c
|
2001-12-14 22:21:45 +00:00
|
|
|
|
2007-12-26 21:11:52 +00:00
|
|
|
.if ${USE_FORT} == "yes"
|
2007-11-13 15:34:51 +00:00
|
|
|
.PATH.c: ${NETBSDSRCDIR}/lib/libc/misc
|
2007-09-27 17:51:40 +00:00
|
|
|
SRCS+= stack_protector.c
|
2007-12-26 21:11:52 +00:00
|
|
|
.endif
|
2007-10-30 17:19:59 +00:00
|
|
|
|
|
|
|
.PATH.c: ${NETBSDSRCDIR}/lib/libc/stdlib
|
|
|
|
SRCS+= exit.c
|
2007-09-27 17:51:40 +00:00
|
|
|
|
2010-12-16 22:52:32 +00:00
|
|
|
errlist_concat.h: ${NETBSDSRCDIR}/lib/libc/gen/errlist.awk ${NETBSDSRCDIR}/sys/sys/errno.h
|
|
|
|
${TOOL_AWK} -v concat=1 -f ${.ALLSRC} > ${.TARGET}.tmp && \
|
|
|
|
mv -f ${.TARGET}.tmp ${.TARGET}
|
|
|
|
|
|
|
|
xprintf.c: errlist_concat.h
|
|
|
|
|
|
|
|
CLEANFILES+= errlist_concat.h
|
|
|
|
|
2012-08-23 21:21:14 +00:00
|
|
|
BINDIR= ${SHLINKINSTALLDIR}
|
|
|
|
|
2004-02-23 21:27:20 +00:00
|
|
|
CPPFLAGS+= -DLIBDIR=\"${LIBDIR}\" -D_PATH_RTLD=\"${BINDIR}/${PROG}\"
|
2010-12-16 22:52:32 +00:00
|
|
|
CPPFLAGS+= -I${.CURDIR} -I.
|
2004-02-23 21:27:20 +00:00
|
|
|
CPPFLAGS+= -DRTLD_LOADER
|
|
|
|
CPPFLAGS+= -D_RTLD_SOURCE
|
2007-02-23 01:17:11 +00:00
|
|
|
CPPFLAGS+= -DCOMBRELOC
|
2005-01-11 07:47:37 +00:00
|
|
|
#CPPFLAGS+= -DDEBUG
|
2004-02-23 21:27:20 +00:00
|
|
|
#CPPFLAGS+= -DRTLD_DEBUG
|
|
|
|
#CPPFLAGS+= -DRTLD_DEBUG_RELOC
|
2013-05-03 15:52:31 +00:00
|
|
|
.if !empty(LDELFSO_MACHINE_ARCH:Mearm*)
|
2013-04-24 22:37:20 +00:00
|
|
|
CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libexecinfo
|
|
|
|
.endif
|
2004-02-23 21:27:20 +00:00
|
|
|
#DBG= -g
|
2013-05-06 22:49:10 +00:00
|
|
|
COPTS+= -O3 -fomit-frame-pointer
|
1996-12-16 20:37:55 +00:00
|
|
|
|
2013-05-03 15:52:31 +00:00
|
|
|
.if ${LDELFSO_MACHINE_ARCH} == "i386" || ${LDELFSO_MACHINE_ARCH} == "x86_64"
|
2012-08-04 15:17:16 +00:00
|
|
|
COPTS+= -mno-3dnow -mno-mmx -mno-sse -mno-sse2 -mno-sse3
|
2011-05-20 22:22:44 +00:00
|
|
|
.endif
|
|
|
|
|
2012-08-23 21:21:14 +00:00
|
|
|
|
|
|
|
.if ${SHLIBDIR} != ${LIBDIR}
|
|
|
|
CPPFLAGS+= -DRTLD_DEFAULT_LIBRARY_PATH=\"${SHLIBDIR}:${LIBDIR}\"
|
|
|
|
.endif
|
|
|
|
|
2010-03-20 16:36:35 +00:00
|
|
|
# rtld.c and symbol.c use alloca, so disable SSP warnings.
|
|
|
|
COPTS.rtld.c+= -Wno-stack-protector
|
|
|
|
COPTS.symbol.c+=-Wno-stack-protector
|
|
|
|
|
2007-03-15 17:27:15 +00:00
|
|
|
LDADD+= -L${CLIBOBJ} -L${DESTDIR}${LIBDIR}
|
|
|
|
.if ${MKPICLIB} != "no"
|
|
|
|
LDADD+= -lc_pic
|
2004-02-26 21:45:59 +00:00
|
|
|
.if ${MKPICINSTALL} != "no"
|
2004-02-23 21:27:20 +00:00
|
|
|
DPADD+= ${LIBC_PIC}
|
2003-02-26 06:03:40 +00:00
|
|
|
.endif
|
2004-02-23 21:27:20 +00:00
|
|
|
DPADD+= ${CLIBOBJ}/libc_pic.a
|
2007-03-15 17:27:15 +00:00
|
|
|
.else
|
|
|
|
LDADD+= -lc
|
|
|
|
DPADD+= ${CLIBOBJ}/libc.a
|
|
|
|
.endif
|
1996-12-16 20:37:55 +00:00
|
|
|
|
2011-06-27 14:27:56 +00:00
|
|
|
.if ${MACHINE_CPU} == "hppa" || ${MACHINE_CPU} == "sh3"
|
2011-06-05 23:08:17 +00:00
|
|
|
# for $$divU, $$remU etc. (millicode)
|
2011-10-07 09:15:21 +00:00
|
|
|
LDADD+= -lgcc
|
|
|
|
DPADD+= ${LIBGCC}
|
2011-06-05 23:08:17 +00:00
|
|
|
.endif
|
|
|
|
|
1997-04-17 22:17:27 +00:00
|
|
|
STRIPFLAG=
|
1996-12-16 20:37:55 +00:00
|
|
|
|
1999-03-03 12:00:18 +00:00
|
|
|
.PATH: $M
|
1996-12-16 20:37:55 +00:00
|
|
|
|
2013-04-05 20:16:40 +00:00
|
|
|
|
2001-01-14 09:39:26 +00:00
|
|
|
${PROG}: ${OBJS} ${DPADD}
|
2003-10-21 10:01:19 +00:00
|
|
|
${_MKMSG_LINK} ${PROG}
|
2005-06-04 16:17:17 +00:00
|
|
|
${CC} ${LDFLAGS} -o ${PROG} ${OBJS} ${LDADD}
|
2013-04-05 20:16:40 +00:00
|
|
|
.if ${MKDEBUG} != "no"
|
|
|
|
( ${OBJCOPY} --only-keep-debug ${.TARGET} ${.TARGET}.debug \
|
|
|
|
&& ${OBJCOPY} --strip-debug -p -R .gnu_debuglink \
|
|
|
|
--add-gnu-debuglink=${.TARGET}.debug ${.TARGET} \
|
|
|
|
) || (rm -f ${.TARGET}.debug; false)
|
|
|
|
|
|
|
|
_PROGDEBUG.${PROG} := ${PROG}.debug
|
|
|
|
.endif
|
|
|
|
|
2001-01-14 09:16:47 +00:00
|
|
|
|
2012-08-23 21:21:14 +00:00
|
|
|
.if ${SHLINKINSTALLDIR} != "/usr/libexec"
|
|
|
|
SYMLINKS+= ${SHLINKINSTALLDIR}/${PROG} /usr/libexec/${PROG}
|
2013-05-08 15:33:45 +00:00
|
|
|
.if ${MKDEBUG} != "no"
|
2013-05-09 11:44:36 +00:00
|
|
|
SYMLINKS+= ${DEBUGDIR}${BINDIR}/${PROG}.debug \
|
|
|
|
${DEBUGDIR}/usr${BINDIR}/${PROG}.debug
|
2013-05-08 15:33:45 +00:00
|
|
|
.endif
|
2001-12-28 05:30:24 +00:00
|
|
|
.endif
|
|
|
|
|
1996-12-16 20:37:55 +00:00
|
|
|
.include <bsd.prog.mk>
|
2002-01-23 15:10:24 +00:00
|
|
|
.else
|
|
|
|
|
2004-02-26 21:45:59 +00:00
|
|
|
MAN= ld.elf_so.1
|
2002-01-23 15:10:24 +00:00
|
|
|
|
|
|
|
.include <bsd.man.mk>
|
|
|
|
.endif
|