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