blob: 768ca46066b630e80deb5c493b236aee4833ed32 [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 +000024top_srcdir ?= $(CURDIR)
25
26include $(top_srcdir)/include/mk/env_pre.mk
27include $(top_srcdir)/include/mk/automake.mk
Garrett Cooperbb557c62010-12-17 03:07:01 -080028include $(top_srcdir)/include/mk/gitignore.mk
yaberauneyaef772532009-10-09 17:55:43 +000029
yaberauneyaef772532009-10-09 17:55:43 +000030.SUFFIXES:
31.SUFFIXES: .am .default .h .in .m4 .mk
subrata_modak8dfa1b32008-07-26 04:15:36 +000032
yaberauneyaef772532009-10-09 17:55:43 +000033vpath %.am $(top_srcdir)/m4
34vpath %.default $(top_srcdir)/include
35vpath %.h $(top_srcdir)/include:$(top_builddir)/include
36vpath %.in $(top_srcdir)/include
37vpath %.m4 $(top_srcdir)/m4
38vpath %.mk $(top_srcdir)/mk:$(top_srcdir)/mk/include
vapier1400d642006-02-24 02:16:55 +000039
yaberauneyaef772532009-10-09 17:55:43 +000040# User wants uclinux binaries?
41UCLINUX ?= 0
yaberauneyaef772532009-10-09 17:55:43 +000042export UCLINUX
alaffincc2e5552000-07-27 17:13:18 +000043
yaberauneyaef772532009-10-09 17:55:43 +000044# CLEAN_TARGETS: Targets which exist solely in clean.
45# COMMON_TARGETS: Targets which exist in all, clean, and install.
46# INSTALL_TARGETS: Targets which exist in clean and install (contains
47# COMMON_TARGETS).
48# BOOTSTRAP_TARGETS: Directories required to bootstrap out-of-build-tree
49# support.
50
51# We're not using uclinux based targets (default).
52ifneq ($(UCLINUX),1)
53COMMON_TARGETS := pan utils
54INSTALL_TARGETS := doc
55endif
56
yaberauneyad26b6ec2009-11-30 08:36:42 +000057define target_to_dir_dep_mapping
yaberauneyad54919e2009-12-11 09:42:01 +000058ifeq ($$(filter %-clean,$(1)),) # not *-clean
59$(1): | $$(abs_top_builddir)/$$(basename $$(subst -,.,$(1)))
60else # clean
61$(1):: | $$(abs_top_builddir)/$$(basename $$(subst -,.,$(1)))
62endif
yaberauneyad26b6ec2009-11-30 08:36:42 +000063endef
64
yaberauneyaef772532009-10-09 17:55:43 +000065COMMON_TARGETS += testcases tools
yaberauneya2100fd72010-01-28 16:00:55 +000066# Don't want to nuke the original files if we're installing in-build-tree.
yaberauneyad1892d72010-01-29 09:41:22 +000067ifneq ($(BUILD_TREE_STATE),$(BUILD_TREE_SRCDIR_INSTALL))
Garrett Cooper9d5dac62010-11-16 22:07:21 -080068INSTALL_TARGETS += runtest scenario_groups testscripts
69CLEAN_TARGETS += include runtest scenario_groups testscripts
yaberauneya2100fd72010-01-28 16:00:55 +000070endif
71INSTALL_TARGETS += $(COMMON_TARGETS)
Cyril Hrubis4f5c1f02019-03-07 15:30:09 +010072CLEAN_TARGETS += $(COMMON_TARGETS) lib libs
yaberauneyaf6380f42010-01-14 08:42:06 +000073BOOTSTRAP_TARGETS := $(sort $(COMMON_TARGETS) $(CLEAN_TARGETS) $(INSTALL_TARGETS))
yaberauneyaef772532009-10-09 17:55:43 +000074
75CLEAN_TARGETS := $(addsuffix -clean,$(CLEAN_TARGETS))
76INSTALL_TARGETS := $(addsuffix -install,$(INSTALL_TARGETS))
77MAKE_TARGETS := $(addsuffix -all,$(filter-out lib,$(COMMON_TARGETS)))
78
79# There's no reason why we should run `all' twice. Otherwise we're just wasting
80# 3+ mins of useful CPU cycles on a modern machine, and even more time on an
81# overtaxed one, or one where -j => 1 was specified.
Garrett Coopere03cee02010-02-18 22:23:31 -080082all: $(addsuffix -all,$(COMMON_TARGETS)) Version
yaberauneyaef772532009-10-09 17:55:43 +000083
Cyril Hrubis4f5c1f02019-03-07 15:30:09 +010084$(MAKE_TARGETS): lib-all libs-all
yaberauneyaef772532009-10-09 17:55:43 +000085
86.PHONY: include-all include-install
yaberauneyad26b6ec2009-11-30 08:36:42 +000087include-install: $(top_builddir)/include/config.h include/mk/config.mk include-all
yaberauneyaef772532009-10-09 17:55:43 +000088
yaberauneyaf6720f22009-10-10 22:13:44 +000089INSTALL_DIR := $(DESTDIR)/$(prefix)
90
yaberauneyaaee37bb2010-02-03 07:44:18 +000091# DO NOT REMOVE THIS CALL (see clean_install_dir call below...)!!!!
92ifdef MAKE_3_80_COMPAT
93INSTALL_DIR := $(call MAKE_3_80_abspath,$(INSTALL_DIR))
94else
95INSTALL_DIR := $(abspath $(INSTALL_DIR))
96endif
97
yaberauneyaf6720f22009-10-10 22:13:44 +000098# build tree bootstrap targets and $(INSTALL_DIR) target.
yaberauneya1c437362009-12-11 15:38:21 +000099$(sort $(addprefix $(abs_top_builddir)/,$(BOOTSTRAP_TARGETS)) $(INSTALL_DIR) $(DESTDIR)/$(bindir)):
yaberauneyaef772532009-10-09 17:55:43 +0000100 mkdir -m 00755 -p "$@"
101
102## Pattern based subtarget rules.
yaberauneyaef772532009-10-09 17:55:43 +0000103lib-install: lib-all
104
Cyril Hrubis17a5b0f2019-03-08 15:51:42 +0100105libs-all: $(abs_top_builddir)/libs
106
Cyril Hrubis4f5c1f02019-03-07 15:30:09 +0100107$(MAKE_TARGETS) include-all lib-all libs-all:
yaberauneyad26b6ec2009-11-30 08:36:42 +0000108 $(MAKE) -C "$(subst -all,,$@)" \
109 -f "$(abs_top_srcdir)/$(subst -all,,$@)/Makefile" all
yaberauneyaef772532009-10-09 17:55:43 +0000110
111# Let's not conflict with ac-clean, maintainer-clean, etc, so.
yaberauneyad26b6ec2009-11-30 08:36:42 +0000112$(filter-out include-clean,$(CLEAN_TARGETS))::
113 -$(MAKE) -C "$(subst -clean,,$@)" \
Chris Dearman37550cf2012-10-17 19:54:01 -0700114 -f "$(abs_top_srcdir)/$(subst -clean,,$@)/Makefile" clean
yaberauneyaef772532009-10-09 17:55:43 +0000115
116# Just like everything depends on include-all / -install, we need to get rid
117# of include last to ensure that things won't be monkey screwed up. Only do
118# this if we're invoking clean or a subclean directly though.
119ifneq ($(filter clean,$(MAKECMDGOALS)),)
120INCLUDE_CLEAN_RDEP_SUBJECT := $(CLEAN_TARGETS)
121else
122ifneq ($(filter %clean,$(MAKECMDGOALS)),)
123INCLUDE_CLEAN_RDEP_SUBJECT := $(MAKECMDGOALS)
124endif
125endif
126
127# Remove potential for circular dependencies.
yaberauneyaf6380f42010-01-14 08:42:06 +0000128INCLUDE_CLEAN_RDEPS := $(filter-out include-clean,$(INCLUDE_CLEAN_RDEP_SUBJECT))
yaberauneyaef772532009-10-09 17:55:43 +0000129
yaberauneyad26b6ec2009-11-30 08:36:42 +0000130include-clean:: $(INCLUDE_CLEAN_RDEPS) | $(abs_top_builddir)/include
yaberauneyaef772532009-10-09 17:55:43 +0000131 -$(MAKE) -C include -f "$(abs_top_srcdir)/include/Makefile" clean
132
133# include-install is separate to avoid creating a circular dependency below in
134# the install target.
yaberauneyad26b6ec2009-11-30 08:36:42 +0000135$(INSTALL_TARGETS) include-install lib-install:
136 $(MAKE) -C "$(subst -install,,$@)" \
yaberauneya84252812009-12-08 10:13:51 +0000137 -f "$(abs_top_srcdir)/$(subst -install,,$@)/Makefile" install
yaberauneyaef772532009-10-09 17:55:43 +0000138
yaberauneyaef772532009-10-09 17:55:43 +0000139# Just in case configure hasn't been run yet, let's not overambitiously remove
140# the $(INSTALL_DIR).
yaberauneyaf6380f42010-01-14 08:42:06 +0000141.PHONY: clean_install_dir
142clean_install_dir::
143 $(RM) -Rf "$(INSTALL_DIR)"
144
yaberauneya7279a862010-02-02 08:25:09 +0000145# Clean the directory if the build-tree is properly configured and not set to
146# the srcdir.
yaberauneyaaee37bb2010-02-03 07:44:18 +0000147ifeq ($(filter $(BUILD_TREE_STATE),$(BUILD_TREE_SRCDIR_INSTALL) $(BUILD_TREE_UNCONFIGURED)),)
148# Make sure that we don't whack `/'!!!!!
149ifneq ($(INSTALL_DIR),/)
150CLEAN_TARGETS += clean_install_dir
151endif
152endif
yaberauneyaef772532009-10-09 17:55:43 +0000153
yaberauneyaf6380f42010-01-14 08:42:06 +0000154clean:: $(CLEAN_TARGETS)
155 $(RM) -f Version
156
157$(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 +0000158
yaberauneyad54919e2009-12-11 09:42:01 +0000159BINDIR_INSTALL_SCRIPTS := execltp
Petr Vorele34ecfc2018-10-15 22:06:10 +0200160SRCDIR_INSTALL_SCRIPTS := IDcheck.sh runltp ver_linux
yaberauneyaef772532009-10-09 17:55:43 +0000161SRCDIR_INSTALL_READONLY := Version
162SRCDIR_INSTALL_TARGETS := $(SRCDIR_INSTALL_SCRIPTS) $(SRCDIR_INSTALL_READONLY)
163
Chris Dearman37550cf2012-10-17 19:54:01 -0700164#
Cyril Hrubis3409b0b2012-01-06 13:54:16 +0100165# If we are in git repository, use git describe to indentify current version,
166# otherwise if downloaded as tarball use VERSION file.
167#
168.PHONY: Version
169Version:
Garrett Cooperdbd8b812012-05-19 23:26:29 -0700170 if git describe >/dev/null 2>&1; then \
Cyril Hrubis3409b0b2012-01-06 13:54:16 +0100171 git describe > "$@"; \
172 else \
Gilles Chanteperdrixa8846212014-04-01 21:10:42 +0200173 cp $(top_srcdir)/VERSION "$@"; \
Cyril Hrubis3409b0b2012-01-06 13:54:16 +0100174 fi
yaberauneyaef772532009-10-09 17:55:43 +0000175
176$(INSTALL_DIR)/Version: Version
177 install -m 00644 "$(top_builddir)/$(@F)" "$@"
178
yaberauneyad54919e2009-12-11 09:42:01 +0000179$(addprefix $(DESTDIR)/$(bindir)/,$(BINDIR_INSTALL_SCRIPTS)): %:
180 install -m 00755 "$(top_builddir)/$(@F)" "$@"
181
yaberauneyaef772532009-10-09 17:55:43 +0000182$(addprefix $(INSTALL_DIR)/,$(SRCDIR_INSTALL_SCRIPTS)): %:
183 install -m 00755 "$(top_srcdir)/$(@F)" "$@"
184
yaberauneyad1892d72010-01-29 09:41:22 +0000185ifneq ($(BUILD_TREE_STATE),$(BUILD_TREE_SRCDIR_INSTALL))
yaberauneya20f26ff2010-01-28 16:16:33 +0000186INSTALL_TARGETS += $(addprefix $(INSTALL_DIR)/,$(SRCDIR_INSTALL_TARGETS))
187endif
188INSTALL_TARGETS += $(addprefix $(DESTDIR)/$(bindir)/,$(BINDIR_INSTALL_SCRIPTS))
yaberauneyaef772532009-10-09 17:55:43 +0000189
yaberauneyad54919e2009-12-11 09:42:01 +0000190$(INSTALL_TARGETS): $(INSTALL_DIR) $(DESTDIR)/$(bindir)
yaberauneyaef772532009-10-09 17:55:43 +0000191
192## Install
193install: $(INSTALL_TARGETS)
robbiewd34d5812005-07-11 22:28:09 +0000194
yaberauneyaef772532009-10-09 17:55:43 +0000195## Help
subrata_modakaba85b92008-12-11 10:30:33 +0000196.PHONY: help
197help:
yaberauneyab68050b2009-10-25 06:07:38 +0000198 @echo "Please read the Configuration section in $(top_srcdir)/INSTALL"
199 @exit 1
yaberauneyaef772532009-10-09 17:55:43 +0000200
201## Menuconfig
202menuconfig:
203 @$(SHELL) "$(top_srcdir)/ltpmenu"
204
yaberauneyaef772532009-10-09 17:55:43 +0000205## End misc targets.