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 BINGRP BINOWN BINMODE DPSRCS MAN PROGNAME \
47 PROG_VARS += CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD LINKS \
48 LDFLAGS MLINKS ${PROG_OVERRIDE_VARS}
49 .for v in ${PROG_VARS:O:u}
50 .if empty(${PROG_OVERRIDE_VARS:M$v})
51 .if defined(${v}.${PROG})
53 .elif defined(${v}_${PROG})
61 # for meta mode, there can be only one!
62 .if ${PROG} == ${UPDATE_DEPENDFILE_PROG}
63 UPDATE_DEPENDFILE ?= yes
65 UPDATE_DEPENDFILE ?= NO
67 # ensure that we don't clobber each other's dependencies
68 DEPENDFILE?= .depend.${PROG}
69 # prog.mk will do the rest
73 # We cannot capture dependencies for meta mode here
74 UPDATE_DEPENDFILE = NO
75 # nor can we safely run in parallel.
78 .endif # PROGS || PROGS_CXX
80 # These are handled by the main make process.
81 .ifdef _RECURSING_PROGS
82 _PROGS_GLOBAL_VARS= CLEANFILES CLEANDIRS FILESGROUPS SCRIPTS
83 .for v in ${_PROGS_GLOBAL_VARS}
88 # handle being called [bsd.]progs.mk
89 .include <bsd.prog.mk>
91 .if !empty(PROGS) && !defined(_RECURSING_PROGS)
92 # tell progs.mk we might want to install things
93 PROGS_TARGETS+= checkdpadd clean cleandepend cleandir depend install
96 .if defined(PROGS_CXX) && !empty(PROGS_CXX:M$p)
97 # bsd.prog.mk may need to know this
102 $p ${p}_p: .PHONY .MAKE
103 (cd ${.CURDIR} && ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS= \
105 DEPENDFILE=.depend.$p .MAKE.DEPENDFILE=.depend.$p \
108 # Pseudo targets for PROG, such as 'install'.
109 .for t in ${PROGS_TARGETS:O:u}
111 (cd ${.CURDIR} && ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS= \
113 DEPENDFILE=.depend.$p .MAKE.DEPENDFILE=.depend.$p \
118 # Depend main pseudo targets on all PROG.pseudo targets too.
119 .for t in ${PROGS_TARGETS:O:u}