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_OVERRIDE_VARS += BINDIR DPSRCS MAN SRCS
46 PROG_VARS += CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD LDFLAGS ${PROG_OVERRIDE_VARS}
47 .for v in ${PROG_VARS:O:u}
48 .if empty(${PROG_OVERRIDE_VARS:M$v})
49 .if defined(${v}.${PROG})
51 .elif defined(${v}_${PROG})
59 # for meta mode, there can be only one!
60 .if ${PROG} == ${UPDATE_DEPENDFILE_PROG}
61 UPDATE_DEPENDFILE ?= yes
63 UPDATE_DEPENDFILE ?= NO
65 # ensure that we don't clobber each other's dependencies
66 DEPENDFILE?= .depend.${PROG}
67 # prog.mk will do the rest
69 all: ${FILES} ${PROGS} ${SCRIPTS}
71 # We cannot capture dependencies for meta mode here
72 UPDATE_DEPENDFILE = NO
73 # nor can we safely run in parallel.
78 # The non-recursive call to bsd.progs.mk will handle FILES; NUL out
79 # FILESGROUPS so recursive calls don't duplicate the work
80 .ifdef _RECURSING_PROGS
84 # handle being called [bsd.]progs.mk
85 .include <bsd.prog.mk>
87 .ifndef _RECURSING_PROGS
88 # tell progs.mk we might want to install things
89 PROGS_TARGETS+= checkdpadd clean cleandepend cleandir cleanobj depend install
92 .if defined(PROGS_CXX) && !empty(PROGS_CXX:M$p)
93 # bsd.prog.mk may need to know this
97 $p ${p}_p: .PHONY .MAKE
98 (cd ${.CURDIR} && ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS= \
100 DEPENDFILE=.depend.$p .MAKE.DEPENDFILE=.depend.$p \
103 .for t in ${PROGS_TARGETS:O:u}
105 (cd ${.CURDIR} && ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS= \
107 DEPENDFILE=.depend.$p .MAKE.DEPENDFILE=.depend.$p \
113 .for t in ${PROGS_TARGETS:O:u}
118 .if empty(PROGS) && !empty(SCRIPTS)
120 .for t in ${PROGS_TARGETS:O:u}
121 scripts.$t: .PHONY .MAKE
122 (cd ${.CURDIR} && ${MAKE} -f ${MAKEFILE} SUBDIR= _RECURSING_PROGS= \