bsd.dep.mk revision 17800
114062Swpaul#	$Id: bsd.dep.mk,v 1.6 1996/07/27 22:16:54 jkh Exp $
214062Swpaul#
314062Swpaul# The include file <bsd.dep.mk> handles Makefile dependencies.
414062Swpaul#
514062Swpaul#
614062Swpaul# +++ variables +++
714062Swpaul#
814062Swpaul# DEPENDFILE	dependencies file [.depend]
914062Swpaul#
1014062Swpaul# MKDEP		Options for ${MKDEPCMD} [not set]
1114062Swpaul#
1214062Swpaul# MKDEPCMD	Makefile dependency list program [mkdep]
1314062Swpaul# 
1414062Swpaul# SRCS          List of source files (c, c++, assembler)
1514062Swpaul#
1614062Swpaul#
1714062Swpaul# +++ targets +++
1814062Swpaul#
1914062Swpaul#	cleandepend:
2014062Swpaul#		Remove depend and tags file
2114062Swpaul#
2214062Swpaul#	depend:
2314062Swpaul#		Make the dependencies for the source files, and store
2414062Swpaul#		them in the file ${DEPENDFILE}.
2514062Swpaul#
2614062Swpaul#	tags:
2714062Swpaul#		Create a tags file for the source files.
2814062Swpaul#
2914062Swpaul
3014062Swpaul.if !defined(NO_DEPEND)
3114062SwpaulDEPEND?=	depend
3214062Swpaul.endif
3314062Swpaul
3414062SwpaulMKDEPCMD?=	mkdep
3514062SwpaulDEPENDFILE?=	.depend
3614062Swpaul
3714062Swpaul# some of the rules involve .h sources, so remove them from mkdep line
3814062Swpaul.if !target(depend)
3914062Swpauldepend: beforedepend ${DEPENDFILE} afterdepend _SUBDIR
4014062Swpaul.if defined(SRCS)
4114062Swpaul
4214062Swpaul# .if defined ${SRCS:M*.[sS]} does not work
4314062Swpaul__depend_s=	${SRCS:M*.[sS]}
4414062Swpaul__depend_c=	${SRCS:M*.c}
4514062Swpaul__depend_cc=	${SRCS:M*.cc} ${SRCS:M*.C} ${SRCS:M*.cxx}
4614062Swpaul
4714062Swpaul${DEPENDFILE}: ${SRCS}
4814062Swpaul	rm -f ${DEPENDFILE}
4914062Swpaul.if defined(__depend_s) && !empty(__depend_s)
5014062Swpaul	${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} ${CFLAGS:M-[ID]*} ${AINC} \
5114062Swpaul		${.ALLSRC:M*.[sS]}
5214062Swpaul.endif
5314062Swpaul.if defined(__depend_c) && !empty(__depend_c)
5414062Swpaul	${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} ${CFLAGS:M-[ID]*} \
5514062Swpaul		${.ALLSRC:M*.c}
56.endif
57.if defined(__depend_cc) && !empty(__depend_cc)
58	${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
59		${CXXFLAGS:M-nostd*} ${CXXFLAGS:M-[ID]*} \
60		${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx}
61.endif
62
63.else
64${DEPENDFILE}: _SUBDIR
65.endif
66.if !target(beforedepend)
67beforedepend:
68.endif
69.if !target(afterdepend)
70afterdepend:
71.endif
72.endif
73
74.if !target(tags)
75.if defined(SRCS)
76tags: ${SRCS} _SUBDIR
77	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \
78	    sed "s;\${.CURDIR}/;;" > tags
79.else
80tags: _SUBDIR
81.endif
82.endif
83
84.if defined(SRCS)
85.if !target(cleandepend)
86cleandepend: _SUBDIR
87	rm -f ${DEPENDFILE} tags
88.endif
89.endif
90
91_SUBDIR: .USE
92.if defined(SUBDIR) && !empty(SUBDIR)
93	@for entry in ${SUBDIR}; do \
94		(${ECHODIR} "===> ${DIRPRFX}$$entry"; \
95		if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
96			cd ${.CURDIR}/$${entry}.${MACHINE}; \
97		else \
98			cd ${.CURDIR}/$${entry}; \
99		fi; \
100		${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/} DIRPRFX=${DIRPRFX}$$entry/); \
101	done
102.endif
103