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