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
|
|
|
|
|
2013-11-13 15:10:32 +00:00
|
|
|
.if defined(PROGS) || defined(PROGS_CXX)
|
|
|
|
# we really only use PROGS below...
|
|
|
|
PROGS += ${PROGS_CXX}
|
2012-11-07 21:44:04 +00:00
|
|
|
|
|
|
|
# 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
|
2015-09-24 00:17:00 +00:00
|
|
|
PROG_OVERRIDE_VARS += BINDIR BINGRP BINOWN BINMODE DPSRCS MAN PROGNAME \
|
|
|
|
SRCS
|
|
|
|
PROG_VARS += CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD LIBADD LINKS \
|
|
|
|
LDFLAGS MLINKS ${PROG_OVERRIDE_VARS}
|
2012-11-07 21:44:04 +00:00
|
|
|
.for v in ${PROG_VARS:O:u}
|
2014-09-24 04:45:35 +00:00
|
|
|
.if empty(${PROG_OVERRIDE_VARS:M$v})
|
|
|
|
.if defined(${v}.${PROG})
|
|
|
|
$v += ${${v}.${PROG}}
|
|
|
|
.elif defined(${v}_${PROG})
|
|
|
|
$v += ${${v}_${PROG}}
|
|
|
|
.endif
|
2013-11-13 15:10:32 +00:00
|
|
|
.else
|
|
|
|
$v ?=
|
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!
|
2013-11-13 15:10:32 +00:00
|
|
|
.if ${PROG} == ${UPDATE_DEPENDFILE_PROG}
|
2012-11-07 21:44:04 +00:00
|
|
|
UPDATE_DEPENDFILE ?= yes
|
2012-10-22 01:18:41 +00:00
|
|
|
.endif
|
2012-11-07 21:44:04 +00:00
|
|
|
UPDATE_DEPENDFILE ?= NO
|
|
|
|
|
|
|
|
# prog.mk will do the rest
|
|
|
|
.else
|
2015-09-23 23:20:49 +00:00
|
|
|
all: ${PROGS}
|
2012-11-07 21:44:04 +00:00
|
|
|
|
|
|
|
# We cannot capture dependencies for meta mode here
|
|
|
|
UPDATE_DEPENDFILE = NO
|
2012-10-22 01:18:41 +00:00
|
|
|
.endif
|
2015-09-23 23:20:49 +00:00
|
|
|
.endif # PROGS || PROGS_CXX
|
2012-10-22 01:18:41 +00:00
|
|
|
|
2015-09-23 23:20:49 +00:00
|
|
|
# These are handled by the main make process.
|
2014-11-04 05:02:22 +00:00
|
|
|
.ifdef _RECURSING_PROGS
|
2015-10-09 21:57:42 +00:00
|
|
|
_PROGS_GLOBAL_VARS= CLEANFILES CLEANDIRS FILESGROUPS SCRIPTS CONFGROUPS
|
2015-09-23 23:20:49 +00:00
|
|
|
.for v in ${_PROGS_GLOBAL_VARS}
|
|
|
|
$v =
|
|
|
|
.endfor
|
2014-11-04 05:02:22 +00:00
|
|
|
.endif
|
|
|
|
|
2012-11-07 21:44:04 +00:00
|
|
|
# handle being called [bsd.]progs.mk
|
2013-11-13 15:10:32 +00:00
|
|
|
.include <bsd.prog.mk>
|
2012-10-22 01:18:41 +00:00
|
|
|
|
2015-09-23 23:20:49 +00:00
|
|
|
.if !empty(PROGS) && !defined(_RECURSING_PROGS)
|
2013-04-22 18:11:29 +00:00
|
|
|
# tell progs.mk we might want to install things
|
2015-09-25 00:07:31 +00:00
|
|
|
PROGS_TARGETS+= checkdpadd clean cleandepend cleandir 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
|
|
|
|
|
2015-09-23 23:20:49 +00:00
|
|
|
# Main PROG target
|
2012-11-07 21:44:04 +00:00
|
|
|
$p ${p}_p: .PHONY .MAKE
|
2015-06-11 21:11:33 +00:00
|
|
|
(cd ${.CURDIR} && \
|
|
|
|
DEPENDFILE=.depend.$p \
|
|
|
|
${MAKE} -f ${MAKEFILE} _RECURSING_PROGS= \
|
|
|
|
SUBDIR= PROG=$p ${x.$p})
|
2012-10-22 01:18:41 +00:00
|
|
|
|
2015-09-23 23:20:49 +00:00
|
|
|
# Pseudo targets for PROG, such as 'install'.
|
2012-11-07 21:44:04 +00:00
|
|
|
.for t in ${PROGS_TARGETS:O:u}
|
|
|
|
$p.$t: .PHONY .MAKE
|
2015-06-11 21:11:33 +00:00
|
|
|
(cd ${.CURDIR} && \
|
|
|
|
DEPENDFILE=.depend.$p \
|
|
|
|
${MAKE} -f ${MAKEFILE} _RECURSING_PROGS= \
|
|
|
|
SUBDIR= PROG=$p ${x.$p} ${@:E})
|
2012-10-22 01:18:41 +00:00
|
|
|
.endfor
|
|
|
|
.endfor
|
|
|
|
|
2015-09-23 23:20:49 +00:00
|
|
|
# Depend main pseudo targets on all PROG.pseudo targets too.
|
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
|
2014-10-16 21:13:46 +00:00
|
|
|
.endif
|