-# $OpenBSD: bsd.dep.mk,v 1.15 2017/06/16 10:20:52 espie Exp $
+# $OpenBSD: bsd.dep.mk,v 1.16 2017/07/01 14:41:54 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
+depend:
+ @:
+.endif
-. 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
+# 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
. endif
.endif
-.if defined(SRCS)
-cleandir: cleandepend
-cleandepend:
- rm -f .depend ${.CURDIR}/tags
-.endif
+CLEANFILES += ${DEPS} .depend
BUILDFIRST ?=
BUILDAFTER ?=
.if !empty(BUILDFIRST) && !empty(BUILDAFTER)
${BUILDAFTER}: ${BUILDFIRST}
.endif
-
-.PHONY: beforedepend depend afterdepend cleandepend realdepend
-# $OpenBSD: bsd.lib.mk,v 1.84 2017/06/16 10:20:52 espie Exp $
+# $OpenBSD: bsd.lib.mk,v 1.85 2017/07/01 14:41:54 espie Exp $
# $NetBSD: bsd.lib.mk,v 1.67 1996/01/17 20:39:26 mycroft Exp $
# @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91
.c.o:
@echo "${COMPILE.c} ${.IMPSRC} -o ${.TARGET}"
- @${COMPILE.c} ${.IMPSRC} -o ${.TARGET}.o
+ @${COMPILE.c} ${DFLAGS} ${.IMPSRC} -o ${.TARGET}.o
+ @-mv $@.d $*.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 $@.d $*.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 $@.d $*.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 $@.d $*.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 $@.d $*.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 $@.d $*.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 $@.d $*.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 $@.d $*.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 $@.d $*.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 $@.d $*.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 $@.d ${CFLAGS:M-[IDM]*} ${AINC} \
+ ${.IMPSRC} -o ${.TARGET}.o
+ @-mv $@.d $*.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 $@.d -DPROF ${CFLAGS:M-[IDM]*} ${AINC} \
+ ${.IMPSRC} -o ${.TARGET}.o
+ @-mv $@.d $*.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 $@.d ${PICFLAG} ${CFLAGS:M-[IDM]*} \
+ ${AINC} ${.IMPSRC} -o ${.TARGET}.o
+ @-mv $@.d $*.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 $@.d ${CFLAGS:M-[IDM]*} ${AINC} \
+ ${DIST_CFLAGS} ${.IMPSRC} -o ${.TARGET}.o
+ @-mv $@.d $*.d
@${LD} -X -r ${.TARGET}.o -o ${.TARGET}
@rm -f ${.TARGET}.o
BUILDAFTER += ${_LIBS}
OBJS+= ${SRCS:N*.h:R:S/$/.o/}
+DEPS+= ${OBJS:S/$/.d/}
BUILDAFTER += ${OBJS}
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
SOBJS+= ${OBJS:.o=.so}
BUILDAFTER += ${SOBJS}
+
${FULLSHLIBNAME}: ${SOBJS} ${DPADD}
@echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
@rm -f ${.TARGET}
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)