Subject: ability to build -g libraries....
To: None <tech-toolchain@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-toolchain
Date: 03/26/2006 20:13:28
Hello,

Here's a simple approach that adds .go as a suffix and builds lib_g.a 
the same way we build lib_p.a. It also fixes a pasto... Can you spot it?

christos

Index: bsd.lib.mk
===================================================================
RCS file: /cvsroot/src/share/mk/bsd.lib.mk,v
retrieving revision 1.264
diff -u -u -r1.264 bsd.lib.mk
--- bsd.lib.mk	16 Mar 2006 18:43:34 -0000	1.264
+++ bsd.lib.mk	27 Mar 2006 01:10:15 -0000
@@ -92,7 +92,7 @@
 # add additional suffixes not exported.
 # .po is used for profiling object files.
 # .so is used for PIC object files.
-.SUFFIXES: .out .a .ln .so .po .o .s .S .c .cc .cpp .cxx .C .m .F .f .r .y .l .cl .p .h
+.SUFFIXES: .out .a .ln .so .po .go .o .s .S .c .cc .cpp .cxx .C .m .F .f .r .y .l .cl .p .h
 .SUFFIXES: .sh .m4 .m
 
 
@@ -196,6 +196,10 @@
 	${OBJCOPY} -X ${.TARGET}
 .endif
 
+.c.go:
+	${_MKTARGET_COMPILE}
+	${COMPILE.c} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -g ${.IMPSRC} -o ${.TARGET}
+
 .c.so:
 	${_MKTARGET_COMPILE}
 	${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
@@ -210,13 +214,17 @@
 	${OBJCOPY} -x ${.TARGET}
 .endif
 
-.cc.po .cpp.po .cxx.o .C.po:
+.cc.po .cpp.po .cxx.po .C.po:
 	${_MKTARGET_COMPILE}
 	${COMPILE.cc} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -pg ${.IMPSRC} -o ${.TARGET}
 .if !defined(COPTS) || empty(COPTS:M*-g*)
 	${OBJCOPY} -X ${.TARGET}
 .endif
 
+.cc.go .cpp.go .cxx.go .C.go:
+	${_MKTARGET_COMPILE}
+	${COMPILE.cc} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -g ${.IMPSRC} -o ${.TARGET}
+
 .cc.so .cpp.so .cxx.so .C.so:
 	${_MKTARGET_COMPILE}
 	${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
@@ -238,6 +246,10 @@
 	${OBJCOPY} -X ${.TARGET}
 .endif
 
+.f.go:
+	${_MKTARGET_COMPILE}
+	${COMPILE.f} ${DEBUGFLAGS} -g ${.IMPSRC} -o ${.TARGET}
+
 .f.so:
 	${_MKTARGET_COMPILE}
 	${COMPILE.f} ${FPICFLAGS} ${.IMPSRC} -o ${.TARGET}
@@ -263,6 +275,13 @@
 	${OBJCOPY} -X ${.TARGET}
 .endif
 
+.m.go:
+	${_MKTARGET_COMPILE}
+	${COMPILE.m} ${DEBUGFLAGS} -g ${.IMPSRC} -o ${.TARGET}
+.if !defined(OBJCFLAGS) || empty(OBJCFLAGS:M*-g*)
+	${OBJCOPY} -X ${.TARGET}
+.endif
+
 .m.so:
 	${_MKTARGET_COMPILE}
 	${COMPILE.m} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
@@ -290,6 +309,14 @@
 	${COMPILE.S} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
 	${OBJCOPY} -X ${.TARGET}
 
+.s.go:
+	${_MKTARGET_COMPILE}
+	${COMPILE.s} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
+
+.S.go:
+	${_MKTARGET_COMPILE}
+	${COMPILE.S} ${DEBUGFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
+
 .s.so:
 	${_MKTARGET_COMPILE}
 	${COMPILE.s} ${CAPICFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
@@ -317,6 +344,12 @@
 libinstall::
 .else	# ${MKPRIVATELIB} == "no"					# {
 
+.if ${MKDEBUG} != "no"
+_LIBS+=lib${LIB}_g.a
+GOBJS+=${OBJS:.o=.go}
+DEBUGFLAGS?=-DDEBUG
+.endif
+
 .if ${MKPROFILE} != "no"
 _LIBS+=lib${LIB}_p.a
 POBJS+=${OBJS:.o=.po}
@@ -393,7 +426,7 @@
 DPSRCS+=	${_YLSRCS}
 CLEANFILES+=	${_YLSRCS}
 
-${STOBJS} ${POBJS} ${SOBJS} ${LOBJS}: ${DPSRCS}
+${STOBJS} ${POBJS} ${GOBJS} ${SOBJS} ${LOBJS}: ${DPSRCS}
 
 lib${LIB}.a:: ${STOBJS} __archivebuild
 
@@ -401,6 +434,8 @@
 
 lib${LIB}_pic.a:: ${SOBJS} __archivebuild
 
+lib${LIB}_g.a:: ${GOBJS} __archivebuild
+
 
 _LIBLDOPTS=
 .if ${SHLIBDIR} != "/usr/lib"
@@ -454,8 +489,9 @@
 	rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
 	rm -f lib${LIB}.a ${STOBJS}
 	rm -f lib${LIB}_p.a ${POBJS}
+	rm -f lib${LIB}_g.a ${GOBJS}
 	rm -f lib${LIB}_pic.a lib${LIB}.so.* lib${LIB}.so ${SOBJS}
-	rm -f ${STOBJS:=.tmp} ${POBJS:=.tmp} ${SOBJS:=.tmp}
+	rm -f ${STOBJS:=.tmp} ${POBJS:=.tmp} ${SOBJS:=.tmp} ${GOBJS:=.tmp}
 	rm -f llib-l${LIB}.ln ${LOBJS}
 
 
@@ -497,6 +533,23 @@
 .endif
 .endif
 
+.if ${MKDEBUG} != "no"
+libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a
+.PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_g.a
+
+.if !defined(UPDATE)
+.if !defined(BUILD) && !make(all) && !make(lib${LIB}_g.a)
+${DESTDIR}${LIBDIR}/lib${LIB}_g.a! .MADE
+.endif
+${DESTDIR}${LIBDIR}/lib${LIB}_g.a! lib${LIB}_g.a __archiveinstall
+.else
+.if !defined(BUILD) && !make(all) && !make(lib${LIB}_g.a)
+${DESTDIR}${LIBDIR}/lib${LIB}_g.a: .MADE
+.endif
+${DESTDIR}${LIBDIR}/lib${LIB}_g.a: lib${LIB}_g.a __archiveinstall
+.endif
+.endif
+
 .if ${MKPIC} != "no" && ${MKPICINSTALL} != "no"
 libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
 .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a