yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 1 | # |
| 2 | # Top-level Makefile for LTP. See INSTALL for more info. |
| 3 | # |
Garrett Cooper | bb557c6 | 2010-12-17 03:07:01 -0800 | [diff] [blame] | 4 | # Copyright (C) 2009-2010, Cisco Systems Inc. |
| 5 | # Copyright (C) 2010-2011, Linux Test Project. |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 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 | # |
Ngie Cooper | 8967f96 | 2017-02-13 22:06:24 -0800 | [diff] [blame] | 21 | # Ngie Cooper, July 2009 |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 22 | # |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 23 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 24 | # 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. |
| 27 | CREATE_ENTRIES ?= 0 |
| 28 | |
| 29 | top_srcdir ?= $(CURDIR) |
| 30 | |
| 31 | include $(top_srcdir)/include/mk/env_pre.mk |
| 32 | include $(top_srcdir)/include/mk/automake.mk |
Garrett Cooper | bb557c6 | 2010-12-17 03:07:01 -0800 | [diff] [blame] | 33 | include $(top_srcdir)/include/mk/gitignore.mk |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 34 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 35 | .SUFFIXES: |
| 36 | .SUFFIXES: .am .default .h .in .m4 .mk |
subrata_modak | 8dfa1b3 | 2008-07-26 04:15:36 +0000 | [diff] [blame] | 37 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 38 | vpath %.am $(top_srcdir)/m4 |
| 39 | vpath %.default $(top_srcdir)/include |
| 40 | vpath %.h $(top_srcdir)/include:$(top_builddir)/include |
| 41 | vpath %.in $(top_srcdir)/include |
| 42 | vpath %.m4 $(top_srcdir)/m4 |
| 43 | vpath %.mk $(top_srcdir)/mk:$(top_srcdir)/mk/include |
vapier | 1400d64 | 2006-02-24 02:16:55 +0000 | [diff] [blame] | 44 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 45 | # Skip running IDcheck.sh at the end of install? |
| 46 | SKIP_IDCHECK ?= 0 |
yaberauneya | 3ab801e | 2009-07-10 23:01:27 +0000 | [diff] [blame] | 47 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 48 | # User wants uclinux binaries? |
| 49 | UCLINUX ?= 0 |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 50 | export UCLINUX |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 51 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 52 | # 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). |
| 60 | ifneq ($(UCLINUX),1) |
| 61 | COMMON_TARGETS := pan utils |
| 62 | INSTALL_TARGETS := doc |
| 63 | endif |
| 64 | |
yaberauneya | d26b6ec | 2009-11-30 08:36:42 +0000 | [diff] [blame] | 65 | define target_to_dir_dep_mapping |
yaberauneya | d54919e | 2009-12-11 09:42:01 +0000 | [diff] [blame] | 66 | ifeq ($$(filter %-clean,$(1)),) # not *-clean |
| 67 | $(1): | $$(abs_top_builddir)/$$(basename $$(subst -,.,$(1))) |
| 68 | else # clean |
| 69 | $(1):: | $$(abs_top_builddir)/$$(basename $$(subst -,.,$(1))) |
| 70 | endif |
yaberauneya | d26b6ec | 2009-11-30 08:36:42 +0000 | [diff] [blame] | 71 | endef |
| 72 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 73 | COMMON_TARGETS += testcases tools |
yaberauneya | 2100fd7 | 2010-01-28 16:00:55 +0000 | [diff] [blame] | 74 | # Don't want to nuke the original files if we're installing in-build-tree. |
yaberauneya | d1892d7 | 2010-01-29 09:41:22 +0000 | [diff] [blame] | 75 | ifneq ($(BUILD_TREE_STATE),$(BUILD_TREE_SRCDIR_INSTALL)) |
Garrett Cooper | 9d5dac6 | 2010-11-16 22:07:21 -0800 | [diff] [blame] | 76 | INSTALL_TARGETS += runtest scenario_groups testscripts |
| 77 | CLEAN_TARGETS += include runtest scenario_groups testscripts |
yaberauneya | 2100fd7 | 2010-01-28 16:00:55 +0000 | [diff] [blame] | 78 | endif |
| 79 | INSTALL_TARGETS += $(COMMON_TARGETS) |
| 80 | CLEAN_TARGETS += $(COMMON_TARGETS) lib |
yaberauneya | f6380f4 | 2010-01-14 08:42:06 +0000 | [diff] [blame] | 81 | BOOTSTRAP_TARGETS := $(sort $(COMMON_TARGETS) $(CLEAN_TARGETS) $(INSTALL_TARGETS)) |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 82 | |
| 83 | CLEAN_TARGETS := $(addsuffix -clean,$(CLEAN_TARGETS)) |
| 84 | INSTALL_TARGETS := $(addsuffix -install,$(INSTALL_TARGETS)) |
| 85 | MAKE_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 Cooper | e03cee0 | 2010-02-18 22:23:31 -0800 | [diff] [blame] | 90 | all: $(addsuffix -all,$(COMMON_TARGETS)) Version |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 91 | |
yaberauneya | 56b6558 | 2010-01-18 05:24:29 +0000 | [diff] [blame] | 92 | $(MAKE_TARGETS): lib-all |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 93 | |
| 94 | .PHONY: include-all include-install |
yaberauneya | d26b6ec | 2009-11-30 08:36:42 +0000 | [diff] [blame] | 95 | include-install: $(top_builddir)/include/config.h include/mk/config.mk include-all |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 96 | |
yaberauneya | f6720f2 | 2009-10-10 22:13:44 +0000 | [diff] [blame] | 97 | INSTALL_DIR := $(DESTDIR)/$(prefix) |
| 98 | |
yaberauneya | aee37bb | 2010-02-03 07:44:18 +0000 | [diff] [blame] | 99 | # DO NOT REMOVE THIS CALL (see clean_install_dir call below...)!!!! |
| 100 | ifdef MAKE_3_80_COMPAT |
| 101 | INSTALL_DIR := $(call MAKE_3_80_abspath,$(INSTALL_DIR)) |
| 102 | else |
| 103 | INSTALL_DIR := $(abspath $(INSTALL_DIR)) |
| 104 | endif |
| 105 | |
yaberauneya | f6720f2 | 2009-10-10 22:13:44 +0000 | [diff] [blame] | 106 | # build tree bootstrap targets and $(INSTALL_DIR) target. |
yaberauneya | 1c43736 | 2009-12-11 15:38:21 +0000 | [diff] [blame] | 107 | $(sort $(addprefix $(abs_top_builddir)/,$(BOOTSTRAP_TARGETS)) $(INSTALL_DIR) $(DESTDIR)/$(bindir)): |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 108 | mkdir -m 00755 -p "$@" |
| 109 | |
| 110 | ## Pattern based subtarget rules. |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 111 | lib-install: lib-all |
| 112 | |
yaberauneya | d26b6ec | 2009-11-30 08:36:42 +0000 | [diff] [blame] | 113 | $(MAKE_TARGETS) include-all lib-all: |
| 114 | $(MAKE) -C "$(subst -all,,$@)" \ |
| 115 | -f "$(abs_top_srcdir)/$(subst -all,,$@)/Makefile" all |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 116 | |
| 117 | # Let's not conflict with ac-clean, maintainer-clean, etc, so. |
yaberauneya | d26b6ec | 2009-11-30 08:36:42 +0000 | [diff] [blame] | 118 | $(filter-out include-clean,$(CLEAN_TARGETS)):: |
| 119 | -$(MAKE) -C "$(subst -clean,,$@)" \ |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 120 | -f "$(abs_top_srcdir)/$(subst -clean,,$@)/Makefile" clean |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 121 | |
| 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. |
| 125 | ifneq ($(filter clean,$(MAKECMDGOALS)),) |
| 126 | INCLUDE_CLEAN_RDEP_SUBJECT := $(CLEAN_TARGETS) |
| 127 | else |
| 128 | ifneq ($(filter %clean,$(MAKECMDGOALS)),) |
| 129 | INCLUDE_CLEAN_RDEP_SUBJECT := $(MAKECMDGOALS) |
| 130 | endif |
| 131 | endif |
| 132 | |
| 133 | # Remove potential for circular dependencies. |
yaberauneya | f6380f4 | 2010-01-14 08:42:06 +0000 | [diff] [blame] | 134 | INCLUDE_CLEAN_RDEPS := $(filter-out include-clean,$(INCLUDE_CLEAN_RDEP_SUBJECT)) |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 135 | |
yaberauneya | d26b6ec | 2009-11-30 08:36:42 +0000 | [diff] [blame] | 136 | include-clean:: $(INCLUDE_CLEAN_RDEPS) | $(abs_top_builddir)/include |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 137 | -$(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. |
yaberauneya | d26b6ec | 2009-11-30 08:36:42 +0000 | [diff] [blame] | 141 | $(INSTALL_TARGETS) include-install lib-install: |
| 142 | $(MAKE) -C "$(subst -install,,$@)" \ |
yaberauneya | 8425281 | 2009-12-08 10:13:51 +0000 | [diff] [blame] | 143 | -f "$(abs_top_srcdir)/$(subst -install,,$@)/Makefile" install |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 144 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 145 | # Just in case configure hasn't been run yet, let's not overambitiously remove |
| 146 | # the $(INSTALL_DIR). |
yaberauneya | f6380f4 | 2010-01-14 08:42:06 +0000 | [diff] [blame] | 147 | .PHONY: clean_install_dir |
| 148 | clean_install_dir:: |
| 149 | $(RM) -Rf "$(INSTALL_DIR)" |
| 150 | |
yaberauneya | 7279a86 | 2010-02-02 08:25:09 +0000 | [diff] [blame] | 151 | # Clean the directory if the build-tree is properly configured and not set to |
| 152 | # the srcdir. |
yaberauneya | aee37bb | 2010-02-03 07:44:18 +0000 | [diff] [blame] | 153 | ifeq ($(filter $(BUILD_TREE_STATE),$(BUILD_TREE_SRCDIR_INSTALL) $(BUILD_TREE_UNCONFIGURED)),) |
| 154 | # Make sure that we don't whack `/'!!!!! |
| 155 | ifneq ($(INSTALL_DIR),/) |
| 156 | CLEAN_TARGETS += clean_install_dir |
| 157 | endif |
| 158 | endif |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 159 | |
yaberauneya | f6380f4 | 2010-01-14 08:42:06 +0000 | [diff] [blame] | 160 | clean:: $(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)))) |
yaberauneya | d26b6ec | 2009-11-30 08:36:42 +0000 | [diff] [blame] | 164 | |
yaberauneya | d54919e | 2009-12-11 09:42:01 +0000 | [diff] [blame] | 165 | BINDIR_INSTALL_SCRIPTS := execltp |
Xiao Yang | 3b3a842 | 2016-11-14 17:55:09 +0800 | [diff] [blame] | 166 | SRCDIR_INSTALL_SCRIPTS := IDcheck.sh runltp runltplite.sh ver_linux |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 167 | SRCDIR_INSTALL_READONLY := Version |
| 168 | SRCDIR_INSTALL_TARGETS := $(SRCDIR_INSTALL_SCRIPTS) $(SRCDIR_INSTALL_READONLY) |
| 169 | |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 170 | # |
Cyril Hrubis | 3409b0b | 2012-01-06 13:54:16 +0100 | [diff] [blame] | 171 | # 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 |
| 175 | Version: |
Garrett Cooper | dbd8b81 | 2012-05-19 23:26:29 -0700 | [diff] [blame] | 176 | if git describe >/dev/null 2>&1; then \ |
Cyril Hrubis | 3409b0b | 2012-01-06 13:54:16 +0100 | [diff] [blame] | 177 | git describe > "$@"; \ |
| 178 | else \ |
Gilles Chanteperdrix | a884621 | 2014-04-01 21:10:42 +0200 | [diff] [blame] | 179 | cp $(top_srcdir)/VERSION "$@"; \ |
Cyril Hrubis | 3409b0b | 2012-01-06 13:54:16 +0100 | [diff] [blame] | 180 | fi |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 181 | |
| 182 | $(INSTALL_DIR)/Version: Version |
| 183 | install -m 00644 "$(top_builddir)/$(@F)" "$@" |
| 184 | |
yaberauneya | d54919e | 2009-12-11 09:42:01 +0000 | [diff] [blame] | 185 | $(addprefix $(DESTDIR)/$(bindir)/,$(BINDIR_INSTALL_SCRIPTS)): %: |
| 186 | install -m 00755 "$(top_builddir)/$(@F)" "$@" |
| 187 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 188 | $(addprefix $(INSTALL_DIR)/,$(SRCDIR_INSTALL_SCRIPTS)): %: |
| 189 | install -m 00755 "$(top_srcdir)/$(@F)" "$@" |
| 190 | |
yaberauneya | d1892d7 | 2010-01-29 09:41:22 +0000 | [diff] [blame] | 191 | ifneq ($(BUILD_TREE_STATE),$(BUILD_TREE_SRCDIR_INSTALL)) |
yaberauneya | 20f26ff | 2010-01-28 16:16:33 +0000 | [diff] [blame] | 192 | INSTALL_TARGETS += $(addprefix $(INSTALL_DIR)/,$(SRCDIR_INSTALL_TARGETS)) |
| 193 | endif |
| 194 | INSTALL_TARGETS += $(addprefix $(DESTDIR)/$(bindir)/,$(BINDIR_INSTALL_SCRIPTS)) |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 195 | |
yaberauneya | d54919e | 2009-12-11 09:42:01 +0000 | [diff] [blame] | 196 | $(INSTALL_TARGETS): $(INSTALL_DIR) $(DESTDIR)/$(bindir) |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 197 | |
| 198 | ## Install |
| 199 | install: $(INSTALL_TARGETS) |
| 200 | ifeq ($(SKIP_IDCHECK),0) |
yaberauneya | 45c3268 | 2009-12-06 19:50:56 +0000 | [diff] [blame] | 201 | -@CREATE_ENTRIES=$(CREATE_ENTRIES) \ |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 202 | DESTDIR="$(DESTDIR)" \ |
| 203 | "$(top_srcdir)/IDcheck.sh" |
| 204 | else |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 205 | @echo "*******************************************************" |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 206 | @echo "** Will not run IDcheck.sh (SKIP_IDCHECK set to 1). **" |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 207 | @echo "*******************************************************" |
yaberauneya | 3ab801e | 2009-07-10 23:01:27 +0000 | [diff] [blame] | 208 | endif |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 209 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 210 | ## Misc targets. |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 211 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 212 | ## Help |
subrata_modak | aba85b9 | 2008-12-11 10:30:33 +0000 | [diff] [blame] | 213 | .PHONY: help |
| 214 | help: |
yaberauneya | b68050b | 2009-10-25 06:07:38 +0000 | [diff] [blame] | 215 | @echo "Please read the Configuration section in $(top_srcdir)/INSTALL" |
| 216 | @exit 1 |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 217 | |
| 218 | ## Menuconfig |
| 219 | menuconfig: |
| 220 | @$(SHELL) "$(top_srcdir)/ltpmenu" |
| 221 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 222 | ## End misc targets. |