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 | |
| 81 | COMMON_TARGETS += testcases tools |
| 82 | INSTALL_TARGETS += $(COMMON_TARGETS) runtest |
| 83 | CLEAN_TARGETS += $(COMMON_TARGETS) lib include runtest |
| 84 | BOOTSTRAP_TARGETS := $(sort $(COMMON_TARGETS) $(CLEAN_TARGETS)\ |
| 85 | $(INSTALL_TARGETS)) |
| 86 | |
| 87 | CLEAN_TARGETS := $(addsuffix -clean,$(CLEAN_TARGETS)) |
| 88 | INSTALL_TARGETS := $(addsuffix -install,$(INSTALL_TARGETS)) |
| 89 | MAKE_TARGETS := $(addsuffix -all,$(filter-out lib,$(COMMON_TARGETS))) |
| 90 | |
| 91 | # There's no reason why we should run `all' twice. Otherwise we're just wasting |
| 92 | # 3+ mins of useful CPU cycles on a modern machine, and even more time on an |
| 93 | # overtaxed one, or one where -j => 1 was specified. |
| 94 | all: $(addsuffix -all,$(COMMON_TARGETS)) |
| 95 | |
| 96 | $(MAKE_TARGETS): lib-install |
| 97 | |
| 98 | .PHONY: include-all include-install |
| 99 | include-install: include/config.h include/mk/config.mk include-all |
| 100 | |
yaberauneya | f6720f2 | 2009-10-10 22:13:44 +0000 | [diff] [blame] | 101 | INSTALL_DIR := $(DESTDIR)/$(prefix) |
| 102 | |
| 103 | # build tree bootstrap targets and $(INSTALL_DIR) target. |
| 104 | $(addprefix $(abs_top_builddir)/,$(BOOTSTRAP_TARGETS)) $(INSTALL_DIR): |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 105 | mkdir -m 00755 -p "$@" |
| 106 | |
| 107 | ## Pattern based subtarget rules. |
| 108 | lib-all: include-install |
| 109 | |
| 110 | lib-install: lib-all |
| 111 | |
| 112 | .SECONDEXPANSION: |
| 113 | $(MAKE_TARGETS) include-all lib-all: %-all: $(abs_top_builddir)/$$* |
| 114 | $(MAKE) -C $* -f "$(abs_top_srcdir)/$*/Makefile" all |
| 115 | |
| 116 | # Let's not conflict with ac-clean, maintainer-clean, etc, so. |
| 117 | .SECONDEXPANSION: |
| 118 | $(filter-out include-clean,$(CLEAN_TARGETS)):: %-clean: $(abs_top_builddir)/$$* |
| 119 | -$(MAKE) -C $* -f "$(abs_top_srcdir)/$*/Makefile" clean |
| 120 | |
| 121 | # Just like everything depends on include-all / -install, we need to get rid |
| 122 | # of include last to ensure that things won't be monkey screwed up. Only do |
| 123 | # this if we're invoking clean or a subclean directly though. |
| 124 | ifneq ($(filter clean,$(MAKECMDGOALS)),) |
| 125 | INCLUDE_CLEAN_RDEP_SUBJECT := $(CLEAN_TARGETS) |
| 126 | else |
| 127 | ifneq ($(filter %clean,$(MAKECMDGOALS)),) |
| 128 | INCLUDE_CLEAN_RDEP_SUBJECT := $(MAKECMDGOALS) |
| 129 | endif |
| 130 | endif |
| 131 | |
| 132 | # Remove potential for circular dependencies. |
| 133 | INCLUDE_CLEAN_RDEPS := $(filter-out include-clean,\ |
| 134 | $(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 | .SECONDEXPANSION: |
yaberauneya | f6720f2 | 2009-10-10 22:13:44 +0000 | [diff] [blame] | 142 | $(INSTALL_TARGETS) include-install lib-install: %-install: $(abs_top_builddir)/$$* |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 143 | $(MAKE) -C $* -f "$(abs_top_srcdir)/$*/Makefile" install |
| 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). |
| 147 | clean:: $(CLEAN_TARGETS) |
| 148 | $(RM) -f Version |
| 149 | $(if $(DESTDIR)$(prefix),-$(RM) -Rf "$(INSTALL_DIR)") |
| 150 | |
yaberauneya | 0f42208 | 2009-10-13 16:58:57 +0000 | [diff] [blame] | 151 | SRCDIR_INSTALL_SCRIPTS := IDcheck.sh runltp runltplite.sh ver_linux |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 152 | SRCDIR_INSTALL_READONLY := Version |
| 153 | SRCDIR_INSTALL_TARGETS := $(SRCDIR_INSTALL_SCRIPTS) $(SRCDIR_INSTALL_READONLY) |
| 154 | |
| 155 | # Save space. We only need the first line in ChangeLog for runltp*. |
| 156 | Version: $(top_srcdir)/ChangeLog |
| 157 | head -n 1 "$^" > "$@" |
| 158 | |
| 159 | $(INSTALL_DIR)/Version: Version |
| 160 | install -m 00644 "$(top_builddir)/$(@F)" "$@" |
| 161 | |
| 162 | $(addprefix $(DESTDIR)/$(bindir)/,$(BINDIR_INSTALL_SCRIPTS)) \ |
| 163 | $(addprefix $(INSTALL_DIR)/,$(SRCDIR_INSTALL_SCRIPTS)): %: |
| 164 | install -m 00755 "$(top_srcdir)/$(@F)" "$@" |
| 165 | |
| 166 | INSTALL_TARGETS += $(addprefix $(INSTALL_DIR)/,\ |
| 167 | $(SRCDIR_INSTALL_TARGETS)) |
| 168 | |
| 169 | $(INSTALL_TARGETS): $(INSTALL_DIR) |
| 170 | |
| 171 | ## Install |
| 172 | install: $(INSTALL_TARGETS) |
| 173 | ifeq ($(SKIP_IDCHECK),0) |
| 174 | @CREATE_ENTRIES=$(CREATE_ENTRIES) \ |
| 175 | DESTDIR="$(DESTDIR)" \ |
| 176 | "$(top_srcdir)/IDcheck.sh" |
| 177 | else |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 178 | @echo "*******************************************************" |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 179 | @echo "** Will not run IDcheck.sh (SKIP_IDCHECK set to 1). **" |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 180 | @echo "*******************************************************" |
yaberauneya | 3ab801e | 2009-07-10 23:01:27 +0000 | [diff] [blame] | 181 | endif |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 182 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 183 | ## Misc targets. |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 184 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 185 | ## Help |
subrata_modak | aba85b9 | 2008-12-11 10:30:33 +0000 | [diff] [blame] | 186 | .PHONY: help |
| 187 | help: |
yaberauneya | b68050b | 2009-10-25 06:07:38 +0000 | [diff] [blame] | 188 | @echo "Please read the Configuration section in $(top_srcdir)/INSTALL" |
| 189 | @exit 1 |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 190 | |
| 191 | ## Menuconfig |
| 192 | menuconfig: |
| 193 | @$(SHELL) "$(top_srcdir)/ltpmenu" |
| 194 | |
| 195 | ## Package |
| 196 | package: |
| 197 | @$(RPMBUILD) -ba ltp-devel.spec |
| 198 | |
| 199 | ## End misc targets. |