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 # Garrett 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. 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 33 include $(top_srcdir)/include/mk/gitignore.mk 34 35 .SUFFIXES: 36 .SUFFIXES: .am .default .h .in .m4 .mk 37 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 44 45 # Skip running IDcheck.sh at the end of install? 46 SKIP_IDCHECK ?= 0 47 48 # User wants uclinux binaries? 49 UCLINUX ?= 0 50 export 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). 60 ifneq ($(UCLINUX),1) 61 COMMON_TARGETS := pan utils 62 INSTALL_TARGETS := doc 63 endif 64 65 define target_to_dir_dep_mapping 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 71 endef 72 73 COMMON_TARGETS += testcases tools 74 # Don't want to nuke the original files if we're installing in-build-tree. 75 ifneq ($(BUILD_TREE_STATE),$(BUILD_TREE_SRCDIR_INSTALL)) 76 INSTALL_TARGETS += runtest scenario_groups testscripts 77 CLEAN_TARGETS += include runtest scenario_groups testscripts 78 endif 79 INSTALL_TARGETS += $(COMMON_TARGETS) 80 CLEAN_TARGETS += $(COMMON_TARGETS) lib 81 BOOTSTRAP_TARGETS := $(sort $(COMMON_TARGETS) $(CLEAN_TARGETS) $(INSTALL_TARGETS)) 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. 90 all: $(addsuffix -all,$(COMMON_TARGETS)) Version 91 92 $(MAKE_TARGETS): lib-all 93 94 .PHONY: include-all include-install 95 include-install: $(top_builddir)/include/config.h include/mk/config.mk include-all 96 97 INSTALL_DIR := $(DESTDIR)/$(prefix) 98 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 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. 111 lib-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. 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. 134 INCLUDE_CLEAN_RDEPS := $(filter-out include-clean,$(INCLUDE_CLEAN_RDEP_SUBJECT)) 135 136 include-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 148 clean_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. 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 159 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)))) 164 165 BINDIR_INSTALL_SCRIPTS := execltp 166 SRCDIR_INSTALL_SCRIPTS := IDcheck.sh runalltests.sh runltp runltplite.sh ver_linux 167 SRCDIR_INSTALL_READONLY := Version 168 SRCDIR_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 175 Version: 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 191 ifneq ($(BUILD_TREE_STATE),$(BUILD_TREE_SRCDIR_INSTALL)) 192 INSTALL_TARGETS += $(addprefix $(INSTALL_DIR)/,$(SRCDIR_INSTALL_TARGETS)) 193 endif 194 INSTALL_TARGETS += $(addprefix $(DESTDIR)/$(bindir)/,$(BINDIR_INSTALL_SCRIPTS)) 195 196 $(INSTALL_TARGETS): $(INSTALL_DIR) $(DESTDIR)/$(bindir) 197 198 ## Install 199 install: $(INSTALL_TARGETS) 200 ifeq ($(SKIP_IDCHECK),0) 201 -@CREATE_ENTRIES=$(CREATE_ENTRIES) \ 202 DESTDIR="$(DESTDIR)" \ 203 "$(top_srcdir)/IDcheck.sh" 204 else 205 @echo "*******************************************************" 206 @echo "** Will not run IDcheck.sh (SKIP_IDCHECK set to 1). **" 207 @echo "*******************************************************" 208 endif 209 210 ## Misc targets. 211 212 ## Help 213 .PHONY: help 214 help: 215 @echo "Please read the Configuration section in $(top_srcdir)/INSTALL" 216 @exit 1 217 218 ## Menuconfig 219 menuconfig: 220 @$(SHELL) "$(top_srcdir)/ltpmenu" 221 222 ## End misc targets. 223