progs.mk revision 250837
1250837Ssjg# $Id: progs.mk,v 1.12 2013/04/22 18:10:04 sjg Exp $ 2246149Ssjg# 3246149Ssjg# @(#) Copyright (c) 2006, Simon J. Gerraty 4246149Ssjg# 5246149Ssjg# This file is provided in the hope that it will 6246149Ssjg# be of use. There is absolutely NO WARRANTY. 7246149Ssjg# Permission to copy, redistribute or otherwise 8246149Ssjg# use this file is hereby granted provided that 9246149Ssjg# the above copyright notice and this notice are 10246149Ssjg# left intact. 11246149Ssjg# 12246149Ssjg# Please send copies of changes and bug-fixes to: 13246149Ssjg# sjg@crufty.net 14246149Ssjg# 15246149Ssjg 16246149Ssjg.MAIN: all 17246149Ssjg 18246149Ssjg.if defined(PROGS) 19246149Ssjg 20246149Ssjg# In meta mode, we can capture dependenices for _one_ of the progs. 21246149Ssjg# if makefile doesn't nominate one, we use the first. 22246149Ssjg.ifndef UPDATE_DEPENDFILE_PROG 23246149SsjgUPDATE_DEPENDFILE_PROG = ${PROGS:[1]} 24246149Ssjg.export UPDATE_DEPENDFILE_PROG 25246149Ssjg.endif 26246149Ssjg 27246149Ssjg.ifndef PROG 28246149Ssjg# They may have asked us to build just one 29246149Ssjg.for t in ${PROGS} 30246149Ssjg.if make($t) 31246149SsjgPROG ?= $t 32246149Ssjg.endif 33246149Ssjg.endfor 34246149Ssjg.endif 35246149Ssjg 36246149Ssjg.if defined(PROG) 37246149Ssjg# just one of many 38250837SsjgPROG_VARS += BINDIR CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD MAN SRCS 39246149Ssjg.for v in ${PROG_VARS:O:u} 40250837Ssjg.if defined(${v}.${PROG}) 41246149Ssjg$v += ${${v}_${PROG}:U${${v}.${PROG}}} 42250837Ssjg.endif 43246149Ssjg.endfor 44246149Ssjg 45246149Ssjg# for meta mode, there can be only one! 46246149Ssjg.if ${PROG} == ${UPDATE_DEPENDFILE_PROG:Uno} 47246149SsjgUPDATE_DEPENDFILE ?= yes 48246149Ssjg.endif 49246149SsjgUPDATE_DEPENDFILE ?= NO 50246149Ssjg 51246149Ssjg# ensure that we don't clobber each other's dependencies 52246149SsjgDEPENDFILE?= .depend.${PROG} 53246149Ssjg# prog.mk will do the rest 54246149Ssjg.else 55246149Ssjgall: ${PROGS} 56246149Ssjg 57246149Ssjg# We cannot capture dependencies for meta mode here 58246149SsjgUPDATE_DEPENDFILE = NO 59246149Ssjg# nor can we safely run in parallel. 60246149Ssjg.NOTPARALLEL: 61246149Ssjg.endif 62246149Ssjg.endif 63246149Ssjg 64246149Ssjg# handle being called [bsd.]progs.mk 65246149Ssjg.include <${.PARSEFILE:S,progs,prog,}> 66246149Ssjg 67246149Ssjg.ifndef PROG 68250837Ssjg# tell progs.mk we might want to install things 69250837SsjgPROGS_TARGETS+= cleandepend cleandir cleanobj depend install 70246149Ssjg 71246149Ssjg.for p in ${PROGS} 72246149Ssjg.if defined(PROGS_CXX) && !empty(PROGS_CXX:M$p) 73246149Ssjg# bsd.prog.mk may need to know this 74246149Ssjgx.$p= PROG_CXX=$p 75246149Ssjg.endif 76246149Ssjg 77246149Ssjg$p ${p}_p: .PHONY .MAKE 78246149Ssjg (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} PROG=$p ${x.$p}) 79246149Ssjg 80246149Ssjg.for t in ${PROGS_TARGETS:O:u} 81246149Ssjg$p.$t: .PHONY .MAKE 82246149Ssjg (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} PROG=$p ${x.$p} ${@:E}) 83246149Ssjg.endfor 84246149Ssjg.endfor 85246149Ssjg 86246149Ssjg.for t in ${PROGS_TARGETS:O:u} 87246149Ssjg$t: ${PROGS:%=%.$t} 88246149Ssjg.endfor 89246149Ssjg 90246149Ssjg.endif 91