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