blob: b0368a472c583d7b1a16dfbc08e7481e193475cf [file] [log] [blame]
yaberauneyaef772532009-10-09 17:55:43 +00001#
2# Top-level Makefile for LTP. See INSTALL for more info.
3#
Garrett Cooperbb557c62010-12-17 03:07:01 -08004# Copyright (C) 2009-2010, Cisco Systems Inc.
5# Copyright (C) 2010-2011, Linux Test Project.
yaberauneyaef772532009-10-09 17:55:43 +00006#
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#
Ngie Cooper8967f962017-02-13 22:06:24 -080021# Ngie Cooper, July 2009
yaberauneyaef772532009-10-09 17:55:43 +000022#
alaffincc2e5552000-07-27 17:13:18 +000023
yaberauneyaef772532009-10-09 17:55:43 +000024# Force IDcheck.sh to fix any issues found with $(DESTDIR)/etc/group and
25# $(DESTDIR)/etc/passwd automatically when after running the top-level
26# install target.
27CREATE_ENTRIES ?= 0
28
29top_srcdir ?= $(CURDIR)
30
31include $(top_srcdir)/include/mk/env_pre.mk
32include $(top_srcdir)/include/mk/automake.mk
Garrett Cooperbb557c62010-12-17 03:07:01 -080033include $(top_srcdir)/include/mk/gitignore.mk
yaberauneyaef772532009-10-09 17:55:43 +000034
yaberauneyaef772532009-10-09 17:55:43 +000035.SUFFIXES:
36.SUFFIXES: .am .default .h .in .m4 .mk
subrata_modak8dfa1b32008-07-26 04:15:36 +000037
yaberauneyaef772532009-10-09 17:55:43 +000038vpath %.am $(top_srcdir)/m4
39vpath %.default $(top_srcdir)/include
40vpath %.h $(top_srcdir)/include:$(top_builddir)/include
41vpath %.in $(top_srcdir)/include
42vpath %.m4 $(top_srcdir)/m4
43vpath %.mk $(top_srcdir)/mk:$(top_srcdir)/mk/include
vapier1400d642006-02-24 02:16:55 +000044
yaberauneyaef772532009-10-09 17:55:43 +000045# Skip running IDcheck.sh at the end of install?
46SKIP_IDCHECK ?= 0
yaberauneya3ab801e2009-07-10 23:01:27 +000047
yaberauneyaef772532009-10-09 17:55:43 +000048# User wants uclinux binaries?
49UCLINUX ?= 0
yaberauneyaef772532009-10-09 17:55:43 +000050export UCLINUX
alaffincc2e5552000-07-27 17:13:18 +000051
yaberauneyaef772532009-10-09 17:55:43 +000052# CLEAN_TARGETS: Targets which exist solely in clean.
53# COMMON_TARGETS: Targets which exist in all, clean, and install.
54# INSTALL_TARGETS: Targets which exist in clean and install (contains
55# COMMON_TARGETS).
56# BOOTSTRAP_TARGETS: Directories required to bootstrap out-of-build-tree
57# support.
58
59# We're not using uclinux based targets (default).
60ifneq ($(UCLINUX),1)
61COMMON_TARGETS := pan utils
62INSTALL_TARGETS := doc
63endif
64
yaberauneyad26b6ec2009-11-30 08:36:42 +000065define target_to_dir_dep_mapping
yaberauneyad54919e2009-12-11 09:42:01 +000066ifeq ($$(filter %-clean,$(1)),) # not *-clean
67$(1): | $$(abs_top_builddir)/$$(basename $$(subst -,.,$(1)))
68else # clean
69$(1):: | $$(abs_top_builddir)/$$(basename $$(subst -,.,$(1)))
70endif
yaberauneyad26b6ec2009-11-30 08:36:42 +000071endef
72
yaberauneyaef772532009-10-09 17:55:43 +000073COMMON_TARGETS += testcases tools
yaberauneya2100fd72010-01-28 16:00:55 +000074# Don't want to nuke the original files if we're installing in-build-tree.
yaberauneyad1892d72010-01-29 09:41:22 +000075ifneq ($(BUILD_TREE_STATE),$(BUILD_TREE_SRCDIR_INSTALL))
Garrett Cooper9d5dac62010-11-16 22:07:21 -080076INSTALL_TARGETS += runtest scenario_groups testscripts
77CLEAN_TARGETS += include runtest scenario_groups testscripts
yaberauneya2100fd72010-01-28 16:00:55 +000078endif
79INSTALL_TARGETS += $(COMMON_TARGETS)
80CLEAN_TARGETS += $(COMMON_TARGETS) lib
yaberauneyaf6380f42010-01-14 08:42:06 +000081BOOTSTRAP_TARGETS := $(sort $(COMMON_TARGETS) $(CLEAN_TARGETS) $(INSTALL_TARGETS))
yaberauneyaef772532009-10-09 17:55:43 +000082
83CLEAN_TARGETS := $(addsuffix -clean,$(CLEAN_TARGETS))
84INSTALL_TARGETS := $(addsuffix -install,$(INSTALL_TARGETS))
85MAKE_TARGETS := $(addsuffix -all,$(filter-out lib,$(COMMON_TARGETS)))
86
87# There's no reason why we should run `all' twice. Otherwise we're just wasting
88# 3+ mins of useful CPU cycles on a modern machine, and even more time on an
89# overtaxed one, or one where -j => 1 was specified.
Garrett Coopere03cee02010-02-18 22:23:31 -080090all: $(addsuffix -all,$(COMMON_TARGETS)) Version
yaberauneyaef772532009-10-09 17:55:43 +000091
yaberauneya56b65582010-01-18 05:24:29 +000092$(MAKE_TARGETS): lib-all
yaberauneyaef772532009-10-09 17:55:43 +000093
94.PHONY: include-all include-install
yaberauneyad26b6ec2009-11-30 08:36:42 +000095include-install: $(top_builddir)/include/config.h include/mk/config.mk include-all
yaberauneyaef772532009-10-09 17:55:43 +000096
yaberauneyaf6720f22009-10-10 22:13:44 +000097INSTALL_DIR := $(DESTDIR)/$(prefix)
98
yaberauneyaaee37bb2010-02-03 07:44:18 +000099# DO NOT REMOVE THIS CALL (see clean_install_dir call below...)!!!!
100ifdef MAKE_3_80_COMPAT
101INSTALL_DIR := $(call MAKE_3_80_abspath,$(INSTALL_DIR))
102else
103INSTALL_DIR := $(abspath $(INSTALL_DIR))
104endif
105
yaberauneyaf6720f22009-10-10 22:13:44 +0000106# build tree bootstrap targets and $(INSTALL_DIR) target.
yaberauneya1c437362009-12-11 15:38:21 +0000107$(sort $(addprefix $(abs_top_builddir)/,$(BOOTSTRAP_TARGETS)) $(INSTALL_DIR) $(DESTDIR)/$(bindir)):
yaberauneyaef772532009-10-09 17:55:43 +0000108 mkdir -m 00755 -p "$@"
109
110## Pattern based subtarget rules.
yaberauneyaef772532009-10-09 17:55:43 +0000111lib-install: lib-all
112
yaberauneyad26b6ec2009-11-30 08:36:42 +0000113$(MAKE_TARGETS) include-all lib-all:
114 $(MAKE) -C "$(subst -all,,$@)" \
115 -f "$(abs_top_srcdir)/$(subst -all,,$@)/Makefile" all
yaberauneyaef772532009-10-09 17:55:43 +0000116
117# Let's not conflict with ac-clean, maintainer-clean, etc, so.
yaberauneyad26b6ec2009-11-30 08:36:42 +0000118$(filter-out include-clean,$(CLEAN_TARGETS))::
119 -$(MAKE) -C "$(subst -clean,,$@)" \
Chris Dearman37550cf2012-10-17 19:54:01 -0700120 -f "$(abs_top_srcdir)/$(subst -clean,,$@)/Makefile" clean
yaberauneyaef772532009-10-09 17:55:43 +0000121
122# Just like everything depends on include-all / -install, we need to get rid
123# of include last to ensure that things won't be monkey screwed up. Only do
124# this if we're invoking clean or a subclean directly though.
125ifneq ($(filter clean,$(MAKECMDGOALS)),)
126INCLUDE_CLEAN_RDEP_SUBJECT := $(CLEAN_TARGETS)
127else
128ifneq ($(filter %clean,$(MAKECMDGOALS)),)
129INCLUDE_CLEAN_RDEP_SUBJECT := $(MAKECMDGOALS)
130endif
131endif
132
133# Remove potential for circular dependencies.
yaberauneyaf6380f42010-01-14 08:42:06 +0000134INCLUDE_CLEAN_RDEPS := $(filter-out include-clean,$(INCLUDE_CLEAN_RDEP_SUBJECT))
yaberauneyaef772532009-10-09 17:55:43 +0000135
yaberauneyad26b6ec2009-11-30 08:36:42 +0000136include-clean:: $(INCLUDE_CLEAN_RDEPS) | $(abs_top_builddir)/include
yaberauneyaef772532009-10-09 17:55:43 +0000137 -$(MAKE) -C include -f "$(abs_top_srcdir)/include/Makefile" clean
138
139# include-install is separate to avoid creating a circular dependency below in
140# the install target.
yaberauneyad26b6ec2009-11-30 08:36:42 +0000141$(INSTALL_TARGETS) include-install lib-install:
142 $(MAKE) -C "$(subst -install,,$@)" \
yaberauneya84252812009-12-08 10:13:51 +0000143 -f "$(abs_top_srcdir)/$(subst -install,,$@)/Makefile" install
yaberauneyaef772532009-10-09 17:55:43 +0000144
yaberauneyaef772532009-10-09 17:55:43 +0000145# Just in case configure hasn't been run yet, let's not overambitiously remove
146# the $(INSTALL_DIR).
yaberauneyaf6380f42010-01-14 08:42:06 +0000147.PHONY: clean_install_dir
148clean_install_dir::
149 $(RM) -Rf "$(INSTALL_DIR)"
150
yaberauneya7279a862010-02-02 08:25:09 +0000151# Clean the directory if the build-tree is properly configured and not set to
152# the srcdir.
yaberauneyaaee37bb2010-02-03 07:44:18 +0000153ifeq ($(filter $(BUILD_TREE_STATE),$(BUILD_TREE_SRCDIR_INSTALL) $(BUILD_TREE_UNCONFIGURED)),)
154# Make sure that we don't whack `/'!!!!!
155ifneq ($(INSTALL_DIR),/)
156CLEAN_TARGETS += clean_install_dir
157endif
158endif
yaberauneyaef772532009-10-09 17:55:43 +0000159
yaberauneyaf6380f42010-01-14 08:42:06 +0000160clean:: $(CLEAN_TARGETS)
161 $(RM) -f Version
162
163$(foreach tgt,$(MAKE_TARGETS) include-all lib-all $(filter-out clean_install_dir,$(CLEAN_TARGETS)) $(INSTALL_TARGETS) include-install lib-install,$(eval $(call target_to_dir_dep_mapping,$(tgt))))
yaberauneyad26b6ec2009-11-30 08:36:42 +0000164
yaberauneyad54919e2009-12-11 09:42:01 +0000165BINDIR_INSTALL_SCRIPTS := execltp
Xiao Yang3b3a8422016-11-14 17:55:09 +0800166SRCDIR_INSTALL_SCRIPTS := IDcheck.sh runltp runltplite.sh ver_linux
yaberauneyaef772532009-10-09 17:55:43 +0000167SRCDIR_INSTALL_READONLY := Version
168SRCDIR_INSTALL_TARGETS := $(SRCDIR_INSTALL_SCRIPTS) $(SRCDIR_INSTALL_READONLY)
169
Chris Dearman37550cf2012-10-17 19:54:01 -0700170#
Cyril Hrubis3409b0b2012-01-06 13:54:16 +0100171# If we are in git repository, use git describe to indentify current version,
172# otherwise if downloaded as tarball use VERSION file.
173#
174.PHONY: Version
175Version:
Garrett Cooperdbd8b812012-05-19 23:26:29 -0700176 if git describe >/dev/null 2>&1; then \
Cyril Hrubis3409b0b2012-01-06 13:54:16 +0100177 git describe > "$@"; \
178 else \
Gilles Chanteperdrixa8846212014-04-01 21:10:42 +0200179 cp $(top_srcdir)/VERSION "$@"; \
Cyril Hrubis3409b0b2012-01-06 13:54:16 +0100180 fi
yaberauneyaef772532009-10-09 17:55:43 +0000181
182$(INSTALL_DIR)/Version: Version
183 install -m 00644 "$(top_builddir)/$(@F)" "$@"
184
yaberauneyad54919e2009-12-11 09:42:01 +0000185$(addprefix $(DESTDIR)/$(bindir)/,$(BINDIR_INSTALL_SCRIPTS)): %:
186 install -m 00755 "$(top_builddir)/$(@F)" "$@"
187
yaberauneyaef772532009-10-09 17:55:43 +0000188$(addprefix $(INSTALL_DIR)/,$(SRCDIR_INSTALL_SCRIPTS)): %:
189 install -m 00755 "$(top_srcdir)/$(@F)" "$@"
190
yaberauneyad1892d72010-01-29 09:41:22 +0000191ifneq ($(BUILD_TREE_STATE),$(BUILD_TREE_SRCDIR_INSTALL))
yaberauneya20f26ff2010-01-28 16:16:33 +0000192INSTALL_TARGETS += $(addprefix $(INSTALL_DIR)/,$(SRCDIR_INSTALL_TARGETS))
193endif
194INSTALL_TARGETS += $(addprefix $(DESTDIR)/$(bindir)/,$(BINDIR_INSTALL_SCRIPTS))
yaberauneyaef772532009-10-09 17:55:43 +0000195
yaberauneyad54919e2009-12-11 09:42:01 +0000196$(INSTALL_TARGETS): $(INSTALL_DIR) $(DESTDIR)/$(bindir)
yaberauneyaef772532009-10-09 17:55:43 +0000197
198## Install
199install: $(INSTALL_TARGETS)
200ifeq ($(SKIP_IDCHECK),0)
yaberauneya45c32682009-12-06 19:50:56 +0000201 -@CREATE_ENTRIES=$(CREATE_ENTRIES) \
yaberauneyaef772532009-10-09 17:55:43 +0000202 DESTDIR="$(DESTDIR)" \
203 "$(top_srcdir)/IDcheck.sh"
204else
robbiewd34d5812005-07-11 22:28:09 +0000205 @echo "*******************************************************"
yaberauneyaef772532009-10-09 17:55:43 +0000206 @echo "** Will not run IDcheck.sh (SKIP_IDCHECK set to 1). **"
robbiewd34d5812005-07-11 22:28:09 +0000207 @echo "*******************************************************"
yaberauneya3ab801e2009-07-10 23:01:27 +0000208endif
robbiewd34d5812005-07-11 22:28:09 +0000209
yaberauneyaef772532009-10-09 17:55:43 +0000210## Misc targets.
robbiewd34d5812005-07-11 22:28:09 +0000211
yaberauneyaef772532009-10-09 17:55:43 +0000212## Help
subrata_modakaba85b92008-12-11 10:30:33 +0000213.PHONY: help
214help:
yaberauneyab68050b2009-10-25 06:07:38 +0000215 @echo "Please read the Configuration section in $(top_srcdir)/INSTALL"
216 @exit 1
yaberauneyaef772532009-10-09 17:55:43 +0000217
218## Menuconfig
219menuconfig:
220 @$(SHELL) "$(top_srcdir)/ltpmenu"
221
yaberauneyaef772532009-10-09 17:55:43 +0000222## End misc targets.