Add this for games/hack, found by krw@

Index: Makefile
===================================================================
RCS file: /cvs/src/games/hack/Makefile,v
retrieving revision 1.14
diff -u -p -r1.14 Makefile
--- Makefile    24 Nov 2015 03:10:10 -0000      1.14
+++ Makefile    29 Jun 2017 00:40:45 -0000
@@ -19,7 +19,7 @@ DPADD+=       ${LIBCURSES}
 LDADD+=        -lcurses
 CLEANFILES+=hack.onames.h makedefs
 
-${PROG}: hack.onames.h
+BUILDFIRST = hack.onames.h
 
 hack.onames.h: makedefs def.objects.h
        ${.OBJDIR}/makedefs ${.CURDIR}/def.objects.h > hack.onames.h


There might be one or two more lurking...  somewhat random build order
with make -j4 doesn't help.

On Wed, Jun 28, 2017 at 04:59:37PM +0200, Marc Espie wrote:
> This is the actual patch that more or less neuters depends.
> 
> So this gets rid of all internals for depend/beforedepend/afterdepend.
> 
> NOTE that this does not *remove* the 'make depend' stage, just it won't do
> anything except for a few select parts (old gcc3 and mesa in particular
> depend on it).
> 
> (aoyama-san, luna88k should be happy with this, hopefully)
> 
> bsd.prog.mk and bsd.lib.mk both use -MD -MP, they both add to DEPS,
> and bsd.dep.mk   sincludes all the *.d files declared in DEPS.
> 
> The rest is there to cope with some funny aspects of our makefiles and
> compilers.
> 
> - both gcc and clang need some extra-handholding when using -MD -MP for
> asm files.   They do need to be told where to put the result with -MF,
> otherwise, they *will* just do the depends part, and not the actual compile.
> 
> - all "behind  the scene" targets that do some intermediate compiles need
> some adjustment. Specifically, yacc and lex rules use some extra sed to
> get the actual target in the .d file. And lib rules always go thru some
> intermediate stage.
> 
> - like for "old-style" depends, all the .o/.po/.so/.do... targets in lib
> end up generating one single .d, with all the targets jumbled together,
> which is then moved atomically to its resting place using mv.
> 
> - final trick: .S rules in bsd.prog.mk are only defined if bsd.lib.mk
> didn't already define it.
> 
> 
> This code has been run thru build, release, xenocara, and ports for a
> while now...
> 
> It should be at least as accurate at generating depends on-the-fly as
> the old code was generating depend in one-go (and this code DOES generate
> depends in clang without any extra mechanism needed).
> 
> 
> Variable names and details are open to discussion, but this should be
> in good enough shape for okays.
> 
> 
> Once this gets in, the final stages mostly involve cleaning up obsolete
> beforedepend/afterdepend targets,   getting rid of depend for the few
> directories that do something special there (e.g., gcc3 and mesa) and no
> longer running depend at all.
> 
> 
> 
> Index: bsd.dep.mk
> ===================================================================
> RCS file: /cvs/src/share/mk/bsd.dep.mk,v
> retrieving revision 1.15
> diff -u -p -r1.15 bsd.dep.mk
> --- bsd.dep.mk        16 Jun 2017 10:20:52 -0000      1.15
> +++ bsd.dep.mk        28 Jun 2017 14:50:51 -0000
> @@ -1,42 +1,22 @@
>  #    $OpenBSD: bsd.dep.mk,v 1.15 2017/06/16 10:20:52 espie Exp $
>  #    $NetBSD: bsd.dep.mk,v 1.12 1995/09/27 01:15:09 christos Exp $
>  
> -# some of the rules involve .h sources, so remove them from mkdep line
> -.if !target(depend)
> -depend: beforedepend .depend realdepend afterdepend
> -.ORDER: beforedepend .depend realdepend afterdepend
> -realdepend: _SUBDIRUSE
> -
> -.  if defined(SRCS) && !empty(SRCS)
> -.depend: ${SRCS} ${_LEXINTM} ${_YACCINTM}
> -     @rm -f .depend
> -     @files="${.ALLSRC:M*.s} ${.ALLSRC:M*.S}"; \
> -     if [ "$$files" != " " ]; then \
> -       echo mkdep -a ${MKDEP} ${CFLAGS:M-std=*} ${CFLAGS:M-[ID]*} 
> ${CPPFLAGS} ${AINC} $$files;\
> -       mkdep -a ${MKDEP} ${CFLAGS:M-std=*} ${CFLAGS:M-[ID]*} ${CPPFLAGS} 
> ${AINC} $$files; \
> -     fi
> -     @files="${.ALLSRC:M*.c}"; \
> -     if [ "$$files" != "" ]; then \
> -       echo mkdep -a ${MKDEP} ${CFLAGS:M-std=*} ${CFLAGS:M-[ID]*} 
> ${CPPFLAGS} $$files; \
> -       mkdep -a ${MKDEP} ${CFLAGS:M-[ID]*} ${CPPFLAGS} $$files; \
> -     fi
> -     @files="${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cpp}"; \
> -     files="$$files ${.ALLSRC:M*.cxx}"; \
> -     if [ "$$files" != "   " ]; then \
> -       echo CC=${CXX:Q} mkdep -a ${MKDEP} ${CXXFLAGS:M-std=*} 
> ${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$files; \
> -       CC=${CXX:Q} mkdep -a ${MKDEP} ${CXXFLAGS:M-std=*} ${CXXFLAGS:M-[ID]*} 
> ${CPPFLAGS} $$files; \
> -     fi
> -.  else
> -.depend:
> -.  endif
> -.  if !target(beforedepend)
> -beforedepend:
> -.  endif
> -.  if !target(afterdepend)
> -afterdepend:
> -.  endif
> +depend:
> +     @:
> +
> +# relies on DEPS defined by bsd.lib.mk and bsd.prog.mk
> +.if defined(DEPS) && !empty(DEPS)
> +.  for o in ${DEPS}
> +     sinclude $o
> +.  endfor
>  .endif
>  
> +CFLAGS += -MD -MP
> +CXXFLAGS += -MD -MP
> +
> +# libraries need some special love
> +DFLAGS = -MT $*.o -MT $*.po -MT $*.so -MT $*.do
> +
>  .if !target(tags)
>  .  if defined(SRCS)
>  tags: ${SRCS} _SUBDIRUSE
> @@ -47,16 +27,10 @@ tags:
>  .  endif
>  .endif
>  
> -.if defined(SRCS)
> -cleandir: cleandepend
> -cleandepend:
> -     rm -f .depend ${.CURDIR}/tags
> -.endif
>  
> +CLEANFILES += ${DEPS}
>  BUILDFIRST ?=
>  BUILDAFTER ?=
>  .if !empty(BUILDFIRST) && !empty(BUILDAFTER)
>  ${BUILDAFTER}: ${BUILDFIRST}
>  .endif
> -
> -.PHONY: beforedepend depend afterdepend cleandepend realdepend
> Index: bsd.lib.mk
> ===================================================================
> RCS file: /cvs/src/share/mk/bsd.lib.mk,v
> retrieving revision 1.84
> diff -u -p -r1.84 bsd.lib.mk
> --- bsd.lib.mk        16 Jun 2017 10:20:52 -0000      1.84
> +++ bsd.lib.mk        28 Jun 2017 14:50:51 -0000
> @@ -38,92 +38,107 @@ DIST_CFLAGS+=    -Os
>  
>  .c.o:
>       @echo "${COMPILE.c} ${.IMPSRC} -o ${.TARGET}"
> -     @${COMPILE.c} ${.IMPSRC}  -o ${.TARGET}.o
> +     @${COMPILE.c} ${DFLAGS} ${.IMPSRC}  -o ${.TARGET}.o
> +     @-mv [email protected] $*.d
>       @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
>       @rm -f ${.TARGET}.o
>  
>  .c.po:
>       @echo "${COMPILE.c} -p ${.IMPSRC} -o ${.TARGET}"
> -     @${COMPILE.c} -p ${.IMPSRC} -o ${.TARGET}.o
> +     @${COMPILE.c} ${DFLAGS} -p ${.IMPSRC} -o ${.TARGET}.o
> +     @-mv [email protected] $*.d
>       @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
>       @rm -f ${.TARGET}.o
>  
>  .c.so:
>       @echo "${COMPILE.c} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}"
> -     @${COMPILE.c} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
> +     @${COMPILE.c} ${DFLAGS} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
> +     @-mv [email protected] $*.d
>       @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
>       @rm -f ${.TARGET}.o
>  
>  .c.do:
>       @echo "${COMPILE.c} ${DIST_CFLAGS} ${.IMPSRC} -o ${.TARGET}"
> -     @${COMPILE.c} ${DIST_CFLAGS} ${.IMPSRC}  -o ${.TARGET}.o
> +     @${COMPILE.c} ${DFLAGS} ${DIST_CFLAGS} ${.IMPSRC}  -o ${.TARGET}.o
> +     @-mv [email protected] $*.d
>       @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
>       @rm -f ${.TARGET}.o
>  
>  .cc.o .cpp.o .C.o .cxx.o:
>       @echo "${COMPILE.cc} ${.IMPSRC} -o ${.TARGET}"
> -     @${COMPILE.cc} ${.IMPSRC} -o ${.TARGET}.o
> +     @${COMPILE.cc} ${DFLAGS} ${.IMPSRC} -o ${.TARGET}.o
> +     @-mv [email protected] $*.d
>       @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
>       @rm -f ${.TARGET}.o
>  
>  .cc.po .cpp.po .C.po .cxx.po:
>       @echo "${COMPILE.cc} -p ${.IMPSRC} -o ${.TARGET}"
> -     @${COMPILE.cc} -p ${.IMPSRC} -o ${.TARGET}.o
> +     @${COMPILE.cc} ${DFLAGS} -p ${.IMPSRC} -o ${.TARGET}.o
> +     @-mv [email protected] $*.d
>       @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
>       @rm -f ${.TARGET}.o
>  
>  .cc.so .cpp.so .C.so .cxx.so:
>       @echo "${COMPILE.cc} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}"
> -     @${COMPILE.cc} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
> +     @${COMPILE.cc} ${DFLAGS} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
> +     @-mv [email protected] $*.d
>       @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
>       @rm -f ${.TARGET}.o
>  
>  # Fortran 77
>  .f.o:
>       @echo "${COMPILE.f} ${.IMPSRC} -o ${.TARGET}"
> -     @${COMPILE.f} ${.IMPSRC} -o ${.TARGET}.o
> +     @${COMPILE.f} ${DFLAGS} ${.IMPSRC} -o ${.TARGET}.o
> +     @-mv [email protected] $*.d
>       @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
>       @rm -f ${.TARGET}.o
>  
>  .f.po:
>       @echo "${COMPILE.f} -p ${.IMPSRC} -o ${.TARGET}"
> -     @${COMPILE.f} -p ${.IMPSRC} -o ${.TARGET}.o
> +     @${COMPILE.f} ${DFLAGS} -p ${.IMPSRC} -o ${.TARGET}.o
> +     @-mv [email protected] $*.d
>       @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
>       @rm -f ${.TARGET}.o
>  
>  .f.so:
>       @echo "${COMPILE.f} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}"
> -     @${COMPILE.f} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
> +     @${COMPILE.f} ${DFLAGS} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
> +     @-mv [email protected] $*.d
>       @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
>       @rm -f ${.TARGET}.o
>  
>  .S.o .s.o:
>       @echo "${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}"
> -     @${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
> +     @${COMPILE.S} ${DFLAGS} -MF [email protected] ${CFLAGS:M-[IDM]*} ${AINC} \
> +         ${.IMPSRC} -o ${.TARGET}.o
> +     @-mv [email protected] $*.d
>       @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
>       @rm -f ${.TARGET}.o
>  
>  .S.po .s.po:
>       @echo "${COMPILE.S} -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} \
>           -o ${.TARGET}"
> -     @${COMPILE.S} -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} \
> -         -o ${.TARGET}.o
> +     @${COMPILE.S} ${DFLAGS} -MF [email protected] -DPROF ${CFLAGS:M-[IDM]*} ${AINC} \
> +         ${.IMPSRC} -o ${.TARGET}.o
> +     @-mv [email protected] $*.d
>       @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
>       @rm -f ${.TARGET}.o
>  
>  .S.so .s.so:
>       @echo "${COMPILE.S} ${PICFLAG} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} \
>           -o ${.TARGET}"
> -     @${COMPILE.S} ${PICFLAG} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} \
> -         -o ${.TARGET}.o
> +     @${COMPILE.S} ${DFLAGS} -MF [email protected] ${PICFLAG} ${CFLAGS:M-[IDM]*} \
> +         ${AINC} ${.IMPSRC} -o ${.TARGET}.o
> +     @-mv [email protected] $*.d
>       @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
>       @rm -f ${.TARGET}.o
>  
>  .S.do .s.do:
>       @echo "${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${DIST_CFLAGS} \
>           ${.IMPSRC} -o ${.TARGET}"
> -     @${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${DIST_CFLAGS} ${.IMPSRC} \
> -         -o ${.TARGET}.o
> +     @${COMPILE.S} ${DFLAGS} -MF [email protected] ${CFLAGS:M-[IDM]*} ${AINC} \
> +         ${DIST_CFLAGS} ${.IMPSRC} -o ${.TARGET}.o
> +     @-mv [email protected] $*.d
>       @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
>       @rm -f ${.TARGET}.o
>  
> @@ -167,6 +182,7 @@ all: ${_LIBS} _SUBDIRUSE
>  BUILDAFTER += ${_LIBS}
>  
>  OBJS+=       ${SRCS:N*.h:R:S/$/.o/}
> +DEPS+=       ${OBJS:S/$/.d/}
>  BUILDAFTER += ${OBJS}
>  
>  lib${LIB}.a: ${OBJS}
> @@ -177,6 +193,7 @@ lib${LIB}.a: ${OBJS}
>  
>  POBJS+=      ${OBJS:.o=.po}
>  BUILDAFTER += ${POBJS}
> +
>  lib${LIB}_p.a: ${POBJS}
>       @echo building profiled ${LIB} library
>       @rm -f lib${LIB}_p.a
> @@ -185,6 +202,7 @@ lib${LIB}_p.a: ${POBJS}
>  
>  SOBJS+=      ${OBJS:.o=.so}
>  BUILDAFTER += ${SOBJS}
> +
>  ${FULLSHLIBNAME}: ${SOBJS} ${DPADD}
>       @echo building shared ${LIB} library \(version 
> ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
>       @rm -f ${.TARGET}
> @@ -237,10 +255,6 @@ clean: _SUBDIRUSE
>  
>  cleandir: _SUBDIRUSE clean
>  
> -.if defined(SRCS)
> -afterdepend: .depend
> -     @sed -i 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so \1.do:/' .depend
> -.endif
>  
>  .if !target(install)
>  .if !target(beforeinstall)
> Index: bsd.prog.mk
> ===================================================================
> RCS file: /cvs/src/share/mk/bsd.prog.mk,v
> retrieving revision 1.71
> diff -u -p -r1.71 bsd.prog.mk
> --- bsd.prog.mk       16 Jun 2017 10:20:52 -0000      1.71
> +++ bsd.prog.mk       28 Jun 2017 14:50:51 -0000
> @@ -72,6 +72,8 @@ LIBARCH?=
>  SRCS?=       ${PROG}.c
>  .  if !empty(SRCS:N*.h:N*.sh)
>  OBJS+=       ${SRCS:N*.h:N*.sh:R:S/$/.o/}
> +DEPS+=       ${OBJS:R:S/$/.d/}
> +
>  _LEXINTM+=${SRCS:M*.l:.l=.c}
>  _YACCINTM+=${SRCS:M*.y:.y=.c}
>  .  endif
> @@ -139,6 +141,15 @@ realinstall: beforeinstall
>  
>  .if !defined(NOMAN)
>  .include <bsd.man.mk>
> +.endif
> +
> +# if we already got bsd.lib.mk we don't want to wreck that
> +.if !defined(_LIBS)
> +.s.o:
> +     ${COMPILE.S} -MD -MF ${.TARGET:R}.d -o $@ ${.IMPSRC}
> +
> +.S.o:
> +     ${COMPILE.S} -MD -MF ${.TARGET:R}.d -o $@ ${.IMPSRC}
>  .endif
>  
>  .include <bsd.obj.mk>
> Index: bsd.sys.mk
> ===================================================================
> RCS file: /cvs/src/share/mk/bsd.sys.mk,v
> retrieving revision 1.10
> diff -u -p -r1.10 bsd.sys.mk
> --- bsd.sys.mk        8 Apr 2012 15:56:28 -0000       1.10
> +++ bsd.sys.mk        28 Jun 2017 14:50:51 -0000
> @@ -22,6 +22,7 @@ CXXFLAGS+= -idirafter ${DESTDIR}/usr/inc
>       ${LEX.l} -o${.TARGET:R}.yy.c ${.IMPSRC}
>       ${COMPILE.c} -o ${.TARGET} ${.TARGET:R}.yy.c 
>       rm -f ${.TARGET:R}.yy.c
> +     if test -f ${.TARGET:R}.d; then sed -i -e 
> 's,${.TARGET:R}.yy.c,${.IMPSRC},' ${.TARGET:R}.d; fi
>  
>  # Yacc
>  .y:
> @@ -35,4 +36,5 @@ CXXFLAGS+= -idirafter ${DESTDIR}/usr/inc
>       ${YACC.y} -b ${.TARGET:R} ${.IMPSRC}
>       ${COMPILE.c} -o ${.TARGET} ${.TARGET:R}.tab.c
>       rm -f ${.TARGET:R}.tab.c
> +     if test -f ${.TARGET:R}.d; then sed -i -e 
> 's,${.TARGET:R}.tab.c,${.IMPSRC},' ${.TARGET:R}.d; fi
>  .endif
> Index: sys.mk
> ===================================================================
> RCS file: /cvs/src/share/mk/sys.mk,v
> retrieving revision 1.77
> diff -u -p -r1.77 sys.mk
> --- sys.mk    4 Mar 2017 16:52:47 -0000       1.77
> +++ sys.mk    28 Jun 2017 14:50:51 -0000
> @@ -195,6 +195,7 @@ CTAGS?=           /usr/bin/ctags
>       ${LEX.l} ${.IMPSRC}
>       ${COMPILE.c} -o ${.TARGET} lex.yy.c 
>       rm -f lex.yy.c
> +     if test -f ${.TARGET:R}.d; then sed -i -e 's,lex.yy.c,${.IMPSRC},' 
> ${.TARGET:R}.d; fi
>  
>  # Yacc
>  .y:
> @@ -208,6 +209,7 @@ CTAGS?=           /usr/bin/ctags
>       ${YACC.y} ${.IMPSRC}
>       ${COMPILE.c} -o ${.TARGET} y.tab.c
>       rm -f y.tab.c
> +     if test -f ${.TARGET:R}.d; then sed -i -e 's,y.tab.c,${.IMPSRC},' 
> ${.TARGET:R}.d; fi
>  
>  # Shell
>  .sh:

Reply via email to