bsd.progs.mk revision 258095
138889Sjdp# $FreeBSD: head/share/mk/bsd.progs.mk 258095 2013-11-13 15:10:32Z sjg $
289857Sobrien# $Id: progs.mk,v 1.11 2012/11/06 17:18:54 sjg Exp $
338889Sjdp#
438889Sjdp#	@(#) Copyright (c) 2006, Simon J. Gerraty
538889Sjdp#
638889Sjdp#	This file is provided in the hope that it will
738889Sjdp#	be of use.  There is absolutely NO WARRANTY.
838889Sjdp#	Permission to copy, redistribute or otherwise
938889Sjdp#	use this file is hereby granted provided that 
1038889Sjdp#	the above copyright notice and this notice are
1138889Sjdp#	left intact. 
1238889Sjdp#      
1338889Sjdp#	Please send copies of changes and bug-fixes to:
1438889Sjdp#	sjg@crufty.net
1538889Sjdp#
1638889Sjdp
1738889Sjdp.MAIN: all
1838889Sjdp
1938889Sjdp.if defined(PROGS) || defined(PROGS_CXX)
2038889Sjdp# we really only use PROGS below...
2138889SjdpPROGS += ${PROGS_CXX}
2238889Sjdp
2338889Sjdp# In meta mode, we can capture dependenices for _one_ of the progs.
2489857Sobrien# if makefile doesn't nominate one, we use the first.
2538889Sjdp.if defined(.PARSEDIR)
2689857Sobrien.ifndef UPDATE_DEPENDFILE_PROG
2789857SobrienUPDATE_DEPENDFILE_PROG = ${PROGS:[1]}
2889857Sobrien.export UPDATE_DEPENDFILE_PROG
2989857Sobrien.endif
3089857Sobrien.else
3138889SjdpUPDATE_DEPENDFILE_PROG?= no
3238889Sjdp.endif
3389857Sobrien
3438889Sjdp.ifndef PROG
3538889Sjdp# They may have asked us to build just one
3638889Sjdp.for t in ${PROGS}
3738889Sjdp.if make($t)
38130561SobrienPROG ?= $t
39130561Sobrien.endif
4038889Sjdp.endfor
4138889Sjdp.endif
4238889Sjdp
4338889Sjdp.if defined(PROG)
4438889Sjdp# just one of many
4538889SjdpPROG_VARS += BINDIR CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD MAN SRCS
4638889Sjdp.for v in ${PROG_VARS:O:u}
4738889Sjdp.if defined(${v}.${PROG})
48130561Sobrien$v += ${${v}_${PROG}:U${${v}.${PROG}}}
4938889Sjdp.else
5038889Sjdp$v ?=
5138889Sjdp.endif
5238889Sjdp.endfor
5338889Sjdp
5438889Sjdp# for meta mode, there can be only one!
5538889Sjdp.if ${PROG} == ${UPDATE_DEPENDFILE_PROG}
56130561SobrienUPDATE_DEPENDFILE ?= yes
5738889Sjdp.endif
5838889SjdpUPDATE_DEPENDFILE ?= NO
5938889Sjdp
6038889Sjdp# ensure that we don't clobber each other's dependencies
6138889SjdpDEPENDFILE?= .depend.${PROG}
6238889Sjdp# prog.mk will do the rest
6338889Sjdp.else
6438889Sjdpall: ${PROGS}
6577298Sobrien
6638889Sjdp# We cannot capture dependencies for meta mode here
6738889SjdpUPDATE_DEPENDFILE = NO
6838889Sjdp# nor can we safely run in parallel.
6938889Sjdp.NOTPARALLEL:
7038889Sjdp.endif
7138889Sjdp.endif
7238889Sjdp
7338889Sjdp# handle being called [bsd.]progs.mk
7438889Sjdp.include <bsd.prog.mk>
7538889Sjdp
7638889Sjdp.ifndef PROG
7738889Sjdp# tell progs.mk we might want to install things
7838889SjdpPROGS_TARGETS+= cleandepend cleandir cleanobj depend install
7938889Sjdp
8038889Sjdp.for p in ${PROGS}
8138889Sjdp.if defined(PROGS_CXX) && !empty(PROGS_CXX:M$p)
82130561Sobrien# bsd.prog.mk may need to know this
8338889Sjdpx.$p= PROG_CXX=$p
8438889Sjdp.endif
8538889Sjdp
8689857Sobrien$p ${p}_p: .PHONY .MAKE
8738889Sjdp	(cd ${.CURDIR} && ${MAKE} -f ${MAKEFILE} PROG=$p ${x.$p})
8838889Sjdp
8938889Sjdp.for t in ${PROGS_TARGETS:O:u}
9089857Sobrien$p.$t: .PHONY .MAKE
9138889Sjdp	(cd ${.CURDIR} && ${MAKE} -f ${MAKEFILE} PROG=$p ${x.$p} ${@:E})
9238889Sjdp.endfor
9338889Sjdp.endfor
9438889Sjdp
9538889Sjdp.for t in ${PROGS_TARGETS:O:u}
9638889Sjdp$t: ${PROGS:%=%.$t}
9738889Sjdp.endfor
9838889Sjdp
9938889Sjdp.endif
10038889Sjdp