btrfs-progs: convert: move implementation for interal conversion API to own file
[platform/upstream/btrfs-progs.git] / Makefile.in
1 # btrfs-progs
2 #
3 # Basic build targets:
4 #   all         all main tools
5 #   static      build static bnaries, requires static version of the libraries
6 #   test        run the full testsuite
7 #   install     install to default location (/usr/local)
8 #   clean       clean built binaries (not the documentation)
9 #   clean-all   clean as above, clean docs and generated files
10 #
11 # Tuning by variables (environment or make arguments):
12 #   V=1            verbose, print command lines (default: quiet)
13 #   C=1            run checker before compilation (default checker: sparse)
14 #   D=1            debugging build, turn off optimizations
15 #   D=dflags       dtto, turn on additional debugging features:
16 #                  verbose - print file:line along with error/warning messages
17 #                  trace   - print trace before the error/warning messages
18 #                  abort   - call abort() on first error (dumps core)
19 #                  all     - shortcut for all of the above
20 #                  asan    - enable address sanitizer compiler feature
21 #                  ubsan   - undefined behaviour sanitizer compiler feature
22 #                  bcheck  - extended build checks
23 #   W=123          build with warnings (default: off)
24 #   DEBUG_CFLAGS   additional compiler flags for debugging build
25 #   EXTRA_CFLAGS   additional compiler flags
26 #   EXTRA_LDFLAGS  additional linker flags
27 #
28 # Testing-specific options (see also tests/README.md):
29 #   TEST=GLOB      run test(s) from directories matching GLOB
30 #   TEST_LOG=tty   print name of a command run via the execution helpers
31 #   TEST_LOG=dump  dump testing log file when a test fails
32 #
33 # Static checkers:
34 #   CHECKER        static checker binary to be called (default: sparse)
35 #   CHECKER_FLAGS  flags to pass to CHECKER, can override CFLAGS
36 #
37
38 # Export all variables to sub-makes by default
39 export
40
41 include Makefile.extrawarn
42
43 CC = @CC@
44 LN_S = @LN_S@
45 AR = @AR@
46 RM = @RM@
47 RMDIR = @RMDIR@
48 INSTALL = @INSTALL@
49 DISABLE_DOCUMENTATION = @DISABLE_DOCUMENTATION@
50 DISABLE_BTRFSCONVERT = @DISABLE_BTRFSCONVERT@
51 BTRFSCONVERT_EXT2 = @BTRFSCONVERT_EXT2@
52
53 EXTRA_CFLAGS :=
54 EXTRA_LDFLAGS :=
55
56 DEBUG_CFLAGS_DEFAULT = -O0 -U_FORTIFY_SOURCE -ggdb3
57 DEBUG_CFLAGS_INTERNAL =
58 DEBUG_CFLAGS :=
59
60 TOPDIR := $(shell pwd)
61
62 # Common build flags
63 CFLAGS = @CFLAGS@ \
64          -include config.h \
65          -DBTRFS_FLAT_INCLUDES \
66          -D_XOPEN_SOURCE=700  \
67          -fno-strict-aliasing \
68          -fPIC \
69          -I$(TOPDIR) \
70          -I$(TOPDIR)/kernel-lib \
71          $(EXTRAWARN_CFLAGS) \
72          $(DEBUG_CFLAGS_INTERNAL) \
73          $(EXTRA_CFLAGS)
74
75 LDFLAGS = @LDFLAGS@ \
76           -rdynamic -L$(TOPDIR) $(EXTRA_LDFLAGS)
77
78 LIBS = @UUID_LIBS@ @BLKID_LIBS@ @ZLIB_LIBS@ @LZO2_LIBS@ -L. -pthread
79 LIBBTRFS_LIBS = $(LIBS)
80
81 # Static compilation flags
82 STATIC_CFLAGS = $(CFLAGS) -ffunction-sections -fdata-sections
83 STATIC_LDFLAGS = -static -Wl,--gc-sections
84 STATIC_LIBS = @UUID_LIBS_STATIC@ @BLKID_LIBS_STATIC@ \
85               @ZLIB_LIBS_STATIC@ @LZO2_LIBS_STATIC@ -L. -pthread
86
87 # don't use FORTIFY with sparse because glibc with FORTIFY can
88 # generate so many sparse errors that sparse stops parsing,
89 # which masks real errors that we want to see.
90 CHECKER := sparse
91 check_defs := .cc-defines.h
92 CHECKER_FLAGS := -include $(check_defs) -D__CHECKER__ \
93         -D__CHECK_ENDIAN__ -Wbitwise -Wuninitialized -Wshadow -Wundef \
94         -U_FORTIFY_SOURCE
95
96 objects = ctree.o disk-io.o kernel-lib/radix-tree.o extent-tree.o print-tree.o \
97           root-tree.o dir-item.o file-item.o inode-item.o inode-map.o \
98           extent-cache.o extent_io.o volumes.o utils.o repair.o \
99           qgroup.o raid56.o free-space-cache.o kernel-lib/list_sort.o props.o \
100           ulist.o qgroup-verify.o backref.o string-table.o task-utils.o \
101           inode.o file.o find-root.o free-space-tree.o help.o send-dump.o \
102           fsfeatures.o
103 cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \
104                cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \
105                cmds-quota.o cmds-qgroup.o cmds-replace.o cmds-check.o \
106                cmds-restore.o cmds-rescue.o chunk-recover.o super-recover.o \
107                cmds-property.o cmds-fi-usage.o cmds-inspect-dump-tree.o \
108                cmds-inspect-dump-super.o cmds-inspect-tree-stats.o cmds-fi-du.o
109 libbtrfs_objects = send-stream.o send-utils.o kernel-lib/rbtree.o btrfs-list.o \
110                    kernel-lib/crc32c.o \
111                    uuid-tree.o utils-lib.o rbtree-utils.o
112 libbtrfs_headers = send-stream.h send-utils.h send.h kernel-lib/rbtree.h btrfs-list.h \
113                kernel-lib/crc32c.h kernel-lib/list.h kerncompat.h \
114                kernel-lib/radix-tree.h extent-cache.h \
115                extent_io.h ioctl.h ctree.h btrfsck.h version.h
116 TESTS = fsck-tests.sh convert-tests.sh
117
118 udev_rules = 64-btrfs-dm.rules
119
120 prefix ?= @prefix@
121 exec_prefix = @exec_prefix@
122 bindir = @bindir@
123 libdir ?= @libdir@
124 incdir = @includedir@/btrfs
125 udevdir = @UDEVDIR@
126 udevruledir = ${udevdir}/rules.d
127
128 ifeq ("$(origin V)", "command line")
129   BUILD_VERBOSE = $(V)
130 endif
131 ifndef BUILD_VERBOSE
132   BUILD_VERBOSE = 0
133 endif
134
135 ifeq ($(BUILD_VERBOSE),1)
136   Q =
137 else
138   Q = @
139 endif
140
141 ifeq ("$(origin D)", "command line")
142   DEBUG_CFLAGS_INTERNAL = $(DEBUG_CFLAGS_DEFAULT) $(DEBUG_CFLAGS)
143 endif
144
145 ifneq (,$(findstring verbose,$(D)))
146   DEBUG_CFLAGS_INTERNAL += -DDEBUG_VERBOSE_ERROR=1
147 endif
148
149 ifneq (,$(findstring trace,$(D)))
150   DEBUG_CFLAGS_INTERNAL += -DDEBUG_TRACE_ON_ERROR=1
151 endif
152
153 ifneq (,$(findstring abort,$(D)))
154   DEBUG_CFLAGS_INTERNAL += -DDEBUG_ABORT_ON_ERROR=1
155 endif
156
157 ifneq (,$(findstring all,$(D)))
158   DEBUG_CFLAGS_INTERNAL += -DDEBUG_VERBOSE_ERROR=1
159   DEBUG_CFLAGS_INTERNAL += -DDEBUG_TRACE_ON_ERROR=1
160   DEBUG_CFLAGS_INTERNAL += -DDEBUG_ABORT_ON_ERROR=1
161 endif
162
163 ifneq (,$(findstring asan,$(D)))
164   DEBUG_CFLAGS_INTERNAL += -fsanitize=address
165 endif
166
167 ifneq (,$(findstring ubsan,$(D)))
168   DEBUG_CFLAGS_INTERNAL += -fsanitize=undefined
169 endif
170
171 ifneq (,$(findstring bcheck,$(D)))
172   DEBUG_CFLAGS_INTERNAL += -DDEBUG_BUILD_CHECKS
173 endif
174
175 MAKEOPTS = --no-print-directory Q=$(Q)
176
177 # build all by default
178 progs = $(progs_install) btrfsck btrfs-corrupt-block
179
180 # install only selected
181 progs_install = btrfs mkfs.btrfs btrfs-debug-tree \
182         btrfs-map-logical btrfs-image btrfs-zero-log \
183         btrfs-find-root btrfstune \
184         btrfs-select-super
185
186 # other tools, not built by default
187 progs_extra = btrfs-fragments btrfs-calc-size btrfs-show-super
188
189 progs_static = $(foreach p,$(progs),$(p).static)
190
191 ifneq ($(DISABLE_BTRFSCONVERT),1)
192 progs_install += btrfs-convert
193 endif
194
195 # external libs required by various binaries; for btrfs-foo,
196 # specify btrfs_foo_libs = <list of libs>; see $($(subst...)) rules below
197 btrfs_convert_libs = @EXT2FS_LIBS@ @COM_ERR_LIBS@
198 btrfs_convert_cflags = -DBTRFSCONVERT_EXT2=$(BTRFSCONVERT_EXT2)
199 btrfs_fragments_libs = -lgd -lpng -ljpeg -lfreetype
200 btrfs_debug_tree_objects = cmds-inspect-dump-tree.o
201 btrfs_show_super_objects = cmds-inspect-dump-super.o
202 btrfs_calc_size_objects = cmds-inspect-tree-stats.o
203
204 # collect values of the variables above
205 standalone_deps = $(foreach dep,$(patsubst %,%_objects,$(subst -,_,$(filter btrfs-%, $(progs)))),$($(dep)))
206
207 SUBDIRS =
208 BUILDDIRS = $(patsubst %,build-%,$(SUBDIRS))
209 INSTALLDIRS = $(patsubst %,install-%,$(SUBDIRS))
210 CLEANDIRS = $(patsubst %,clean-%,$(SUBDIRS))
211
212 ifneq ($(DISABLE_DOCUMENTATION),1)
213 BUILDDIRS += build-Documentation
214 INSTALLDIRS += install-Documentation
215 endif
216
217 .PHONY: $(SUBDIRS)
218 .PHONY: $(BUILDDIRS)
219 .PHONY: $(INSTALLDIRS)
220 .PHONY: $(TESTDIRS)
221 .PHONY: $(CLEANDIRS)
222 .PHONY: all install clean
223
224 # Create all the static targets
225 static_objects = $(patsubst %.o, %.static.o, $(objects))
226 static_cmds_objects = $(patsubst %.o, %.static.o, $(cmds_objects))
227 static_libbtrfs_objects = $(patsubst %.o, %.static.o, $(libbtrfs_objects))
228
229 libs_shared = libbtrfs.so.0.1
230 libs_static = libbtrfs.a
231 libs = $(libs_shared) $(libs_static)
232 lib_links = libbtrfs.so.0 libbtrfs.so
233 headers = $(libbtrfs_headers)
234
235 # make C=1 to enable sparse
236 ifdef C
237         # We're trying to use sparse against glibc headers which go wild
238         # trying to use internal compiler macros to test features.  We
239         # copy gcc's and give them to sparse.  But not __SIZE_TYPE__
240         # 'cause sparse defines that one.
241         #
242         dummy := $(shell $(CC) -dM -E -x c - < /dev/null | \
243                         grep -v __SIZE_TYPE__ > $(check_defs))
244         check = $(CHECKER)
245         check_echo = echo
246 else
247         check = true
248         check_echo = true
249 endif
250
251 %.o.d: %.c
252         $(Q)$(CC) -MD -MM -MG -MF $@ -MT $(@:.o.d=.o) -MT $(@:.o.d=.static.o) -MT $@ $(CFLAGS) $<
253
254 #
255 # Pick from per-file variables, btrfs_*_cflags
256 #
257 .c.o:
258         @$(check_echo) "    [SP]     $<"
259         $(Q)$(check) $(CFLAGS) $(CHECKER_FLAGS) $<
260         @echo "    [CC]     $@"
261         $(Q)$(CC) $(CFLAGS) -c $< -o $@ $($(subst -,_,$(@:%.o=%)-cflags)) \
262                 $($(subst -,_,btrfs-$(@:%/$(notdir $@)=%)-cflags))
263
264 %.static.o: %.c
265         @echo "    [CC]     $@"
266         $(Q)$(CC) $(STATIC_CFLAGS) -c $< -o $@ $($(subst -,_,$(@:%.static.o=%)-cflags)) \
267                 $($(subst -,_,btrfs-$(@:%/$(notdir $@)=%)-cflags))
268
269 all: $(progs) $(BUILDDIRS)
270 $(SUBDIRS): $(BUILDDIRS)
271 $(BUILDDIRS):
272         @echo "Making all in $(patsubst build-%,%,$@)"
273         $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst build-%,%,$@)
274
275 test-convert: btrfs btrfs-convert
276         @echo "    [TEST]   convert-tests.sh"
277         $(Q)bash tests/convert-tests.sh
278
279 test-check: test-fsck
280 test-fsck: btrfs btrfs-image btrfs-corrupt-block btrfs-debug-tree mkfs.btrfs
281         @echo "    [TEST]   fsck-tests.sh"
282         $(Q)bash tests/fsck-tests.sh
283
284 test-misc: btrfs btrfs-image btrfs-corrupt-block btrfs-debug-tree mkfs.btrfs btrfstune
285         @echo "    [TEST]   misc-tests.sh"
286         $(Q)bash tests/misc-tests.sh
287
288 test-mkfs: btrfs mkfs.btrfs
289         @echo "    [TEST]   mkfs-tests.sh"
290         $(Q)bash tests/mkfs-tests.sh
291
292 test-fuzz: btrfs
293         @echo "    [TEST]   fuzz-tests.sh"
294         $(Q)bash tests/fuzz-tests.sh
295
296 test-cli: btrfs
297         @echo "    [TEST]   cli-tests.sh"
298         $(Q)bash tests/cli-tests.sh
299
300 test-clean:
301         @echo "Cleaning tests"
302         $(Q)bash tests/clean-tests.sh
303
304 test-inst: all
305         @tmpdest=`mktemp --tmpdir -d btrfs-inst.XXXXXX` && \
306                 echo "Test installation to $$tmpdest" && \
307                 $(MAKE) DESTDIR=$$tmpdest install && \
308                 $(RM) -rf -- $$tmpdest
309
310 test: test-fsck test-mkfs test-convert test-misc test-fuzz test-cli
311
312 #
313 # NOTE: For static compiles, you need to have all the required libs
314 #       static equivalent available
315 #
316 static: $(progs_static)
317
318 version.h: version.sh version.h.in configure.ac
319         @echo "    [SH]     $@"
320         $(Q)bash ./config.status --silent $@
321
322 $(libs_shared): $(libbtrfs_objects) $(lib_links) send.h
323         @echo "    [LD]     $@"
324         $(Q)$(CC) $(CFLAGS) $(libbtrfs_objects) $(LDFLAGS) $(LIBBTRFS_LIBS) \
325                 -shared -Wl,-soname,libbtrfs.so.0 -o libbtrfs.so.0.1
326
327 $(libs_static): $(libbtrfs_objects)
328         @echo "    [AR]     $@"
329         $(Q)$(AR) cr libbtrfs.a $(libbtrfs_objects)
330
331 $(lib_links):
332         @echo "    [LN]     $@"
333         $(Q)$(LN_S) -f libbtrfs.so.0.1 $@
334
335 # keep intermediate files from the below implicit rules around
336 .PRECIOUS: $(addsuffix .o,$(progs))
337
338 # Make any btrfs-foo out of btrfs-foo.o, with appropriate libs.
339 # The $($(subst...)) bits below takes the btrfs_*_libs definitions above and
340 # turns them into a list of libraries to link against if they exist
341 #
342 # For static variants, use an extra $(subst) to get rid of the ".static"
343 # from the target name before translating to list of libs
344
345 btrfs-%.static: $(static_objects) btrfs-%.static.o $(static_libbtrfs_objects) $(patsubst %.o,%.static.o,$(standalone_deps))
346         @echo "    [LD]     $@"
347         $(Q)$(CC) $(STATIC_CFLAGS) -o $@ $@.o $(static_objects) \
348                 $(patsubst %.o, %.static.o, $($(subst -,_,$(subst .static,,$@)-objects))) \
349                 $(static_libbtrfs_objects) $(STATIC_LDFLAGS) \
350                 $($(subst -,_,$(subst .static,,$@)-libs)) $(STATIC_LIBS)
351
352 btrfs-%: $(objects) $(libs_static) btrfs-%.o $(standalone_deps)
353         @echo "    [LD]     $@"
354         $(Q)$(CC) $(CFLAGS) -o $@ $(objects) $@.o \
355                 $($(subst -,_,$@-objects)) \
356                 $(libs_static) \
357                 $(LDFLAGS) $(LIBS) $($(subst -,_,$@-libs))
358
359 btrfs: $(objects) btrfs.o $(cmds_objects) $(libs_static)
360         @echo "    [LD]     $@"
361         $(Q)$(CC) $(CFLAGS) -o btrfs btrfs.o $(cmds_objects) \
362                 $(objects) $(libs_static) $(LDFLAGS) $(LIBS)
363
364 btrfs.static: $(static_objects) btrfs.static.o $(static_cmds_objects) $(static_libbtrfs_objects)
365         @echo "    [LD]     $@"
366         $(Q)$(CC) $(STATIC_CFLAGS) -o btrfs.static btrfs.static.o $(static_cmds_objects) \
367                 $(static_objects) $(static_libbtrfs_objects) $(STATIC_LDFLAGS) $(STATIC_LIBS)
368
369 # For backward compatibility, 'btrfs' changes behaviour to fsck if it's named 'btrfsck'
370 btrfsck: btrfs
371         @echo "    [LN]     $@"
372         $(Q)$(LN_S) -f btrfs btrfsck
373
374 btrfsck.static: btrfs.static
375         @echo "    [LN]     $@"
376         $(Q)$(LN_S) -f $^ $@
377
378 mkfs.btrfs: $(objects) $(libs_static) mkfs/main.o mkfs/common.o
379         @echo "    [LD]     $@"
380         $(Q)$(CC) $(CFLAGS) -o mkfs.btrfs $(objects) $(libs_static) \
381                 mkfs/main.o mkfs/common.o $(LDFLAGS) $(LIBS)
382
383 mkfs.btrfs.static: $(static_objects) mkfs/main.static.o mkfs/common.static.o $(static_libbtrfs_objects)
384         @echo "    [LD]     $@"
385         $(Q)$(CC) $(STATIC_CFLAGS) -o mkfs.btrfs.static \
386                 mkfs/main.static.o mkfs/common.static.o $(static_objects) \
387                 $(static_libbtrfs_objects) $(STATIC_LDFLAGS) $(STATIC_LIBS)
388
389 btrfstune: $(objects) $(libs_static) btrfstune.o
390         @echo "    [LD]     $@"
391         $(Q)$(CC) $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(libs_static) $(LDFLAGS) $(LIBS)
392
393 btrfstune.static: $(static_objects) btrfstune.static.o $(static_libbtrfs_objects)
394         @echo "    [LD]     $@"
395         $(Q)$(CC) $(STATIC_CFLAGS) -o $@ btrfstune.static.o $(static_objects) \
396                 $(static_libbtrfs_objects) $(STATIC_LDFLAGS) $(STATIC_LIBS)
397
398 btrfs-image: $(objects) $(libs_static) image/main.o
399         @echo "    [LD]     $@"
400         $(Q)$(CC) $(CFLAGS) -I$(TOPDIR)/image -o btrfs-image $(objects) image/main.o $(libs_static) $(LDFLAGS) $(LIBS)
401
402 btrfs-image.static: $(static_objects) image/main.static.o $(static_libbtrfs_objects)
403         @echo "    [LD]     $@"
404         $(Q)$(CC) $(STATIC_CFLAGS) -o $@ image/main.static.o $(static_objects) \
405                 $(static_libbtrfs_objects) $(STATIC_LDFLAGS) $(STATIC_LIBS)
406
407 btrfs-convert: $(objects) $(libs_static) convert/main.o convert/common.o convert/source-fs.o convert/source-ext2.o
408         @echo "    [LD]     $@"
409         $(Q)$(CC) $(CFLAGS) -I$(TOPDIR)/convert -o btrfs-convert $(objects) \
410                 convert/main.o convert/common.o convert/source-fs.o convert/source-ext2.o $(libs_static) \
411                 $(LDFLAGS) $(btrfs_convert_libs) $(LIBS)
412
413 btrfs-convert.static: $(static_objects) convert/main.static.o convert/common.static.o \
414                 convert/source-fs.static.o convert/source-ext2.static. o $(static_libbtrfs_objects)
415         @echo "    [LD]     $@"
416         $(Q)$(CC) $(STATIC_CFLAGS) -o $@ convert/main.static.o convert/common.static.o \
417                 convert/source-fs.static.o convert/source-ext2.static.o $(static_objects) \
418                 $(static_libbtrfs_objects) $(STATIC_LDFLAGS) $(btrfs_convert_libs) $(STATIC_LIBS)
419
420 dir-test: $(objects) $(libs) dir-test.o
421         @echo "    [LD]     $@"
422         $(Q)$(CC) $(CFLAGS) -o dir-test $(objects) $(libs) dir-test.o $(LDFLAGS) $(LIBS)
423
424 quick-test: $(objects) $(libs) quick-test.o
425         @echo "    [LD]     $@"
426         $(Q)$(CC) $(CFLAGS) -o quick-test $(objects) $(libs) quick-test.o $(LDFLAGS) $(LIBS)
427
428 ioctl-test.o: ioctl-test.c ioctl.h kerncompat.h ctree.h
429         @echo "    [CC]   $@"
430         $(Q)$(CC) $(CFLAGS) -c $< -o $@
431
432 ioctl-test-32.o: ioctl-test.c ioctl.h kerncompat.h ctree.h
433         @echo "    [CC32]   $@"
434         $(Q)$(CC) $(CFLAGS) -m32 -c $< -o $@
435
436 ioctl-test-64.o: ioctl-test.c ioctl.h kerncompat.h ctree.h
437         @echo "    [CC64]   $@"
438         $(Q)$(CC) $(CFLAGS) -m64 -c $< -o $@
439
440 ioctl-test: ioctl-test.o
441         @echo "    [LD]   $@"
442         $(Q)$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
443         @echo "   ?[PAHOLE] $@.pahole"
444         -$(Q)pahole $@ > $@.pahole
445
446 ioctl-test-32: ioctl-test-32.o
447         @echo "    [LD32]   $@"
448         $(Q)$(CC) $(CFLAGS) -m32 -o $@ $< $(LDFLAGS)
449         @echo "   ?[PAHOLE] $@.pahole"
450         -$(Q)pahole $@ > $@.pahole
451
452 ioctl-test-64: ioctl-test-64.o
453         @echo "    [LD64]   $@"
454         $(Q)$(CC) $(CFLAGS) -m64 -o $@ $< $(LDFLAGS)
455         @echo "   ?[PAHOLE] $@.pahole"
456         -$(Q)pahole $@ > $@.pahole
457
458 test-ioctl: ioctl-test ioctl-test-32 ioctl-test-64
459         @echo "    [TEST/ioctl]"
460         $(Q)./ioctl-test > ioctl-test.log
461         $(Q)./ioctl-test-32 > ioctl-test-32.log
462         $(Q)./ioctl-test-64 > ioctl-test-64.log
463
464 library-test: $(libs_shared) library-test.o
465         @echo "    [LD]     $@"
466         $(Q)$(CC) $(CFLAGS) -o library-test library-test.o $(LDFLAGS) -Wl,-rpath=$(TOPDIR) -lbtrfs
467         @echo "    [TEST]   $@"
468         $(Q)./$@
469
470 library-test.static: $(libs_static) library-test.static.o
471         @echo "    [LD]     $@"
472         $(Q)$(CC) $(STATIC_CFLAGS) -o library-test.static library-test.static.o $(STATIC_LDFLAGS) $(libs_static) $(STATIC_LIBS)
473         @echo "    [TEST]   $@"
474         $(Q)./$@
475
476 test-build: test-build-pre test-build-real
477
478 test-build-pre:
479         $(MAKE) clean-all
480         ./autogen.sh
481         ./configure
482
483 test-build-real:
484         $(MAKE) library-test
485         -$(MAKE) library-test.static
486         $(MAKE) -j 8 all
487         -$(MAKE) -j 8 static
488         $(MAKE) -j 8 $(progs_extra)
489
490 manpages:
491         $(Q)$(MAKE) $(MAKEOPTS) -C Documentation
492
493
494 clean-all: clean clean-doc clean-gen
495
496 clean: $(CLEANDIRS)
497         @echo "Cleaning"
498         $(Q)$(RM) -f -- $(progs) cscope.out *.o *.o.d \
499                 kernel-lib/*.o kernel-lib/*.o.d \
500                 image/*.o image/*.o.d \
501                 convert/*.o convert/*.o.d \
502                 mkfs/*.o mkfs/*.o.d \
503               dir-test ioctl-test quick-test library-test library-test-static \
504               btrfs.static mkfs.btrfs.static \
505               $(check_defs) \
506               $(libs) $(lib_links) \
507               $(progs_static) $(progs_extra)
508
509 clean-doc:
510         @echo "Cleaning Documentation"
511         $(Q)$(MAKE) $(MAKEOPTS) -C Documentation clean
512
513 clean-gen:
514         @echo "Cleaning Generated Files"
515         $(Q)$(RM) -rf -- version.h config.status config.cache connfig.log \
516                 configure.lineno config.status.lineno Makefile \
517                 Documentation/Makefile \
518                 config.log config.h config.h.in~ aclocal.m4 \
519                 configure autom4te.cache/ config/
520
521 $(CLEANDIRS):
522         @echo "Cleaning $(patsubst clean-%,%,$@)"
523         $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst clean-%,%,$@) clean
524
525 install: $(libs) $(progs_install) $(INSTALLDIRS)
526         $(INSTALL) -m755 -d $(DESTDIR)$(bindir)
527         $(INSTALL) $(progs_install) $(DESTDIR)$(bindir)
528         $(INSTALL) fsck.btrfs $(DESTDIR)$(bindir)
529         # btrfsck is a link to btrfs in the src tree, make it so for installed file as well
530         $(LN_S) -f btrfs $(DESTDIR)$(bindir)/btrfsck
531         $(INSTALL) -m755 -d $(DESTDIR)$(libdir)
532         $(INSTALL) $(libs) $(DESTDIR)$(libdir)
533         cp -a $(lib_links) $(DESTDIR)$(libdir)
534         $(INSTALL) -m755 -d $(DESTDIR)$(incdir)
535         $(INSTALL) -m644 $(headers) $(DESTDIR)$(incdir)
536 ifneq ($(udevdir),)
537         $(INSTALL) -m755 -d $(DESTDIR)$(udevruledir)
538         $(INSTALL) -m644 $(udev_rules) $(DESTDIR)$(udevruledir)
539 endif
540
541 install-static: $(progs_static) $(INSTALLDIRS)
542         $(INSTALL) -m755 -d $(DESTDIR)$(bindir)
543         $(INSTALL) $(progs_static) $(DESTDIR)$(bindir)
544         # btrfsck is a link to btrfs in the src tree, make it so for installed file as well
545         $(LN_S) -f btrfs.static $(DESTDIR)$(bindir)/btrfsck.static
546
547 $(INSTALLDIRS):
548         @echo "Making install in $(patsubst install-%,%,$@)"
549         $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst install-%,%,$@) install
550
551 uninstall:
552         $(Q)$(MAKE) $(MAKEOPTS) -C Documentation uninstall
553         cd $(DESTDIR)$(incdir); $(RM) -f -- $(headers)
554         $(RMDIR) -p --ignore-fail-on-non-empty -- $(DESTDIR)$(incdir)
555         cd $(DESTDIR)$(libdir); $(RM) -f -- $(lib_links) $(libs)
556         cd $(DESTDIR)$(bindir); $(RM) -f -- btrfsck fsck.btrfs $(progs_install)
557
558 ifneq ($(MAKECMDGOALS),clean)
559 -include $(objects:.o=.o.d) $(cmds_objects:.o=.o.d) $(subst .btrfs,, $(filter-out btrfsck.o.d, $(progs:=.o.d)))
560 endif