blob: f298d23ed839d15dbc69842169aaf20b4515806f [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
33# This variable is automatically changed from help to all once someone has
yaberauneya2f27b052009-11-07 01:23:20 +000034# run configure, or the equivalent steps manually, as described in INSTALL.
yaberauneyaef772532009-10-09 17:55:43 +000035ifeq ($(wildcard $(top_builddir)/include/config.h),)
36.DEFAULT_GOAL := help
yaberauneya87e48532009-08-12 21:29:07 +000037else
yaberauneyaef772532009-10-09 17:55:43 +000038.DEFAULT_GOAL := all
vapier1400d642006-02-24 02:16:55 +000039endif
vapierd4e145e2006-02-11 04:33:08 +000040
yaberauneyaef772532009-10-09 17:55:43 +000041.SUFFIXES:
42.SUFFIXES: .am .default .h .in .m4 .mk
subrata_modak8dfa1b32008-07-26 04:15:36 +000043
yaberauneyaef772532009-10-09 17:55:43 +000044vpath %.am $(top_srcdir)/m4
45vpath %.default $(top_srcdir)/include
46vpath %.h $(top_srcdir)/include:$(top_builddir)/include
47vpath %.in $(top_srcdir)/include
48vpath %.m4 $(top_srcdir)/m4
49vpath %.mk $(top_srcdir)/mk:$(top_srcdir)/mk/include
vapier1400d642006-02-24 02:16:55 +000050
yaberauneyaef772532009-10-09 17:55:43 +000051# Skip running IDcheck.sh at the end of install?
52SKIP_IDCHECK ?= 0
yaberauneya3ab801e2009-07-10 23:01:27 +000053
yaberauneyaef772532009-10-09 17:55:43 +000054# User wants uclinux binaries?
55UCLINUX ?= 0
alaffincc2e5552000-07-27 17:13:18 +000056
yaberauneyaef772532009-10-09 17:55:43 +000057# User wants uclinux binaries. Do this for backwards compatibility, but
58# print out a warning.
59ifneq ($(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.)
63UCLINUX := 1
yaberauneya3ab801e2009-07-10 23:01:27 +000064endif
alaffincc2e5552000-07-27 17:13:18 +000065
yaberauneyaef772532009-10-09 17:55:43 +000066export UCLINUX
alaffincc2e5552000-07-27 17:13:18 +000067
yaberauneyaef772532009-10-09 17:55:43 +000068# 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).
76ifneq ($(UCLINUX),1)
77COMMON_TARGETS := pan utils
78INSTALL_TARGETS := doc
79endif
80
yaberauneyad26b6ec2009-11-30 08:36:42 +000081define target_to_dir_dep_mapping
yaberauneyad54919e2009-12-11 09:42:01 +000082ifeq ($$(filter %-clean,$(1)),) # not *-clean
83$(1): | $$(abs_top_builddir)/$$(basename $$(subst -,.,$(1)))
84else # clean
85$(1):: | $$(abs_top_builddir)/$$(basename $$(subst -,.,$(1)))
86endif
yaberauneyad26b6ec2009-11-30 08:36:42 +000087endef
88
yaberauneyaef772532009-10-09 17:55:43 +000089COMMON_TARGETS += testcases tools
yaberauneya1c437362009-12-11 15:38:21 +000090INSTALL_TARGETS += $(COMMON_TARGETS) runtest testscripts
91CLEAN_TARGETS += $(COMMON_TARGETS) lib include runtest testscripts
yaberauneyaef772532009-10-09 17:55:43 +000092BOOTSTRAP_TARGETS := $(sort $(COMMON_TARGETS) $(CLEAN_TARGETS)\
93 $(INSTALL_TARGETS))
94
95CLEAN_TARGETS := $(addsuffix -clean,$(CLEAN_TARGETS))
96INSTALL_TARGETS := $(addsuffix -install,$(INSTALL_TARGETS))
97MAKE_TARGETS := $(addsuffix -all,$(filter-out lib,$(COMMON_TARGETS)))
98
99# There's no reason why we should run `all' twice. Otherwise we're just wasting
100# 3+ mins of useful CPU cycles on a modern machine, and even more time on an
101# overtaxed one, or one where -j => 1 was specified.
102all: $(addsuffix -all,$(COMMON_TARGETS))
103
104$(MAKE_TARGETS): lib-install
105
106.PHONY: include-all include-install
yaberauneyad26b6ec2009-11-30 08:36:42 +0000107include-install: $(top_builddir)/include/config.h include/mk/config.mk include-all
yaberauneyaef772532009-10-09 17:55:43 +0000108
yaberauneyaf6720f22009-10-10 22:13:44 +0000109INSTALL_DIR := $(DESTDIR)/$(prefix)
110
111# build tree bootstrap targets and $(INSTALL_DIR) target.
yaberauneya1c437362009-12-11 15:38:21 +0000112$(sort $(addprefix $(abs_top_builddir)/,$(BOOTSTRAP_TARGETS)) $(INSTALL_DIR) $(DESTDIR)/$(bindir)):
yaberauneyaef772532009-10-09 17:55:43 +0000113 mkdir -m 00755 -p "$@"
114
115## Pattern based subtarget rules.
116lib-all: include-install
117
118lib-install: lib-all
119
yaberauneyad26b6ec2009-11-30 08:36:42 +0000120$(MAKE_TARGETS) include-all lib-all:
121 $(MAKE) -C "$(subst -all,,$@)" \
122 -f "$(abs_top_srcdir)/$(subst -all,,$@)/Makefile" all
yaberauneyaef772532009-10-09 17:55:43 +0000123
124# Let's not conflict with ac-clean, maintainer-clean, etc, so.
yaberauneyad26b6ec2009-11-30 08:36:42 +0000125$(filter-out include-clean,$(CLEAN_TARGETS))::
126 -$(MAKE) -C "$(subst -clean,,$@)" \
127 -f "$(abs_top_srcdir)/$(subst -clean,,$@)/Makefile" clean
yaberauneyaef772532009-10-09 17:55:43 +0000128
129# Just like everything depends on include-all / -install, we need to get rid
130# of include last to ensure that things won't be monkey screwed up. Only do
131# this if we're invoking clean or a subclean directly though.
132ifneq ($(filter clean,$(MAKECMDGOALS)),)
133INCLUDE_CLEAN_RDEP_SUBJECT := $(CLEAN_TARGETS)
134else
135ifneq ($(filter %clean,$(MAKECMDGOALS)),)
136INCLUDE_CLEAN_RDEP_SUBJECT := $(MAKECMDGOALS)
137endif
138endif
139
140# Remove potential for circular dependencies.
141INCLUDE_CLEAN_RDEPS := $(filter-out include-clean,\
142 $(INCLUDE_CLEAN_RDEP_SUBJECT))
143
yaberauneyad26b6ec2009-11-30 08:36:42 +0000144include-clean:: $(INCLUDE_CLEAN_RDEPS) | $(abs_top_builddir)/include
yaberauneyaef772532009-10-09 17:55:43 +0000145 -$(MAKE) -C include -f "$(abs_top_srcdir)/include/Makefile" clean
146
147# include-install is separate to avoid creating a circular dependency below in
148# the install target.
yaberauneyad26b6ec2009-11-30 08:36:42 +0000149$(INSTALL_TARGETS) include-install lib-install:
150 $(MAKE) -C "$(subst -install,,$@)" \
yaberauneya84252812009-12-08 10:13:51 +0000151 -f "$(abs_top_srcdir)/$(subst -install,,$@)/Makefile" install
yaberauneyaef772532009-10-09 17:55:43 +0000152
yaberauneyaef772532009-10-09 17:55:43 +0000153# Just in case configure hasn't been run yet, let's not overambitiously remove
154# the $(INSTALL_DIR).
155clean:: $(CLEAN_TARGETS)
156 $(RM) -f Version
yaberauneya1c437362009-12-11 15:38:21 +0000157ifneq ($(INSTALL_IN_BUILD_TREE),1)
158 -$(RM) -Rf "$(INSTALL_DIR)"
159endif
yaberauneyaef772532009-10-09 17:55:43 +0000160
yaberauneyad54919e2009-12-11 09:42:01 +0000161$(foreach tgt,\
yaberauneyad26b6ec2009-11-30 08:36:42 +0000162 $(MAKE_TARGETS) include-all lib-all $(CLEAN_TARGETS) \
yaberauneyad54919e2009-12-11 09:42:01 +0000163 $(INSTALL_TARGETS) include-install lib-install,\
164 $(eval $(call target_to_dir_dep_mapping,$(tgt))))
yaberauneyad26b6ec2009-11-30 08:36:42 +0000165
yaberauneyad54919e2009-12-11 09:42:01 +0000166BINDIR_INSTALL_SCRIPTS := execltp
167SRCDIR_INSTALL_SCRIPTS := IDcheck.sh runalltests.sh runltp runltplite.sh ver_linux
yaberauneyaef772532009-10-09 17:55:43 +0000168SRCDIR_INSTALL_READONLY := Version
169SRCDIR_INSTALL_TARGETS := $(SRCDIR_INSTALL_SCRIPTS) $(SRCDIR_INSTALL_READONLY)
170
171# Save space. We only need the first line in ChangeLog for runltp*.
172Version: $(top_srcdir)/ChangeLog
173 head -n 1 "$^" > "$@"
174
175$(INSTALL_DIR)/Version: Version
176 install -m 00644 "$(top_builddir)/$(@F)" "$@"
177
yaberauneyad54919e2009-12-11 09:42:01 +0000178$(addprefix $(DESTDIR)/$(bindir)/,$(BINDIR_INSTALL_SCRIPTS)): %:
179 install -m 00755 "$(top_builddir)/$(@F)" "$@"
180
yaberauneyaef772532009-10-09 17:55:43 +0000181$(addprefix $(INSTALL_DIR)/,$(SRCDIR_INSTALL_SCRIPTS)): %:
182 install -m 00755 "$(top_srcdir)/$(@F)" "$@"
183
184INSTALL_TARGETS += $(addprefix $(INSTALL_DIR)/,\
yaberauneyad54919e2009-12-11 09:42:01 +0000185 $(SRCDIR_INSTALL_TARGETS))\
186 $(addprefix $(DESTDIR)/$(bindir)/,\
187 $(BINDIR_INSTALL_SCRIPTS))
yaberauneyaef772532009-10-09 17:55:43 +0000188
yaberauneyad54919e2009-12-11 09:42:01 +0000189$(INSTALL_TARGETS): $(INSTALL_DIR) $(DESTDIR)/$(bindir)
yaberauneyaef772532009-10-09 17:55:43 +0000190
191## Install
192install: $(INSTALL_TARGETS)
193ifeq ($(SKIP_IDCHECK),0)
yaberauneya45c32682009-12-06 19:50:56 +0000194 -@CREATE_ENTRIES=$(CREATE_ENTRIES) \
yaberauneyaef772532009-10-09 17:55:43 +0000195 DESTDIR="$(DESTDIR)" \
196 "$(top_srcdir)/IDcheck.sh"
197else
robbiewd34d5812005-07-11 22:28:09 +0000198 @echo "*******************************************************"
yaberauneyaef772532009-10-09 17:55:43 +0000199 @echo "** Will not run IDcheck.sh (SKIP_IDCHECK set to 1). **"
robbiewd34d5812005-07-11 22:28:09 +0000200 @echo "*******************************************************"
yaberauneya3ab801e2009-07-10 23:01:27 +0000201endif
robbiewd34d5812005-07-11 22:28:09 +0000202
yaberauneyaef772532009-10-09 17:55:43 +0000203## Misc targets.
robbiewd34d5812005-07-11 22:28:09 +0000204
yaberauneyaef772532009-10-09 17:55:43 +0000205## Help
subrata_modakaba85b92008-12-11 10:30:33 +0000206.PHONY: help
207help:
yaberauneyab68050b2009-10-25 06:07:38 +0000208 @echo "Please read the Configuration section in $(top_srcdir)/INSTALL"
209 @exit 1
yaberauneyaef772532009-10-09 17:55:43 +0000210
211## Menuconfig
212menuconfig:
213 @$(SHELL) "$(top_srcdir)/ltpmenu"
214
215## Package
216package:
217 @$(RPMBUILD) -ba ltp-devel.spec
218
219## End misc targets.