From owner-svn-src-all@FreeBSD.ORG Fri Jun 7 21:40:06 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 5DDCF898; Fri, 7 Jun 2013 21:40:06 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 4DA8016E6; Fri, 7 Jun 2013 21:40:06 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r57Le6m2069270; Fri, 7 Jun 2013 21:40:06 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r57Le2Ct069230; Fri, 7 Jun 2013 21:40:02 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201306072140.r57Le2Ct069230@svn.freebsd.org> From: Ed Maste Date: Fri, 7 Jun 2013 21:40:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r251512 - in head: . etc etc/mtree gnu/usr.bin/gdb gnu/usr.bin/gdb/arch/amd64 gnu/usr.bin/gdb/arch/arm gnu/usr.bin/gdb/arch/i386 gnu/usr.bin/gdb/arch/ia64 gnu/usr.bin/gdb/arch/mips gnu/... X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Jun 2013 21:40:06 -0000 Author: emaste Date: Fri Jun 7 21:40:02 2013 New Revision: 251512 URL: http://svnweb.freebsd.org/changeset/base/251512 Log: Add a new knob WITH_DEBUG_FILES to control the building of standalone debug files for userland programs and libraries. The "-g" debug flag is automatically applied when WITH_DEBUG_FILES is set. The debug files are now named ${prog}.debug and ${shlib}.debug for consistency with other systems and documentation. In addition they are installed under /usr/lib/debug, to simplify the process of installing them if needed after a crash. Users of bsd.{prog,lib}.mk outside of the base system place the standalone debug files in a .debug subdirectory. GDB automatically searches both of these directories for standalone debug files. Thanks to everyone who contributed changes, review, and testing during development. Added: head/etc/mtree/BSD.debug.dist (contents, props changed) head/tools/build/options/WITH_DEBUG_FILES (contents, props changed) Modified: head/Makefile.inc1 head/etc/Makefile head/etc/mtree/Makefile head/gnu/usr.bin/gdb/Makefile.inc head/gnu/usr.bin/gdb/arch/amd64/config.h head/gnu/usr.bin/gdb/arch/arm/config.h head/gnu/usr.bin/gdb/arch/i386/config.h head/gnu/usr.bin/gdb/arch/ia64/config.h head/gnu/usr.bin/gdb/arch/mips/config.h head/gnu/usr.bin/gdb/arch/powerpc/config.h head/gnu/usr.bin/gdb/arch/powerpc64/config.h head/gnu/usr.bin/gdb/arch/sparc64/config.h head/gnu/usr.bin/gdb/gdb/Makefile head/share/mk/bsd.crunchgen.mk head/share/mk/bsd.lib.mk head/share/mk/bsd.own.mk head/share/mk/bsd.prog.mk Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Fri Jun 7 21:39:46 2013 (r251511) +++ head/Makefile.inc1 Fri Jun 7 21:40:02 2013 (r251512) @@ -470,6 +470,13 @@ _worldtmp: mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ -p ${WORLDTMP}/usr/include >/dev/null ln -sf ${.CURDIR}/sys ${WORLDTMP} +.if ${MK_DEBUG_FILES} != "no" + # We could instead disable debug files for these build stages + mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ + -p ${WORLDTMP}/legacy/usr/lib >/dev/null + mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ + -p ${WORLDTMP}/usr/lib >/dev/null +.endif .if ${MK_BIND_LIBS} != "no" mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \ -p ${WORLDTMP}/usr/include >/dev/null @@ -555,6 +562,10 @@ build32: -p ${LIB32TMP}/usr >/dev/null mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ -p ${LIB32TMP}/usr/include >/dev/null +.if ${MK_DEBUG_FILES} != "no" + mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ + -p ${LIB32TMP}/usr/lib >/dev/null +.endif mkdir -p ${WORLDTMP} ln -sf ${.CURDIR}/sys ${WORLDTMP} .for _t in obj includes @@ -779,6 +790,10 @@ distributeworld installworld: installche -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null +.if ${MK_DEBUG_FILES} != "no" + mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ + -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null +.endif .if defined(NO_ROOT) ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \ sed -e 's#^\./#./${dist}/#' >> ${METALOG} Modified: head/etc/Makefile ============================================================================== --- head/etc/Makefile Fri Jun 7 21:39:46 2013 (r251511) +++ head/etc/Makefile Fri Jun 7 21:40:02 2013 (r251512) @@ -143,6 +143,9 @@ MTREE+= BIND.chroot.dist MTREE+= BIND.include.dist .endif .endif +.if ${MK_DEBUG_FILES} != "no" +MTREE+= BSD.debug.dist +.endif PPPCNF= ppp.conf @@ -312,6 +315,9 @@ MTREES= mtree/BSD.root.dist / \ mtree/BSD.var.dist /var \ mtree/BSD.usr.dist /usr \ mtree/BSD.include.dist /usr/include +.if ${MK_DEBUG_FILES} != "no" +MTREES+= mtree/BSD.debug.dist /usr/lib +.endif .if ${MK_BIND_LIBS} != "no" MTREES+= mtree/BIND.include.dist /usr/include .endif Added: head/etc/mtree/BSD.debug.dist ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/etc/mtree/BSD.debug.dist Fri Jun 7 21:40:02 2013 (r251512) @@ -0,0 +1,48 @@ +# $FreeBSD$ +# +# Please see the file src/etc/mtree/README before making changes to this file. +# + +/set type=dir uname=root gname=wheel mode=0755 +. + debug + bin + .. + boot + .. + lib + geom + .. + .. + libexec + .. + sbin + .. + usr + bin + .. + games + .. + lib + engines + .. + .. + lib32 + .. + libexec + bsdinstall + .. + lpr + ru + .. + .. + sendmail + .. + sm.bin + .. + .. + sbin + .. + .. + .. +.. Modified: head/etc/mtree/Makefile ============================================================================== --- head/etc/mtree/Makefile Fri Jun 7 21:39:46 2013 (r251511) +++ head/etc/mtree/Makefile Fri Jun 7 21:40:02 2013 (r251512) @@ -4,6 +4,7 @@ FILES= ${_BIND.chroot.dist} \ ${_BIND.include.dist} \ + ${_BSD.debug.dist} \ BSD.include.dist \ BSD.root.dist \ ${_BSD.sendmail.dist} \ @@ -16,6 +17,9 @@ _BIND.chroot.dist= BIND.chroot.dist _BIND.include.dist= BIND.include.dist .endif .endif +.if ${MK_DEBUG_FILES} != "no" +_BSD.debug.dist= BSD.debug.dist +.endif .if ${MK_GROFF} != "no" _BSD.groff.dist= BSD.groff.dist .endif Modified: head/gnu/usr.bin/gdb/Makefile.inc ============================================================================== --- head/gnu/usr.bin/gdb/Makefile.inc Fri Jun 7 21:39:46 2013 (r251511) +++ head/gnu/usr.bin/gdb/Makefile.inc Fri Jun 7 21:40:02 2013 (r251512) @@ -37,6 +37,7 @@ GDB_CROSS_DEBUGGER= ${CNTRB_GDB}/gdb/signals ${CNTRB_GDB}/gdb/tui ${TARGET_SUBDIR} CFLAGS+= -DHAVE_CONFIG_H -DRL_NO_COMPAT -DMI_OUT=1 -DTUI=1 +CFLAGS+= -DDEBUGDIR=\"${DEBUGDIR}\" CFLAGS+= -I. CFLAGS+= -I${TARGET_SUBDIR} CFLAGS+= -I${BMAKE_BU}/libbfd -I${BMAKE_BU}/libbfd/${TARGET_CPUARCH} Modified: head/gnu/usr.bin/gdb/arch/amd64/config.h ============================================================================== --- head/gnu/usr.bin/gdb/arch/amd64/config.h Fri Jun 7 21:39:46 2013 (r251511) +++ head/gnu/usr.bin/gdb/arch/amd64/config.h Fri Jun 7 21:40:02 2013 (r251512) @@ -439,9 +439,6 @@ /* Name of this package. */ #define PACKAGE "gdb" -/* Global directory for separate debug files. */ -#define DEBUGDIR "/usr/local/lib/debug" - /* Define to BFD's default architecture. */ #define DEFAULT_BFD_ARCH bfd_i386_arch Modified: head/gnu/usr.bin/gdb/arch/arm/config.h ============================================================================== --- head/gnu/usr.bin/gdb/arch/arm/config.h Fri Jun 7 21:39:46 2013 (r251511) +++ head/gnu/usr.bin/gdb/arch/arm/config.h Fri Jun 7 21:40:02 2013 (r251512) @@ -451,9 +451,6 @@ /* Name of this package. */ #define PACKAGE "gdb" -/* Global directory for separate debug files. */ -#define DEBUGDIR "/usr/local/lib/debug" - /* Define to BFD's default architecture. */ #define DEFAULT_BFD_ARCH bfd_arm_arch Modified: head/gnu/usr.bin/gdb/arch/i386/config.h ============================================================================== --- head/gnu/usr.bin/gdb/arch/i386/config.h Fri Jun 7 21:39:46 2013 (r251511) +++ head/gnu/usr.bin/gdb/arch/i386/config.h Fri Jun 7 21:40:02 2013 (r251512) @@ -439,9 +439,6 @@ /* Name of this package. */ #define PACKAGE "gdb" -/* Global directory for separate debug files. */ -#define DEBUGDIR "/usr/local/lib/debug" - /* Define to BFD's default architecture. */ #define DEFAULT_BFD_ARCH bfd_i386_arch Modified: head/gnu/usr.bin/gdb/arch/ia64/config.h ============================================================================== --- head/gnu/usr.bin/gdb/arch/ia64/config.h Fri Jun 7 21:39:46 2013 (r251511) +++ head/gnu/usr.bin/gdb/arch/ia64/config.h Fri Jun 7 21:40:02 2013 (r251512) @@ -439,9 +439,6 @@ /* Name of this package. */ #define PACKAGE "gdb" -/* Global directory for separate debug files. */ -#define DEBUGDIR "/usr/local/lib/debug" - /* Define to BFD's default architecture. */ #define DEFAULT_BFD_ARCH bfd_ia64_arch Modified: head/gnu/usr.bin/gdb/arch/mips/config.h ============================================================================== --- head/gnu/usr.bin/gdb/arch/mips/config.h Fri Jun 7 21:39:46 2013 (r251511) +++ head/gnu/usr.bin/gdb/arch/mips/config.h Fri Jun 7 21:40:02 2013 (r251512) @@ -439,9 +439,6 @@ /* Name of this package. */ #define PACKAGE "gdb" -/* Global directory for separate debug files. */ -#define DEBUGDIR "/usr/local/lib/debug" - /* Define to BFD's default architecture. */ #define DEFAULT_BFD_ARCH bfd_mips_arch Modified: head/gnu/usr.bin/gdb/arch/powerpc/config.h ============================================================================== --- head/gnu/usr.bin/gdb/arch/powerpc/config.h Fri Jun 7 21:39:46 2013 (r251511) +++ head/gnu/usr.bin/gdb/arch/powerpc/config.h Fri Jun 7 21:40:02 2013 (r251512) @@ -439,9 +439,6 @@ /* Name of this package. */ #define PACKAGE "gdb" -/* Global directory for separate debug files. */ -#define DEBUGDIR "/usr/local/lib/debug" - /* Define to BFD's default architecture. */ #define DEFAULT_BFD_ARCH bfd_rs6000_arch Modified: head/gnu/usr.bin/gdb/arch/powerpc64/config.h ============================================================================== --- head/gnu/usr.bin/gdb/arch/powerpc64/config.h Fri Jun 7 21:39:46 2013 (r251511) +++ head/gnu/usr.bin/gdb/arch/powerpc64/config.h Fri Jun 7 21:40:02 2013 (r251512) @@ -439,9 +439,6 @@ /* Name of this package. */ #define PACKAGE "gdb" -/* Global directory for separate debug files. */ -#define DEBUGDIR "/usr/local/lib/debug" - /* Define to BFD's default architecture. */ #define DEFAULT_BFD_ARCH bfd_rs6000_arch Modified: head/gnu/usr.bin/gdb/arch/sparc64/config.h ============================================================================== --- head/gnu/usr.bin/gdb/arch/sparc64/config.h Fri Jun 7 21:39:46 2013 (r251511) +++ head/gnu/usr.bin/gdb/arch/sparc64/config.h Fri Jun 7 21:40:02 2013 (r251512) @@ -439,9 +439,6 @@ /* Name of this package. */ #define PACKAGE "gdb" -/* Global directory for separate debug files. */ -#define DEBUGDIR "/usr/local/lib/debug" - /* Define to BFD's default architecture. */ #define DEFAULT_BFD_ARCH bfd_sparc_arch Modified: head/gnu/usr.bin/gdb/gdb/Makefile ============================================================================== --- head/gnu/usr.bin/gdb/gdb/Makefile Fri Jun 7 21:39:46 2013 (r251511) +++ head/gnu/usr.bin/gdb/gdb/Makefile Fri Jun 7 21:40:02 2013 (r251512) @@ -15,3 +15,4 @@ DPADD= ${GDBLIBS} ${BULIBS} ${LIBM} ${LI LDADD= ${GDBLIBS} ${BULIBS} -lm -lreadline -ltermcap -lgnuregex .include +CFLAGS+= -DDEBUGDIR=\"${DEBUGDIR}\" Modified: head/share/mk/bsd.crunchgen.mk ============================================================================== --- head/share/mk/bsd.crunchgen.mk Fri Jun 7 21:39:46 2013 (r251511) +++ head/share/mk/bsd.crunchgen.mk Fri Jun 7 21:40:02 2013 (r251512) @@ -47,6 +47,9 @@ CRUNCH_GENERATE_LINKS?= yes CLEANFILES+= $(CONF) *.o *.lo *.c *.mk *.cache *.a *.h +# Don't try to extract debug info from ${PROG}. +NO_DEBUG_FILES= + # Program names and their aliases contribute hardlinks to 'rescue' executable, # except for those that get suppressed. .for D in $(CRUNCH_SRCDIRS) Modified: head/share/mk/bsd.lib.mk ============================================================================== --- head/share/mk/bsd.lib.mk Fri Jun 7 21:39:46 2013 (r251511) +++ head/share/mk/bsd.lib.mk Fri Jun 7 21:40:02 2013 (r251512) @@ -43,6 +43,12 @@ CTFFLAGS+= -g STRIP?= -s .endif +.if ${MK_DEBUG_FILES} != "no" && empty(DEBUG_FLAGS:M-g) && \ + empty(DEBUG_FLAGS:M-gdwarf*) +CFLAGS+= -g +CTFFLAGS+= -g +.endif + .include # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries @@ -114,8 +120,17 @@ PO_FLAG=-pg all: objwarn .if defined(SHLIB_NAME) -.if defined(DEBUG_FLAGS) -SHLIB_NAME_FULL=${SHLIB_NAME}.debug +.if ${MK_DEBUG_FILES} != "no" +SHLIB_NAME_FULL=${SHLIB_NAME}.full +# Use ${DEBUGDIR} for base system debug files, else .debug subdirectory +.if ${SHLIBDIR} == "/boot" ||\ + ${SHLIBDIR:C%/lib(/.*)?$%/lib%} == "/lib" ||\ + ${SHLIBDIR:C%/usr/lib(32)?(/.*)?%/usr/lib%} == "/usr/lib" +DEBUGFILEDIR=${DEBUGDIR}${SHLIBDIR} +.else +DEBUGFILEDIR=${SHLIBDIR}/.debug +DEBUGMKDIR= +.endif .else SHLIB_NAME_FULL=${SHLIB_NAME} .endif @@ -201,13 +216,13 @@ ${SHLIB_NAME_FULL}: ${SOBJS} ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS} .endif -.if defined(DEBUG_FLAGS) -CLEANFILES+= ${SHLIB_NAME_FULL} ${SHLIB_NAME}.symbols -${SHLIB_NAME}: ${SHLIB_NAME_FULL} ${SHLIB_NAME}.symbols - ${OBJCOPY} --strip-debug --add-gnu-debuglink=${SHLIB_NAME}.symbols \ +.if ${MK_DEBUG_FILES} != "no" +CLEANFILES+= ${SHLIB_NAME_FULL} ${SHLIB_NAME}.debug +${SHLIB_NAME}: ${SHLIB_NAME_FULL} ${SHLIB_NAME}.debug + ${OBJCOPY} --strip-debug --add-gnu-debuglink=${SHLIB_NAME}.debug \ ${SHLIB_NAME_FULL} ${.TARGET} -${SHLIB_NAME}.symbols: ${SHLIB_NAME_FULL} +${SHLIB_NAME}.debug: ${SHLIB_NAME_FULL} ${OBJCOPY} --only-keep-debug ${SHLIB_NAME_FULL} ${.TARGET} .endif .endif #defined(SHLIB_NAME) @@ -286,10 +301,13 @@ _libinstall: ${INSTALL} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \ ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR} -.if defined(DEBUG_FLAGS) - ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ +.if ${MK_DEBUG_FILES} != "no" +.if defined(DEBUGMKDIR) + ${INSTALL} -T debug -d ${DESTDIR}${DEBUGFILEDIR} +.endif + ${INSTALL} -T debug -o ${LIBOWN} -g ${LIBGRP} -m ${DEBUGMODE} \ ${_INSTALLFLAGS} \ - ${SHLIB_NAME}.symbols ${DESTDIR}${SHLIBDIR} + ${SHLIB_NAME}.debug ${DESTDIR}${DEBUGFILEDIR} .endif .if defined(SHLIB_LINK) # ${_SHLIBDIRPREFIX} and ${_LDSCRIPTROOT} are both needed when cross-building Modified: head/share/mk/bsd.own.mk ============================================================================== --- head/share/mk/bsd.own.mk Fri Jun 7 21:39:46 2013 (r251511) +++ head/share/mk/bsd.own.mk Fri Jun 7 21:40:02 2013 (r251512) @@ -43,6 +43,11 @@ # LIBMODE Library mode. [${NOBINMODE}] # # +# DEBUGDIR Base path for standalone debug files. [/usr/lib/debug] +# +# DEBUGMODE Mode for debug files. [${NOBINMODE}] +# +# # KMODDIR Base path for loadable kernel modules # (see kld(4)). [/boot/kernel] # @@ -147,6 +152,9 @@ LIBOWN?= ${BINOWN} LIBGRP?= ${BINGRP} LIBMODE?= ${NOBINMODE} +DEBUGDIR?= /usr/lib/debug +DEBUGMODE?= ${NOBINMODE} + # Share files SHAREDIR?= /usr/share @@ -213,6 +221,7 @@ COMPRESS_EXT?= .gz # .for var in \ CTF \ + DEBUG_FILES \ INSTALLLIB \ MAN \ PROFILE @@ -365,6 +374,7 @@ __DEFAULT_NO_OPTIONS = \ BSD_GREP \ CLANG_EXTRAS \ CTF \ + DEBUG_FILES \ GPL_DTC \ HESIOD \ ICONV \ Modified: head/share/mk/bsd.prog.mk ============================================================================== --- head/share/mk/bsd.prog.mk Fri Jun 7 21:39:46 2013 (r251511) +++ head/share/mk/bsd.prog.mk Fri Jun 7 21:40:02 2013 (r251512) @@ -24,8 +24,24 @@ CTFFLAGS+= -g .endif .endif +.if defined(PROG_CXX) +PROG= ${PROG_CXX} +.endif + +.if defined(PROG) && target(${PROG}) +MK_DEBUG_FILES= no +.elif !empty(LDFLAGS:M-Wl,*--oformat,*) || !empty(LDFLAGS:M-static) +MK_DEBUG_FILES= no +.endif + .if defined(CRUNCH_CFLAGS) CFLAGS+=${CRUNCH_CFLAGS} +.else +.if ${MK_DEBUG_FILES} != "no" && empty(DEBUG_FLAGS:M-g) && \ + empty(DEBUG_FLAGS:M-gdwarf-*) +CFLAGS+= -g +CTFFLAGS+= -g +.endif .endif .if !defined(DEBUG_FLAGS) @@ -36,21 +52,36 @@ STRIP?= -s LDFLAGS+= -static .endif -.if defined(PROG_CXX) -PROG= ${PROG_CXX} +.if ${MK_DEBUG_FILES} != "no" +PROG_FULL=${PROG}.full +# Use ${DEBUGDIR} for base system debug files, else .debug subdirectory +.if defined(BINDIR) && (\ + ${BINDIR} == "/bin" ||\ + ${BINDIR} == "/libexec" ||\ + ${BINDIR} == "/sbin" ||\ + ${BINDIR:C%/usr/(bin|bsdinstall|games|libexec|lpr|sendmail|sm.bin|sbin)(/.*)?%/usr/bin%} == "/usr/bin"\ + ) +DEBUGFILEDIR= ${DEBUGDIR}${BINDIR} +.else +DEBUGFILEDIR?= ${BINDIR}/.debug +DEBUGMKDIR= +.endif +.else +PROG_FULL= ${PROG} .endif .if defined(PROG) PROGNAME?= ${PROG} + .if defined(SRCS) OBJS+= ${SRCS:N*.h:R:S/$/.o/g} .if target(beforelinking) beforelinking: ${OBJS} -${PROG}: beforelinking +${PROG_FULL}: beforelinking .endif -${PROG}: ${OBJS} +${PROG_FULL}: ${OBJS} .if defined(PROG_CXX) ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} .else @@ -78,9 +109,9 @@ OBJS+= ${PROG}.o .if target(beforelinking) beforelinking: ${OBJS} -${PROG}: beforelinking +${PROG_FULL}: beforelinking .endif -${PROG}: ${OBJS} +${PROG_FULL}: ${OBJS} .if defined(PROG_CXX) ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} .else @@ -89,10 +120,19 @@ ${PROG}: ${OBJS} .if ${MK_CTF} != "no" ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} .endif -.endif +.endif # !target(${PROG}) .endif # !defined(SRCS) +.if ${MK_DEBUG_FILES} != "no" +${PROG}: ${PROG_FULL} ${PROGNAME}.debug + ${OBJCOPY} --strip-debug --add-gnu-debuglink=${PROGNAME}.debug \ + ${PROG_FULL} ${.TARGET} + +${PROGNAME}.debug: ${PROG_FULL} + ${OBJCOPY} --only-keep-debug ${PROG_FULL} ${.TARGET} +.endif + .if ${MK_MAN} != "no" && !defined(MAN) && \ !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ @@ -109,6 +149,9 @@ all: _manpages .if defined(PROG) CLEANFILES+= ${PROG} +.if ${MK_DEBUG_FILES} != "no" +CLEANFILES+= ${PROG_FULL} ${PROGNAME}.debug +.endif .endif .if defined(OBJS) @@ -156,6 +199,13 @@ _proginstall: .if defined(PROG) ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME} +.if ${MK_DEBUG_FILES} != "no" +.if defined(DEBUGMKDIR) + ${INSTALL} -T debug -d ${DESTDIR}${DEBUGFILEDIR} +.endif + ${INSTALL} -T debug -o ${BINOWN} -g ${BINGRP} -m ${DEBUGMODE} \ + ${PROGNAME}.debug ${DESTDIR}${DEBUGFILEDIR}/${PROGNAME}.debug +.endif .endif .endif # !target(realinstall) Added: head/tools/build/options/WITH_DEBUG_FILES ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/build/options/WITH_DEBUG_FILES Fri Jun 7 21:40:02 2013 (r251512) @@ -0,0 +1,7 @@ +.\" $FreeBSD$ +Set to strip debug info into a separate file for each executable binary +and shared library. +The debug files will be placed in a subdirectory of +.Pa /usr/lib/debug +and are located automatically by +.Xr gdb 1 .