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