1*a34d5fb1SAntonio Huete Jimenez# $Id: libs.mk,v 1.6 2020/08/19 17:51:53 sjg Exp $ 25f1e34d9SAlexandre Perrin# 35f1e34d9SAlexandre Perrin# @(#) Copyright (c) 2006, Simon J. Gerraty 45f1e34d9SAlexandre Perrin# 55f1e34d9SAlexandre Perrin# This file is provided in the hope that it will 65f1e34d9SAlexandre Perrin# be of use. There is absolutely NO WARRANTY. 75f1e34d9SAlexandre Perrin# Permission to copy, redistribute or otherwise 85f1e34d9SAlexandre Perrin# use this file is hereby granted provided that 95f1e34d9SAlexandre Perrin# the above copyright notice and this notice are 105f1e34d9SAlexandre Perrin# left intact. 115f1e34d9SAlexandre Perrin# 125f1e34d9SAlexandre Perrin# Please send copies of changes and bug-fixes to: 135f1e34d9SAlexandre Perrin# sjg@crufty.net 145f1e34d9SAlexandre Perrin# 155f1e34d9SAlexandre Perrin 165f1e34d9SAlexandre Perrin.MAIN: all 175f1e34d9SAlexandre Perrin 185f1e34d9SAlexandre Perrin.if defined(LIBS) 195f1e34d9SAlexandre Perrin 205f1e34d9SAlexandre Perrin# In meta mode, we can capture dependenices for _one_ of the progs. 215f1e34d9SAlexandre Perrin# if makefile doesn't nominate one, we use the first. 225f1e34d9SAlexandre Perrin.ifndef UPDATE_DEPENDFILE_LIB 235f1e34d9SAlexandre PerrinUPDATE_DEPENDFILE_LIB = ${LIBS:[1]} 245f1e34d9SAlexandre Perrin.export UPDATE_DEPENDFILE_LIB 255f1e34d9SAlexandre Perrin.endif 265f1e34d9SAlexandre Perrin 275f1e34d9SAlexandre Perrin.ifndef LIB 285f1e34d9SAlexandre Perrin# They may have asked us to build just one 295f1e34d9SAlexandre Perrin.for t in ${LIBS:R:T:S,^lib,,} 305f1e34d9SAlexandre Perrin.if make(lib$t) 315f1e34d9SAlexandre PerrinLIB?= $t 325f1e34d9SAlexandre Perrinlib$t: all 335f1e34d9SAlexandre Perrin.endif 345f1e34d9SAlexandre Perrin.endfor 355f1e34d9SAlexandre Perrin.endif 365f1e34d9SAlexandre Perrin 375f1e34d9SAlexandre Perrin.if defined(LIB) 385f1e34d9SAlexandre Perrin# just one of many 395f1e34d9SAlexandre PerrinLIB_VARS += \ 405f1e34d9SAlexandre Perrin LIBDIR \ 415f1e34d9SAlexandre Perrin CFLAGS \ 425f1e34d9SAlexandre Perrin COPTS \ 435f1e34d9SAlexandre Perrin CPPFLAGS \ 445f1e34d9SAlexandre Perrin CXXFLAGS \ 455f1e34d9SAlexandre Perrin DPADD \ 465f1e34d9SAlexandre Perrin DPLIBS \ 475f1e34d9SAlexandre Perrin LDADD \ 485f1e34d9SAlexandre Perrin LDFLAGS \ 495f1e34d9SAlexandre Perrin MAN \ 505f1e34d9SAlexandre Perrin SRCS 515f1e34d9SAlexandre Perrin 525f1e34d9SAlexandre Perrin.for v in ${LIB_VARS:O:u} 535f1e34d9SAlexandre Perrin.if defined(${v}.${LIB}) || defined(${v}_${LIB}) 545f1e34d9SAlexandre Perrin$v += ${${v}_${LIB}:U${${v}.${LIB}}} 555f1e34d9SAlexandre Perrin.endif 565f1e34d9SAlexandre Perrin.endfor 575f1e34d9SAlexandre Perrin 585f1e34d9SAlexandre Perrin# for meta mode, there can be only one! 595f1e34d9SAlexandre Perrin.if ${LIB} == ${UPDATE_DEPENDFILE_LIB:Uno} 605f1e34d9SAlexandre PerrinUPDATE_DEPENDFILE ?= yes 615f1e34d9SAlexandre Perrin.endif 625f1e34d9SAlexandre PerrinUPDATE_DEPENDFILE ?= NO 635f1e34d9SAlexandre Perrin 645f1e34d9SAlexandre Perrin# ensure that we don't clobber each other's dependencies 655f1e34d9SAlexandre PerrinDEPENDFILE?= .depend.${LIB} 665f1e34d9SAlexandre Perrin# lib.mk will do the rest 675f1e34d9SAlexandre Perrin.else 685f1e34d9SAlexandre Perrinall: ${LIBS:S,^lib,,:@t@lib$t.a@} .MAKE 695f1e34d9SAlexandre Perrin 705f1e34d9SAlexandre Perrin# We cannot capture dependencies for meta mode here 715f1e34d9SAlexandre PerrinUPDATE_DEPENDFILE = NO 725f1e34d9SAlexandre Perrin# nor can we safely run in parallel. 735f1e34d9SAlexandre Perrin.NOTPARALLEL: 745f1e34d9SAlexandre Perrin.endif 755f1e34d9SAlexandre Perrin.endif 765f1e34d9SAlexandre Perrin 775f1e34d9SAlexandre Perrin# handle being called [bsd.]libs.mk 785f1e34d9SAlexandre Perrin.include <${.PARSEFILE:S,libs,lib,}> 795f1e34d9SAlexandre Perrin 805f1e34d9SAlexandre Perrin.ifndef LIB 815f1e34d9SAlexandre Perrin# tell libs.mk we might want to install things 825f1e34d9SAlexandre PerrinLIBS_TARGETS+= cleandepend cleandir cleanobj depend install 835f1e34d9SAlexandre Perrin 845f1e34d9SAlexandre Perrin.for b in ${LIBS:R:T:S,^lib,,} 855f1e34d9SAlexandre Perrinlib$b.a: ${SRCS} ${DPADD} ${SRCS_lib$b} ${DPADD_lib$b} 86*a34d5fb1SAntonio Huete Jimenez (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$b -DWITHOUT_META_STATS) 875f1e34d9SAlexandre Perrin 885f1e34d9SAlexandre Perrin.for t in ${LIBS_TARGETS:O:u} 895f1e34d9SAlexandre Perrin$b.$t: .PHONY .MAKE 90*a34d5fb1SAntonio Huete Jimenez (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$b ${@:E} -DWITHOUT_META_STATS) 915f1e34d9SAlexandre Perrin.endfor 925f1e34d9SAlexandre Perrin.endfor 93*a34d5fb1SAntonio Huete Jimenez 94*a34d5fb1SAntonio Huete Jimenez.if !defined(WITHOUT_META_STATS) && ${.MAKE.LEVEL} > 0 95*a34d5fb1SAntonio Huete Jimenez.END: _reldir_finish 96*a34d5fb1SAntonio Huete Jimenez.ERROR: _reldir_failed 97*a34d5fb1SAntonio Huete Jimenez.endif 98*a34d5fb1SAntonio Huete Jimenez 995f1e34d9SAlexandre Perrin.endif 100