1# 2# A Makefile with a collection of reusable functions. 3# 4# Copyright (c) Linux Test Project, 2009-2020 5# Copyright (c) Cisco Systems Inc., 2009 6# 7# This program is free software; you can redistribute it and/or modify 8# it under the terms of the GNU General Public License as published by 9# the Free Software Foundation; either version 2 of the License, or 10# (at your option) any later version. 11# 12# This program is distributed in the hope that it will be useful, 13# but WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15# GNU General Public License for more details. 16# 17# You should have received a copy of the GNU General Public License along 18# with this program; if not, write to the Free Software Foundation, Inc., 19# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20# 21# Ngie Cooper, July 2009 22# 23 24# Generate an install rule which also creates the install directory if needed 25# to avoid unnecessary bourne shell based for-loops and install errors, as well 26# as adhoc install rules. 27# 28# 1 -> Target basename. 29# 2 -> Source directory. 30# 3 -> Destination directory. 31 32define generate_install_rule 33 34INSTALL_FILES += $$(abspath $$(DESTDIR)/$(3)/$(1)) 35 36$$(abspath $$(DESTDIR)/$(3)/$(1)): \ 37 $$(abspath $$(dir $$(DESTDIR)/$(3)/$(1))) 38 install -m $$(INSTALL_MODE) $(shell test -d "$(2)/$(1)" && echo "-d") $(PARAM) "$(2)/$(1)" $$@ 39 $(shell test -d "$(2)/$(1)" && echo "install -m "'$$(INSTALL_MODE) $(PARAM)' "$(2)/$(1)/*" -t '$$@') 40endef 41 42# 43# Set SUBDIRS to the subdirectories where Makefiles were found. 44# 45define get_make_dirs 46SUBDIRS ?= $$(subst $$(abs_srcdir)/,,$$(patsubst %/Makefile,%,$$(wildcard $$(abs_srcdir)/*/Makefile))) 47SUBDIRS := $$(filter-out $$(FILTER_OUT_DIRS),$$(SUBDIRS)) 48endef 49