Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/share/mk - make the CTFCONVERT command lines consistent and ...



details:   https://anonhg.NetBSD.org/src/rev/2a6af7a6ddf9
branches:  trunk
changeset: 942519:2a6af7a6ddf9
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Nov 09 16:15:05 2020 +0000

description:
- make the CTFCONVERT command lines consistent and concise by putting all
  the implementation stuff in a variable CTFCONVERT_RUN
- introduce an OBJECT_TARGET variable that contains the output object file
- when we need to run ctfconvert, go through an intermediate ${.TARGET}.o
  file, instead of writing directly to ${.TARGET} and then overwriting
  ${.TARGET} with ctfconvert. This avoids build failures after a build
  got interrupted (the "partially built from C" scourge).

diffstat:

 share/mk/bsd.lib.mk  |  62 +++++++++++++--------------------------
 share/mk/bsd.prog.mk |  14 +++-----
 share/mk/bsd.sys.mk  |  26 +++++-----------
 share/mk/sys.mk      |  79 ++++++++++++++++++++++++++++-----------------------
 4 files changed, 79 insertions(+), 102 deletions(-)

diffs (truncated from 401 to 300 lines):

diff -r 5c279911a6e3 -r 2a6af7a6ddf9 share/mk/bsd.lib.mk
--- a/share/mk/bsd.lib.mk       Mon Nov 09 12:12:08 2020 +0000
+++ b/share/mk/bsd.lib.mk       Mon Nov 09 16:15:05 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: bsd.lib.mk,v 1.383 2020/06/01 14:39:14 christos Exp $
+#      $NetBSD: bsd.lib.mk,v 1.384 2020/11/09 16:15:05 christos Exp $
 #      @(#)bsd.lib.mk  8.3 (Berkeley) 4/22/94
 
 .include <bsd.init.mk>
@@ -221,20 +221,16 @@
 
 .c.o:
        ${_MKTARGET_COMPILE}
-       ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
-.if defined(CTFCONVERT)
-       ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
-.endif
+       ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} ${OBJECT_TARGET}
+       ${CTFCONVERT_RUN}
 .if defined(LIBSTRIPCOBJS)
        ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
 .endif
 
 .c.po:
        ${_MKTARGET_COMPILE}
-       ${COMPILE.c} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${PGFLAGS} ${.IMPSRC} -o ${.TARGET}
-.if defined(CTFCONVERT)
-       ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
-.endif
+       ${COMPILE.c} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${PGFLAGS} ${.IMPSRC} ${OBJECT_TARGET}
+       ${CTFCONVERT_RUN}
 .if defined(LIBSTRIPCOBJS)
        ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
 .endif
@@ -277,20 +273,16 @@
 
 .f.o:
        ${_MKTARGET_COMPILE}
-       ${COMPILE.f} ${.IMPSRC} -o ${.TARGET}
-.if defined(CTFCONVERT)
-       ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
-.endif
+       ${COMPILE.f} ${.IMPSRC} ${OBJECT_TARGET}
+       ${CTFCONVERT_RUN}
 .if defined(LIBSTRIPFOBJS)
        ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
 .endif
 
 .f.po:
        ${_MKTARGET_COMPILE}
-       ${COMPILE.f} ${PROFFLAGS} ${PGFLAGS} ${.IMPSRC} -o ${.TARGET}
-.if defined(CTFCONVERT)
-       ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
-.endif
+       ${COMPILE.f} ${PROFFLAGS} ${PGFLAGS} ${.IMPSRC} ${OBJECT_TARGET}
+       ${CTFCONVERT_RUN}
 .if defined(LIBSTRIPFOBJS)
        ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
 .endif
@@ -312,20 +304,16 @@
 
 .m.o:
        ${_MKTARGET_COMPILE}
-       ${COMPILE.m} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
-.if defined(CTFCONVERT)
-       ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
-.endif
+       ${COMPILE.m} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} ${OBJECT_TARGET}
+       ${CTFCONVERT_RUN}
 .if defined(LIBSTRIPOBJCOBJS)
        ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
 .endif
 
 .m.po:
        ${_MKTARGET_COMPILE}
-       ${COMPILE.m} ${PROFFLAGS} ${PGFLAGS} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
-.if defined(CTFCONVERT)
-       ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
-.endif
+       ${COMPILE.m} ${PROFFLAGS} ${PGFLAGS} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} ${OBJECT_TARGET}
+       ${CTFCONVERT_RUN}
 .if defined(LIBSTRIPOBJCOBJS)
        ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
 .endif
@@ -346,40 +334,32 @@
 
 .s.o:
        ${_MKTARGET_COMPILE}
-       ${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
-.if defined(CTFCONVERT)
-       ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
-.endif
+       ${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} ${OBJECT_TARGET}
+       ${CTFCONVERT_RUN}
 .if defined(LIBSTRIPAOBJS)
        ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
 .endif
 
 .S.o:
        ${_MKTARGET_COMPILE}
-       ${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
-.if defined(CTFCONVERT)
-       ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
-.endif
+       ${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} ${OBJECT_TARGET}
+       ${CTFCONVERT_RUN}
 .if defined(LIBSTRIPAOBJS)
        ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
 .endif
 
 .s.po:
        ${_MKTARGET_COMPILE}
-       ${COMPILE.s} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
-.if defined(CTFCONVERT)
-       ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
-.endif
+       ${COMPILE.s} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} ${OBJECT_TARGET}
+       ${CTFCONVERT_RUN}
 .if defined(LIBSTRIPAOBJS)
        ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
 .endif
 
 .S.po:
        ${_MKTARGET_COMPILE}
-       ${COMPILE.S} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
-.if defined(CTFCONVERT)
-       ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
-.endif
+       ${COMPILE.S} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} ${OBJECT_TARGET}
+       ${CTFCONVERT_RUN}
 .if defined(LIBSTRIPAOBJS)
        ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}
 .endif
diff -r 5c279911a6e3 -r 2a6af7a6ddf9 share/mk/bsd.prog.mk
--- a/share/mk/bsd.prog.mk      Mon Nov 09 12:12:08 2020 +0000
+++ b/share/mk/bsd.prog.mk      Mon Nov 09 16:15:05 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: bsd.prog.mk,v 1.334 2020/11/09 10:19:18 martin Exp $
+#      $NetBSD: bsd.prog.mk,v 1.335 2020/11/09 16:15:05 christos Exp $
 #      @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94
 
 .ifndef HOSTPROG
@@ -39,19 +39,15 @@
 CLEANFILES+=strings
 .c.o:
        ${CC} -E ${CPPFLAGS} ${CFLAGS} ${.IMPSRC} | xstr -c -
-       @${CC} ${CPPFLAGS} ${CFLAGS} -c x.c -o ${.TARGET}
-.if defined(CTFCONVERT)
-       ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
-.endif
+       @${CC} ${CPPFLAGS} ${CFLAGS} -c x.c ${OBJECT_TARGET}
+       ${CTFCONVERT_RUN}
        @rm -f x.c
 
 .cc.o .cpp.o .cxx.o .C.o:
        ${CXX} -E ${CPPFLAGS} ${CXXFLAGS} ${.IMPSRC} | xstr -c -
        @${MV} x.c x.cc
-       @${CXX} ${CPPFLAGS} ${CXXFLAGS} -c x.cc -o ${.TARGET}
-.if defined(CTFCONVERT)
-       ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
-.endif
+       @${CXX} ${CPPFLAGS} ${CXXFLAGS} -c x.cc ${OBJECT_TARGET}
+       ${CTFCONVERT_RUN}
        @rm -f x.cc
 .endif
 
diff -r 5c279911a6e3 -r 2a6af7a6ddf9 share/mk/bsd.sys.mk
--- a/share/mk/bsd.sys.mk       Mon Nov 09 12:12:08 2020 +0000
+++ b/share/mk/bsd.sys.mk       Mon Nov 09 16:15:05 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: bsd.sys.mk,v 1.303 2020/09/05 13:38:43 mrg Exp $
+#      $NetBSD: bsd.sys.mk,v 1.304 2020/11/09 16:15:05 christos Exp $
 #
 # Build definitions used for NetBSD source tree builds.
 
@@ -266,10 +266,8 @@
 # C
 .c.o:
        ${_MKTARGET_COMPILE}
-       ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
-.if defined(CTFCONVERT)
-       ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
-.endif
+       ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} ${OBJECT_TARGET}
+       ${CTFCONVERT_RUN}
 
 .c.ln:
        ${_MKTARGET_COMPILE}
@@ -288,10 +286,8 @@
 #  used for Objective C source)
 .m.o:
        ${_MKTARGET_COMPILE}
-       ${COMPILE.m} ${OBJCOPTS} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC}
-.if defined(CTFCONVERT)
-       ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
-.endif
+       ${COMPILE.m} ${OBJCOPTS} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} ${OBJECT_TARGET}
+       ${CTFCONVERT_RUN}
 
 # Host-compiled C objects
 # The intermediate step is necessary for Sun CC, which objects to calling
@@ -310,17 +306,13 @@
 # Assembly
 .s.o:
        ${_MKTARGET_COMPILE}
-       ${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
-.if defined(CTFCONVERT)
-       ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
-.endif
+       ${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} ${OBJECT_TARGET}
+       ${CTFCONVERT_RUN}
 
 .S.o:
        ${_MKTARGET_COMPILE}
-       ${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
-.if defined(CTFCONVERT)
-       ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
-.endif
+       ${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} ${OBJECT_TARGET}
+       ${CTFCONVERT_RUN}
 
 # Lex
 LFLAGS+=       ${LPREFIX.${.IMPSRC:T}:D-P${LPREFIX.${.IMPSRC:T}}}
diff -r 5c279911a6e3 -r 2a6af7a6ddf9 share/mk/sys.mk
--- a/share/mk/sys.mk   Mon Nov 09 12:12:08 2020 +0000
+++ b/share/mk/sys.mk   Mon Nov 09 16:15:05 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: sys.mk,v 1.143 2020/02/08 21:16:53 maya Exp $
+#      $NetBSD: sys.mk,v 1.144 2020/11/09 16:15:05 christos Exp $
 #      @(#)sys.mk      8.2 (Berkeley) 3/21/94
 #
 # This file contains the basic rules for make(1) and is read first
@@ -47,6 +47,8 @@
 # C Type Format data is required for DTrace
 CTFFLAGS       ?=      -g -L VERSION
 CTFMFLAGS      ?=      -t -g -L VERSION
+OBJECT_TARGET  ?= -o ${.TARGET}${defined(CTFCONVERT):?.o:}
+CTFCONVERT_RUN ?= ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} -o ${.TARGET} ${.TARGET}.o && rm -f ${.TARGET}.o:}
 
 CXX?=          c++
 # Strip flags unsupported by C++ compilers
@@ -119,12 +121,12 @@
 
 # C
 .c:
-       ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+       ${LINK.c} ${OBJECT_TARGET} ${.IMPSRC} ${LDLIBS}
 # XXX: disable for now
-#      ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
+#      ${CTFCONVERT_RUN}
 .c.o:
-       ${COMPILE.c} ${.IMPSRC}
-       ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
+       ${COMPILE.c} ${.IMPSRC} ${OBJECT_TARGET}
+       ${CTFCONVERT_RUN}
 .c.a:
        ${COMPILE.c} ${.IMPSRC}
        ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
@@ -136,9 +138,12 @@
 
 # C++
 .cc .cpp .cxx .C:
-       ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+       ${LINK.cc} ${OBJECT_TARGET} ${.IMPSRC} ${LDLIBS}
+# XXX: disable for now
+#      ${CTFCONVERT_RUN}
 .cc.o .cpp.o .cxx.o .C.o:
-       ${COMPILE.cc} ${.IMPSRC}
+       ${COMPILE.cc} ${.IMPSRC} ${OBJECT_TARGET}
+       ${CTFCONVERT_RUN}
 .cc.a .cpp.a .cxx.a .C.a:
        ${COMPILE.cc} ${.IMPSRC}
        ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
@@ -146,31 +151,33 @@
 
 # Fortran/Ratfor
 .f:
-       ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+       ${LINK.f} ${OBJECT_TARGET} ${.IMPSRC} ${LDLIBS}
+       ${CTFCONVERT_RUN}
 .f.o:
-       ${COMPILE.f} ${.IMPSRC}
-       ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
+       ${COMPILE.f} ${.IMPSRC} ${OBJECT_TARGET}
+       ${CTFCONVERT_RUN}
 .f.a:
        ${COMPILE.f} ${.IMPSRC}
        ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
        rm -f ${.PREFIX}.o
 
 .F:
-       ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-       ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
+       ${LINK.F} ${OBJECT_TARGET} ${.IMPSRC} ${LDLIBS}
+       ${CTFCONVERT_RUN}
 .F.o:
-       ${COMPILE.F} ${.IMPSRC}
-       ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} ${.TARGET}:}
+       ${COMPILE.F} ${.IMPSRC} ${OBJECT_TARGET}
+       ${CTFCONVERT_RUN}



Home | Main Index | Thread Index | Old Index