1# Copyright (c) 2010-2013 by Aleksey Cheusov 2# Copyright (c) 1994-2009 The NetBSD Foundation, Inc. 3# Copyright (c) 1988, 1989, 1993 The Regents of the University of California 4# Copyright (c) 1988, 1989 by Adam de Boor 5# Copyright (c) 1989 by Berkeley Softworks 6# 7# See LICENSE file in the distribution. 8############################################################ 9 10.if !defined(_MKC_IMP_SUBPRJ_MK) 11_MKC_IMP_SUBPRJ_MK := 1 12 13EXPORT_VARNAMES += STATICLIBS COMPATLIB SRCTOP OBJTOP 14 15.for dir in ${SUBPRJ:S/:/ /g} 16.if empty(NOSUBDIR:U:M${dir}) 17__REALSUBPRJ += ${dir} 18.endif 19.endfor 20 21.for dir in ${NOSUBDIR} 22NODEPS += *-${dir}:* *:*-${dir} *-*/${dir}:* *:*-*/${dir} 23.endfor 24.for dir in ${INTERNALLIBS} 25NODEPS += install-${dir}:* install-*/${dir}:* \ 26 uninstall-${dir}:* uninstall-*/${dir}:* \ 27 installdirs-${dir}:* installdirs-*/${dir}:* 28.endfor 29 30.ifndef SUBDIR 31__REALSUBPRJ := ${__REALSUBPRJ:O:u} 32.endif 33 34.if !empty(__REALSUBPRJ:M*-*) 35.error "Dash symbol is not allowed inside subdir (${__REALSUBPRJ:M*-*})" 36.endif 37 38SUBPRJ_DFLT ?= ${__REALSUBPRJ} 39 40.for targ in ${TARGETS} 41.for dir in ${__REALSUBPRJ:N.WAIT} 42_ALLTARGDEPS3 += ${targ}-${dir} 43.PHONY: nodeps-${targ}-${dir} subdir-${targ}-${dir} ${targ}-${dir} 44nodeps-${targ}-${dir}: .MAKE __recurse 45 ${targ}-${dir}: .MAKE __recurse 46subdir-${targ}-${dir}: .MAKE __recurse 47.if ${SHORTPRJNAME:tl} == "yes" && ${dir} != ${dir:T} 48_ALLTARGDEPS3 += ${targ}-${dir:T} 49.PHONY: nodeps-${targ}-${dir:T} subdir-${targ}-${dir:T} ${targ}-${dir:T} 50nodeps-${targ}-${dir:T}: nodeps-${targ}-${dir} 51 ${targ}-${dir:T}: ${targ}-${dir} 52subdir-${targ}-${dir:T}: subdir-${targ}-${dir} 53_ALLTARGDEPS3 += ${targ}-${dir}:${targ}-${dir:T} 54.endif 55.endfor # dir 56 57.if !commands(${targ}) 58. for dir in ${SUBPRJ_DFLT} 59dir_ = ${dir} 60. if ${dir_} == ".WAIT" 61_SUBDIR_${targ} += .WAIT 62. else 63_SUBDIR_${targ} += ${targ}-${dir}:${targ} 64. endif # .WAIT 65. endfor # dir 66.for excl in ${NODEPS} 67_SUBDIR_${targ} := ${_SUBDIR_${targ}:N${excl}} 68.endfor # excl 69_ALLTARGDEPS2 += ${_SUBDIR_${targ}} 70${targ}: ${_SUBDIR_${targ}:S/:${targ}$//} 71.endif #!command(${targ}) 72 73.for dep prj in ${SUBPRJ:M*\:*:S/:/ /} 74_ALLTARGDEPS += ${targ}-${dep}:${targ}-${prj} 75.endfor # dep prj 76 77.endfor # targ 78 79.for dir in ${__REALSUBPRJ} 80.if ${SHORTPRJNAME:tl} == "yes" && ${dir:T} != ${dir} 81SRCDIR_${dir:T} = ${.CURDIR}/${dir} 82EXPORT_VARNAMES += SRCDIR_${dir:T} 83_ALLTARGDEPS += all-${dir}:${dir:T} 84_ALLTARGDEPS3 += ${dir:T} 85.endif # .if ${SHORTPRJNAME:tl} == "yes" ... 86j:=${dir:S,/,_,g} 87.if empty(j:M*[.]*) 88SRCDIR_${j} = ${.CURDIR}/${dir} 89EXPORT_VARNAMES += SRCDIR_${dir:S,/,_,g} 90.endif # .if dir contains . 91_ALLTARGDEPS += all-${dir}:${dir} 92.endfor # dir 93 94.for dir in ${__REALSUBPRJ} 95errorcheck-${dir}: configure-${dir} 96do_errorcheck-${dir}: do_configure-${dir} 97pre_errorcheck-${dir}: pre_configure-${dir} 98post_errorcheck-${dir}: post_configure-${dir} 99nodeps-errorcheck-${dir}: nodeps-configure-${dir} 100.endfor 101 102.for excl in ${NODEPS} 103_ALLTARGDEPS := ${_ALLTARGDEPS:N${excl}} 104.endfor # excl 105 106.for deptarg prjtarg in ${_ALLTARGDEPS:S/:/ /} 107.PHONY: ${prjtarg} ${deptarg} 108${prjtarg}: ${deptarg} 109.endfor 110 111.PHONY: print_deps 112print_deps: 113.for i in ${_ALLTARGDEPS} ${_ALLTARGDEPS2} ${_ALLTARGDEPS3} ${TARGETS} 114 @echo ${i:S/:/ /} 115.endfor 116 117__recurse: .USE 118 @targ=${.TARGET:S/^nodeps-//:C/-.*$//}; \ 119 dir=${.TARGET:S/^nodeps-//:C/^[^-]*-//}; \ 120 if ! test -f ${.CURDIR}/$$dir/Makefile; then exit 0; fi; \ 121 test "$${targ}_${MKINSTALL:tl}" = 'install_no' && exit 0; \ 122 test "$${targ}_${MKINSTALL:tl}" = 'installdirs_no' && exit 0; \ 123 ${export_cmd} \ 124 set -e; \ 125 ${VERBOSE_ECHO} ================================================== 1>&2;\ 126 case "$$dir" in /*) \ 127 ${VERBOSE_ECHO} "$$targ ===> $$dir" 1>&2; \ 128 cd "$$dir"; \ 129 env "_THISDIR_=$$dir/" ${MAKE} ${MAKEFLAGS} $$targ; \ 130 ;; \ 131 *) \ 132 ${VERBOSE_ECHO} "$$targ ===> ${_THISDIR_}$$dir" 1>&2; \ 133 cd "${.CURDIR}/$$dir"; \ 134 env "_THISDIR_=${_THISDIR_}$$dir/" ${MAKE} ${MAKEFLAGS} $$targ; \ 135 ;; \ 136 esac 137 138########### 139SUBPRJSRCTOP = ${.CURDIR} 140.export SUBPRJSRCTOP 141########### 142 143.include "mkc_imp.objdir.mk" 144 145.endif # _MKC_IMP_SUBPRJ_MK 146