yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 1 | # |
| 2 | # Top-level Makefile for LTP. See INSTALL for more info. |
| 3 | # |
| 4 | # Copyright (C) 2009, Cisco Systems Inc. |
| 5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify |
| 7 | # it under the terms of the GNU General Public License as published by |
| 8 | # the Free Software Foundation; either version 2 of the License, or |
| 9 | # (at your option) any later version. |
| 10 | # |
| 11 | # This program is distributed in the hope that it will be useful, |
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | # GNU General Public License for more details. |
| 15 | # |
| 16 | # You should have received a copy of the GNU General Public License along |
| 17 | # with this program; if not, write to the Free Software Foundation, Inc., |
| 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | # |
| 20 | # Garrett Cooper, July 2009 |
| 21 | # |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 22 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 23 | # Force IDcheck.sh to fix any issues found with $(DESTDIR)/etc/group and |
| 24 | # $(DESTDIR)/etc/passwd automatically when after running the top-level |
| 25 | # install target. |
| 26 | CREATE_ENTRIES ?= 0 |
| 27 | |
| 28 | top_srcdir ?= $(CURDIR) |
| 29 | |
| 30 | include $(top_srcdir)/include/mk/env_pre.mk |
| 31 | include $(top_srcdir)/include/mk/automake.mk |
| 32 | |
| 33 | # This variable is automatically changed from help to all once someone has |
yaberauneya | 2f27b05 | 2009-11-07 01:23:20 +0000 | [diff] [blame] | 34 | # run configure, or the equivalent steps manually, as described in INSTALL. |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 35 | ifeq ($(wildcard $(top_builddir)/include/config.h),) |
| 36 | .DEFAULT_GOAL := help |
yaberauneya | 87e4853 | 2009-08-12 21:29:07 +0000 | [diff] [blame] | 37 | else |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 38 | .DEFAULT_GOAL := all |
vapier | 1400d64 | 2006-02-24 02:16:55 +0000 | [diff] [blame] | 39 | endif |
vapier | d4e145e | 2006-02-11 04:33:08 +0000 | [diff] [blame] | 40 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 41 | .SUFFIXES: |
| 42 | .SUFFIXES: .am .default .h .in .m4 .mk |
subrata_modak | 8dfa1b3 | 2008-07-26 04:15:36 +0000 | [diff] [blame] | 43 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 44 | vpath %.am $(top_srcdir)/m4 |
| 45 | vpath %.default $(top_srcdir)/include |
| 46 | vpath %.h $(top_srcdir)/include:$(top_builddir)/include |
| 47 | vpath %.in $(top_srcdir)/include |
| 48 | vpath %.m4 $(top_srcdir)/m4 |
| 49 | vpath %.mk $(top_srcdir)/mk:$(top_srcdir)/mk/include |
vapier | 1400d64 | 2006-02-24 02:16:55 +0000 | [diff] [blame] | 50 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 51 | # Skip running IDcheck.sh at the end of install? |
| 52 | SKIP_IDCHECK ?= 0 |
yaberauneya | 3ab801e | 2009-07-10 23:01:27 +0000 | [diff] [blame] | 53 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 54 | # User wants uclinux binaries? |
| 55 | UCLINUX ?= 0 |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 56 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 57 | # User wants uclinux binaries. Do this for backwards compatibility, but |
| 58 | # print out a warning. |
| 59 | ifneq ($(filter uclinux%,$(MAKECMDGOALS)),) |
| 60 | $(warning uclinux* targets will be deprecated in the future.) |
| 61 | $(warning Please specify UCLINUX=1 on the command line to achieve the same) |
| 62 | $(warning functionality.) |
| 63 | UCLINUX := 1 |
yaberauneya | 3ab801e | 2009-07-10 23:01:27 +0000 | [diff] [blame] | 64 | endif |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 65 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 66 | export UCLINUX |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 67 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 68 | # CLEAN_TARGETS: Targets which exist solely in clean. |
| 69 | # COMMON_TARGETS: Targets which exist in all, clean, and install. |
| 70 | # INSTALL_TARGETS: Targets which exist in clean and install (contains |
| 71 | # COMMON_TARGETS). |
| 72 | # BOOTSTRAP_TARGETS: Directories required to bootstrap out-of-build-tree |
| 73 | # support. |
| 74 | |
| 75 | # We're not using uclinux based targets (default). |
| 76 | ifneq ($(UCLINUX),1) |
| 77 | COMMON_TARGETS := pan utils |
| 78 | INSTALL_TARGETS := doc |
| 79 | endif |
| 80 | |
yaberauneya | d26b6ec | 2009-11-30 08:36:42 +0000 | [diff] [blame] | 81 | define target_to_dir_dep_mapping |
| 82 | $(1): | $$(abs_top_builddir)/$(patsubst %-,%,$(1)) |
| 83 | endef |
| 84 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 85 | COMMON_TARGETS += testcases tools |
| 86 | INSTALL_TARGETS += $(COMMON_TARGETS) runtest |
| 87 | CLEAN_TARGETS += $(COMMON_TARGETS) lib include runtest |
| 88 | BOOTSTRAP_TARGETS := $(sort $(COMMON_TARGETS) $(CLEAN_TARGETS)\ |
| 89 | $(INSTALL_TARGETS)) |
| 90 | |
| 91 | CLEAN_TARGETS := $(addsuffix -clean,$(CLEAN_TARGETS)) |
| 92 | INSTALL_TARGETS := $(addsuffix -install,$(INSTALL_TARGETS)) |
| 93 | MAKE_TARGETS := $(addsuffix -all,$(filter-out lib,$(COMMON_TARGETS))) |
| 94 | |
| 95 | # There's no reason why we should run `all' twice. Otherwise we're just wasting |
| 96 | # 3+ mins of useful CPU cycles on a modern machine, and even more time on an |
| 97 | # overtaxed one, or one where -j => 1 was specified. |
| 98 | all: $(addsuffix -all,$(COMMON_TARGETS)) |
| 99 | |
| 100 | $(MAKE_TARGETS): lib-install |
| 101 | |
| 102 | .PHONY: include-all include-install |
yaberauneya | d26b6ec | 2009-11-30 08:36:42 +0000 | [diff] [blame] | 103 | include-install: $(top_builddir)/include/config.h include/mk/config.mk include-all |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 104 | |
yaberauneya | f6720f2 | 2009-10-10 22:13:44 +0000 | [diff] [blame] | 105 | INSTALL_DIR := $(DESTDIR)/$(prefix) |
| 106 | |
| 107 | # build tree bootstrap targets and $(INSTALL_DIR) target. |
| 108 | $(addprefix $(abs_top_builddir)/,$(BOOTSTRAP_TARGETS)) $(INSTALL_DIR): |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 109 | mkdir -m 00755 -p "$@" |
| 110 | |
| 111 | ## Pattern based subtarget rules. |
| 112 | lib-all: include-install |
| 113 | |
| 114 | lib-install: lib-all |
| 115 | |
yaberauneya | d26b6ec | 2009-11-30 08:36:42 +0000 | [diff] [blame] | 116 | $(MAKE_TARGETS) include-all lib-all: |
| 117 | $(MAKE) -C "$(subst -all,,$@)" \ |
| 118 | -f "$(abs_top_srcdir)/$(subst -all,,$@)/Makefile" all |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 119 | |
| 120 | # Let's not conflict with ac-clean, maintainer-clean, etc, so. |
yaberauneya | d26b6ec | 2009-11-30 08:36:42 +0000 | [diff] [blame] | 121 | $(filter-out include-clean,$(CLEAN_TARGETS)):: |
| 122 | -$(MAKE) -C "$(subst -clean,,$@)" \ |
| 123 | -f "$(abs_top_srcdir)/$(subst -clean,,$@)/Makefile" clean |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 124 | |
| 125 | # Just like everything depends on include-all / -install, we need to get rid |
| 126 | # of include last to ensure that things won't be monkey screwed up. Only do |
| 127 | # this if we're invoking clean or a subclean directly though. |
| 128 | ifneq ($(filter clean,$(MAKECMDGOALS)),) |
| 129 | INCLUDE_CLEAN_RDEP_SUBJECT := $(CLEAN_TARGETS) |
| 130 | else |
| 131 | ifneq ($(filter %clean,$(MAKECMDGOALS)),) |
| 132 | INCLUDE_CLEAN_RDEP_SUBJECT := $(MAKECMDGOALS) |
| 133 | endif |
| 134 | endif |
| 135 | |
| 136 | # Remove potential for circular dependencies. |
| 137 | INCLUDE_CLEAN_RDEPS := $(filter-out include-clean,\ |
| 138 | $(INCLUDE_CLEAN_RDEP_SUBJECT)) |
| 139 | |
yaberauneya | d26b6ec | 2009-11-30 08:36:42 +0000 | [diff] [blame] | 140 | include-clean:: $(INCLUDE_CLEAN_RDEPS) | $(abs_top_builddir)/include |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 141 | -$(MAKE) -C include -f "$(abs_top_srcdir)/include/Makefile" clean |
| 142 | |
| 143 | # include-install is separate to avoid creating a circular dependency below in |
| 144 | # the install target. |
yaberauneya | d26b6ec | 2009-11-30 08:36:42 +0000 | [diff] [blame] | 145 | $(INSTALL_TARGETS) include-install lib-install: |
| 146 | $(MAKE) -C "$(subst -install,,$@)" \ |
yaberauneya | 8425281 | 2009-12-08 10:13:51 +0000 | [diff] [blame^] | 147 | -f "$(abs_top_srcdir)/$(subst -install,,$@)/Makefile" install |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 148 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 149 | # Just in case configure hasn't been run yet, let's not overambitiously remove |
| 150 | # the $(INSTALL_DIR). |
| 151 | clean:: $(CLEAN_TARGETS) |
| 152 | $(RM) -f Version |
| 153 | $(if $(DESTDIR)$(prefix),-$(RM) -Rf "$(INSTALL_DIR)") |
| 154 | |
yaberauneya | d26b6ec | 2009-11-30 08:36:42 +0000 | [diff] [blame] | 155 | $(foreach tgt,$(eval $(call target_to_dir_dep_mapping,$(tgt))),\ |
| 156 | $(MAKE_TARGETS) include-all lib-all $(CLEAN_TARGETS) \ |
| 157 | $(INSTALL_TARGETS) include-install lib-install) |
| 158 | |
yaberauneya | 0d39b83 | 2009-11-20 05:45:41 +0000 | [diff] [blame] | 159 | SRCDIR_INSTALL_SCRIPTS := execltp IDcheck.sh runalltests.sh runltp runltplite.sh ver_linux |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 160 | SRCDIR_INSTALL_READONLY := Version |
| 161 | SRCDIR_INSTALL_TARGETS := $(SRCDIR_INSTALL_SCRIPTS) $(SRCDIR_INSTALL_READONLY) |
| 162 | |
| 163 | # Save space. We only need the first line in ChangeLog for runltp*. |
| 164 | Version: $(top_srcdir)/ChangeLog |
| 165 | head -n 1 "$^" > "$@" |
| 166 | |
| 167 | $(INSTALL_DIR)/Version: Version |
| 168 | install -m 00644 "$(top_builddir)/$(@F)" "$@" |
| 169 | |
| 170 | $(addprefix $(DESTDIR)/$(bindir)/,$(BINDIR_INSTALL_SCRIPTS)) \ |
| 171 | $(addprefix $(INSTALL_DIR)/,$(SRCDIR_INSTALL_SCRIPTS)): %: |
| 172 | install -m 00755 "$(top_srcdir)/$(@F)" "$@" |
| 173 | |
| 174 | INSTALL_TARGETS += $(addprefix $(INSTALL_DIR)/,\ |
| 175 | $(SRCDIR_INSTALL_TARGETS)) |
| 176 | |
| 177 | $(INSTALL_TARGETS): $(INSTALL_DIR) |
| 178 | |
| 179 | ## Install |
| 180 | install: $(INSTALL_TARGETS) |
| 181 | ifeq ($(SKIP_IDCHECK),0) |
yaberauneya | 45c3268 | 2009-12-06 19:50:56 +0000 | [diff] [blame] | 182 | -@CREATE_ENTRIES=$(CREATE_ENTRIES) \ |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 183 | DESTDIR="$(DESTDIR)" \ |
| 184 | "$(top_srcdir)/IDcheck.sh" |
| 185 | else |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 186 | @echo "*******************************************************" |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 187 | @echo "** Will not run IDcheck.sh (SKIP_IDCHECK set to 1). **" |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 188 | @echo "*******************************************************" |
yaberauneya | 3ab801e | 2009-07-10 23:01:27 +0000 | [diff] [blame] | 189 | endif |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 190 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 191 | ## Misc targets. |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 192 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 193 | ## Help |
subrata_modak | aba85b9 | 2008-12-11 10:30:33 +0000 | [diff] [blame] | 194 | .PHONY: help |
| 195 | help: |
yaberauneya | b68050b | 2009-10-25 06:07:38 +0000 | [diff] [blame] | 196 | @echo "Please read the Configuration section in $(top_srcdir)/INSTALL" |
| 197 | @exit 1 |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 198 | |
| 199 | ## Menuconfig |
| 200 | menuconfig: |
| 201 | @$(SHELL) "$(top_srcdir)/ltpmenu" |
| 202 | |
| 203 | ## Package |
| 204 | package: |
| 205 | @$(RPMBUILD) -ba ltp-devel.spec |
| 206 | |
| 207 | ## End misc targets. |