xref: /freebsd/contrib/bmake/mk/libs.mk (revision 2c3632d1)
1*2c3632d1SSimon J. Gerraty# $Id: libs.mk,v 1.6 2020/08/19 17:51:53 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
201bbe5942SSimon J. Gerraty# In meta mode, we can capture dependenices for _one_ of the progs.
211bbe5942SSimon J. Gerraty# if makefile doesn't nominate one, we use the first.
221bbe5942SSimon J. Gerraty.ifndef UPDATE_DEPENDFILE_LIB
231bbe5942SSimon J. GerratyUPDATE_DEPENDFILE_LIB = ${LIBS:[1]}
241bbe5942SSimon J. Gerraty.export UPDATE_DEPENDFILE_LIB
251bbe5942SSimon J. Gerraty.endif
261bbe5942SSimon J. Gerraty
273cbdda60SSimon J. Gerraty.ifndef LIB
281bbe5942SSimon 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
391bbe5942SSimon J. GerratyLIB_VARS += \
401bbe5942SSimon J. Gerraty	LIBDIR \
411bbe5942SSimon J. Gerraty	CFLAGS \
421bbe5942SSimon J. Gerraty	COPTS \
431bbe5942SSimon J. Gerraty	CPPFLAGS \
441bbe5942SSimon J. Gerraty	CXXFLAGS \
451bbe5942SSimon J. Gerraty	DPADD \
461bbe5942SSimon J. Gerraty	DPLIBS \
471bbe5942SSimon J. Gerraty	LDADD \
481bbe5942SSimon J. Gerraty	LDFLAGS \
491bbe5942SSimon J. Gerraty	MAN \
501bbe5942SSimon J. Gerraty	SRCS
511bbe5942SSimon J. Gerraty
521bbe5942SSimon J. Gerraty.for v in ${LIB_VARS:O:u}
531bbe5942SSimon J. Gerraty.if defined(${v}.${LIB}) || defined(${v}_${LIB})
541bbe5942SSimon J. Gerraty$v += ${${v}_${LIB}:U${${v}.${LIB}}}
551bbe5942SSimon J. Gerraty.endif
563cbdda60SSimon J. Gerraty.endfor
571bbe5942SSimon J. Gerraty
581bbe5942SSimon J. Gerraty# for meta mode, there can be only one!
591bbe5942SSimon J. Gerraty.if ${LIB} == ${UPDATE_DEPENDFILE_LIB:Uno}
601bbe5942SSimon J. GerratyUPDATE_DEPENDFILE ?= yes
611bbe5942SSimon J. Gerraty.endif
621bbe5942SSimon J. GerratyUPDATE_DEPENDFILE ?= NO
631bbe5942SSimon 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
691bbe5942SSimon J. Gerraty
701bbe5942SSimon J. Gerraty# We cannot capture dependencies for meta mode here
711bbe5942SSimon J. GerratyUPDATE_DEPENDFILE = NO
721bbe5942SSimon J. Gerraty# nor can we safely run in parallel.
731bbe5942SSimon 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
811bbe5942SSimon J. Gerraty# tell libs.mk we might want to install things
821bbe5942SSimon J. GerratyLIBS_TARGETS+= cleandepend cleandir cleanobj depend install
833cbdda60SSimon J. Gerraty
841bbe5942SSimon J. Gerraty.for b in ${LIBS:R:T:S,^lib,,}
851bbe5942SSimon J. Gerratylib$b.a: ${SRCS} ${DPADD} ${SRCS_lib$b} ${DPADD_lib$b}
86*2c3632d1SSimon J. Gerraty	(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$b -DWITHOUT_META_STATS)
871bbe5942SSimon J. Gerraty
881bbe5942SSimon J. Gerraty.for t in ${LIBS_TARGETS:O:u}
891bbe5942SSimon J. Gerraty$b.$t: .PHONY .MAKE
90*2c3632d1SSimon J. Gerraty	(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$b ${@:E} -DWITHOUT_META_STATS)
911bbe5942SSimon J. Gerraty.endfor
923cbdda60SSimon J. Gerraty.endfor
93*2c3632d1SSimon J. Gerraty
94*2c3632d1SSimon J. Gerraty.if !defined(WITHOUT_META_STATS) && ${.MAKE.LEVEL} > 0
95*2c3632d1SSimon J. Gerraty.END: _reldir_finish
96*2c3632d1SSimon J. Gerraty.ERROR: _reldir_failed
97*2c3632d1SSimon J. Gerraty.endif
98*2c3632d1SSimon J. Gerraty
993cbdda60SSimon J. Gerraty.endif
100