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 .ifndef UPDATE_DEPENDFILE_PROG
26 UPDATE_DEPENDFILE_PROG = ${PROGS:[1]}
27 .export UPDATE_DEPENDFILE_PROG
32 PROG_OVERRIDE_VARS += BINDIR BINGRP BINOWN BINMODE DPSRCS MAN NO_WERROR \
34 PROG_VARS += CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD LIBADD LINKS \
35 LDFLAGS MLINKS ${PROG_OVERRIDE_VARS}
36 .for v in ${PROG_VARS:O:u}
37 .if empty(${PROG_OVERRIDE_VARS:M$v})
38 .if defined(${v}.${PROG})
40 .elif defined(${v}_${PROG})
48 # for meta mode, there can be only one!
49 .if ${PROG} == ${UPDATE_DEPENDFILE_PROG}
50 UPDATE_DEPENDFILE ?= yes
52 UPDATE_DEPENDFILE ?= NO
54 # prog.mk will do the rest
55 .else # !defined(PROG)
56 .if !defined(_SKIP_BUILD)
60 # We cannot capture dependencies for meta mode here
61 UPDATE_DEPENDFILE = NO
63 .if ${MK_STAGING} != "no"
65 stage_files.prog: ${PROGS}
67 .endif # ${MK_STAGING} != "no"
69 .endif # PROGS || PROGS_CXX
71 # These are handled by the main make process.
72 .ifdef _RECURSING_PROGS
75 _PROGS_GLOBAL_VARS= CLEANFILES CLEANDIRS CONFGROUPS FILESGROUPS INCSGROUPS \
77 .for v in ${_PROGS_GLOBAL_VARS}
82 # handle being called [bsd.]progs.mk
83 .include <bsd.prog.mk>
85 .if !empty(PROGS) && !defined(_RECURSING_PROGS) && !defined(PROG)
86 # tell progs.mk we might want to install things
87 PROGS_TARGETS+= checkdpadd clean cleandepend cleandir depend install
89 # Find common sources among the PROGS and depend on them before building
90 # anything. This allows parallelization without them each fighting over
95 .for s in ${SRCS.${p}}
96 .if ${_PROGS_ALL_SRCS:M${s}} && !${_PROGS_COMMON_SRCS:M${s}}
97 _PROGS_COMMON_SRCS+= ${s}
99 _PROGS_ALL_SRCS+= ${s}
103 .if !empty(_PROGS_COMMON_SRCS)
104 _PROGS_COMMON_OBJS= ${_PROGS_COMMON_SRCS:M*.[dhly]}
105 .if !empty(_PROGS_COMMON_SRCS:N*.[dhly])
106 _PROGS_COMMON_OBJS+= ${_PROGS_COMMON_SRCS:N*.[dhly]:R:S/$/.o/g}
108 ${PROGS}: ${_PROGS_COMMON_OBJS}
112 .if defined(PROGS_CXX) && !empty(PROGS_CXX:M$p)
113 # bsd.prog.mk may need to know this
118 $p ${p}_p: .PHONY .MAKE
120 DEPENDFILE=.depend.$p \
121 NO_SUBDIR=1 ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS=t \
124 # Pseudo targets for PROG, such as 'install'.
125 .for t in ${PROGS_TARGETS:O:u}
128 DEPENDFILE=.depend.$p \
129 NO_SUBDIR=1 ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS=t \
130 PROG=$p ${x.$p} ${@:E})
134 # Depend main pseudo targets on all PROG.pseudo targets too.
135 .for t in ${PROGS_TARGETS:O:u}
140 .endif # !empty(PROGS) && !defined(_RECURSING_PROGS) && !defined(PROG)