1255253Ssjg# $Id: progs.mk,v 1.13 2013/08/02 18:28:48 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 38255253SsjgPROG_VARS += \ 39255253Ssjg BINDIR \ 40255253Ssjg CFLAGS \ 41255253Ssjg COPTS \ 42255253Ssjg CPPFLAGS \ 43255253Ssjg CXXFLAGS \ 44255253Ssjg DPADD \ 45255253Ssjg DPLIBS \ 46255253Ssjg LDADD \ 47255253Ssjg LDFLAGS \ 48255253Ssjg MAN \ 49255253Ssjg SRCS 50255253Ssjg 51246149Ssjg.for v in ${PROG_VARS:O:u} 52255253Ssjg.if defined(${v}.${PROG}) || defined(${v}_${PROG}) 53246149Ssjg$v += ${${v}_${PROG}:U${${v}.${PROG}}} 54250837Ssjg.endif 55246149Ssjg.endfor 56246149Ssjg 57246149Ssjg# for meta mode, there can be only one! 58246149Ssjg.if ${PROG} == ${UPDATE_DEPENDFILE_PROG:Uno} 59246149SsjgUPDATE_DEPENDFILE ?= yes 60246149Ssjg.endif 61246149SsjgUPDATE_DEPENDFILE ?= NO 62246149Ssjg 63246149Ssjg# ensure that we don't clobber each other's dependencies 64246149SsjgDEPENDFILE?= .depend.${PROG} 65246149Ssjg# prog.mk will do the rest 66246149Ssjg.else 67246149Ssjgall: ${PROGS} 68246149Ssjg 69246149Ssjg# We cannot capture dependencies for meta mode here 70246149SsjgUPDATE_DEPENDFILE = NO 71246149Ssjg# nor can we safely run in parallel. 72246149Ssjg.NOTPARALLEL: 73246149Ssjg.endif 74246149Ssjg.endif 75246149Ssjg 76246149Ssjg# handle being called [bsd.]progs.mk 77246149Ssjg.include <${.PARSEFILE:S,progs,prog,}> 78246149Ssjg 79246149Ssjg.ifndef PROG 80250837Ssjg# tell progs.mk we might want to install things 81250837SsjgPROGS_TARGETS+= cleandepend cleandir cleanobj depend install 82246149Ssjg 83246149Ssjg.for p in ${PROGS} 84246149Ssjg.if defined(PROGS_CXX) && !empty(PROGS_CXX:M$p) 85246149Ssjg# bsd.prog.mk may need to know this 86246149Ssjgx.$p= PROG_CXX=$p 87246149Ssjg.endif 88246149Ssjg 89246149Ssjg$p ${p}_p: .PHONY .MAKE 90246149Ssjg (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} PROG=$p ${x.$p}) 91246149Ssjg 92246149Ssjg.for t in ${PROGS_TARGETS:O:u} 93246149Ssjg$p.$t: .PHONY .MAKE 94246149Ssjg (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} PROG=$p ${x.$p} ${@:E}) 95246149Ssjg.endfor 96246149Ssjg.endfor 97246149Ssjg 98246149Ssjg.for t in ${PROGS_TARGETS:O:u} 99246149Ssjg$t: ${PROGS:%=%.$t} 100246149Ssjg.endfor 101246149Ssjg 102246149Ssjg.endif 103