blob: 500548bd4d4acc67d3d4d1cd99291ada7b1bf6b9 [file] [log] [blame]
yaberauneyaef772532009-10-09 17:55:43 +00001#
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#
alaffincc2e5552000-07-27 17:13:18 +000022
yaberauneyaef772532009-10-09 17:55:43 +000023# 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.
26CREATE_ENTRIES ?= 0
27
28top_srcdir ?= $(CURDIR)
29
30include $(top_srcdir)/include/mk/env_pre.mk
31include $(top_srcdir)/include/mk/automake.mk
32
yaberauneyaef772532009-10-09 17:55:43 +000033.SUFFIXES:
34.SUFFIXES: .am .default .h .in .m4 .mk
subrata_modak8dfa1b32008-07-26 04:15:36 +000035
yaberauneyaef772532009-10-09 17:55:43 +000036vpath %.am $(top_srcdir)/m4
37vpath %.default $(top_srcdir)/include
38vpath %.h $(top_srcdir)/include:$(top_builddir)/include
39vpath %.in $(top_srcdir)/include
40vpath %.m4 $(top_srcdir)/m4
41vpath %.mk $(top_srcdir)/mk:$(top_srcdir)/mk/include
vapier1400d642006-02-24 02:16:55 +000042
yaberauneyaef772532009-10-09 17:55:43 +000043# Skip running IDcheck.sh at the end of install?
44SKIP_IDCHECK ?= 0
yaberauneya3ab801e2009-07-10 23:01:27 +000045
yaberauneyaef772532009-10-09 17:55:43 +000046# User wants uclinux binaries?
47UCLINUX ?= 0
yaberauneyaef772532009-10-09 17:55:43 +000048export UCLINUX
alaffincc2e5552000-07-27 17:13:18 +000049
yaberauneyaef772532009-10-09 17:55:43 +000050# CLEAN_TARGETS: Targets which exist solely in clean.
51# COMMON_TARGETS: Targets which exist in all, clean, and install.
52# INSTALL_TARGETS: Targets which exist in clean and install (contains
53# COMMON_TARGETS).
54# BOOTSTRAP_TARGETS: Directories required to bootstrap out-of-build-tree
55# support.
56
57# We're not using uclinux based targets (default).
58ifneq ($(UCLINUX),1)
59COMMON_TARGETS := pan utils
60INSTALL_TARGETS := doc
61endif
62
yaberauneyad26b6ec2009-11-30 08:36:42 +000063define target_to_dir_dep_mapping
yaberauneyad54919e2009-12-11 09:42:01 +000064ifeq ($$(filter %-clean,$(1)),) # not *-clean
65$(1): | $$(abs_top_builddir)/$$(basename $$(subst -,.,$(1)))
66else # clean
67$(1):: | $$(abs_top_builddir)/$$(basename $$(subst -,.,$(1)))
68endif
yaberauneyad26b6ec2009-11-30 08:36:42 +000069endef
70
yaberauneyaef772532009-10-09 17:55:43 +000071COMMON_TARGETS += testcases tools
yaberauneya2100fd72010-01-28 16:00:55 +000072# Don't want to nuke the original files if we're installing in-build-tree.
yaberauneyad1892d72010-01-29 09:41:22 +000073ifneq ($(BUILD_TREE_STATE),$(BUILD_TREE_SRCDIR_INSTALL))
yaberauneya2100fd72010-01-28 16:00:55 +000074INSTALL_TARGETS += runtest testscripts
75CLEAN_TARGETS += include runtest testscripts
76endif
77INSTALL_TARGETS += $(COMMON_TARGETS)
78CLEAN_TARGETS += $(COMMON_TARGETS) lib
yaberauneyaf6380f42010-01-14 08:42:06 +000079BOOTSTRAP_TARGETS := $(sort $(COMMON_TARGETS) $(CLEAN_TARGETS) $(INSTALL_TARGETS))
yaberauneyaef772532009-10-09 17:55:43 +000080
81CLEAN_TARGETS := $(addsuffix -clean,$(CLEAN_TARGETS))
82INSTALL_TARGETS := $(addsuffix -install,$(INSTALL_TARGETS))
83MAKE_TARGETS := $(addsuffix -all,$(filter-out lib,$(COMMON_TARGETS)))
84
85# There's no reason why we should run `all' twice. Otherwise we're just wasting
86# 3+ mins of useful CPU cycles on a modern machine, and even more time on an
87# overtaxed one, or one where -j => 1 was specified.
88all: $(addsuffix -all,$(COMMON_TARGETS))
89
yaberauneya56b65582010-01-18 05:24:29 +000090$(MAKE_TARGETS): lib-all
yaberauneyaef772532009-10-09 17:55:43 +000091
92.PHONY: include-all include-install
yaberauneyad26b6ec2009-11-30 08:36:42 +000093include-install: $(top_builddir)/include/config.h include/mk/config.mk include-all
yaberauneyaef772532009-10-09 17:55:43 +000094
yaberauneyaf6720f22009-10-10 22:13:44 +000095INSTALL_DIR := $(DESTDIR)/$(prefix)
96
97# build tree bootstrap targets and $(INSTALL_DIR) target.
yaberauneya1c437362009-12-11 15:38:21 +000098$(sort $(addprefix $(abs_top_builddir)/,$(BOOTSTRAP_TARGETS)) $(INSTALL_DIR) $(DESTDIR)/$(bindir)):
yaberauneyaef772532009-10-09 17:55:43 +000099 mkdir -m 00755 -p "$@"
100
101## Pattern based subtarget rules.
yaberauneyaef772532009-10-09 17:55:43 +0000102lib-install: lib-all
103
yaberauneyad26b6ec2009-11-30 08:36:42 +0000104$(MAKE_TARGETS) include-all lib-all:
105 $(MAKE) -C "$(subst -all,,$@)" \
106 -f "$(abs_top_srcdir)/$(subst -all,,$@)/Makefile" all
yaberauneyaef772532009-10-09 17:55:43 +0000107
108# Let's not conflict with ac-clean, maintainer-clean, etc, so.
yaberauneyad26b6ec2009-11-30 08:36:42 +0000109$(filter-out include-clean,$(CLEAN_TARGETS))::
110 -$(MAKE) -C "$(subst -clean,,$@)" \
111 -f "$(abs_top_srcdir)/$(subst -clean,,$@)/Makefile" clean
yaberauneyaef772532009-10-09 17:55:43 +0000112
113# Just like everything depends on include-all / -install, we need to get rid
114# of include last to ensure that things won't be monkey screwed up. Only do
115# this if we're invoking clean or a subclean directly though.
116ifneq ($(filter clean,$(MAKECMDGOALS)),)
117INCLUDE_CLEAN_RDEP_SUBJECT := $(CLEAN_TARGETS)
118else
119ifneq ($(filter %clean,$(MAKECMDGOALS)),)
120INCLUDE_CLEAN_RDEP_SUBJECT := $(MAKECMDGOALS)
121endif
122endif
123
124# Remove potential for circular dependencies.
yaberauneyaf6380f42010-01-14 08:42:06 +0000125INCLUDE_CLEAN_RDEPS := $(filter-out include-clean,$(INCLUDE_CLEAN_RDEP_SUBJECT))
yaberauneyaef772532009-10-09 17:55:43 +0000126
yaberauneyad26b6ec2009-11-30 08:36:42 +0000127include-clean:: $(INCLUDE_CLEAN_RDEPS) | $(abs_top_builddir)/include
yaberauneyaef772532009-10-09 17:55:43 +0000128 -$(MAKE) -C include -f "$(abs_top_srcdir)/include/Makefile" clean
129
130# include-install is separate to avoid creating a circular dependency below in
131# the install target.
yaberauneyad26b6ec2009-11-30 08:36:42 +0000132$(INSTALL_TARGETS) include-install lib-install:
133 $(MAKE) -C "$(subst -install,,$@)" \
yaberauneya84252812009-12-08 10:13:51 +0000134 -f "$(abs_top_srcdir)/$(subst -install,,$@)/Makefile" install
yaberauneyaef772532009-10-09 17:55:43 +0000135
yaberauneyaef772532009-10-09 17:55:43 +0000136# Just in case configure hasn't been run yet, let's not overambitiously remove
137# the $(INSTALL_DIR).
yaberauneyaf6380f42010-01-14 08:42:06 +0000138.PHONY: clean_install_dir
139clean_install_dir::
140 $(RM) -Rf "$(INSTALL_DIR)"
141
yaberauneyad1892d72010-01-29 09:41:22 +0000142# Don't clean the directory if the build-tree is set to the srcdir, or the
143# build tree is unconfigured.
144ifneq ($(filter $(BUILD_TREE_STATE),$(BUILD_TREE_SRCDIR_INSTALL) $(BUILD_TREE_UNCONFIGURED)),)
yaberauneyaf6380f42010-01-14 08:42:06 +0000145CLEAN_TARGETS += clean_install_dir
yaberauneya1c437362009-12-11 15:38:21 +0000146endif
yaberauneyaef772532009-10-09 17:55:43 +0000147
yaberauneyaf6380f42010-01-14 08:42:06 +0000148clean:: $(CLEAN_TARGETS)
149 $(RM) -f Version
150
151$(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))))
yaberauneyad26b6ec2009-11-30 08:36:42 +0000152
yaberauneyad54919e2009-12-11 09:42:01 +0000153BINDIR_INSTALL_SCRIPTS := execltp
154SRCDIR_INSTALL_SCRIPTS := IDcheck.sh runalltests.sh runltp runltplite.sh ver_linux
yaberauneyaef772532009-10-09 17:55:43 +0000155SRCDIR_INSTALL_READONLY := Version
156SRCDIR_INSTALL_TARGETS := $(SRCDIR_INSTALL_SCRIPTS) $(SRCDIR_INSTALL_READONLY)
157
158# Save space. We only need the first line in ChangeLog for runltp*.
159Version: $(top_srcdir)/ChangeLog
160 head -n 1 "$^" > "$@"
161
162$(INSTALL_DIR)/Version: Version
163 install -m 00644 "$(top_builddir)/$(@F)" "$@"
164
yaberauneyad54919e2009-12-11 09:42:01 +0000165$(addprefix $(DESTDIR)/$(bindir)/,$(BINDIR_INSTALL_SCRIPTS)): %:
166 install -m 00755 "$(top_builddir)/$(@F)" "$@"
167
yaberauneyaef772532009-10-09 17:55:43 +0000168$(addprefix $(INSTALL_DIR)/,$(SRCDIR_INSTALL_SCRIPTS)): %:
169 install -m 00755 "$(top_srcdir)/$(@F)" "$@"
170
yaberauneyad1892d72010-01-29 09:41:22 +0000171ifneq ($(BUILD_TREE_STATE),$(BUILD_TREE_SRCDIR_INSTALL))
yaberauneya20f26ff2010-01-28 16:16:33 +0000172INSTALL_TARGETS += $(addprefix $(INSTALL_DIR)/,$(SRCDIR_INSTALL_TARGETS))
173endif
174INSTALL_TARGETS += $(addprefix $(DESTDIR)/$(bindir)/,$(BINDIR_INSTALL_SCRIPTS))
yaberauneyaef772532009-10-09 17:55:43 +0000175
yaberauneyad54919e2009-12-11 09:42:01 +0000176$(INSTALL_TARGETS): $(INSTALL_DIR) $(DESTDIR)/$(bindir)
yaberauneyaef772532009-10-09 17:55:43 +0000177
178## Install
179install: $(INSTALL_TARGETS)
180ifeq ($(SKIP_IDCHECK),0)
yaberauneya45c32682009-12-06 19:50:56 +0000181 -@CREATE_ENTRIES=$(CREATE_ENTRIES) \
yaberauneyaef772532009-10-09 17:55:43 +0000182 DESTDIR="$(DESTDIR)" \
183 "$(top_srcdir)/IDcheck.sh"
184else
robbiewd34d5812005-07-11 22:28:09 +0000185 @echo "*******************************************************"
yaberauneyaef772532009-10-09 17:55:43 +0000186 @echo "** Will not run IDcheck.sh (SKIP_IDCHECK set to 1). **"
robbiewd34d5812005-07-11 22:28:09 +0000187 @echo "*******************************************************"
yaberauneya3ab801e2009-07-10 23:01:27 +0000188endif
robbiewd34d5812005-07-11 22:28:09 +0000189
yaberauneyaef772532009-10-09 17:55:43 +0000190## Misc targets.
robbiewd34d5812005-07-11 22:28:09 +0000191
yaberauneyaef772532009-10-09 17:55:43 +0000192## Help
subrata_modakaba85b92008-12-11 10:30:33 +0000193.PHONY: help
194help:
yaberauneyab68050b2009-10-25 06:07:38 +0000195 @echo "Please read the Configuration section in $(top_srcdir)/INSTALL"
196 @exit 1
yaberauneyaef772532009-10-09 17:55:43 +0000197
198## Menuconfig
199menuconfig:
200 @$(SHELL) "$(top_srcdir)/ltpmenu"
201
202## Package
203package:
204 @$(RPMBUILD) -ba ltp-devel.spec
205
206## End misc targets.