2 # $Id: progs.mk,v 1.11 2012/11/06 17:18:54 sjg Exp $
4 # @(#) Copyright (c) 2006, Simon J. Gerraty
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
13 # Please send copies of changes and bug-fixes to:
19 .if defined(PROGS) || defined(PROGS_CXX)
20 # we really only use PROGS below...
23 # In meta mode, we can capture dependenices for _one_ of the progs.
24 # if makefile doesn't nominate one, we use the first.
25 .if defined(.PARSEDIR)
26 .ifndef UPDATE_DEPENDFILE_PROG
27 UPDATE_DEPENDFILE_PROG = ${PROGS:[1]}
28 .export UPDATE_DEPENDFILE_PROG
31 UPDATE_DEPENDFILE_PROG?= no
35 # They may have asked us to build just one
45 PROG_VARS += BINDIR CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD MAN SRCS
46 .for v in ${PROG_VARS:O:u}
47 .if defined(${v}.${PROG}) || defined(${v}_${PROG})
48 $v += ${${v}_${PROG}:U${${v}.${PROG}}}
54 # for meta mode, there can be only one!
55 .if ${PROG} == ${UPDATE_DEPENDFILE_PROG}
56 UPDATE_DEPENDFILE ?= yes
58 UPDATE_DEPENDFILE ?= NO
60 # ensure that we don't clobber each other's dependencies
61 DEPENDFILE?= .depend.${PROG}
62 # prog.mk will do the rest
66 # We cannot capture dependencies for meta mode here
67 UPDATE_DEPENDFILE = NO
68 # nor can we safely run in parallel.
73 # handle being called [bsd.]progs.mk
74 .include <bsd.prog.mk>
76 .ifndef _RECURSING_PROGS
77 # tell progs.mk we might want to install things
78 PROGS_TARGETS+= cleandepend cleandir cleanobj depend install
81 .if defined(PROGS_CXX) && !empty(PROGS_CXX:M$p)
82 # bsd.prog.mk may need to know this
86 $p ${p}_p: .PHONY .MAKE
87 (cd ${.CURDIR} && ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS= \
88 SUBDIR= PROG=$p ${x.$p})
90 .for t in ${PROGS_TARGETS:O:u}
92 (cd ${.CURDIR} && ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS= \
93 SUBDIR= PROG=$p ${x.$p} ${@:E})
97 .for t in ${PROGS_TARGETS:O:u}
101 SCRIPTS_TARGETS+= cleandepend cleandir cleanobj depend install
104 .for t in ${SCRIPTS_TARGETS:O:u}
106 (cd ${.CURDIR} && ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS= \
107 SUBDIR= SCRIPT=$p ${x.$p} ${@:E})
111 .for t in ${SCRIPTS_TARGETS:O:u}
112 $t: ${SCRIPTS:%=%.$t}