1255253Ssjg# $Id: libs.mk,v 1.3 2013/08/02 18:28:48 sjg Exp $ 2246149Ssjg# 3246149Ssjg# @(#) Copyright (c) 2006, Simon J. Gerraty 4246149Ssjg# 5246149Ssjg# This file is provided in the hope that it will 6246149Ssjg# be of use. There is absolutely NO WARRANTY. 7246149Ssjg# Permission to copy, redistribute or otherwise 8246149Ssjg# use this file is hereby granted provided that 9246149Ssjg# the above copyright notice and this notice are 10246149Ssjg# left intact. 11246149Ssjg# 12246149Ssjg# Please send copies of changes and bug-fixes to: 13246149Ssjg# sjg@crufty.net 14246149Ssjg# 15246149Ssjg 16246149Ssjg.MAIN: all 17246149Ssjg 18246149Ssjg.if defined(LIBS) 19246149Ssjg 20255253Ssjg# In meta mode, we can capture dependenices for _one_ of the progs. 21255253Ssjg# if makefile doesn't nominate one, we use the first. 22255253Ssjg.ifndef UPDATE_DEPENDFILE_LIB 23255253SsjgUPDATE_DEPENDFILE_LIB = ${LIBS:[1]} 24255253Ssjg.export UPDATE_DEPENDFILE_LIB 25255253Ssjg.endif 26255253Ssjg 27246149Ssjg.ifndef LIB 28255253Ssjg# They may have asked us to build just one 29246149Ssjg.for t in ${LIBS:R:T:S,^lib,,} 30246149Ssjg.if make(lib$t) 31246149SsjgLIB?= $t 32246149Ssjglib$t: all 33246149Ssjg.endif 34246149Ssjg.endfor 35246149Ssjg.endif 36246149Ssjg 37246149Ssjg.if defined(LIB) 38246149Ssjg# just one of many 39255253SsjgLIB_VARS += \ 40255253Ssjg LIBDIR \ 41255253Ssjg CFLAGS \ 42255253Ssjg COPTS \ 43255253Ssjg CPPFLAGS \ 44255253Ssjg CXXFLAGS \ 45255253Ssjg DPADD \ 46255253Ssjg DPLIBS \ 47255253Ssjg LDADD \ 48255253Ssjg LDFLAGS \ 49255253Ssjg MAN \ 50255253Ssjg SRCS 51255253Ssjg 52255253Ssjg.for v in ${LIB_VARS:O:u} 53255253Ssjg.if defined(${v}.${LIB}) || defined(${v}_${LIB}) 54255253Ssjg$v += ${${v}_${LIB}:U${${v}.${LIB}}} 55255253Ssjg.endif 56246149Ssjg.endfor 57255253Ssjg 58255253Ssjg# for meta mode, there can be only one! 59255253Ssjg.if ${LIB} == ${UPDATE_DEPENDFILE_LIB:Uno} 60255253SsjgUPDATE_DEPENDFILE ?= yes 61255253Ssjg.endif 62255253SsjgUPDATE_DEPENDFILE ?= NO 63255253Ssjg 64246149Ssjg# ensure that we don't clobber each other's dependencies 65246149SsjgDEPENDFILE?= .depend.${LIB} 66246149Ssjg# lib.mk will do the rest 67246149Ssjg.else 68246149Ssjgall: ${LIBS:S,^lib,,:@t@lib$t.a@} .MAKE 69255253Ssjg 70255253Ssjg# We cannot capture dependencies for meta mode here 71255253SsjgUPDATE_DEPENDFILE = NO 72255253Ssjg# nor can we safely run in parallel. 73255253Ssjg.NOTPARALLEL: 74246149Ssjg.endif 75246149Ssjg.endif 76246149Ssjg 77246149Ssjg# handle being called [bsd.]libs.mk 78246149Ssjg.include <${.PARSEFILE:S,libs,lib,}> 79246149Ssjg 80246149Ssjg.ifndef LIB 81255253Ssjg# tell libs.mk we might want to install things 82255253SsjgLIBS_TARGETS+= cleandepend cleandir cleanobj depend install 83246149Ssjg 84255253Ssjg.for b in ${LIBS:R:T:S,^lib,,} 85255253Ssjglib$b.a: ${SRCS} ${DPADD} ${SRCS_lib$b} ${DPADD_lib$b} 86255253Ssjg (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$b) 87255253Ssjg 88255253Ssjg.for t in ${LIBS_TARGETS:O:u} 89255253Ssjg$b.$t: .PHONY .MAKE 90255253Ssjg (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$b ${@:E}) 91246149Ssjg.endfor 92255253Ssjg.endfor 93246149Ssjg.endif 94