xref: /aosp_15_r20/external/ltp/include/mk/env_post.mk (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1#
2#    Environment post-setup Makefile.
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
24ENV_PRE_LOADED			?= $(error You must load env_pre.mk before including this file)
25
26include $(top_srcdir)/include/mk/functions.mk
27
28ifndef ENV_POST_LOADED
29ENV_POST_LOADED = 1
30
31# Default source search path. Modify as necessary, but I would call that
32# poor software design if you need more than one search directory, and
33# would suggest creating a general purpose static library to that end.
34vpath %.c $(abs_srcdir)
35vpath %.S $(abs_srcdir)
36
37# For config.h, et all.
38CPPFLAGS			+= -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/include/old/
39
40LDFLAGS				+= -L$(top_builddir)/lib
41
42ifeq ($(ANDROID),1)
43LDFLAGS				+= -L$(top_builddir)/lib/android_libpthread
44LDFLAGS				+= -L$(top_builddir)/lib/android_librt
45endif
46
47MAKE_TARGETS			?= $(notdir $(patsubst %.c,%,$(sort $(wildcard $(abs_srcdir)/*.c))))
48MAKE_TARGETS			:= $(filter-out $(FILTER_OUT_MAKE_TARGETS),$(MAKE_TARGETS))
49
50# with only *.dwo, .[0-9]+.dwo can not be cleaned
51CLEAN_TARGETS			+= $(MAKE_TARGETS) $(HOST_MAKE_TARGETS) *.o *.pyc .cache.mk *.dwo .*.dwo
52
53# Majority of the files end up in testcases/bin...
54INSTALL_DIR			?= testcases/bin
55
56ifneq ($(filter-out install,$(MAKECMDGOALS)),$(MAKECMDGOALS))
57
58ifeq ($(strip $(INSTALL_DIR)),)
59INSTALL_DIR			:= $(error You must define INSTALL_DIR before including this file)
60endif
61
62ifneq ($(strip $(prefix)),)
63# Value specified by INSTALL_DIR isn't an absolute path, so let's tack on $(prefix).
64ifneq ($(patsubst /%,,$(INSTALL_DIR)),)
65INSTALL_DIR			:= $(prefix)/$(INSTALL_DIR)
66endif
67
68# Glob any possible expressions, but make sure to zap the $(abs_srcdir)
69# reference at the start of the filename instead of using $(notdir), so that
70# way we don't accidentally nuke the relative path from $(abs_srcdir) that
71# may have been set in the Makefile.
72INSTALL_TARGETS			:= $(wildcard $(addprefix $(abs_srcdir)/,$(INSTALL_TARGETS)))
73INSTALL_TARGETS			:= $(patsubst $(abs_srcdir)/%,%,$(INSTALL_TARGETS))
74
75# The large majority of the files that we install are going to be apps and
76# scripts, so let's chmod them like that.
77INSTALL_MODE			?= 00775
78
79$(abspath $(addprefix $(DESTDIR)/$(INSTALL_DIR)/,$(sort $(dir $(INSTALL_TARGETS) $(MAKE_TARGETS))))):
80	mkdir -p "$@"
81$(foreach install_target,$(INSTALL_TARGETS),$(eval $(call generate_install_rule,$(install_target),$(abs_srcdir),$(INSTALL_DIR))))
82$(foreach make_target,$(MAKE_TARGETS),$(eval $(call generate_install_rule,$(make_target),$(abs_builddir),$(INSTALL_DIR))))
83
84else  # else ! $(filter-out install,$(MAKECMDGOALS)),$(MAKECMDGOALS)
85$(error You must define $$(prefix) before executing install)
86endif # END $(filter-out install,$(MAKECMDGOALS)),$(MAKECMDGOALS)
87endif
88
89CHECK_TARGETS			?= $(addprefix check-,$(notdir $(patsubst %.c,%,$(sort $(wildcard $(abs_srcdir)/*.c)))))
90CHECK_TARGETS			:= $(filter-out $(addprefix check-, $(FILTER_OUT_MAKE_TARGETS)), $(CHECK_TARGETS))
91CHECK_HEADER_TARGETS		?= $(addprefix check-,$(notdir $(sort $(wildcard $(abs_srcdir)/*.h))))
92CHECK				?= $(abs_top_srcdir)/tools/sparse/sparse-ltp
93CHECK_NOFLAGS			?= $(abs_top_srcdir)/scripts/checkpatch.pl -f --no-tree --terse --no-summary --ignore CONST_STRUCT,VOLATILE,SPLIT_STRING
94SHELL_CHECK			?= $(abs_top_srcdir)/scripts/checkbashisms.pl --force --extra
95SHELL_CHECK_TARGETS		?= $(addprefix check-,$(notdir $(sort $(wildcard $(abs_srcdir)/*.sh))))
96
97ifeq ($(CHECK),$(abs_top_srcdir)/tools/sparse/sparse-ltp)
98CHECK_DEPS			+= $(CHECK)
99endif
100
101include $(top_srcdir)/include/mk/rules.mk
102
103endif
104