bsd.dep.mk revision 34829
1# $Id: bsd.dep.mk,v 1.18 1998/03/07 13:57:37 bde Exp $ 2# 3# The include file <bsd.dep.mk> handles Makefile dependencies. 4# 5# 6# +++ variables +++ 7# 8# DEPENDFILE dependencies file [.depend] 9# 10# MKDEP Options for ${MKDEPCMD} [not set] 11# 12# MKDEPCMD Makefile dependency list program [mkdep] 13# 14# SRCS List of source files (c, c++, assembler) 15# 16# 17# +++ targets +++ 18# 19# cleandepend: 20# Remove depend and tags file 21# 22# depend: 23# Make the dependencies for the source files, and store 24# them in the file ${DEPENDFILE}. 25# 26# tags: 27# Create a (GLOBAL) gtags file for the source files. 28# If HTML is defined, htags is also run after gtags. 29 30 31MKDEPCMD?= mkdep 32DEPENDFILE?= .depend 33 34.if !target(depend) 35.if defined(SRCS) 36depend: beforedepend ${DEPENDFILE} afterdepend _SUBDIR 37 38# Different types of sources are compiled with slightly different flags. 39# Split up the sources, and filter out headers and non-applicable flags. 40${DEPENDFILE}: ${SRCS} 41 rm -f ${DEPENDFILE} 42.if ${SRCS:M*.[sS]} != "" 43 ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \ 44 ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BID]*} \ 45 ${AINC} \ 46 ${.ALLSRC:M*.[sS]} 47.endif 48.if ${SRCS:M*.c} != "" 49 ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \ 50 ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BID]*} \ 51 ${.ALLSRC:M*.c} 52.endif 53.if ${SRCS:M*.cc} != "" || ${SRCS:M*.C} != "" || ${SRCS:M*.cxx} != "" 54 ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \ 55 ${CXXFLAGS:M-nostdinc*} ${CXXFLAGS:M-[BID]*} \ 56 ${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx} 57.endif 58.if target(_EXTRADEPEND) 59 cd ${.CURDIR}; ${MAKE} _EXTRADEPEND 60.endif 61 62.ORDER: ${DEPENDFILE} afterdepend 63.else 64depend: beforedepend afterdepend _SUBDIR 65.endif 66.if !target(beforedepend) 67beforedepend: 68.else 69.ORDER: beforedepend ${DEPENDFILE} 70.ORDER: beforedepend afterdepend 71.endif 72.if !target(afterdepend) 73afterdepend: 74.endif 75.endif 76 77.if defined(NOTAGS) 78tags: 79.endif 80 81.if !target(tags) 82tags: ${SRCS} _SUBDIR 83 @cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR} 84.if defined(HTML) 85 @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR} 86.endif 87.endif 88 89.if !target(cleandepend) 90cleandepend: _SUBDIR 91.if defined(SRCS) 92 rm -f ${DEPENDFILE} ${.OBJDIR}/GRTAGS ${.OBJDIR}/GSYMS ${.OBJDIR}/GTAGS 93.if defined(HTML) 94 rm -rf ${.OBJDIR}/HTML 95.endif 96.endif 97.endif 98 99_SUBDIR: .USE 100.if defined(SUBDIR) && !empty(SUBDIR) 101 @for entry in ${SUBDIR}; do \ 102 (${ECHODIR} "===> ${DIRPRFX}$$entry"; \ 103 if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \ 104 cd ${.CURDIR}/$${entry}.${MACHINE}; \ 105 else \ 106 cd ${.CURDIR}/$${entry}; \ 107 fi; \ 108 ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/} DIRPRFX=${DIRPRFX}$$entry/); \ 109 done 110.endif 111