1*1bbe5942SSimon J. Gerraty# $Id: libs.mk,v 1.3 2013/08/02 18:28:48 sjg Exp $ 23cbdda60SSimon J. Gerraty# 33cbdda60SSimon J. Gerraty# @(#) Copyright (c) 2006, Simon J. Gerraty 43cbdda60SSimon J. Gerraty# 53cbdda60SSimon J. Gerraty# This file is provided in the hope that it will 63cbdda60SSimon J. Gerraty# be of use. There is absolutely NO WARRANTY. 73cbdda60SSimon J. Gerraty# Permission to copy, redistribute or otherwise 83cbdda60SSimon J. Gerraty# use this file is hereby granted provided that 93cbdda60SSimon J. Gerraty# the above copyright notice and this notice are 103cbdda60SSimon J. Gerraty# left intact. 113cbdda60SSimon J. Gerraty# 123cbdda60SSimon J. Gerraty# Please send copies of changes and bug-fixes to: 133cbdda60SSimon J. Gerraty# sjg@crufty.net 143cbdda60SSimon J. Gerraty# 153cbdda60SSimon J. Gerraty 163cbdda60SSimon J. Gerraty.MAIN: all 173cbdda60SSimon J. Gerraty 183cbdda60SSimon J. Gerraty.if defined(LIBS) 193cbdda60SSimon J. Gerraty 20*1bbe5942SSimon J. Gerraty# In meta mode, we can capture dependenices for _one_ of the progs. 21*1bbe5942SSimon J. Gerraty# if makefile doesn't nominate one, we use the first. 22*1bbe5942SSimon J. Gerraty.ifndef UPDATE_DEPENDFILE_LIB 23*1bbe5942SSimon J. GerratyUPDATE_DEPENDFILE_LIB = ${LIBS:[1]} 24*1bbe5942SSimon J. Gerraty.export UPDATE_DEPENDFILE_LIB 25*1bbe5942SSimon J. Gerraty.endif 26*1bbe5942SSimon J. Gerraty 273cbdda60SSimon J. Gerraty.ifndef LIB 28*1bbe5942SSimon J. Gerraty# They may have asked us to build just one 293cbdda60SSimon J. Gerraty.for t in ${LIBS:R:T:S,^lib,,} 303cbdda60SSimon J. Gerraty.if make(lib$t) 313cbdda60SSimon J. GerratyLIB?= $t 323cbdda60SSimon J. Gerratylib$t: all 333cbdda60SSimon J. Gerraty.endif 343cbdda60SSimon J. Gerraty.endfor 353cbdda60SSimon J. Gerraty.endif 363cbdda60SSimon J. Gerraty 373cbdda60SSimon J. Gerraty.if defined(LIB) 383cbdda60SSimon J. Gerraty# just one of many 39*1bbe5942SSimon J. GerratyLIB_VARS += \ 40*1bbe5942SSimon J. Gerraty LIBDIR \ 41*1bbe5942SSimon J. Gerraty CFLAGS \ 42*1bbe5942SSimon J. Gerraty COPTS \ 43*1bbe5942SSimon J. Gerraty CPPFLAGS \ 44*1bbe5942SSimon J. Gerraty CXXFLAGS \ 45*1bbe5942SSimon J. Gerraty DPADD \ 46*1bbe5942SSimon J. Gerraty DPLIBS \ 47*1bbe5942SSimon J. Gerraty LDADD \ 48*1bbe5942SSimon J. Gerraty LDFLAGS \ 49*1bbe5942SSimon J. Gerraty MAN \ 50*1bbe5942SSimon J. Gerraty SRCS 51*1bbe5942SSimon J. Gerraty 52*1bbe5942SSimon J. Gerraty.for v in ${LIB_VARS:O:u} 53*1bbe5942SSimon J. Gerraty.if defined(${v}.${LIB}) || defined(${v}_${LIB}) 54*1bbe5942SSimon J. Gerraty$v += ${${v}_${LIB}:U${${v}.${LIB}}} 55*1bbe5942SSimon J. Gerraty.endif 563cbdda60SSimon J. Gerraty.endfor 57*1bbe5942SSimon J. Gerraty 58*1bbe5942SSimon J. Gerraty# for meta mode, there can be only one! 59*1bbe5942SSimon J. Gerraty.if ${LIB} == ${UPDATE_DEPENDFILE_LIB:Uno} 60*1bbe5942SSimon J. GerratyUPDATE_DEPENDFILE ?= yes 61*1bbe5942SSimon J. Gerraty.endif 62*1bbe5942SSimon J. GerratyUPDATE_DEPENDFILE ?= NO 63*1bbe5942SSimon J. Gerraty 643cbdda60SSimon J. Gerraty# ensure that we don't clobber each other's dependencies 653cbdda60SSimon J. GerratyDEPENDFILE?= .depend.${LIB} 663cbdda60SSimon J. Gerraty# lib.mk will do the rest 673cbdda60SSimon J. Gerraty.else 683cbdda60SSimon J. Gerratyall: ${LIBS:S,^lib,,:@t@lib$t.a@} .MAKE 69*1bbe5942SSimon J. Gerraty 70*1bbe5942SSimon J. Gerraty# We cannot capture dependencies for meta mode here 71*1bbe5942SSimon J. GerratyUPDATE_DEPENDFILE = NO 72*1bbe5942SSimon J. Gerraty# nor can we safely run in parallel. 73*1bbe5942SSimon J. Gerraty.NOTPARALLEL: 743cbdda60SSimon J. Gerraty.endif 753cbdda60SSimon J. Gerraty.endif 763cbdda60SSimon J. Gerraty 773cbdda60SSimon J. Gerraty# handle being called [bsd.]libs.mk 783cbdda60SSimon J. Gerraty.include <${.PARSEFILE:S,libs,lib,}> 793cbdda60SSimon J. Gerraty 803cbdda60SSimon J. Gerraty.ifndef LIB 81*1bbe5942SSimon J. Gerraty# tell libs.mk we might want to install things 82*1bbe5942SSimon J. GerratyLIBS_TARGETS+= cleandepend cleandir cleanobj depend install 833cbdda60SSimon J. Gerraty 84*1bbe5942SSimon J. Gerraty.for b in ${LIBS:R:T:S,^lib,,} 85*1bbe5942SSimon J. Gerratylib$b.a: ${SRCS} ${DPADD} ${SRCS_lib$b} ${DPADD_lib$b} 86*1bbe5942SSimon J. Gerraty (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$b) 87*1bbe5942SSimon J. Gerraty 88*1bbe5942SSimon J. Gerraty.for t in ${LIBS_TARGETS:O:u} 89*1bbe5942SSimon J. Gerraty$b.$t: .PHONY .MAKE 90*1bbe5942SSimon J. Gerraty (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$b ${@:E}) 91*1bbe5942SSimon J. Gerraty.endfor 923cbdda60SSimon J. Gerraty.endfor 933cbdda60SSimon J. Gerraty.endif 94