diff --git a/etc/mtree/BSD.usr.dist b/etc/mtree/BSD.usr.dist index 336d055..7b428d5 100644 --- a/etc/mtree/BSD.usr.dist +++ b/etc/mtree/BSD.usr.dist @@ -18,6 +18,22 @@ aout .. .. + debug + boot + .. + lib + geom + .. + .. + usr + lib + engines + .. + .. + lib32 + .. + .. + .. dtrace .. engines diff --git a/gnu/usr.bin/gdb/arch/amd64/config.h b/gnu/usr.bin/gdb/arch/amd64/config.h index ac81c54..ae3e104 100644 --- a/gnu/usr.bin/gdb/arch/amd64/config.h +++ b/gnu/usr.bin/gdb/arch/amd64/config.h @@ -440,7 +440,7 @@ #define PACKAGE "gdb" /* Global directory for separate debug files. */ -#define DEBUGDIR "/usr/local/lib/debug" +#define DEBUGDIR "/usr/lib/debug" /* Define to BFD's default architecture. */ #define DEFAULT_BFD_ARCH bfd_i386_arch diff --git a/gnu/usr.bin/gdb/arch/arm/config.h b/gnu/usr.bin/gdb/arch/arm/config.h index e1b128c..26b1891 100644 --- a/gnu/usr.bin/gdb/arch/arm/config.h +++ b/gnu/usr.bin/gdb/arch/arm/config.h @@ -452,7 +452,7 @@ #define PACKAGE "gdb" /* Global directory for separate debug files. */ -#define DEBUGDIR "/usr/local/lib/debug" +#define DEBUGDIR "/usr/lib/debug" /* Define to BFD's default architecture. */ #define DEFAULT_BFD_ARCH bfd_arm_arch diff --git a/gnu/usr.bin/gdb/arch/i386/config.h b/gnu/usr.bin/gdb/arch/i386/config.h index f21da4c..30e75c3 100644 --- a/gnu/usr.bin/gdb/arch/i386/config.h +++ b/gnu/usr.bin/gdb/arch/i386/config.h @@ -440,7 +440,7 @@ #define PACKAGE "gdb" /* Global directory for separate debug files. */ -#define DEBUGDIR "/usr/local/lib/debug" +#define DEBUGDIR "/usr/lib/debug" /* Define to BFD's default architecture. */ #define DEFAULT_BFD_ARCH bfd_i386_arch diff --git a/gnu/usr.bin/gdb/arch/ia64/config.h b/gnu/usr.bin/gdb/arch/ia64/config.h index 5faa96b..f8c84ab 100644 --- a/gnu/usr.bin/gdb/arch/ia64/config.h +++ b/gnu/usr.bin/gdb/arch/ia64/config.h @@ -440,7 +440,7 @@ #define PACKAGE "gdb" /* Global directory for separate debug files. */ -#define DEBUGDIR "/usr/local/lib/debug" +#define DEBUGDIR "/usr/lib/debug" /* Define to BFD's default architecture. */ #define DEFAULT_BFD_ARCH bfd_ia64_arch diff --git a/gnu/usr.bin/gdb/arch/mips/config.h b/gnu/usr.bin/gdb/arch/mips/config.h index 41a6731..01a7869 100644 --- a/gnu/usr.bin/gdb/arch/mips/config.h +++ b/gnu/usr.bin/gdb/arch/mips/config.h @@ -440,7 +440,7 @@ #define PACKAGE "gdb" /* Global directory for separate debug files. */ -#define DEBUGDIR "/usr/local/lib/debug" +#define DEBUGDIR "/usr/lib/debug" /* Define to BFD's default architecture. */ #define DEFAULT_BFD_ARCH bfd_mips_arch diff --git a/gnu/usr.bin/gdb/arch/powerpc/config.h b/gnu/usr.bin/gdb/arch/powerpc/config.h index f169fad..49472e7 100644 --- a/gnu/usr.bin/gdb/arch/powerpc/config.h +++ b/gnu/usr.bin/gdb/arch/powerpc/config.h @@ -440,7 +440,7 @@ #define PACKAGE "gdb" /* Global directory for separate debug files. */ -#define DEBUGDIR "/usr/local/lib/debug" +#define DEBUGDIR "/usr/lib/debug" /* Define to BFD's default architecture. */ #define DEFAULT_BFD_ARCH bfd_rs6000_arch diff --git a/gnu/usr.bin/gdb/arch/powerpc64/config.h b/gnu/usr.bin/gdb/arch/powerpc64/config.h index d8b9b6d..c904d1d 100644 --- a/gnu/usr.bin/gdb/arch/powerpc64/config.h +++ b/gnu/usr.bin/gdb/arch/powerpc64/config.h @@ -440,7 +440,7 @@ #define PACKAGE "gdb" /* Global directory for separate debug files. */ -#define DEBUGDIR "/usr/local/lib/debug" +#define DEBUGDIR "/usr/lib/debug" /* Define to BFD's default architecture. */ #define DEFAULT_BFD_ARCH bfd_rs6000_arch diff --git a/gnu/usr.bin/gdb/arch/sparc64/config.h b/gnu/usr.bin/gdb/arch/sparc64/config.h index 5527a79..ff87c28 100644 --- a/gnu/usr.bin/gdb/arch/sparc64/config.h +++ b/gnu/usr.bin/gdb/arch/sparc64/config.h @@ -440,7 +440,7 @@ #define PACKAGE "gdb" /* Global directory for separate debug files. */ -#define DEBUGDIR "/usr/local/lib/debug" +#define DEBUGDIR "/usr/lib/debug" /* Define to BFD's default architecture. */ #define DEFAULT_BFD_ARCH bfd_sparc_arch diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5 index faa117f..93f4295 100644 --- a/share/man/man5/src.conf.5 +++ b/share/man/man5/src.conf.5 @@ -383,6 +383,12 @@ When set, it also enforces the following options: .It .Va WITHOUT_GROFF .El +.It Va WITH_DEBUG_FILES +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 . .It Va WITHOUT_DICT .\" from FreeBSD: head/tools/build/options/WITHOUT_DICT 156932 2006-03-21 07:50:50Z ru Set to not build the Webster dictionary files. diff --git a/share/mk/bsd.crunchgen.mk b/share/mk/bsd.crunchgen.mk index cb0ce65..a0d8d19 100644 --- a/share/mk/bsd.crunchgen.mk +++ b/share/mk/bsd.crunchgen.mk @@ -48,7 +48,7 @@ CRUNCH_GENERATE_LINKS?= yes CLEANFILES+= $(CONF) *.o *.lo *.c *.mk *.cache *.a *.h # Don't try to extract debug info from ${PROG}. -.undef DEBUG_FLAGS +.undef MK_DEBUG_FILES # Program names and their aliases contribute hardlinks to 'rescue' executable, # except for those that get suppressed. diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index aa3567b..8afc008 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -43,6 +43,10 @@ CTFFLAGS+= -g STRIP?= -s .endif +.if defined(MK_DEBUG_FILES) +CFLAGS+= -g +.endif + .include # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries @@ -173,7 +177,7 @@ SOLINKOPTS+= -Wl,--fatal-warnings -Wl,--warn-shared-textrel .if target(beforelinking) ${SHLIB_NAME}: beforelinking .endif -.if defined(DEBUG_FLAGS) +.if defined(MK_DEBUG_FILES) ${SHLIB_NAME}.debug: ${SOBJS} .else ${SHLIB_NAME}: ${SOBJS} @@ -196,7 +200,7 @@ ${SHLIB_NAME}: ${SOBJS} ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS} .endif -.if defined(DEBUG_FLAGS) +.if defined(MK_DEBUG_FILES) ${SHLIB_NAME}: ${SHLIB_NAME}.debug ${SHLIB_NAME}.symbols ${OBJCOPY} --strip-debug --add-gnu-debuglink=${SHLIB_NAME}.symbols \ ${SHLIB_NAME}.debug ${.TARGET} @@ -280,10 +284,10 @@ _libinstall: ${INSTALL} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \ ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR} -.if defined(DEBUG_FLAGS) +.if defined(MK_DEBUG_FILES) ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ ${_INSTALLFLAGS} \ - ${SHLIB_NAME}.symbols ${DESTDIR}${SHLIBDIR} + ${SHLIB_NAME}.symbols ${DESTDIR}${DEBUGDIR}${SHLIBDIR} .endif .if defined(SHLIB_LINK) # ${_SHLIBDIRPREFIX} and ${_LDSCRIPTROOT} are both needed when cross-building diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index 669043f..bef57f4 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -43,6 +43,9 @@ # LIBMODE Library mode. [${NOBINMODE}] # # +# DEBUGDIR Base path for standalone debug files. [/usr/lib/debug] +# +# # KMODDIR Base path for loadable kernel modules # (see kld(4)). [/boot/kernel] # @@ -147,6 +150,8 @@ LIBOWN?= ${BINOWN} LIBGRP?= ${BINGRP} LIBMODE?= ${NOBINMODE} +DEBUGDIR?= /usr/lib/debug + # Share files SHAREDIR?= /usr/share @@ -417,16 +422,17 @@ __DEFAULT_YES_OPTIONS = \ ZONEINFO __DEFAULT_NO_OPTIONS = \ - BMAKE \ - BSD_GREP \ BIND_IDN \ BIND_LARGE_FILE \ BIND_LIBS \ BIND_SIGCHASE \ BIND_XML \ + BMAKE \ BSDCONFIG \ + BSD_GREP \ CLANG_EXTRAS \ CTF \ + DEBUG_FILES \ HESIOD \ ICONV \ IDEA \ diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk index b032eee..878c77c 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -22,14 +22,16 @@ CXXFLAGS+=${DEBUG_FLAGS} .if ${MK_CTF} != "no" && ${DEBUG_FLAGS:M-g} != "" CTFFLAGS+= -g .endif +.else +STRIP?= -s .endif -.if defined(CRUNCH_CFLAGS) -CFLAGS+=${CRUNCH_CFLAGS} +.if defined(MK_DEBUG_FLAGS) +CFLAGS+= -g .endif -.if !defined(DEBUG_FLAGS) -STRIP?= -s +.if defined(CRUNCH_CFLAGS) +CFLAGS+=${CRUNCH_CFLAGS} .endif .if defined(NO_SHARED) && (${NO_SHARED} != "no" && ${NO_SHARED} != "NO") @@ -48,7 +50,7 @@ OBJS+= ${SRCS:N*.h:R:S/$/.o/g} .if target(beforelinking) ${PROG}: beforelinking .endif -.if defined(DEBUG_FLAGS) +.if defined(MK_DEBUG_FILES) ${PROG}.debug: ${OBJS} .else ${PROG}: ${OBJS} @@ -81,7 +83,7 @@ OBJS= ${PROG}.o .if target(beforelinking) ${PROG}: beforelinking .endif -.if defined(DEBUG_FLAGS) +.if defined(MK_DEBUG_FILES) ${PROG}.debug: ${OBJS} .else ${PROG}: ${OBJS} @@ -109,12 +111,12 @@ MAN1= ${MAN} PROGNAME?= ${PROG} -.if defined(DEBUG_FLAGS) -${PROG}: ${PROG}.debug ${PROG}.symbols - ${OBJCOPY} --strip-debug --add-gnu-debuglink=${PROG}.symbols \ +.if defined(MK_DEBUG_FILES) +${PROG}: ${PROG}.debug ${PROGNAME}.symbols + ${OBJCOPY} --strip-debug --add-gnu-debuglink=${PROGNAME}.symbols \ ${PROG}.debug ${.TARGET} || cp -f ${PROG}.debug ${.TARGET} -${PROG}.symbols: ${PROG}.debug +${PROGNAME}.symbols: ${PROG}.debug ${OBJCOPY} --only-keep-debug ${PROG}.debug ${.TARGET} || \ touch ${.TARGET} .endif @@ -127,8 +129,8 @@ all: _manpages .if defined(PROG) CLEANFILES+= ${PROG} -.if defined(DEBUG_FLAGS) -CLEANFILES+= ${PROG}.debug ${PROG}.symbols +.if defined(MK_DEBUG_FILES) +CLEANFILES+= ${PROG}.debug ${PROGNAME}.symbols .endif .endif @@ -177,9 +179,10 @@ _proginstall: .if defined(PROG) ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME} -.if defined(DEBUG_FLAGS) - -${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ - ${_INSTALLFLAGS} ${PROG}.symbols ${DESTDIR}${BINDIR} +.if defined(MK_DEBUG_FILES) + test -f ${PROGNAME}.symbols && ${INSTALL} -o ${BINOWN} -g ${BINGRP} \ + -m ${BINMODE} ${_INSTALLFLAGS} ${PROGNAME}.symbols \ + ${DESTDIR}${BINDIR} .endif .endif .endif # !target(realinstall)