Home | History | Annotate | Line # | Download | only in mk
bsd.dep.mk revision 1.44
      1 #	$NetBSD: bsd.dep.mk,v 1.44 2003/06/11 17:32:45 wiz Exp $
      2 
      3 ##### Basic targets
      4 .PHONY:		cleandepend
      5 cleandir:	cleandepend
      6 realdepend:	beforedepend .depend afterdepend
      7 .ORDER:		beforedepend .depend afterdepend
      8 
      9 beforedepend .depend afterdepend: # ensure existence
     10 
     11 ##### Default values
     12 MKDEP?=		mkdep
     13 
     14 ##### Build rules
     15 # some of the rules involve .h sources, so remove them from mkdep line
     16 
     17 .if defined(SRCS)
     18 __acpp_flags=	-traditional-cpp
     19 .NOPATH:	.depend
     20 .if empty(HOST_CYGWIN)
     21 .depend: ${SRCS} ${DPSRCS}
     22 	@rm -f .depend
     23 	@files="${.ALLSRC:M*.s} ${.ALLSRC:M*.S}"; \
     24 	if [ "$$files" != " " ]; then \
     25 	  echo ${MKDEP} -a ${MKDEPFLAGS} \
     26 	    ${AFLAGS:M-[ID]*:Q} ${CPPFLAGS:Q} ${__acpp_flags} ${AINC:Q} \
     27 	    $$files; \
     28 	  ${MKDEP} -a ${MKDEPFLAGS} \
     29 	    ${AFLAGS:M-[ID]*} ${CPPFLAGS} ${__acpp_flags} ${AINC} $$files; \
     30 	fi
     31 	@files="${.ALLSRC:M*.c}"; \
     32 	if [ "$$files" != "" ]; then \
     33 	  echo ${MKDEP} -a ${MKDEPFLAGS} \
     34 	    ${CFLAGS:M-[ID]*:Q} ${CPPFLAGS:Q} $$files; \
     35 	  ${MKDEP} -a ${MKDEPFLAGS} \
     36 	    ${CFLAGS:M-[ID]*} ${CPPFLAGS} $$files; \
     37 	fi
     38 	@files="${.ALLSRC:M*.m}"; \
     39 	if [ "$$files" != "" ]; then \
     40 	  echo ${MKDEP} -a ${MKDEPFLAGS} \
     41 	    ${OBJCFLAGS:M-[ID]*:Q} ${CPPFLAGS:Q} $$files; \
     42 	  ${MKDEP} -a ${MKDEPFLAGS} \
     43 	    ${OBJCFLAGS:M-[ID]*} ${CPPFLAGS} $$files; \
     44 	fi
     45 	@files="${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx} ${.ALLSRC:M*.cpp"; \
     46 	if [ "$$files" != "   " ]; then \
     47 	  echo ${MKDEP} -a ${MKDEPFLAGS} \
     48 	    ${CXXFLAGS:M-[ID]*:Q} ${CPPFLAGS:Q} $$files; \
     49 	  ${MKDEP} -a ${MKDEPFLAGS} \
     50 	    ${CXXFLAGS:M-[ID]*} ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include/g++} ${CPPFLAGS} $$files; \
     51 	fi
     52 .else
     53 #
     54 # Cygwin workarounds for limited environment & command line space
     55 #
     56 
     57 SRCS_S = ${SRCS:M*.[sS]} ${DPSRCS:M*.[sS]}
     58 SRCS_C = ${SRCS:M*.c} ${DPSRCS:M*.c}
     59 SRCS_M = ${SRCS:M*.m} ${DPSRCS:M*.m}
     60 SRCS_X = ${SRCS:M*.C} ${DPSRCS:M*.C} \
     61          ${SRCS:M*.cc} ${DPSRCS:M*.cc} \
     62          ${SRCS:M*.cpp} ${DPSRCS:M*.cpp} \
     63 	 ${SRCS:M*.cxx} ${DPSRCS:M*.cxx} 
     64 
     65 .depend: ${SRCS} ${DPSRCS} \
     66 	 ${SRCS_S:C/(.*)/\1.dep/g:S/^.dep$//g} \
     67 	 ${SRCS_C:C/(.*)/\1.dep/g:S/^.dep$//g} \
     68 	 ${SRCS_M:C/(.*)/\1.dep/g:S/^.dep$//g} \
     69 	 ${SRCS_X:C/(.*)/\1.dep/g:S/^.dep$//g}
     70 	@rm -f .depend
     71 	@cat ${.ALLSRC:M*.dep} > .depend
     72 
     73 .for F in ${SRCS_S:O:u}
     74 .NOPATH: ${F:C/(.*)/\1.dep/g}
     75 ${F:C/(.*)/\1.dep/g}: ${F}
     76 	@echo ${MKDEP} -a -f $@ ${MKDEPFLAGS} \
     77 	    ${AFLAGS:M-[ID]*:Q} ${CPPFLAGS:Q} ${__acpp_flags} ${AINC:Q} \
     78 	    ${.ALLSRC}
     79 	@${MKDEP} -a -f $@ ${MKDEPFLAGS} ${AFLAGS:M-[ID]*} ${CPPFLAGS} \
     80 	    ${__acpp_flags} ${AINC} ${.ALLSRC}
     81 .endfor
     82 
     83 .for F in ${SRCS_C:O:u}
     84 .NOPATH: ${F:C/(.*)/\1.dep/g}
     85 ${F:C/(.*)/\1.dep/g}: ${F}
     86 	@echo ${MKDEP} -a -f $@ ${MKDEPFLAGS} ${CFLAGS:M-[ID]*:Q} \
     87 	    ${CPPFLAGS:Q} ${.ALLSRC}
     88 	@${MKDEP} -a -f $@ ${MKDEPFLAGS} ${CFLAGS:M-[ID]*} ${CPPFLAGS} \
     89 	    ${.ALLSRC}
     90 .endfor
     91 
     92 .for F in ${SRCS_M:O:u}
     93 .NOPATH: ${F:C/(.*)/\1.dep/g}
     94 ${F:C/(.*)/\1.dep/g}: ${F}
     95 	@echo ${MKDEP} -a -f $@ ${MKDEPFLAGS} ${OBJCFLAGS:M-[ID]*:Q} \
     96 	    ${CPPFLAGS:Q} ${.ALLSRC}
     97 	@${MKDEP} -a -f $@ ${MKDEPFLAGS} ${OBJCFLAGS:M-[ID]*} ${CPPFLAGS} \
     98 	    ${.ALLSRC}
     99 .endfor
    100 
    101 .for F in ${SRCS_X:O:u}
    102 .NOPATH: ${F:C/(.*)/\1.dep/g}
    103 ${F:C/(.*)/\1.dep/g}: ${F}
    104 	@echo ${MKDEP} -a -f $@ ${MKDEPFLAGS} \
    105 	    ${CXXFLAGS:M-[ID]*:Q} ${CPPFLAGS:Q} ${.ALLSRC}
    106 	@${MKDEP} -a -f $@ ${MKDEPFLAGS} ${CXXFLAGS:M-[ID]*} \
    107 	    ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEM} \
    108 	    ${DESTDIR}/usr/include/g++} ${CPPFLAGS} ${.ALLSRC}
    109 .endfor
    110 
    111 .endif # Cygwin
    112 .endif # defined(SRCS)
    113 
    114 ##### Clean rules
    115 cleandepend:
    116 .if defined(SRCS)
    117 	rm -f .depend ${.CURDIR}/tags ${CLEANDEPEND}
    118 .endif
    119 
    120 ##### Custom rules
    121 .if !target(tags)
    122 tags: ${SRCS}
    123 .if defined(SRCS)
    124 	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \
    125 	    sed "s;\${.CURDIR}/;;" > tags
    126 .endif
    127 .endif
    128