2011-05-21 02:22:44 +04:00
|
|
|
# $NetBSD: Makefile,v 1.105 2011/05/20 22:22:44 joerg Exp $
|
2009-05-20 23:38:38 +04:00
|
|
|
#
|
|
|
|
# NOTE: when changing ld.so, ensure that ldd still compiles.
|
|
|
|
#
|
2009-03-16 05:24:55 +03:00
|
|
|
|
2009-05-20 00:44:52 +04:00
|
|
|
WARNS?=4
|
1996-12-16 23:37:55 +03:00
|
|
|
|
2009-12-13 12:01:45 +03:00
|
|
|
# This needs to be before bsd.init.mk
|
|
|
|
.if defined(BSD_MK_COMPAT_FILE)
|
|
|
|
.include <${BSD_MK_COMPAT_FILE}>
|
|
|
|
.endif
|
|
|
|
|
2008-10-16 18:36:20 +04: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 09:59:50 +04:00
|
|
|
.include <bsd.init.mk> # for MKPIC definition
|
Only use the MKDYNAMICROOT semantics (i.e. -rpath=/lib,/usr/lib and
-dynamic-linker=/libexec/ld.elf_so) if the BINDIR of the program being
built is /bin or /sbin.
The reason we do this is because now all programs *except* those in
/bin and /sbin (i.e. the "special cases") match the default the compiler
uses, which is what is used for things in e.g. xsrc, pkgsrc, and other
random 3rd party programs.
This is done by decoupling where a shlib is installed from how it
is located. Two new variables, SHLIBINSTALLDIR and SHLINKINSTALLDIR,
contain the former information, and key off MKDYNAMICROOT only. SHLIBDIR
and SHLINKDIR contain the latter, and key off MKDYNAMICROOT and BINDIR.
The SHLIBINSTALLDIR, SHLIBDIR, _LIBSODIR, SHLINKINSTALLDIR, and
SHLINKDIR parameters are moved to a new <bsd.shlib.mk>; see bsd.README
for usage details.
2002-09-28 01:37:50 +04:00
|
|
|
.include <bsd.shlib.mk> # for SHLINKINSTALLDIR definition
|
1998-02-23 13:09:31 +03:00
|
|
|
|
2008-10-26 10:11:54 +03:00
|
|
|
.if defined(LDELFSO_MACHINE_CPU) && !empty(LDELFSO_MACHINE_CPU) && \
|
|
|
|
exists(${.CURDIR}/arch/${LDELFSO_MACHINE_CPU})
|
|
|
|
ARCHSUBDIR= ${LDELFSO_MACHINE_CPU}
|
|
|
|
.else
|
2004-02-24 00:27:20 +03:00
|
|
|
ARCHSUBDIR= ${MACHINE_CPU}
|
2008-10-26 10:11:54 +03:00
|
|
|
.endif
|
2004-02-24 00:27:20 +03:00
|
|
|
M= ${.CURDIR}/arch/${ARCHSUBDIR}
|
1999-03-03 15:00:18 +03:00
|
|
|
|
1999-05-08 02:04:27 +04:00
|
|
|
.if ((${MACHINE_ARCH} == "alpha") || \
|
2006-08-27 11:22:02 +04:00
|
|
|
(${MACHINE_CPU} == "arm") || \
|
2002-07-10 19:12:33 +04:00
|
|
|
(${MACHINE_ARCH} == "hppa") || \
|
1999-05-08 02:04:27 +04:00
|
|
|
(${MACHINE_ARCH} == "i386") || \
|
|
|
|
(${MACHINE_ARCH} == "m68k") || \
|
2006-08-27 11:22:02 +04:00
|
|
|
(${MACHINE_CPU} == "mips") || \
|
1999-05-08 02:04:27 +04:00
|
|
|
(${MACHINE_ARCH} == "powerpc") || \
|
2006-08-27 11:22:02 +04:00
|
|
|
(${MACHINE_CPU} == "sh3") || \
|
1999-05-08 02:04:27 +04:00
|
|
|
(${MACHINE_ARCH} == "sparc") || \
|
2000-07-03 07:30:52 +04:00
|
|
|
(${MACHINE_ARCH} == "sparc64") || \
|
2001-06-19 05:11:03 +04:00
|
|
|
(${MACHINE_ARCH} == "x86_64") || \
|
2000-07-03 07:30:52 +04:00
|
|
|
(${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 09:59:50 +04:00
|
|
|
${MKPIC} != "no"
|
1999-05-08 02:04:27 +04:00
|
|
|
|
2011-05-21 02:21:32 +04:00
|
|
|
LDFLAGS+= -shared -symbolic -nostartfiles -nodefaultlibs
|
2006-06-29 23:30:59 +04:00
|
|
|
LDFLAGS+= -Wl,-static
|
2011-01-16 05:36:05 +03:00
|
|
|
LDFLAGS+= -Wl,--warn-shared-textrel
|
|
|
|
|
2010-12-05 03:56:06 +03:00
|
|
|
CFLAGS+= -fvisibility=hidden
|
2004-02-22 04:39:43 +03:00
|
|
|
|
1997-10-22 09:45:08 +04:00
|
|
|
# Adds SRCS, CPPFLAGS, LDFLAGS, etc. Must go first so MD startup source
|
1996-12-16 23:37:55 +03:00
|
|
|
# is first.
|
1999-03-03 15:00:18 +03:00
|
|
|
.if exists($M/Makefile.inc)
|
|
|
|
.include "$M/Makefile.inc"
|
1997-04-10 21:39:20 +04:00
|
|
|
.endif
|
1996-12-16 23:37:55 +03:00
|
|
|
|
2009-12-13 12:31:47 +03:00
|
|
|
# Support compat ld.elf_so.
|
2009-12-13 11:25:20 +03:00
|
|
|
.if defined(MLIBDIR)
|
2009-12-13 12:31:47 +03:00
|
|
|
PROG= ld.elf_so-${MLIBDIR}
|
|
|
|
CPPFLAGS+= -DRTLD_ARCH_SUBDIR=\"${MLIBDIR}\"
|
2008-10-26 10:11:54 +03:00
|
|
|
.else
|
2009-12-13 12:31:47 +03:00
|
|
|
PROG= ld.elf_so
|
2008-10-26 10:11:54 +03:00
|
|
|
.endif
|
2002-01-04 22:08:04 +03:00
|
|
|
|
2009-12-13 12:31:47 +03:00
|
|
|
CLIBOBJ!= cd ${NETBSDSRCDIR}/lib/libc && ${PRINTOBJDIR}
|
|
|
|
|
2010-12-17 01:47:27 +03:00
|
|
|
SRCS+= rtld.c reloc.c symbol.c xmalloc.c xprintf.c debug.c \
|
2011-03-10 02:10:05 +03:00
|
|
|
map_object.c load.c search.c headers.c paths.c expand.c \
|
|
|
|
tls.c
|
2001-12-15 01:21:45 +03:00
|
|
|
|
2007-12-27 00:11:52 +03:00
|
|
|
.if ${USE_FORT} == "yes"
|
2007-11-13 18:34:51 +03:00
|
|
|
.PATH.c: ${NETBSDSRCDIR}/lib/libc/misc
|
2007-09-27 21:51:40 +04:00
|
|
|
SRCS+= stack_protector.c
|
2007-12-27 00:11:52 +03:00
|
|
|
.endif
|
2007-10-30 20:19:59 +03:00
|
|
|
|
|
|
|
.PATH.c: ${NETBSDSRCDIR}/lib/libc/stdlib
|
|
|
|
SRCS+= exit.c
|
2007-09-27 21:51:40 +04:00
|
|
|
|
2010-12-17 01:52:32 +03: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
|
|
|
|
|
2004-02-24 00:27:20 +03:00
|
|
|
BINDIR= ${SHLINKINSTALLDIR}
|
* Add user-controlled mk.conf variables
- SHLIBDIR Location to install shared libraries if ${USE_SHLIBDIR}
is "yes". Defaults to "/usr/lib".
- USE_SHLIBDIR If "yes", install shared libraries in ${SHLIBDIR}
instead of ${LIBDIR}. Defaults to "no".
Sets ${_LIBSODIR} to the appropriate value.
This may be set by individual Makefiles as well.
- SHLINKDIR Location of shared linker. Defaults to "/usr/libexec".
If != "/usr/libexec", change the dynamic-linker
encoded in shared programs
* Set USE_SHLIBDIR for libraries used by /bin and /sbin:
libc libcrypt libcrypto libedit libipsec libkvm libm libmi387
libtermcap libutil libz
* If ${_LIBSODIR} != ${LIBDIR}, add symlinks from ${LIBDIR}/${LIB}.so*
to ${_LIBSODIR}/${LIB}.so* for compatibility.
* Always install /sbin/init statically (for now)
The net effect of these changes depends on how the variables are set:
1.) If nothing is set or changed, there is no change from the
current behaviour:
- Static /bin, /sbin, and bits of /usr/*
- Dynamic rest
- Shared linker is /usr/libexec/ld*so
2.) If the following make variables are set:
LDSTATIC=
SHLINKDIR=/lib
SHLIBDIR=/lib
Then the behaviour becomes:
- Dynamic tools
- .so libraries used by /bin and /sbin are installed to /lib,
with symlinks from /usr/lib/lib*so to -> /lib/lib*so
where appropriate
- Shared linker is /lib/ld*so
3.) As per 2.), but add the following variable:
USE_SHLIBDIR=yes
This forces all .so's to be instaleld in /lib (with compat
symlinks), not just those tagged by their Makefiles to be.
Again, compat symlinks are installed
2001-12-28 04:32:37 +03:00
|
|
|
|
2004-02-24 00:27:20 +03:00
|
|
|
CPPFLAGS+= -DLIBDIR=\"${LIBDIR}\" -D_PATH_RTLD=\"${BINDIR}/${PROG}\"
|
2010-12-17 01:52:32 +03:00
|
|
|
CPPFLAGS+= -I${.CURDIR} -I.
|
2004-02-24 00:27:20 +03:00
|
|
|
CPPFLAGS+= -DRTLD_LOADER
|
|
|
|
CPPFLAGS+= -D_RTLD_SOURCE
|
2007-02-23 04:17:11 +03:00
|
|
|
CPPFLAGS+= -DCOMBRELOC
|
2005-01-11 10:47:37 +03:00
|
|
|
#CPPFLAGS+= -DDEBUG
|
2004-02-24 00:27:20 +03:00
|
|
|
#CPPFLAGS+= -DRTLD_DEBUG
|
|
|
|
#CPPFLAGS+= -DRTLD_DEBUG_RELOC
|
|
|
|
#DBG= -g
|
|
|
|
DBG= -O3 -fomit-frame-pointer
|
1996-12-16 23:37:55 +03:00
|
|
|
|
2011-05-21 02:22:44 +04:00
|
|
|
.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
|
|
|
|
DBG+= -mno-3dnow -mno-mmx -mno-sse -mno-sse2 -mno-sse3
|
|
|
|
.endif
|
|
|
|
|
2001-12-28 08:44:22 +03:00
|
|
|
.if ${SHLIBDIR} != ${LIBDIR}
|
2004-02-24 00:27:20 +03:00
|
|
|
CPPFLAGS+= -DRTLD_DEFAULT_LIBRARY_PATH=\"${SHLIBDIR}:${LIBDIR}\"
|
2001-12-28 08:44:22 +03:00
|
|
|
.endif
|
|
|
|
|
2010-03-20 19:36:35 +03: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 20:27:15 +03:00
|
|
|
LDADD+= -L${CLIBOBJ} -L${DESTDIR}${LIBDIR}
|
|
|
|
.if ${MKPICLIB} != "no"
|
|
|
|
LDADD+= -lc_pic
|
2004-02-27 00:45:59 +03:00
|
|
|
.if ${MKPICINSTALL} != "no"
|
2004-02-24 00:27:20 +03:00
|
|
|
DPADD+= ${LIBC_PIC}
|
2003-02-26 09:03:40 +03:00
|
|
|
.endif
|
2004-02-24 00:27:20 +03:00
|
|
|
DPADD+= ${CLIBOBJ}/libc_pic.a
|
2007-03-15 20:27:15 +03:00
|
|
|
.else
|
|
|
|
LDADD+= -lc
|
|
|
|
DPADD+= ${CLIBOBJ}/libc.a
|
|
|
|
.endif
|
1996-12-16 23:37:55 +03:00
|
|
|
|
1997-04-18 02:17:27 +04:00
|
|
|
STRIPFLAG=
|
1996-12-16 23:37:55 +03:00
|
|
|
|
1999-03-03 15:00:18 +03:00
|
|
|
.PATH: $M
|
1996-12-16 23:37:55 +03:00
|
|
|
|
2001-01-14 12:39:26 +03:00
|
|
|
${PROG}: ${OBJS} ${DPADD}
|
2003-10-21 14:01:19 +04:00
|
|
|
${_MKMSG_LINK} ${PROG}
|
2005-06-04 20:17:17 +04:00
|
|
|
${CC} ${LDFLAGS} -o ${PROG} ${OBJS} ${LDADD}
|
2001-01-14 12:16:47 +03:00
|
|
|
|
Only use the MKDYNAMICROOT semantics (i.e. -rpath=/lib,/usr/lib and
-dynamic-linker=/libexec/ld.elf_so) if the BINDIR of the program being
built is /bin or /sbin.
The reason we do this is because now all programs *except* those in
/bin and /sbin (i.e. the "special cases") match the default the compiler
uses, which is what is used for things in e.g. xsrc, pkgsrc, and other
random 3rd party programs.
This is done by decoupling where a shlib is installed from how it
is located. Two new variables, SHLIBINSTALLDIR and SHLINKINSTALLDIR,
contain the former information, and key off MKDYNAMICROOT only. SHLIBDIR
and SHLINKDIR contain the latter, and key off MKDYNAMICROOT and BINDIR.
The SHLIBINSTALLDIR, SHLIBDIR, _LIBSODIR, SHLINKINSTALLDIR, and
SHLINKDIR parameters are moved to a new <bsd.shlib.mk>; see bsd.README
for usage details.
2002-09-28 01:37:50 +04:00
|
|
|
.if ${SHLINKINSTALLDIR} != "/usr/libexec"
|
|
|
|
SYMLINKS+= ${SHLINKINSTALLDIR}/${PROG} /usr/libexec/${PROG}
|
2001-12-28 08:30:24 +03:00
|
|
|
.endif
|
|
|
|
|
1996-12-16 23:37:55 +03:00
|
|
|
.include <bsd.prog.mk>
|
2002-01-23 18:10:24 +03:00
|
|
|
.else
|
|
|
|
|
2004-02-27 00:45:59 +03:00
|
|
|
MAN= ld.elf_so.1
|
2002-01-23 18:10:24 +03:00
|
|
|
|
|
|
|
.include <bsd.man.mk>
|
|
|
|
.endif
|