2012-10-22 01:18:41 +00:00
|
|
|
# $FreeBSD$
|
2012-11-07 21:44:04 +00:00
|
|
|
# $Id: progs.mk,v 1.11 2012/11/06 17:18:54 sjg Exp $
|
|
|
|
#
|
|
|
|
# @(#) Copyright (c) 2006, Simon J. Gerraty
|
|
|
|
#
|
|
|
|
# This file is provided in the hope that it will
|
|
|
|
# be of use. There is absolutely NO WARRANTY.
|
|
|
|
# Permission to copy, redistribute or otherwise
|
|
|
|
# use this file is hereby granted provided that
|
|
|
|
# the above copyright notice and this notice are
|
|
|
|
# left intact.
|
|
|
|
#
|
|
|
|
# Please send copies of changes and bug-fixes to:
|
|
|
|
# sjg@crufty.net
|
|
|
|
#
|
|
|
|
|
|
|
|
.MAIN: all
|
|
|
|
|
|
|
|
.if defined(PROGS)
|
|
|
|
|
|
|
|
# In meta mode, we can capture dependenices for _one_ of the progs.
|
|
|
|
# if makefile doesn't nominate one, we use the first.
|
|
|
|
.ifndef UPDATE_DEPENDFILE_PROG
|
|
|
|
UPDATE_DEPENDFILE_PROG = ${PROGS:[1]}
|
|
|
|
.export UPDATE_DEPENDFILE_PROG
|
2012-10-22 01:18:41 +00:00
|
|
|
.endif
|
|
|
|
|
2012-11-07 21:44:04 +00:00
|
|
|
.ifndef PROG
|
|
|
|
# They may have asked us to build just one
|
|
|
|
.for t in ${PROGS}
|
|
|
|
.if make($t)
|
|
|
|
PROG ?= $t
|
|
|
|
.endif
|
|
|
|
.endfor
|
2012-10-22 01:18:41 +00:00
|
|
|
.endif
|
|
|
|
|
2012-11-07 21:44:04 +00:00
|
|
|
.if defined(PROG)
|
|
|
|
# just one of many
|
2013-04-22 18:11:29 +00:00
|
|
|
PROG_VARS += BINDIR CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD MAN SRCS
|
2012-11-07 21:44:04 +00:00
|
|
|
.for v in ${PROG_VARS:O:u}
|
2013-04-22 18:11:29 +00:00
|
|
|
.if defined(${v}.${PROG})
|
2012-11-07 21:44:04 +00:00
|
|
|
$v += ${${v}_${PROG}:U${${v}.${PROG}}}
|
2013-04-22 18:11:29 +00:00
|
|
|
.endif
|
2012-11-07 21:44:04 +00:00
|
|
|
.endfor
|
2012-10-22 01:18:41 +00:00
|
|
|
|
2012-11-07 21:44:04 +00:00
|
|
|
# for meta mode, there can be only one!
|
|
|
|
.if ${PROG} == ${UPDATE_DEPENDFILE_PROG:Uno}
|
|
|
|
UPDATE_DEPENDFILE ?= yes
|
2012-10-22 01:18:41 +00:00
|
|
|
.endif
|
2012-11-07 21:44:04 +00:00
|
|
|
UPDATE_DEPENDFILE ?= NO
|
|
|
|
|
|
|
|
# ensure that we don't clobber each other's dependencies
|
|
|
|
DEPENDFILE?= .depend.${PROG}
|
|
|
|
# prog.mk will do the rest
|
|
|
|
.else
|
|
|
|
all: ${PROGS}
|
|
|
|
|
|
|
|
# We cannot capture dependencies for meta mode here
|
|
|
|
UPDATE_DEPENDFILE = NO
|
|
|
|
# nor can we safely run in parallel.
|
|
|
|
.NOTPARALLEL:
|
2012-10-22 01:18:41 +00:00
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
2012-11-07 21:44:04 +00:00
|
|
|
# handle being called [bsd.]progs.mk
|
|
|
|
.include <${.PARSEFILE:S,progs,prog,}>
|
2012-10-22 01:18:41 +00:00
|
|
|
|
2012-11-07 21:44:04 +00:00
|
|
|
.ifndef PROG
|
2013-04-22 18:11:29 +00:00
|
|
|
# tell progs.mk we might want to install things
|
|
|
|
PROGS_TARGETS+= cleandepend cleandir cleanobj depend install
|
2012-10-22 01:18:41 +00:00
|
|
|
|
2012-11-07 21:44:04 +00:00
|
|
|
.for p in ${PROGS}
|
|
|
|
.if defined(PROGS_CXX) && !empty(PROGS_CXX:M$p)
|
|
|
|
# bsd.prog.mk may need to know this
|
|
|
|
x.$p= PROG_CXX=$p
|
2012-10-22 01:18:41 +00:00
|
|
|
.endif
|
|
|
|
|
2012-11-07 21:44:04 +00:00
|
|
|
$p ${p}_p: .PHONY .MAKE
|
|
|
|
(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} PROG=$p ${x.$p})
|
2012-10-22 01:18:41 +00:00
|
|
|
|
2012-11-07 21:44:04 +00:00
|
|
|
.for t in ${PROGS_TARGETS:O:u}
|
|
|
|
$p.$t: .PHONY .MAKE
|
|
|
|
(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} PROG=$p ${x.$p} ${@:E})
|
2012-10-22 01:18:41 +00:00
|
|
|
.endfor
|
|
|
|
.endfor
|
|
|
|
|
2012-11-07 21:44:04 +00:00
|
|
|
.for t in ${PROGS_TARGETS:O:u}
|
|
|
|
$t: ${PROGS:%=%.$t}
|
2012-10-22 01:18:41 +00:00
|
|
|
.endfor
|
|
|
|
|
|
|
|
.endif
|