blob: 703e0c78432845f6558f12812d032251b24d1677 [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
34# run configure, or the equivalent steps manually, as described in
35# README.mk-user.
36ifeq ($(wildcard $(top_builddir)/include/config.h),)
37.DEFAULT_GOAL := help
yaberauneya87e48532009-08-12 21:29:07 +000038else
yaberauneyaef772532009-10-09 17:55:43 +000039.DEFAULT_GOAL := all
vapier1400d642006-02-24 02:16:55 +000040endif
vapierd4e145e2006-02-11 04:33:08 +000041
yaberauneyaef772532009-10-09 17:55:43 +000042.SUFFIXES:
43.SUFFIXES: .am .default .h .in .m4 .mk
subrata_modak8dfa1b32008-07-26 04:15:36 +000044
yaberauneyaef772532009-10-09 17:55:43 +000045vpath %.am $(top_srcdir)/m4
46vpath %.default $(top_srcdir)/include
47vpath %.h $(top_srcdir)/include:$(top_builddir)/include
48vpath %.in $(top_srcdir)/include
49vpath %.m4 $(top_srcdir)/m4
50vpath %.mk $(top_srcdir)/mk:$(top_srcdir)/mk/include
vapier1400d642006-02-24 02:16:55 +000051
yaberauneyaef772532009-10-09 17:55:43 +000052# Skip running IDcheck.sh at the end of install?
53SKIP_IDCHECK ?= 0
yaberauneya3ab801e2009-07-10 23:01:27 +000054
yaberauneyaef772532009-10-09 17:55:43 +000055# User wants uclinux binaries?
56UCLINUX ?= 0
alaffincc2e5552000-07-27 17:13:18 +000057
yaberauneyaef772532009-10-09 17:55:43 +000058# User wants uclinux binaries. Do this for backwards compatibility, but
59# print out a warning.
60ifneq ($(filter uclinux%,$(MAKECMDGOALS)),)
61$(warning uclinux* targets will be deprecated in the future.)
62$(warning Please specify UCLINUX=1 on the command line to achieve the same)
63$(warning functionality.)
64UCLINUX := 1
yaberauneya3ab801e2009-07-10 23:01:27 +000065endif
alaffincc2e5552000-07-27 17:13:18 +000066
yaberauneyaef772532009-10-09 17:55:43 +000067export UCLINUX
alaffincc2e5552000-07-27 17:13:18 +000068
yaberauneyaef772532009-10-09 17:55:43 +000069# CLEAN_TARGETS: Targets which exist solely in clean.
70# COMMON_TARGETS: Targets which exist in all, clean, and install.
71# INSTALL_TARGETS: Targets which exist in clean and install (contains
72# COMMON_TARGETS).
73# BOOTSTRAP_TARGETS: Directories required to bootstrap out-of-build-tree
74# support.
75
76# We're not using uclinux based targets (default).
77ifneq ($(UCLINUX),1)
78COMMON_TARGETS := pan utils
79INSTALL_TARGETS := doc
80endif
81
82COMMON_TARGETS += testcases tools
83INSTALL_TARGETS += $(COMMON_TARGETS) runtest
84CLEAN_TARGETS += $(COMMON_TARGETS) lib include runtest
85BOOTSTRAP_TARGETS := $(sort $(COMMON_TARGETS) $(CLEAN_TARGETS)\
86 $(INSTALL_TARGETS))
87
88CLEAN_TARGETS := $(addsuffix -clean,$(CLEAN_TARGETS))
89INSTALL_TARGETS := $(addsuffix -install,$(INSTALL_TARGETS))
90MAKE_TARGETS := $(addsuffix -all,$(filter-out lib,$(COMMON_TARGETS)))
91
92# There's no reason why we should run `all' twice. Otherwise we're just wasting
93# 3+ mins of useful CPU cycles on a modern machine, and even more time on an
94# overtaxed one, or one where -j => 1 was specified.
95all: $(addsuffix -all,$(COMMON_TARGETS))
96
97$(MAKE_TARGETS): lib-install
98
99.PHONY: include-all include-install
100include-install: include/config.h include/mk/config.mk include-all
101
102# build tree bootstrap targets.
103$(addprefix $(abs_top_builddir)/,$(BOOTSTRAP_TARGETS)) $(INSTALL_DIR): %:
104 mkdir -m 00755 -p "$@"
105
106## Pattern based subtarget rules.
107lib-all: include-install
108
109lib-install: lib-all
110
111.SECONDEXPANSION:
112$(MAKE_TARGETS) include-all lib-all: %-all: $(abs_top_builddir)/$$*
113 $(MAKE) -C $* -f "$(abs_top_srcdir)/$*/Makefile" all
114
115# Let's not conflict with ac-clean, maintainer-clean, etc, so.
116.SECONDEXPANSION:
117$(filter-out include-clean,$(CLEAN_TARGETS)):: %-clean: $(abs_top_builddir)/$$*
118 -$(MAKE) -C $* -f "$(abs_top_srcdir)/$*/Makefile" clean
119
120# Just like everything depends on include-all / -install, we need to get rid
121# of include last to ensure that things won't be monkey screwed up. Only do
122# this if we're invoking clean or a subclean directly though.
123ifneq ($(filter clean,$(MAKECMDGOALS)),)
124INCLUDE_CLEAN_RDEP_SUBJECT := $(CLEAN_TARGETS)
125else
126ifneq ($(filter %clean,$(MAKECMDGOALS)),)
127INCLUDE_CLEAN_RDEP_SUBJECT := $(MAKECMDGOALS)
128endif
129endif
130
131# Remove potential for circular dependencies.
132INCLUDE_CLEAN_RDEPS := $(filter-out include-clean,\
133 $(INCLUDE_CLEAN_RDEP_SUBJECT))
134
135include-clean:: $(INCLUDE_CLEAN_RDEPS) $(abs_top_builddir)/include
136 -$(MAKE) -C include -f "$(abs_top_srcdir)/include/Makefile" clean
137
138# include-install is separate to avoid creating a circular dependency below in
139# the install target.
140.SECONDEXPANSION:
141$(INSTALL_TARGETS) include-install lib-install: %-install: \
142 $(abs_top_builddir)/$$*
143 $(MAKE) -C $* -f "$(abs_top_srcdir)/$*/Makefile" install
144
145INSTALL_DIR := $(DESTDIR)/$(prefix)
146
147# Just in case configure hasn't been run yet, let's not overambitiously remove
148# the $(INSTALL_DIR).
149clean:: $(CLEAN_TARGETS)
150 $(RM) -f Version
151 $(if $(DESTDIR)$(prefix),-$(RM) -Rf "$(INSTALL_DIR)")
152
153SRCDIR_INSTALL_SCRIPTS := runltp runltplite.sh ver_linux
154SRCDIR_INSTALL_READONLY := Version
155SRCDIR_INSTALL_TARGETS := $(SRCDIR_INSTALL_SCRIPTS) $(SRCDIR_INSTALL_READONLY)
156
157# Save space. We only need the first line in ChangeLog for runltp*.
158Version: $(top_srcdir)/ChangeLog
159 head -n 1 "$^" > "$@"
160
161$(INSTALL_DIR)/Version: Version
162 install -m 00644 "$(top_builddir)/$(@F)" "$@"
163
164$(addprefix $(DESTDIR)/$(bindir)/,$(BINDIR_INSTALL_SCRIPTS)) \
165$(addprefix $(INSTALL_DIR)/,$(SRCDIR_INSTALL_SCRIPTS)): %:
166 install -m 00755 "$(top_srcdir)/$(@F)" "$@"
167
168INSTALL_TARGETS += $(addprefix $(INSTALL_DIR)/,\
169 $(SRCDIR_INSTALL_TARGETS))
170
171$(INSTALL_TARGETS): $(INSTALL_DIR)
172
173## Install
174install: $(INSTALL_TARGETS)
175ifeq ($(SKIP_IDCHECK),0)
176 @CREATE_ENTRIES=$(CREATE_ENTRIES) \
177 DESTDIR="$(DESTDIR)" \
178 "$(top_srcdir)/IDcheck.sh"
179else
robbiewd34d5812005-07-11 22:28:09 +0000180 @echo "*******************************************************"
yaberauneyaef772532009-10-09 17:55:43 +0000181 @echo "** Will not run IDcheck.sh (SKIP_IDCHECK set to 1). **"
robbiewd34d5812005-07-11 22:28:09 +0000182 @echo "*******************************************************"
yaberauneya3ab801e2009-07-10 23:01:27 +0000183endif
robbiewd34d5812005-07-11 22:28:09 +0000184
yaberauneyaef772532009-10-09 17:55:43 +0000185## Misc targets.
robbiewd34d5812005-07-11 22:28:09 +0000186
yaberauneyaef772532009-10-09 17:55:43 +0000187## Help
subrata_modakaba85b92008-12-11 10:30:33 +0000188.PHONY: help
189help:
yaberauneyaef772532009-10-09 17:55:43 +0000190 @cat "$(top_srcdir)/README.mk-user"; exit 1
191
192## Menuconfig
193menuconfig:
194 @$(SHELL) "$(top_srcdir)/ltpmenu"
195
196## Package
197package:
198 @$(RPMBUILD) -ba ltp-devel.spec
199
200## End misc targets.