1*52d86256SSimon J. Gerraty# $Id: progs.mk,v 1.12 2013/04/22 18:10:04 sjg Exp $ 23cbdda60SSimon J. Gerraty# 33cbdda60SSimon J. Gerraty# @(#) Copyright (c) 2006, Simon J. Gerraty 43cbdda60SSimon J. Gerraty# 53cbdda60SSimon J. Gerraty# This file is provided in the hope that it will 63cbdda60SSimon J. Gerraty# be of use. There is absolutely NO WARRANTY. 73cbdda60SSimon J. Gerraty# Permission to copy, redistribute or otherwise 83cbdda60SSimon J. Gerraty# use this file is hereby granted provided that 93cbdda60SSimon J. Gerraty# the above copyright notice and this notice are 103cbdda60SSimon J. Gerraty# left intact. 113cbdda60SSimon J. Gerraty# 123cbdda60SSimon J. Gerraty# Please send copies of changes and bug-fixes to: 133cbdda60SSimon J. Gerraty# sjg@crufty.net 143cbdda60SSimon J. Gerraty# 153cbdda60SSimon J. Gerraty 163cbdda60SSimon J. Gerraty.MAIN: all 173cbdda60SSimon J. Gerraty 183cbdda60SSimon J. Gerraty.if defined(PROGS) 193cbdda60SSimon J. Gerraty 203cbdda60SSimon J. Gerraty# In meta mode, we can capture dependenices for _one_ of the progs. 213cbdda60SSimon J. Gerraty# if makefile doesn't nominate one, we use the first. 223cbdda60SSimon J. Gerraty.ifndef UPDATE_DEPENDFILE_PROG 233cbdda60SSimon J. GerratyUPDATE_DEPENDFILE_PROG = ${PROGS:[1]} 243cbdda60SSimon J. Gerraty.export UPDATE_DEPENDFILE_PROG 253cbdda60SSimon J. Gerraty.endif 263cbdda60SSimon J. Gerraty 273cbdda60SSimon J. Gerraty.ifndef PROG 283cbdda60SSimon J. Gerraty# They may have asked us to build just one 293cbdda60SSimon J. Gerraty.for t in ${PROGS} 303cbdda60SSimon J. Gerraty.if make($t) 313cbdda60SSimon J. GerratyPROG ?= $t 323cbdda60SSimon J. Gerraty.endif 333cbdda60SSimon J. Gerraty.endfor 343cbdda60SSimon J. Gerraty.endif 353cbdda60SSimon J. Gerraty 363cbdda60SSimon J. Gerraty.if defined(PROG) 373cbdda60SSimon J. Gerraty# just one of many 38*52d86256SSimon J. GerratyPROG_VARS += BINDIR CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD MAN SRCS 393cbdda60SSimon J. Gerraty.for v in ${PROG_VARS:O:u} 40*52d86256SSimon J. Gerraty.if defined(${v}.${PROG}) 413cbdda60SSimon J. Gerraty$v += ${${v}_${PROG}:U${${v}.${PROG}}} 42*52d86256SSimon J. Gerraty.endif 433cbdda60SSimon J. Gerraty.endfor 443cbdda60SSimon J. Gerraty 453cbdda60SSimon J. Gerraty# for meta mode, there can be only one! 463cbdda60SSimon J. Gerraty.if ${PROG} == ${UPDATE_DEPENDFILE_PROG:Uno} 473cbdda60SSimon J. GerratyUPDATE_DEPENDFILE ?= yes 483cbdda60SSimon J. Gerraty.endif 493cbdda60SSimon J. GerratyUPDATE_DEPENDFILE ?= NO 503cbdda60SSimon J. Gerraty 513cbdda60SSimon J. Gerraty# ensure that we don't clobber each other's dependencies 523cbdda60SSimon J. GerratyDEPENDFILE?= .depend.${PROG} 533cbdda60SSimon J. Gerraty# prog.mk will do the rest 543cbdda60SSimon J. Gerraty.else 553cbdda60SSimon J. Gerratyall: ${PROGS} 563cbdda60SSimon J. Gerraty 573cbdda60SSimon J. Gerraty# We cannot capture dependencies for meta mode here 583cbdda60SSimon J. GerratyUPDATE_DEPENDFILE = NO 593cbdda60SSimon J. Gerraty# nor can we safely run in parallel. 603cbdda60SSimon J. Gerraty.NOTPARALLEL: 613cbdda60SSimon J. Gerraty.endif 623cbdda60SSimon J. Gerraty.endif 633cbdda60SSimon J. Gerraty 643cbdda60SSimon J. Gerraty# handle being called [bsd.]progs.mk 653cbdda60SSimon J. Gerraty.include <${.PARSEFILE:S,progs,prog,}> 663cbdda60SSimon J. Gerraty 673cbdda60SSimon J. Gerraty.ifndef PROG 68*52d86256SSimon J. Gerraty# tell progs.mk we might want to install things 69*52d86256SSimon J. GerratyPROGS_TARGETS+= cleandepend cleandir cleanobj depend install 703cbdda60SSimon J. Gerraty 713cbdda60SSimon J. Gerraty.for p in ${PROGS} 723cbdda60SSimon J. Gerraty.if defined(PROGS_CXX) && !empty(PROGS_CXX:M$p) 733cbdda60SSimon J. Gerraty# bsd.prog.mk may need to know this 743cbdda60SSimon J. Gerratyx.$p= PROG_CXX=$p 753cbdda60SSimon J. Gerraty.endif 763cbdda60SSimon J. Gerraty 773cbdda60SSimon J. Gerraty$p ${p}_p: .PHONY .MAKE 783cbdda60SSimon J. Gerraty (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} PROG=$p ${x.$p}) 793cbdda60SSimon J. Gerraty 803cbdda60SSimon J. Gerraty.for t in ${PROGS_TARGETS:O:u} 813cbdda60SSimon J. Gerraty$p.$t: .PHONY .MAKE 823cbdda60SSimon J. Gerraty (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} PROG=$p ${x.$p} ${@:E}) 833cbdda60SSimon J. Gerraty.endfor 843cbdda60SSimon J. Gerraty.endfor 853cbdda60SSimon J. Gerraty 863cbdda60SSimon J. Gerraty.for t in ${PROGS_TARGETS:O:u} 873cbdda60SSimon J. Gerraty$t: ${PROGS:%=%.$t} 883cbdda60SSimon J. Gerraty.endfor 893cbdda60SSimon J. Gerraty 903cbdda60SSimon J. Gerraty.endif 91