xref: /aosp_15_r20/external/ltp/include/mk/lib.mk (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1*49cdfc7eSAndroid Build Coastguard Worker#
2*49cdfc7eSAndroid Build Coastguard Worker#    library include Makefile.
3*49cdfc7eSAndroid Build Coastguard Worker#
4*49cdfc7eSAndroid Build Coastguard Worker#    Copyright (c) Linux Test Project, 2009-2020
5*49cdfc7eSAndroid Build Coastguard Worker#    Copyright (c) Cisco Systems Inc., 2009
6*49cdfc7eSAndroid Build Coastguard Worker#
7*49cdfc7eSAndroid Build Coastguard Worker#    This program is free software; you can redistribute it and/or modify
8*49cdfc7eSAndroid Build Coastguard Worker#    it under the terms of the GNU General Public License as published by
9*49cdfc7eSAndroid Build Coastguard Worker#    the Free Software Foundation; either version 2 of the License, or
10*49cdfc7eSAndroid Build Coastguard Worker#    (at your option) any later version.
11*49cdfc7eSAndroid Build Coastguard Worker#
12*49cdfc7eSAndroid Build Coastguard Worker#    This program is distributed in the hope that it will be useful,
13*49cdfc7eSAndroid Build Coastguard Worker#    but WITHOUT ANY WARRANTY; without even the implied warranty of
14*49cdfc7eSAndroid Build Coastguard Worker#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*49cdfc7eSAndroid Build Coastguard Worker#    GNU General Public License for more details.
16*49cdfc7eSAndroid Build Coastguard Worker#
17*49cdfc7eSAndroid Build Coastguard Worker#    You should have received a copy of the GNU General Public License along
18*49cdfc7eSAndroid Build Coastguard Worker#    with this program; if not, write to the Free Software Foundation, Inc.,
19*49cdfc7eSAndroid Build Coastguard Worker#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20*49cdfc7eSAndroid Build Coastguard Worker#
21*49cdfc7eSAndroid Build Coastguard Worker# Ngie Cooper, July 2009
22*49cdfc7eSAndroid Build Coastguard Worker#
23*49cdfc7eSAndroid Build Coastguard Worker# Copyright (C) Cyril Hrubis <[email protected]> 2012
24*49cdfc7eSAndroid Build Coastguard Worker#
25*49cdfc7eSAndroid Build Coastguard Worker
26*49cdfc7eSAndroid Build Coastguard Worker# Makefile to include for libraries.
27*49cdfc7eSAndroid Build Coastguard Worker
28*49cdfc7eSAndroid Build Coastguard Workerinclude $(top_srcdir)/include/mk/env_pre.mk
29*49cdfc7eSAndroid Build Coastguard Workerinclude $(top_srcdir)/include/mk/sparse.mk
30*49cdfc7eSAndroid Build Coastguard Worker
31*49cdfc7eSAndroid Build Coastguard WorkerINSTALL_DIR	:= $(libdir)
32*49cdfc7eSAndroid Build Coastguard Worker
33*49cdfc7eSAndroid Build Coastguard Worker# An extension of generic_leaf_target, strictly for libraries.
34*49cdfc7eSAndroid Build Coastguard Worker.PHONY: install_headers
35*49cdfc7eSAndroid Build Coastguard Worker
36*49cdfc7eSAndroid Build Coastguard Workerifndef LIB
37*49cdfc7eSAndroid Build Coastguard Workerifndef INTERNAL_LIB
38*49cdfc7eSAndroid Build Coastguard Worker$(error You must define LIB or INTERNAL_LIB when including this Makefile)
39*49cdfc7eSAndroid Build Coastguard Workerendif
40*49cdfc7eSAndroid Build Coastguard Workerendif
41*49cdfc7eSAndroid Build Coastguard Worker
42*49cdfc7eSAndroid Build Coastguard Workerinstall_headers: $(addprefix $(DESTDIR)/$(includedir)/,$(notdir $(HEADER_FILES)))
43*49cdfc7eSAndroid Build Coastguard Worker
44*49cdfc7eSAndroid Build Coastguard WorkerINSTALL_MODE	?= 00664
45*49cdfc7eSAndroid Build Coastguard Worker
46*49cdfc7eSAndroid Build Coastguard Worker# Hide the LIB target for internal libs on install
47*49cdfc7eSAndroid Build Coastguard Workerifneq ($(MAKECMDGOALS),install)
48*49cdfc7eSAndroid Build Coastguard WorkerLIB ?= $(INTERNAL_LIB)
49*49cdfc7eSAndroid Build Coastguard Workerendif
50*49cdfc7eSAndroid Build Coastguard Worker
51*49cdfc7eSAndroid Build Coastguard WorkerMAKE_TARGETS	+= $(LIB)
52*49cdfc7eSAndroid Build Coastguard Worker
53*49cdfc7eSAndroid Build Coastguard WorkerLIBSRCS		?= $(wildcard $(abs_srcdir)/*.c)
54*49cdfc7eSAndroid Build Coastguard WorkerLIBSRCS		:= $(sort $(LIBSRCS))
55*49cdfc7eSAndroid Build Coastguard WorkerLIBSRCS		:= $(abspath $(LIBSRCS))
56*49cdfc7eSAndroid Build Coastguard WorkerLIBSRCS		:= $(subst $(abs_srcdir)/,,$(wildcard $(LIBSRCS)))
57*49cdfc7eSAndroid Build Coastguard WorkerLIBSRCS		:= $(filter-out $(FILTER_OUT_LIBSRCS),$(LIBSRCS))
58*49cdfc7eSAndroid Build Coastguard Worker
59*49cdfc7eSAndroid Build Coastguard WorkerLIBOBJS		:= $(LIBSRCS:.c=.o)
60*49cdfc7eSAndroid Build Coastguard Worker
61*49cdfc7eSAndroid Build Coastguard WorkerCHECK_TARGETS	:= $(addprefix check-,$(notdir $(LIBSRCS:.c=)))
62*49cdfc7eSAndroid Build Coastguard Worker
63*49cdfc7eSAndroid Build Coastguard Worker$(LIB): $(notdir $(LIBOBJS))
64*49cdfc7eSAndroid Build Coastguard Worker	@if [ -z "$(strip $^)" ] ; then \
65*49cdfc7eSAndroid Build Coastguard Worker		echo "Cowardly refusing to create empty archive"; \
66*49cdfc7eSAndroid Build Coastguard Worker		exit 1; \
67*49cdfc7eSAndroid Build Coastguard Worker	fi
68*49cdfc7eSAndroid Build Coastguard Workerifdef VERBOSE
69*49cdfc7eSAndroid Build Coastguard Worker	$(if $(AR),$(AR),ar) -rc "$@" $^
70*49cdfc7eSAndroid Build Coastguard Worker	$(if $(RANLIB),$(RANLIB),ranlib) "$@"
71*49cdfc7eSAndroid Build Coastguard Workerelse
72*49cdfc7eSAndroid Build Coastguard Worker	@echo "AR $@"
73*49cdfc7eSAndroid Build Coastguard Worker	@$(if $(AR),$(AR),ar) -rc "$@" $^
74*49cdfc7eSAndroid Build Coastguard Worker	@echo "RANLIB $@"
75*49cdfc7eSAndroid Build Coastguard Worker	@$(if $(RANLIB),$(RANLIB),ranlib) "$@"
76*49cdfc7eSAndroid Build Coastguard Workerendif
77*49cdfc7eSAndroid Build Coastguard Worker
78*49cdfc7eSAndroid Build Coastguard Workerinclude $(top_srcdir)/include/mk/generic_leaf_target.mk
79