3 # $Id: auto.dep.mk,v 1.5 2016/04/05 15:58:37 sjg Exp $
5 # @(#) Copyright (c) 2010, Simon J. Gerraty
7 # This file is provided in the hope that it will
8 # be of use. There is absolutely NO WARRANTY.
9 # Permission to copy, redistribute or otherwise
10 # use this file is hereby granted provided that
11 # the above copyright notice and this notice are
14 # Please send copies of changes and bug-fixes to:
18 # This module provides automagic dependency generation along the
19 # lines suggested in the GNU make.info
21 # set MKDEP_MK=auto.dep.mk and dep.mk will include us
23 # This version differs from autodep.mk, in that
24 # we use ${.TARGET:T}.d rather than ${.TARGET:T:R}.d
25 # this makes it simpler to get the args to -MF and -MT right
26 # and ensure we can simply include all the .d files.
28 # However suffix rules do not work with something like .o.d so we
29 # don't even try to handle 'make depend' gracefully.
30 # dep.mk will handle that itself.
32 .if
!target
(__
${.PARSEFILE
}__
)
35 # this what bmake > 20100401 will look for
36 .MAKE.DEPENDFILE ?
= .depend
38 # set this to -MMD to ignore /usr/include
39 # actually it ignores <> so may not be a great idea
41 # -MF etc not available on all gcc versions.
42 CFLAGS_MF ?
= -MF
${.TARGET
:T
}.d
-MT
${.TARGET
:T
}
43 CFLAGS
+= ${CFLAGS_MD} ${CFLAGS_MF}
44 CXXFLAGS
+= ${CFLAGS_MD} ${CFLAGS_MF}
46 CLEANFILES
+= .depend
${.MAKE.DEPENDFILE
} *.d
48 .if
${MAKE_VERSION} < 20160218
49 # skip generating dependfile for misc targets
50 .if
${.TARGETS
:Uall
:M
*all} != ""
51 .END
: ${.MAKE.DEPENDFILE
}
54 # doing 'make depend' isn't a big win with this model
56 depend
: ${.MAKE.DEPENDFILE
}
60 ${.MAKE.DEPENDFILE
}: ${OBJS} ${POBJS} ${SOBJS}
61 -@for f in
${.ALLSRC
:M
*o
:T
:O
:u
:%=%.d
}; do \
62 echo
".-include \"$$f\""; \
66 .if empty
(_SKIP_BUILD
)
67 _all_objs
= ${OBJS} ${POBJS} ${SOBJS}
68 .for d in
${_all_objs
:M
*o
:T
:O
:u
:%=%.d
}