1*3cbdda60SSimon J. Gerraty# $Id: progs.mk,v 1.11 2012/11/06 17:18:54 sjg Exp $ 2*3cbdda60SSimon J. Gerraty# 3*3cbdda60SSimon J. Gerraty# @(#) Copyright (c) 2006, Simon J. Gerraty 4*3cbdda60SSimon J. Gerraty# 5*3cbdda60SSimon J. Gerraty# This file is provided in the hope that it will 6*3cbdda60SSimon J. Gerraty# be of use. There is absolutely NO WARRANTY. 7*3cbdda60SSimon J. Gerraty# Permission to copy, redistribute or otherwise 8*3cbdda60SSimon J. Gerraty# use this file is hereby granted provided that 9*3cbdda60SSimon J. Gerraty# the above copyright notice and this notice are 10*3cbdda60SSimon J. Gerraty# left intact. 11*3cbdda60SSimon J. Gerraty# 12*3cbdda60SSimon J. Gerraty# Please send copies of changes and bug-fixes to: 13*3cbdda60SSimon J. Gerraty# sjg@crufty.net 14*3cbdda60SSimon J. Gerraty# 15*3cbdda60SSimon J. Gerraty 16*3cbdda60SSimon J. Gerraty.MAIN: all 17*3cbdda60SSimon J. Gerraty 18*3cbdda60SSimon J. Gerraty.if defined(PROGS) 19*3cbdda60SSimon J. Gerraty 20*3cbdda60SSimon J. Gerraty# In meta mode, we can capture dependenices for _one_ of the progs. 21*3cbdda60SSimon J. Gerraty# if makefile doesn't nominate one, we use the first. 22*3cbdda60SSimon J. Gerraty.ifndef UPDATE_DEPENDFILE_PROG 23*3cbdda60SSimon J. GerratyUPDATE_DEPENDFILE_PROG = ${PROGS:[1]} 24*3cbdda60SSimon J. Gerraty.export UPDATE_DEPENDFILE_PROG 25*3cbdda60SSimon J. Gerraty.endif 26*3cbdda60SSimon J. Gerraty 27*3cbdda60SSimon J. Gerraty.ifndef PROG 28*3cbdda60SSimon J. Gerraty# They may have asked us to build just one 29*3cbdda60SSimon J. Gerraty.for t in ${PROGS} 30*3cbdda60SSimon J. Gerraty.if make($t) 31*3cbdda60SSimon J. GerratyPROG ?= $t 32*3cbdda60SSimon J. Gerraty.endif 33*3cbdda60SSimon J. Gerraty.endfor 34*3cbdda60SSimon J. Gerraty.endif 35*3cbdda60SSimon J. Gerraty 36*3cbdda60SSimon J. Gerraty.if defined(PROG) 37*3cbdda60SSimon J. Gerraty# just one of many 38*3cbdda60SSimon J. GerratyPROG_VARS += CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD MAN SRCS 39*3cbdda60SSimon J. Gerraty.for v in ${PROG_VARS:O:u} 40*3cbdda60SSimon J. Gerraty$v += ${${v}_${PROG}:U${${v}.${PROG}}} 41*3cbdda60SSimon J. Gerraty.endfor 42*3cbdda60SSimon J. Gerraty 43*3cbdda60SSimon J. Gerraty# for meta mode, there can be only one! 44*3cbdda60SSimon J. Gerraty.if ${PROG} == ${UPDATE_DEPENDFILE_PROG:Uno} 45*3cbdda60SSimon J. GerratyUPDATE_DEPENDFILE ?= yes 46*3cbdda60SSimon J. Gerraty.endif 47*3cbdda60SSimon J. GerratyUPDATE_DEPENDFILE ?= NO 48*3cbdda60SSimon J. Gerraty 49*3cbdda60SSimon J. Gerraty# ensure that we don't clobber each other's dependencies 50*3cbdda60SSimon J. GerratyDEPENDFILE?= .depend.${PROG} 51*3cbdda60SSimon J. Gerraty# prog.mk will do the rest 52*3cbdda60SSimon J. Gerraty.else 53*3cbdda60SSimon J. Gerratyall: ${PROGS} 54*3cbdda60SSimon J. Gerraty 55*3cbdda60SSimon J. Gerraty# We cannot capture dependencies for meta mode here 56*3cbdda60SSimon J. GerratyUPDATE_DEPENDFILE = NO 57*3cbdda60SSimon J. Gerraty# nor can we safely run in parallel. 58*3cbdda60SSimon J. Gerraty.NOTPARALLEL: 59*3cbdda60SSimon J. Gerraty.endif 60*3cbdda60SSimon J. Gerraty.endif 61*3cbdda60SSimon J. Gerraty 62*3cbdda60SSimon J. Gerraty# handle being called [bsd.]progs.mk 63*3cbdda60SSimon J. Gerraty.include <${.PARSEFILE:S,progs,prog,}> 64*3cbdda60SSimon J. Gerraty 65*3cbdda60SSimon J. Gerraty.ifndef PROG 66*3cbdda60SSimon J. GerratyPROGS_TARGETS += clean 67*3cbdda60SSimon J. Gerraty 68*3cbdda60SSimon J. Gerraty.for p in ${PROGS} 69*3cbdda60SSimon J. Gerraty.if defined(PROGS_CXX) && !empty(PROGS_CXX:M$p) 70*3cbdda60SSimon J. Gerraty# bsd.prog.mk may need to know this 71*3cbdda60SSimon J. Gerratyx.$p= PROG_CXX=$p 72*3cbdda60SSimon J. Gerraty.endif 73*3cbdda60SSimon J. Gerraty 74*3cbdda60SSimon J. Gerraty$p ${p}_p: .PHONY .MAKE 75*3cbdda60SSimon J. Gerraty (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} PROG=$p ${x.$p}) 76*3cbdda60SSimon J. Gerraty 77*3cbdda60SSimon J. Gerraty.for t in ${PROGS_TARGETS:O:u} 78*3cbdda60SSimon J. Gerraty$p.$t: .PHONY .MAKE 79*3cbdda60SSimon J. Gerraty (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} PROG=$p ${x.$p} ${@:E}) 80*3cbdda60SSimon J. Gerraty.endfor 81*3cbdda60SSimon J. Gerraty.endfor 82*3cbdda60SSimon J. Gerraty 83*3cbdda60SSimon J. Gerraty.for t in ${PROGS_TARGETS:O:u} 84*3cbdda60SSimon J. Gerraty$t: ${PROGS:%=%.$t} 85*3cbdda60SSimon J. Gerraty.endfor 86*3cbdda60SSimon J. Gerraty 87*3cbdda60SSimon J. Gerraty.endif 88