1# 2# Top-level Makefile for LTP. See INSTALL for more info. 3# 4# Copyright (C) 2009-2010, Cisco Systems Inc. 5# Copyright (C) 2010-2011, Linux Test Project. 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 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. 27CREATE_ENTRIES ?= 0 28 29top_srcdir ?= $(CURDIR) 30 31include $(top_srcdir)/include/mk/env_pre.mk 32include $(top_srcdir)/include/mk/automake.mk 33include $(top_srcdir)/include/mk/gitignore.mk 34 35.SUFFIXES: 36.SUFFIXES: .am .default .h .in .m4 .mk 37 38vpath %.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 44 45# Skip running IDcheck.sh at the end of install? 46SKIP_IDCHECK ?= 0 47 48# User wants uclinux binaries? 49UCLINUX ?= 0 50export UCLINUX 51 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). 60ifneq ($(UCLINUX),1) 61COMMON_TARGETS := pan utils 62INSTALL_TARGETS := doc 63endif 64 65define target_to_dir_dep_mapping 66ifeq ($$(filter %-clean,$(1)),) # not *-clean 67$(1): | $$(abs_top_builddir)/$$(basename $$(subst -,.,$(1))) 68else # clean 69$(1):: | $$(abs_top_builddir)/$$(basename $$(subst -,.,$(1))) 70endif 71endef 72 73COMMON_TARGETS += testcases tools 74# Don't want to nuke the original files if we're installing in-build-tree. 75ifneq ($(BUILD_TREE_STATE),$(BUILD_TREE_SRCDIR_INSTALL)) 76INSTALL_TARGETS += runtest scenario_groups testscripts 77CLEAN_TARGETS += include runtest scenario_groups testscripts 78endif 79INSTALL_TARGETS += $(COMMON_TARGETS) 80CLEAN_TARGETS += $(COMMON_TARGETS) lib 81BOOTSTRAP_TARGETS := $(sort $(COMMON_TARGETS) $(CLEAN_TARGETS) $(INSTALL_TARGETS)) 82 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. 90all: $(addsuffix -all,$(COMMON_TARGETS)) Version 91 92$(MAKE_TARGETS): lib-all 93 94.PHONY: include-all include-install 95include-install: $(top_builddir)/include/config.h include/mk/config.mk include-all 96 97INSTALL_DIR := $(DESTDIR)/$(prefix) 98 99# 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 106# build tree bootstrap targets and $(INSTALL_DIR) target. 107$(sort $(addprefix $(abs_top_builddir)/,$(BOOTSTRAP_TARGETS)) $(INSTALL_DIR) $(DESTDIR)/$(bindir)): 108 mkdir -m 00755 -p "$@" 109 110## Pattern based subtarget rules. 111lib-install: lib-all 112 113$(MAKE_TARGETS) include-all lib-all: 114 $(MAKE) -C "$(subst -all,,$@)" \ 115 -f "$(abs_top_srcdir)/$(subst -all,,$@)/Makefile" all 116 117# Let's not conflict with ac-clean, maintainer-clean, etc, so. 118$(filter-out include-clean,$(CLEAN_TARGETS)):: 119 -$(MAKE) -C "$(subst -clean,,$@)" \ 120 -f "$(abs_top_srcdir)/$(subst -clean,,$@)/Makefile" clean 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. 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. 134INCLUDE_CLEAN_RDEPS := $(filter-out include-clean,$(INCLUDE_CLEAN_RDEP_SUBJECT)) 135 136include-clean:: $(INCLUDE_CLEAN_RDEPS) | $(abs_top_builddir)/include 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. 141$(INSTALL_TARGETS) include-install lib-install: 142 $(MAKE) -C "$(subst -install,,$@)" \ 143 -f "$(abs_top_srcdir)/$(subst -install,,$@)/Makefile" install 144 145# Just in case configure hasn't been run yet, let's not overambitiously remove 146# the $(INSTALL_DIR). 147.PHONY: clean_install_dir 148clean_install_dir:: 149 $(RM) -Rf "$(INSTALL_DIR)" 150 151# Clean the directory if the build-tree is properly configured and not set to 152# the srcdir. 153ifeq ($(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 159 160clean:: $(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)))) 164 165BINDIR_INSTALL_SCRIPTS := execltp 166SRCDIR_INSTALL_SCRIPTS := IDcheck.sh runltp ver_linux 167SRCDIR_INSTALL_READONLY := Version 168SRCDIR_INSTALL_TARGETS := $(SRCDIR_INSTALL_SCRIPTS) $(SRCDIR_INSTALL_READONLY) 169 170# 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 175Version: 176 if git describe >/dev/null 2>&1; then \ 177 git describe > "$@"; \ 178 else \ 179 cp $(top_srcdir)/VERSION "$@"; \ 180 fi 181 182$(INSTALL_DIR)/Version: Version 183 install -m 00644 "$(top_builddir)/$(@F)" "$@" 184 185$(addprefix $(DESTDIR)/$(bindir)/,$(BINDIR_INSTALL_SCRIPTS)): %: 186 install -m 00755 "$(top_builddir)/$(@F)" "$@" 187 188$(addprefix $(INSTALL_DIR)/,$(SRCDIR_INSTALL_SCRIPTS)): %: 189 install -m 00755 "$(top_srcdir)/$(@F)" "$@" 190 191ifneq ($(BUILD_TREE_STATE),$(BUILD_TREE_SRCDIR_INSTALL)) 192INSTALL_TARGETS += $(addprefix $(INSTALL_DIR)/,$(SRCDIR_INSTALL_TARGETS)) 193endif 194INSTALL_TARGETS += $(addprefix $(DESTDIR)/$(bindir)/,$(BINDIR_INSTALL_SCRIPTS)) 195 196$(INSTALL_TARGETS): $(INSTALL_DIR) $(DESTDIR)/$(bindir) 197 198## Install 199install: $(INSTALL_TARGETS) 200ifeq ($(SKIP_IDCHECK),0) 201 -@CREATE_ENTRIES=$(CREATE_ENTRIES) \ 202 DESTDIR="$(DESTDIR)" \ 203 "$(top_srcdir)/IDcheck.sh" 204else 205 @echo "*******************************************************" 206 @echo "** Will not run IDcheck.sh (SKIP_IDCHECK set to 1). **" 207 @echo "*******************************************************" 208endif 209 210## Misc targets. 211 212## Help 213.PHONY: help 214help: 215 @echo "Please read the Configuration section in $(top_srcdir)/INSTALL" 216 @exit 1 217 218## Menuconfig 219menuconfig: 220 @$(SHELL) "$(top_srcdir)/ltpmenu" 221 222## End misc targets. 223