1c59c3bf3SSimon J. Gerraty# SPDX-License-Identifier: BSD-2-Clause 2c59c3bf3SSimon J. Gerraty# 3*548bfc56SSimon J. Gerraty# $Id: progs.mk,v 1.18 2024/04/09 17:18:24 sjg Exp $ 43cbdda60SSimon J. Gerraty# 53cbdda60SSimon J. Gerraty# @(#) Copyright (c) 2006, Simon J. Gerraty 63cbdda60SSimon J. Gerraty# 73cbdda60SSimon J. Gerraty# This file is provided in the hope that it will 83cbdda60SSimon J. Gerraty# be of use. There is absolutely NO WARRANTY. 93cbdda60SSimon J. Gerraty# Permission to copy, redistribute or otherwise 103cbdda60SSimon J. Gerraty# use this file is hereby granted provided that 113cbdda60SSimon J. Gerraty# the above copyright notice and this notice are 123cbdda60SSimon J. Gerraty# left intact. 133cbdda60SSimon J. Gerraty# 143cbdda60SSimon J. Gerraty# Please send copies of changes and bug-fixes to: 153cbdda60SSimon J. Gerraty# sjg@crufty.net 163cbdda60SSimon J. Gerraty# 173cbdda60SSimon J. Gerraty 183cbdda60SSimon J. Gerraty.MAIN: all 193cbdda60SSimon J. Gerraty 203cbdda60SSimon J. Gerraty.if defined(PROGS) 213cbdda60SSimon J. Gerraty 223cbdda60SSimon J. Gerraty# In meta mode, we can capture dependenices for _one_ of the progs. 233cbdda60SSimon J. Gerraty# if makefile doesn't nominate one, we use the first. 243cbdda60SSimon J. Gerraty.ifndef UPDATE_DEPENDFILE_PROG 253cbdda60SSimon J. GerratyUPDATE_DEPENDFILE_PROG = ${PROGS:[1]} 263cbdda60SSimon J. Gerraty.export UPDATE_DEPENDFILE_PROG 273cbdda60SSimon J. Gerraty.endif 283cbdda60SSimon J. Gerraty 293cbdda60SSimon J. Gerraty.ifndef PROG 303cbdda60SSimon J. Gerraty# They may have asked us to build just one 313cbdda60SSimon J. Gerraty.for t in ${PROGS} 323cbdda60SSimon J. Gerraty.if make($t) 333cbdda60SSimon J. GerratyPROG ?= $t 343cbdda60SSimon J. Gerraty.endif 353cbdda60SSimon J. Gerraty.endfor 363cbdda60SSimon J. Gerraty.endif 373cbdda60SSimon J. Gerraty 383cbdda60SSimon J. Gerraty.if defined(PROG) 393cbdda60SSimon J. Gerraty# just one of many 401bbe5942SSimon J. GerratyPROG_VARS += \ 411bbe5942SSimon J. Gerraty BINDIR \ 421bbe5942SSimon J. Gerraty CXXFLAGS \ 431bbe5942SSimon J. Gerraty DPADD \ 441bbe5942SSimon J. Gerraty DPLIBS \ 451bbe5942SSimon J. Gerraty LDADD \ 461bbe5942SSimon J. Gerraty MAN \ 47*548bfc56SSimon J. Gerraty 48*548bfc56SSimon J. Gerraty.ifndef SYS_OS_MK 49*548bfc56SSimon J. Gerraty# assume we are not using init.mk, otherwise 50*548bfc56SSimon J. Gerraty# we need to avoid overlap with its 51*548bfc56SSimon J. Gerraty# QUALIFIED_VAR_LIST which includes these and its 52*548bfc56SSimon J. Gerraty# VAR_QUALIFIER_LIST includes .TARGET which 53*548bfc56SSimon J. Gerraty# would match PROG 54*548bfc56SSimon J. GerratyPROG_VARS += \ 55*548bfc56SSimon J. Gerraty CFLAGS \ 56*548bfc56SSimon J. Gerraty COPTS \ 57*548bfc56SSimon J. Gerraty CPPFLAGS \ 58*548bfc56SSimon J. Gerraty LDFLAGS \ 59*548bfc56SSimon J. Gerraty SRCS \ 60*548bfc56SSimon J. Gerraty 61*548bfc56SSimon J. Gerraty.endif 621bbe5942SSimon J. Gerraty 633cbdda60SSimon J. Gerraty.for v in ${PROG_VARS:O:u} 641bbe5942SSimon J. Gerraty.if defined(${v}.${PROG}) || defined(${v}_${PROG}) 653cbdda60SSimon J. Gerraty$v += ${${v}_${PROG}:U${${v}.${PROG}}} 6652d86256SSimon J. Gerraty.endif 673cbdda60SSimon J. Gerraty.endfor 683cbdda60SSimon J. Gerraty 693cbdda60SSimon J. Gerraty# for meta mode, there can be only one! 703cbdda60SSimon J. Gerraty.if ${PROG} == ${UPDATE_DEPENDFILE_PROG:Uno} 713cbdda60SSimon J. GerratyUPDATE_DEPENDFILE ?= yes 723cbdda60SSimon J. Gerraty.endif 733cbdda60SSimon J. GerratyUPDATE_DEPENDFILE ?= NO 743cbdda60SSimon J. Gerraty 753cbdda60SSimon J. Gerraty# ensure that we don't clobber each other's dependencies 763cbdda60SSimon J. GerratyDEPENDFILE?= .depend.${PROG} 773cbdda60SSimon J. Gerraty# prog.mk will do the rest 783cbdda60SSimon J. Gerraty.else 793cbdda60SSimon J. Gerratyall: ${PROGS} 803cbdda60SSimon J. Gerraty 813cbdda60SSimon J. Gerraty# We cannot capture dependencies for meta mode here 823cbdda60SSimon J. GerratyUPDATE_DEPENDFILE = NO 833cbdda60SSimon J. Gerraty# nor can we safely run in parallel. 843cbdda60SSimon J. Gerraty.NOTPARALLEL: 853cbdda60SSimon J. Gerraty.endif 863cbdda60SSimon J. Gerraty.endif 873cbdda60SSimon J. Gerraty 883cbdda60SSimon J. Gerraty# handle being called [bsd.]progs.mk 893cbdda60SSimon J. Gerraty.include <${.PARSEFILE:S,progs,prog,}> 903cbdda60SSimon J. Gerraty 913cbdda60SSimon J. Gerraty.ifndef PROG 9252d86256SSimon J. Gerraty# tell progs.mk we might want to install things 9352d86256SSimon J. GerratyPROGS_TARGETS+= cleandepend cleandir cleanobj depend install 943cbdda60SSimon J. Gerraty 953cbdda60SSimon J. Gerraty.for p in ${PROGS} 963cbdda60SSimon J. Gerraty.if defined(PROGS_CXX) && !empty(PROGS_CXX:M$p) 973cbdda60SSimon J. Gerraty# bsd.prog.mk may need to know this 983cbdda60SSimon J. Gerratyx.$p= PROG_CXX=$p 993cbdda60SSimon J. Gerraty.endif 1003cbdda60SSimon J. Gerraty 1013cbdda60SSimon J. Gerraty$p ${p}_p: .PHONY .MAKE 1022c3632d1SSimon J. Gerraty (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} PROG=$p ${x.$p} -DWITHOUT_META_STATS) 1033cbdda60SSimon J. Gerraty 1043cbdda60SSimon J. Gerraty.for t in ${PROGS_TARGETS:O:u} 1053cbdda60SSimon J. Gerraty$p.$t: .PHONY .MAKE 1062c3632d1SSimon J. Gerraty (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} PROG=$p ${x.$p} ${@:E} -DWITHOUT_META_STATS) 1073cbdda60SSimon J. Gerraty.endfor 1083cbdda60SSimon J. Gerraty.endfor 1093cbdda60SSimon J. Gerraty 1103cbdda60SSimon J. Gerraty.for t in ${PROGS_TARGETS:O:u} 1113cbdda60SSimon J. Gerraty$t: ${PROGS:%=%.$t} 1123cbdda60SSimon J. Gerraty.endfor 1133cbdda60SSimon J. Gerraty 1142c3632d1SSimon J. Gerraty.if !defined(WITHOUT_META_STATS) && ${.MAKE.LEVEL} > 0 1152c3632d1SSimon J. Gerraty.END: _reldir_finish 1162c3632d1SSimon J. Gerraty.ERROR: _reldir_failed 1172c3632d1SSimon J. Gerraty.endif 1182c3632d1SSimon J. Gerraty 1193cbdda60SSimon J. Gerraty.endif 120