unwritten_sync: convert XFS_IOC_FREESP64 to ftruncate
[xfstests-dev.git] / Makefile
1 # SPDX-License-Identifier: GPL-2.0+
2 # Copyright (C) 2000-2008, 2011 SGI  All Rights Reserved.
3 #
4 ifeq ("$(origin V)", "command line")
5   BUILD_VERBOSE = $(V)
6 endif
7 ifndef BUILD_VERBOSE
8   BUILD_VERBOSE = 0
9 endif
10
11 ifeq ($(BUILD_VERBOSE),1)
12   Q =
13 else
14   Q = @
15 endif
16
17 MAKEOPTS = --no-print-directory Q=$(Q)
18
19 TOPDIR = .
20 HAVE_BUILDDEFS = $(shell test -f $(TOPDIR)/include/builddefs && echo yes || echo no)
21
22 ifeq ($(HAVE_BUILDDEFS), yes)
23 include $(TOPDIR)/include/builddefs
24 else
25 export TESTS_DIR = tests
26 endif
27
28 SRCTAR = $(PKG_NAME)-$(PKG_VERSION).tar.gz
29
30 CONFIGURE = configure include/config.h include/config.h.in \
31             aclocal.m4 config.guess config.sub install-sh ltmain.sh \
32             m4/libtool.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 \
33             m4/lt~obsolete.m4
34 LSRCFILES = configure configure.ac aclocal.m4 README VERSION
35 LDIRT = config.log .ltdep .dep config.status config.cache confdefs.h \
36         conftest* check.log check.time libtool include/builddefs
37
38 ifeq ($(HAVE_BUILDDEFS), yes)
39 LDIRT += $(SRCTAR)
40 endif
41
42 LIB_SUBDIRS = include lib
43 TOOL_SUBDIRS = ltp src m4 common
44
45 SUBDIRS = $(LIB_SUBDIRS) $(TOOL_SUBDIRS) $(TESTS_DIR)
46
47 default: include/builddefs
48 ifeq ($(HAVE_BUILDDEFS), no)
49         $(Q)$(MAKE) $(MAKEOPTS) $@
50 else
51         $(Q)$(MAKE) $(MAKEOPTS) $(SUBDIRS)
52 endif
53
54 # tool/lib dependencies
55 $(TOOL_SUBDIRS): $(LIB_SUBDIRS)
56
57 ifeq ($(HAVE_BUILDDEFS), yes)
58 include $(BUILDRULES)
59 else
60 clean:  # if configure hasn't run, nothing to clean
61 endif
62
63 configure: configure.ac
64         libtoolize -cfi
65         cp include/install-sh .
66         aclocal -I m4
67         autoheader
68         autoconf
69
70 include/builddefs include/config.h: configure
71         ./configure \
72                 --libexecdir=/usr/lib \
73                 --exec_prefix=/var/lib
74
75 aclocal.m4::
76         aclocal --acdir=`pwd`/m4 --output=$@
77
78 depend: include/builddefs $(addsuffix -depend,$(SUBDIRS))
79
80 install: default $(addsuffix -install,$(SUBDIRS))
81         $(INSTALL) -m 755 -d $(PKG_LIB_DIR)
82         $(INSTALL) -m 755 check $(PKG_LIB_DIR)
83         $(INSTALL) -m 644 randomize.awk $(PKG_LIB_DIR)
84
85 # Nothing.
86 install-dev install-lib:
87
88 %-install:
89         $(MAKE) $(MAKEOPTS) -C $* install
90
91 realclean distclean: clean
92         $(Q)rm -f $(LDIRT) $(CONFIGURE)
93         $(Q)rm -rf autom4te.cache Logs
94
95 dist: include/builddefs include/config.h default
96 ifeq ($(HAVE_BUILDDEFS), no)
97         $(Q)$(MAKE) $(MAKEOPTS) -C . $@
98 else
99         $(Q)$(MAKE) $(MAKEOPTS) $(SRCTAR)
100 endif
101
102 $(SRCTAR) : default
103         $(Q)git archive --prefix=$(PKG_NAME)-$(PKG_VERSION)/ --format=tar \
104           v$(PKG_VERSION) > $(PKG_NAME)-$(PKG_VERSION).tar
105         $(Q)$(TAR) --transform "s,^,$(PKG_NAME)-$(PKG_VERSION)/," \
106           -rf $(PKG_NAME)-$(PKG_VERSION).tar $(CONFIGURE)
107         $(Q)$(ZIP) $(PKG_NAME)-$(PKG_VERSION).tar
108         echo Wrote: $@