bsd.obj.mk revision 17116
117116Spst# $Id: bsd.obj.mk,v 1.5 1996/06/24 04:24:06 jkh Exp $ 215353Swosch# 315353Swosch# The include file <bsd.obj.mk> handles creating 'obj' directory 415353Swosch# and cleaning up object files, log files etc. 515353Swosch# 615353Swosch# 715353Swosch# +++ variables +++ 815353Swosch# 915948Swosch# CLEANFILES Additional files to remove for the clean and cleandir targets. 1015948Swosch# 1116663Sjkh# MAKEOBJDIR Specify somewhere other than /usr/obj to root the object 1216663Sjkh# tree. Note: MAKEOBJDIR is an *enviroment* variable 1315948Swosch# and does work proper only if set as enviroment variable, 1415948Swosch# not as global or command line variable! [obj] 1515353Swosch# 1616663Sjkh# E.g. use `env MAKEOBJDIR=/somewhere/obj make' 1715948Swosch# 1816663Sjkh# NOOBJ Do not create build directory in object tree. 1915353Swosch# 2016663Sjkh# OBJLINK Create a symbolic link from ${.TARGETOBJDIR} to ${.CURDIR}/obj 2116663Sjkh# Note: This BREAKS the read-only src tree rule! 2215353Swosch# 2315353Swosch# +++ targets +++ 2415353Swosch# 2515353Swosch# clean: 2615353Swosch# remove a.out Errs errs mklog ${CLEANFILES} 2715353Swosch# 2815353Swosch# cleandir: 2916663Sjkh# remove the build directory (and all its contents) created by obj 3015353Swosch# 3115353Swosch# obj: 3216663Sjkh# create build directory. 3315353Swosch# 3414801Swosch 3514801Swosch 3614801Swosch.if !target(obj) 3714801Swosch.if defined(NOOBJ) 3814801Swoschobj: 3914801Swosch.else 4016663Sjkh.if !defined(OBJLINK) 4116663Sjkhobj: _SUBDIR 4216663Sjkh @if ! test -d ${.TARGETOBJDIR}; then \ 4316663Sjkh mkdir -p ${.TARGETOBJDIR}; \ 4416663Sjkh if ! test -d ${.TARGETOBJDIR}; then \ 4516663Sjkh ${ECHO} "Unable to create ${.TARGETOBJDIR}."; \ 4616663Sjkh exit 1; \ 4716663Sjkh fi; \ 4816663Sjkh ${ECHO} "${.TARGETOBJDIR} created for ${.CURDIR}"; \ 4916663Sjkh fi 5015353Swosch.else 5116663Sjkhobj: _SUBDIR 5216663Sjkh @if ! test -d ${.TARGETOBJDIR}; then \ 5316663Sjkh mkdir -p ${.TARGETOBJDIR}; \ 5416663Sjkh if ! test -d ${.TARGETOBJDIR}; then \ 5516663Sjkh ${ECHO} "Unable to create ${.TARGETOBJDIR}."; \ 5616663Sjkh exit 1; \ 5716663Sjkh fi; \ 5816663Sjkh ln -fs ${.TARGETOBJDIR} ${.CURDIR}/obj; \ 5916663Sjkh ${ECHO} "${.CURDIR} -> ${.TARGETOBJDIR}"; \ 6014801Swosch fi 6114801Swosch.endif 6214801Swosch.endif 6315353Swosch.endif 6414801Swosch 6516663Sjkh.if !target(objlink) 6616663Sjkhobjlink: _SUBDIR 6716663Sjkh @if test -d ${.TARGETOBJDIR}; then \ 6816663Sjkh ln -fs ${.TARGETOBJDIR} ${.CURDIR}/obj; \ 6916663Sjkh else \ 7016663Sjkh echo "No ${.TARGETOBJDIR} to link to - do a make obj."; \ 7116663Sjkh fi 7216663Sjkh.endif 7316663Sjkh 7415166Swosch# 7517116Spst# where would that obj directory be? 7617116Spst# 7717116Spst.if !target(whereobj) 7817116Spstwhereobj: 7917116Spst.if defined(NOOBJ) 8017116Spst @echo ${.CURDIR} 8117116Spst.else 8217116Spst @if ! test -d ${.TARGETOBJDIR}; then \ 8317116Spst @echo ${.CURDIR}; \ 8417116Spst else 8517116Spst @echo ${.TARGETOBJDIR}; \ 8617116Spst fi 8717116Spst.endif 8817116Spst.endif 8917116Spst 9017116Spst# 9115166Swosch# cleanup 9215166Swosch# 9316663Sjkhcleanobj: 9416663Sjkh @if [ -d ${.TARGETOBJDIR} ]; then \ 9516663Sjkh rm -rf ${.TARGETOBJDIR}; \ 9616663Sjkh else \ 9716663Sjkh cd ${.CURDIR} && ${MAKE} clean cleandepend; \ 9816663Sjkh fi 9916663Sjkh.if defined(OBJLINK) 10016663Sjkh @if [ -h ${.CURDIR}/obj ]; then rm -f ${.CURDIR}/obj; fi 10116663Sjkh.endif 10215166Swosch 10316663Sjkh.if !target(cleanfiles) 10415166Swoschcleanfiles: 10515166Swosch rm -f a.out Errs errs mklog ${CLEANFILES} 10616663Sjkh.endif 10715166Swosch 10815166Swosch# see bsd.dep.mk 10915166Swosch.if !target(cleandepend) 11015166Swoschcleandepend: 11116663Sjkh @rm -f .depend 11215166Swosch.endif 11315166Swosch 11415166Swosch.if !target(clean) 11516663Sjkhclean: cleanfiles _SUBDIR 11615166Swosch.endif 11715166Swosch 11816663Sjkhcleandir: cleanobj _SUBDIR 119