build: allow cros-compilation on chromeOS
[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             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
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         autoreconf --include=m4
83         libtoolize -i
84
85 include/builddefs include/config.h: configure
86         ./configure \
87                 --libexecdir=/usr/lib \
88                 --exec_prefix=/var/lib
89
90 aclocal.m4::
91         aclocal --acdir=`pwd`/m4 --output=$@
92
93 depend: include/builddefs $(addsuffix -depend,$(SUBDIRS))
94
95 install: default $(addsuffix -install,$(SUBDIRS))
96         $(INSTALL) -m 755 -d $(PKG_LIB_DIR)
97         $(INSTALL) -m 755 check $(PKG_LIB_DIR)
98         $(INSTALL) -m 644 randomize.awk $(PKG_LIB_DIR)
99
100 # Nothing.
101 install-dev install-lib:
102
103 %-install:
104         $(MAKE) $(MAKEOPTS) -C $* install
105
106 realclean distclean: clean
107         $(Q)rm -f $(LDIRT) $(CONFIGURE)
108         $(Q)rm -rf autom4te.cache Logs
109
110 dist: include/builddefs include/config.h default
111 ifeq ($(HAVE_BUILDDEFS), no)
112         $(Q)$(MAKE) $(MAKEOPTS) -C . $@
113 else
114         $(Q)$(MAKE) $(MAKEOPTS) $(SRCTAR)
115 endif
116
117 $(SRCTAR) : default
118         $(Q)git archive --prefix=$(PKG_NAME)-$(PKG_VERSION)/ --format=tar \
119           v$(PKG_VERSION) > $(PKG_NAME)-$(PKG_VERSION).tar
120         $(Q)$(TAR) --transform "s,^,$(PKG_NAME)-$(PKG_VERSION)/," \
121           -rf $(PKG_NAME)-$(PKG_VERSION).tar $(CONFIGURE)
122         $(Q)$(ZIP) $(PKG_NAME)-$(PKG_VERSION).tar
123         echo Wrote: $@