8498 ficl: variable 'count' might be clobbered by 'longjmp' or 'vfork'
[unleashed.git] / share / mk / auto.dep.mk
blob55b2971be6e0649d29bd79d638010dc654038a79
2 # RCSid:
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
12 # left intact.
14 # Please send copies of changes and bug-fixes to:
15 # sjg@crufty.net
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}__)
33 __${.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
40 CFLAGS_MD ?= -MD
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}
52 .endif
54 # doing 'make depend' isn't a big win with this model
55 .if !target(depend)
56 depend: ${.MAKE.DEPENDFILE}
57 .endif
59 # this is trivial
60 ${.MAKE.DEPENDFILE}: ${OBJS} ${POBJS} ${SOBJS}
61 -@for f in ${.ALLSRC:M*o:T:O:u:%=%.d}; do \
62 echo ".-include \"$$f\""; \
63 done > $@
64 .else
65 # we have .dinclude
66 .if empty(_SKIP_BUILD)
67 _all_objs = ${OBJS} ${POBJS} ${SOBJS}
68 .for d in ${_all_objs:M*o:T:O:u:%=%.d}
69 .dinclude <$d>
70 .endfor
71 .endif
73 .endif
74 .endif