common/inject: refactor helpers to use new errortag interface
[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/config.h include/config.h.in \
45             aclocal.m4 config.guess config.sub install-sh ltmain.sh \
46             m4/libtool.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 \
47             m4/lt~obsolete.m4
48 LSRCFILES = configure configure.ac aclocal.m4 README VERSION
49 LDIRT = config.log .ltdep .dep config.status config.cache confdefs.h \
50         conftest* check.log check.time libtool include/builddefs
51
52 ifeq ($(HAVE_BUILDDEFS), yes)
53 LDIRT += $(SRCTAR)
54 endif
55
56 LIB_SUBDIRS = include lib
57 TOOL_SUBDIRS = ltp src m4 common
58 ifeq ($(HAVE_DMAPI), true)
59 TOOL_SUBDIRS += dmapi
60 endif
61
62 export TESTS_DIR = tests
63 SUBDIRS = $(LIB_SUBDIRS) $(TOOL_SUBDIRS) $(TESTS_DIR)
64
65 default: include/builddefs $(DMAPI_MAKEFILE)
66 ifeq ($(HAVE_BUILDDEFS), no)
67         $(Q)$(MAKE) $(MAKEOPTS) $@
68 else
69         $(Q)$(MAKE) $(MAKEOPTS) $(SUBDIRS)
70 endif
71
72 # tool/lib dependencies
73 $(TOOL_SUBDIRS): $(LIB_SUBDIRS)
74
75 ifeq ($(HAVE_BUILDDEFS), yes)
76 include $(BUILDRULES)
77 else
78 clean:  # if configure hasn't run, nothing to clean
79 endif
80
81 configure: configure.ac
82         libtoolize -cfi
83         aclocal -I m4
84         autoheader
85         autoconf
86
87 include/builddefs include/config.h: configure
88         ./configure \
89                 --libexecdir=/usr/lib \
90                 --exec_prefix=/var/lib
91
92 aclocal.m4::
93         aclocal --acdir=`pwd`/m4 --output=$@
94
95 depend: include/builddefs $(addsuffix -depend,$(SUBDIRS))
96
97 install: default $(addsuffix -install,$(SUBDIRS))
98         $(INSTALL) -m 755 -d $(PKG_LIB_DIR)
99         $(INSTALL) -m 755 check $(PKG_LIB_DIR)
100         $(INSTALL) -m 644 randomize.awk $(PKG_LIB_DIR)
101
102 # Nothing.
103 install-dev install-lib:
104
105 %-install:
106         $(MAKE) $(MAKEOPTS) -C $* install
107
108 realclean distclean: clean
109         $(Q)rm -f $(LDIRT) $(CONFIGURE)
110         $(Q)rm -rf autom4te.cache Logs
111
112 dist: include/builddefs include/config.h default
113 ifeq ($(HAVE_BUILDDEFS), no)
114         $(Q)$(MAKE) $(MAKEOPTS) -C . $@
115 else
116         $(Q)$(MAKE) $(MAKEOPTS) $(SRCTAR)
117 endif
118
119 $(SRCTAR) : default
120         $(Q)git archive --prefix=$(PKG_NAME)-$(PKG_VERSION)/ --format=tar \
121           v$(PKG_VERSION) > $(PKG_NAME)-$(PKG_VERSION).tar
122         $(Q)$(TAR) --transform "s,^,$(PKG_NAME)-$(PKG_VERSION)/," \
123           -rf $(PKG_NAME)-$(PKG_VERSION).tar $(CONFIGURE)
124         $(Q)$(ZIP) $(PKG_NAME)-$(PKG_VERSION).tar
125         echo Wrote: $@