1*c59c3bf3SSimon J. Gerraty# SPDX-License-Identifier: BSD-2-Clause 2*c59c3bf3SSimon J. Gerraty# 3*c59c3bf3SSimon J. Gerraty# $Id: libs.mk,v 1.7 2024/02/17 17:26:57 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(LIBS) 213cbdda60SSimon J. Gerraty 221bbe5942SSimon J. Gerraty# In meta mode, we can capture dependenices for _one_ of the progs. 231bbe5942SSimon J. Gerraty# if makefile doesn't nominate one, we use the first. 241bbe5942SSimon J. Gerraty.ifndef UPDATE_DEPENDFILE_LIB 251bbe5942SSimon J. GerratyUPDATE_DEPENDFILE_LIB = ${LIBS:[1]} 261bbe5942SSimon J. Gerraty.export UPDATE_DEPENDFILE_LIB 271bbe5942SSimon J. Gerraty.endif 281bbe5942SSimon J. Gerraty 293cbdda60SSimon J. Gerraty.ifndef LIB 301bbe5942SSimon J. Gerraty# They may have asked us to build just one 313cbdda60SSimon J. Gerraty.for t in ${LIBS:R:T:S,^lib,,} 323cbdda60SSimon J. Gerraty.if make(lib$t) 333cbdda60SSimon J. GerratyLIB?= $t 343cbdda60SSimon J. Gerratylib$t: all 353cbdda60SSimon J. Gerraty.endif 363cbdda60SSimon J. Gerraty.endfor 373cbdda60SSimon J. Gerraty.endif 383cbdda60SSimon J. Gerraty 393cbdda60SSimon J. Gerraty.if defined(LIB) 403cbdda60SSimon J. Gerraty# just one of many 411bbe5942SSimon J. GerratyLIB_VARS += \ 421bbe5942SSimon J. Gerraty LIBDIR \ 431bbe5942SSimon J. Gerraty CFLAGS \ 441bbe5942SSimon J. Gerraty COPTS \ 451bbe5942SSimon J. Gerraty CPPFLAGS \ 461bbe5942SSimon J. Gerraty CXXFLAGS \ 471bbe5942SSimon J. Gerraty DPADD \ 481bbe5942SSimon J. Gerraty DPLIBS \ 491bbe5942SSimon J. Gerraty LDADD \ 501bbe5942SSimon J. Gerraty LDFLAGS \ 511bbe5942SSimon J. Gerraty MAN \ 521bbe5942SSimon J. Gerraty SRCS 531bbe5942SSimon J. Gerraty 541bbe5942SSimon J. Gerraty.for v in ${LIB_VARS:O:u} 551bbe5942SSimon J. Gerraty.if defined(${v}.${LIB}) || defined(${v}_${LIB}) 561bbe5942SSimon J. Gerraty$v += ${${v}_${LIB}:U${${v}.${LIB}}} 571bbe5942SSimon J. Gerraty.endif 583cbdda60SSimon J. Gerraty.endfor 591bbe5942SSimon J. Gerraty 601bbe5942SSimon J. Gerraty# for meta mode, there can be only one! 611bbe5942SSimon J. Gerraty.if ${LIB} == ${UPDATE_DEPENDFILE_LIB:Uno} 621bbe5942SSimon J. GerratyUPDATE_DEPENDFILE ?= yes 631bbe5942SSimon J. Gerraty.endif 641bbe5942SSimon J. GerratyUPDATE_DEPENDFILE ?= NO 651bbe5942SSimon J. Gerraty 663cbdda60SSimon J. Gerraty# ensure that we don't clobber each other's dependencies 673cbdda60SSimon J. GerratyDEPENDFILE?= .depend.${LIB} 683cbdda60SSimon J. Gerraty# lib.mk will do the rest 693cbdda60SSimon J. Gerraty.else 703cbdda60SSimon J. Gerratyall: ${LIBS:S,^lib,,:@t@lib$t.a@} .MAKE 711bbe5942SSimon J. Gerraty 721bbe5942SSimon J. Gerraty# We cannot capture dependencies for meta mode here 731bbe5942SSimon J. GerratyUPDATE_DEPENDFILE = NO 741bbe5942SSimon J. Gerraty# nor can we safely run in parallel. 751bbe5942SSimon J. Gerraty.NOTPARALLEL: 763cbdda60SSimon J. Gerraty.endif 773cbdda60SSimon J. Gerraty.endif 783cbdda60SSimon J. Gerraty 793cbdda60SSimon J. Gerraty# handle being called [bsd.]libs.mk 803cbdda60SSimon J. Gerraty.include <${.PARSEFILE:S,libs,lib,}> 813cbdda60SSimon J. Gerraty 823cbdda60SSimon J. Gerraty.ifndef LIB 831bbe5942SSimon J. Gerraty# tell libs.mk we might want to install things 841bbe5942SSimon J. GerratyLIBS_TARGETS+= cleandepend cleandir cleanobj depend install 853cbdda60SSimon J. Gerraty 861bbe5942SSimon J. Gerraty.for b in ${LIBS:R:T:S,^lib,,} 871bbe5942SSimon J. Gerratylib$b.a: ${SRCS} ${DPADD} ${SRCS_lib$b} ${DPADD_lib$b} 882c3632d1SSimon J. Gerraty (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$b -DWITHOUT_META_STATS) 891bbe5942SSimon J. Gerraty 901bbe5942SSimon J. Gerraty.for t in ${LIBS_TARGETS:O:u} 911bbe5942SSimon J. Gerraty$b.$t: .PHONY .MAKE 922c3632d1SSimon J. Gerraty (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$b ${@:E} -DWITHOUT_META_STATS) 931bbe5942SSimon J. Gerraty.endfor 943cbdda60SSimon J. Gerraty.endfor 952c3632d1SSimon J. Gerraty 962c3632d1SSimon J. Gerraty.if !defined(WITHOUT_META_STATS) && ${.MAKE.LEVEL} > 0 972c3632d1SSimon J. Gerraty.END: _reldir_finish 982c3632d1SSimon J. Gerraty.ERROR: _reldir_failed 992c3632d1SSimon J. Gerraty.endif 1002c3632d1SSimon J. Gerraty 1013cbdda60SSimon J. Gerraty.endif 102