30d8747d1f79f497dc2b39c670300a1f52de0ef0
[xfstests-dev.git] / Makefile
1 #
2 # Copyright (C) 2000-2008, 2011 SGI  All Rights Reserved.
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 2 of the
7 # License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 # 02110-1301, USA.
18 #
19
20 ifeq ("$(origin V)", "command line")
21   BUILD_VERBOSE = $(V)
22 endif
23 ifndef BUILD_VERBOSE
24   BUILD_VERBOSE = 0
25 endif
26
27 ifeq ($(BUILD_VERBOSE),1)
28   Q =
29 else
30   Q = @
31 endif
32
33 MAKEOPTS = --no-print-directory Q=$(Q)
34
35 TOPDIR = .
36 HAVE_BUILDDEFS = $(shell test -f $(TOPDIR)/include/builddefs && echo yes || echo no)
37
38 ifeq ($(HAVE_BUILDDEFS), yes)
39 include $(TOPDIR)/include/builddefs
40 endif
41
42 SRCTAR = $(PKG_NAME)-$(PKG_VERSION).tar.gz
43
44 CONFIGURE = configure include/builddefs include/config.h
45 LSRCFILES = configure configure.ac aclocal.m4 README VERSION
46 LDIRT = config.log .ltdep .dep config.status config.cache confdefs.h \
47         conftest* check.log check.time
48
49 ifeq ($(HAVE_BUILDDEFS), yes)
50 LDIRT += $(SRCTAR)
51 endif
52
53 LIB_SUBDIRS = include lib
54 TOOL_SUBDIRS = ltp src m4 common
55 ifeq ($(HAVE_DMAPI), true)
56 TOOL_SUBDIRS += dmapi
57 endif
58
59 export TESTS_DIR = tests
60 SUBDIRS = $(LIB_SUBDIRS) $(TOOL_SUBDIRS) $(TESTS_DIR)
61
62 default: include/builddefs $(DMAPI_MAKEFILE)
63 ifeq ($(HAVE_BUILDDEFS), no)
64         $(Q)$(MAKE) $(MAKEOPTS) $@
65 else
66         $(Q)$(MAKE) $(MAKEOPTS) $(SUBDIRS)
67 endif
68
69 # tool/lib dependencies
70 $(TOOL_SUBDIRS): $(LIB_SUBDIRS)
71
72 ifeq ($(HAVE_BUILDDEFS), yes)
73 include $(BUILDRULES)
74 else
75 clean:  # if configure hasn't run, nothing to clean
76 endif
77
78 configure: configure.ac
79         autoheader
80         autoconf
81
82 include/builddefs include/config.h: configure
83         ./configure \
84                 --libexecdir=/usr/lib
85
86 aclocal.m4::
87         aclocal --acdir=`pwd`/m4 --output=$@
88
89 depend: include/builddefs $(addsuffix -depend,$(SUBDIRS))
90
91 install: default $(addsuffix -install,$(SUBDIRS))
92         $(INSTALL) -m 755 -d $(PKG_LIB_DIR)
93         $(INSTALL) -m 755 check $(PKG_LIB_DIR)
94         $(INSTALL) -m 644 randomize.awk $(PKG_LIB_DIR)
95
96 # Nothing.
97 install-dev install-lib:
98
99 %-install:
100         $(MAKE) $(MAKEOPTS) -C $* install
101
102 realclean distclean: clean
103         $(Q)rm -f $(LDIRT) $(CONFIGURE)
104         $(Q)rm -rf autom4te.cache Logs
105
106 dist: include/builddefs include/config.h default
107 ifeq ($(HAVE_BUILDDEFS), no)
108         $(Q)$(MAKE) $(MAKEOPTS) -C . $@
109 else
110         $(Q)$(MAKE) $(MAKEOPTS) $(SRCTAR)
111 endif
112
113 $(SRCTAR) : default
114         $(Q)git archive --prefix=$(PKG_NAME)-$(PKG_VERSION)/ --format=tar \
115           v$(PKG_VERSION) > $(PKG_NAME)-$(PKG_VERSION).tar
116         $(Q)$(TAR) --transform "s,^,$(PKG_NAME)-$(PKG_VERSION)/," \
117           -rf $(PKG_NAME)-$(PKG_VERSION).tar $(CONFIGURE)
118         $(Q)$(ZIP) $(PKG_NAME)-$(PKG_VERSION).tar
119         echo Wrote: $@