btrfs-progs: tests: add correct rpath to library-test
[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
102 cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \
103                cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \
104                cmds-quota.o cmds-qgroup.o cmds-replace.o cmds-check.o \
105                cmds-restore.o cmds-rescue.o chunk-recover.o super-recover.o \
106                cmds-property.o cmds-fi-usage.o cmds-inspect-dump-tree.o \
107                cmds-inspect-dump-super.o cmds-inspect-tree-stats.o cmds-fi-du.o
108 libbtrfs_objects = send-stream.o send-utils.o kernel-lib/rbtree.o btrfs-list.o \
109                    kernel-lib/crc32c.o \
110                    uuid-tree.o utils-lib.o rbtree-utils.o
111 libbtrfs_headers = send-stream.h send-utils.h send.h kernel-lib/rbtree.h btrfs-list.h \
112                kernel-lib/crc32c.h kernel-lib/list.h kerncompat.h \
113                kernel-lib/radix-tree.h extent-cache.h \
114                extent_io.h ioctl.h ctree.h btrfsck.h version.h
115 TESTS = fsck-tests.sh convert-tests.sh
116
117 udev_rules = 64-btrfs-dm.rules
118
119 prefix ?= @prefix@
120 exec_prefix = @exec_prefix@
121 bindir = @bindir@
122 libdir ?= @libdir@
123 incdir = @includedir@/btrfs
124 udevdir = @UDEVDIR@
125 udevruledir = ${udevdir}/rules.d
126
127 ifeq ("$(origin V)", "command line")
128   BUILD_VERBOSE = $(V)
129 endif
130 ifndef BUILD_VERBOSE
131   BUILD_VERBOSE = 0
132 endif
133
134 ifeq ($(BUILD_VERBOSE),1)
135   Q =
136 else
137   Q = @
138 endif
139
140 ifeq ("$(origin D)", "command line")
141   DEBUG_CFLAGS_INTERNAL = $(DEBUG_CFLAGS_DEFAULT) $(DEBUG_CFLAGS)
142 endif
143
144 ifneq (,$(findstring verbose,$(D)))
145   DEBUG_CFLAGS_INTERNAL += -DDEBUG_VERBOSE_ERROR=1
146 endif
147
148 ifneq (,$(findstring trace,$(D)))
149   DEBUG_CFLAGS_INTERNAL += -DDEBUG_TRACE_ON_ERROR=1
150 endif
151
152 ifneq (,$(findstring abort,$(D)))
153   DEBUG_CFLAGS_INTERNAL += -DDEBUG_ABORT_ON_ERROR=1
154 endif
155
156 ifneq (,$(findstring all,$(D)))
157   DEBUG_CFLAGS_INTERNAL += -DDEBUG_VERBOSE_ERROR=1
158   DEBUG_CFLAGS_INTERNAL += -DDEBUG_TRACE_ON_ERROR=1
159   DEBUG_CFLAGS_INTERNAL += -DDEBUG_ABORT_ON_ERROR=1
160 endif
161
162 ifneq (,$(findstring asan,$(D)))
163   DEBUG_CFLAGS_INTERNAL += -fsanitize=address
164 endif
165
166 ifneq (,$(findstring ubsan,$(D)))
167   DEBUG_CFLAGS_INTERNAL += -fsanitize=undefined
168 endif
169
170 ifneq (,$(findstring bcheck,$(D)))
171   DEBUG_CFLAGS_INTERNAL += -DDEBUG_BUILD_CHECKS
172 endif
173
174 MAKEOPTS = --no-print-directory Q=$(Q)
175
176 # build all by default
177 progs = $(progs_install) btrfsck btrfs-corrupt-block
178
179 # install only selected
180 progs_install = btrfs mkfs.btrfs btrfs-debug-tree \
181         btrfs-map-logical btrfs-image btrfs-zero-log \
182         btrfs-find-root btrfstune \
183         btrfs-select-super
184
185 # other tools, not built by default
186 progs_extra = btrfs-fragments btrfs-calc-size btrfs-show-super
187
188 progs_static = $(foreach p,$(progs),$(p).static)
189
190 ifneq ($(DISABLE_BTRFSCONVERT),1)
191 progs_install += btrfs-convert
192 endif
193
194 # external libs required by various binaries; for btrfs-foo,
195 # specify btrfs_foo_libs = <list of libs>; see $($(subst...)) rules below
196 btrfs_convert_libs = @EXT2FS_LIBS@ @COM_ERR_LIBS@
197 btrfs_convert_cflags = -DBTRFSCONVERT_EXT2=$(BTRFSCONVERT_EXT2)
198 btrfs_fragments_libs = -lgd -lpng -ljpeg -lfreetype
199 btrfs_debug_tree_objects = cmds-inspect-dump-tree.o
200 btrfs_show_super_objects = cmds-inspect-dump-super.o
201 btrfs_calc_size_objects = cmds-inspect-tree-stats.o
202
203 # collect values of the variables above
204 standalone_deps = $(foreach dep,$(patsubst %,%_objects,$(subst -,_,$(filter btrfs-%, $(progs)))),$($(dep)))
205
206 SUBDIRS =
207 BUILDDIRS = $(patsubst %,build-%,$(SUBDIRS))
208 INSTALLDIRS = $(patsubst %,install-%,$(SUBDIRS))
209 CLEANDIRS = $(patsubst %,clean-%,$(SUBDIRS))
210
211 ifneq ($(DISABLE_DOCUMENTATION),1)
212 BUILDDIRS += build-Documentation
213 INSTALLDIRS += install-Documentation
214 endif
215
216 .PHONY: $(SUBDIRS)
217 .PHONY: $(BUILDDIRS)
218 .PHONY: $(INSTALLDIRS)
219 .PHONY: $(TESTDIRS)
220 .PHONY: $(CLEANDIRS)
221 .PHONY: all install clean
222
223 # Create all the static targets
224 static_objects = $(patsubst %.o, %.static.o, $(objects))
225 static_cmds_objects = $(patsubst %.o, %.static.o, $(cmds_objects))
226 static_libbtrfs_objects = $(patsubst %.o, %.static.o, $(libbtrfs_objects))
227
228 libs_shared = libbtrfs.so.0.1
229 libs_static = libbtrfs.a
230 libs = $(libs_shared) $(libs_static)
231 lib_links = libbtrfs.so.0 libbtrfs.so
232 headers = $(libbtrfs_headers)
233
234 # make C=1 to enable sparse
235 ifdef C
236         # We're trying to use sparse against glibc headers which go wild
237         # trying to use internal compiler macros to test features.  We
238         # copy gcc's and give them to sparse.  But not __SIZE_TYPE__
239         # 'cause sparse defines that one.
240         #
241         dummy := $(shell $(CC) -dM -E -x c - < /dev/null | \
242                         grep -v __SIZE_TYPE__ > $(check_defs))
243         check = $(CHECKER)
244         check_echo = echo
245 else
246         check = true
247         check_echo = true
248 endif
249
250 %.o.d: %.c
251         $(Q)$(CC) -MD -MM -MG -MF $@ -MT $(@:.o.d=.o) -MT $(@:.o.d=.static.o) -MT $@ $(CFLAGS) $<
252
253 #
254 # Pick from per-file variables, btrfs_*_cflags
255 #
256 .c.o:
257         @$(check_echo) "    [SP]     $<"
258         $(Q)$(check) $(CFLAGS) $(CHECKER_FLAGS) $<
259         @echo "    [CC]     $@"
260         $(Q)$(CC) $(CFLAGS) -c $< -o $@ $($(subst -,_,$(@:%.o=%)-cflags))
261
262 %.static.o: %.c
263         @echo "    [CC]     $@"
264         $(Q)$(CC) $(STATIC_CFLAGS) -c $< -o $@ $($(subst -,_,$(@:%.static.o=%)-cflags))
265
266 all: $(progs) $(BUILDDIRS)
267 $(SUBDIRS): $(BUILDDIRS)
268 $(BUILDDIRS):
269         @echo "Making all in $(patsubst build-%,%,$@)"
270         $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst build-%,%,$@)
271
272 test-convert: btrfs btrfs-convert
273         @echo "    [TEST]   convert-tests.sh"
274         $(Q)bash tests/convert-tests.sh
275
276 test-check: test-fsck
277 test-fsck: btrfs btrfs-image btrfs-corrupt-block btrfs-debug-tree mkfs.btrfs
278         @echo "    [TEST]   fsck-tests.sh"
279         $(Q)bash tests/fsck-tests.sh
280
281 test-misc: btrfs btrfs-image btrfs-corrupt-block btrfs-debug-tree mkfs.btrfs btrfstune
282         @echo "    [TEST]   misc-tests.sh"
283         $(Q)bash tests/misc-tests.sh
284
285 test-mkfs: btrfs mkfs.btrfs
286         @echo "    [TEST]   mkfs-tests.sh"
287         $(Q)bash tests/mkfs-tests.sh
288
289 test-fuzz: btrfs
290         @echo "    [TEST]   fuzz-tests.sh"
291         $(Q)bash tests/fuzz-tests.sh
292
293 test-cli: btrfs
294         @echo "    [TEST]   cli-tests.sh"
295         $(Q)bash tests/cli-tests.sh
296
297 test-clean:
298         @echo "Cleaning tests"
299         $(Q)bash tests/clean-tests.sh
300
301 test-inst: all
302         @tmpdest=`mktemp --tmpdir -d btrfs-inst.XXXXXX` && \
303                 echo "Test installation to $$tmpdest" && \
304                 $(MAKE) DESTDIR=$$tmpdest install && \
305                 $(RM) -rf -- $$tmpdest
306
307 test: test-fsck test-mkfs test-convert test-misc test-fuzz test-cli
308
309 #
310 # NOTE: For static compiles, you need to have all the required libs
311 #       static equivalent available
312 #
313 static: $(progs_static)
314
315 version.h: version.sh version.h.in configure.ac
316         @echo "    [SH]     $@"
317         $(Q)bash ./config.status --silent $@
318
319 $(libs_shared): $(libbtrfs_objects) $(lib_links) send.h
320         @echo "    [LD]     $@"
321         $(Q)$(CC) $(CFLAGS) $(libbtrfs_objects) $(LDFLAGS) $(LIBBTRFS_LIBS) \
322                 -shared -Wl,-soname,libbtrfs.so.0 -o libbtrfs.so.0.1
323
324 $(libs_static): $(libbtrfs_objects)
325         @echo "    [AR]     $@"
326         $(Q)$(AR) cr libbtrfs.a $(libbtrfs_objects)
327
328 $(lib_links):
329         @echo "    [LN]     $@"
330         $(Q)$(LN_S) -f libbtrfs.so.0.1 $@
331
332 # keep intermediate files from the below implicit rules around
333 .PRECIOUS: $(addsuffix .o,$(progs))
334
335 # Make any btrfs-foo out of btrfs-foo.o, with appropriate libs.
336 # The $($(subst...)) bits below takes the btrfs_*_libs definitions above and
337 # turns them into a list of libraries to link against if they exist
338 #
339 # For static variants, use an extra $(subst) to get rid of the ".static"
340 # from the target name before translating to list of libs
341
342 btrfs-%.static: $(static_objects) btrfs-%.static.o $(static_libbtrfs_objects) $(patsubst %.o,%.static.o,$(standalone_deps))
343         @echo "    [LD]     $@"
344         $(Q)$(CC) $(STATIC_CFLAGS) -o $@ $@.o $(static_objects) \
345                 $(patsubst %.o, %.static.o, $($(subst -,_,$(subst .static,,$@)-objects))) \
346                 $(static_libbtrfs_objects) $(STATIC_LDFLAGS) \
347                 $($(subst -,_,$(subst .static,,$@)-libs)) $(STATIC_LIBS)
348
349 btrfs-%: $(objects) $(libs_static) btrfs-%.o $(standalone_deps)
350         @echo "    [LD]     $@"
351         $(Q)$(CC) $(CFLAGS) -o $@ $(objects) $@.o \
352                 $($(subst -,_,$@-objects)) \
353                 $(libs_static) \
354                 $(LDFLAGS) $(LIBS) $($(subst -,_,$@-libs))
355
356 btrfs: $(objects) btrfs.o $(cmds_objects) $(libs_static)
357         @echo "    [LD]     $@"
358         $(Q)$(CC) $(CFLAGS) -o btrfs btrfs.o $(cmds_objects) \
359                 $(objects) $(libs_static) $(LDFLAGS) $(LIBS)
360
361 btrfs.static: $(static_objects) btrfs.static.o $(static_cmds_objects) $(static_libbtrfs_objects)
362         @echo "    [LD]     $@"
363         $(Q)$(CC) $(STATIC_CFLAGS) -o btrfs.static btrfs.static.o $(static_cmds_objects) \
364                 $(static_objects) $(static_libbtrfs_objects) $(STATIC_LDFLAGS) $(STATIC_LIBS)
365
366 # For backward compatibility, 'btrfs' changes behaviour to fsck if it's named 'btrfsck'
367 btrfsck: btrfs
368         @echo "    [LN]     $@"
369         $(Q)$(LN_S) -f btrfs btrfsck
370
371 btrfsck.static: btrfs.static
372         @echo "    [LN]     $@"
373         $(Q)$(LN_S) -f $^ $@
374
375 mkfs.btrfs: $(objects) $(libs_static) mkfs.o
376         @echo "    [LD]     $@"
377         $(Q)$(CC) $(CFLAGS) -o mkfs.btrfs $(objects) $(libs_static) mkfs.o $(LDFLAGS) $(LIBS)
378
379 mkfs.btrfs.static: $(static_objects) mkfs.static.o $(static_libbtrfs_objects)
380         @echo "    [LD]     $@"
381         $(Q)$(CC) $(STATIC_CFLAGS) -o mkfs.btrfs.static mkfs.static.o $(static_objects) \
382                 $(static_libbtrfs_objects) $(STATIC_LDFLAGS) $(STATIC_LIBS)
383
384 btrfstune: $(objects) $(libs_static) btrfstune.o
385         @echo "    [LD]     $@"
386         $(Q)$(CC) $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(libs_static) $(LDFLAGS) $(LIBS)
387
388 btrfstune.static: $(static_objects) btrfstune.static.o $(static_libbtrfs_objects)
389         @echo "    [LD]     $@"
390         $(Q)$(CC) $(STATIC_CFLAGS) -o $@ btrfstune.static.o $(static_objects) \
391                 $(static_libbtrfs_objects) $(STATIC_LDFLAGS) $(STATIC_LIBS)
392
393 btrfs-image: $(objects) $(libs_static) image/main.o
394         @echo "    [LD]     $@"
395         $(Q)$(CC) $(CFLAGS) -I$(TOPDIR)/image -o btrfs-image $(objects) image/main.o $(libs_static) $(LDFLAGS) $(LIBS)
396
397 btrfs-image.static: $(static_objects) image/main.static.o $(static_libbtrfs_objects)
398         @echo "    [LD]     $@"
399         $(Q)$(CC) $(STATIC_CFLAGS) -o $@ image/main.static.o $(static_objects) \
400                 $(static_libbtrfs_objects) $(STATIC_LDFLAGS) $(STATIC_LIBS)
401
402 dir-test: $(objects) $(libs) dir-test.o
403         @echo "    [LD]     $@"
404         $(Q)$(CC) $(CFLAGS) -o dir-test $(objects) $(libs) dir-test.o $(LDFLAGS) $(LIBS)
405
406 quick-test: $(objects) $(libs) quick-test.o
407         @echo "    [LD]     $@"
408         $(Q)$(CC) $(CFLAGS) -o quick-test $(objects) $(libs) quick-test.o $(LDFLAGS) $(LIBS)
409
410 ioctl-test.o: ioctl-test.c ioctl.h kerncompat.h ctree.h
411         @echo "    [CC]   $@"
412         $(Q)$(CC) $(CFLAGS) -c $< -o $@
413
414 ioctl-test-32.o: ioctl-test.c ioctl.h kerncompat.h ctree.h
415         @echo "    [CC32]   $@"
416         $(Q)$(CC) $(CFLAGS) -m32 -c $< -o $@
417
418 ioctl-test-64.o: ioctl-test.c ioctl.h kerncompat.h ctree.h
419         @echo "    [CC64]   $@"
420         $(Q)$(CC) $(CFLAGS) -m64 -c $< -o $@
421
422 ioctl-test: ioctl-test.o
423         @echo "    [LD]   $@"
424         $(Q)$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
425         @echo "   ?[PAHOLE] $@.pahole"
426         -$(Q)pahole $@ > $@.pahole
427
428 ioctl-test-32: ioctl-test-32.o
429         @echo "    [LD32]   $@"
430         $(Q)$(CC) $(CFLAGS) -m32 -o $@ $< $(LDFLAGS)
431         @echo "   ?[PAHOLE] $@.pahole"
432         -$(Q)pahole $@ > $@.pahole
433
434 ioctl-test-64: ioctl-test-64.o
435         @echo "    [LD64]   $@"
436         $(Q)$(CC) $(CFLAGS) -m64 -o $@ $< $(LDFLAGS)
437         @echo "   ?[PAHOLE] $@.pahole"
438         -$(Q)pahole $@ > $@.pahole
439
440 test-ioctl: ioctl-test ioctl-test-32 ioctl-test-64
441         @echo "    [TEST/ioctl]"
442         $(Q)./ioctl-test > ioctl-test.log
443         $(Q)./ioctl-test-32 > ioctl-test-32.log
444         $(Q)./ioctl-test-64 > ioctl-test-64.log
445
446 library-test: $(libs_shared) library-test.o
447         @echo "    [LD]     $@"
448         $(Q)$(CC) $(CFLAGS) -o library-test library-test.o $(LDFLAGS) -Wl,-rpath=$(TOPDIR) -lbtrfs
449         @echo "    [TEST]   $@"
450         $(Q)./$@
451
452 library-test.static: $(libs_static) library-test.o
453         @echo "    [LD]     $@"
454         $(Q)$(CC) $(CFLAGS) -o library-test-static library-test.o $(LDFLAGS) $(libs_static)
455         @echo "    [TEST]   $@"
456         $(Q)./$@
457
458 test-build: test-build-pre test-build-real
459
460 test-build-pre:
461         $(MAKE) clean-all
462         ./autogen.sh
463         ./configure
464
465 test-build-real:
466         $(MAKE) library-test
467         -$(MAKE) library-test.static
468         $(MAKE) -j 8 all
469         -$(MAKE) -j 8 static
470         $(MAKE) -j 8 $(progs_extra)
471
472 manpages:
473         $(Q)$(MAKE) $(MAKEOPTS) -C Documentation
474
475
476 clean-all: clean clean-doc clean-gen
477
478 clean: $(CLEANDIRS)
479         @echo "Cleaning"
480         $(Q)$(RM) -f -- $(progs) cscope.out *.o *.o.d \
481                 kernel-lib/*.o kernel-lib/*.o.d \
482                 image/*.o image/*.o.d \
483               dir-test ioctl-test quick-test library-test library-test-static \
484               btrfs.static mkfs.btrfs.static \
485               $(check_defs) \
486               $(libs) $(lib_links) \
487               $(progs_static) $(progs_extra)
488
489 clean-doc:
490         @echo "Cleaning Documentation"
491         $(Q)$(MAKE) $(MAKEOPTS) -C Documentation clean
492
493 clean-gen:
494         @echo "Cleaning Generated Files"
495         $(Q)$(RM) -rf -- version.h config.status config.cache connfig.log \
496                 configure.lineno config.status.lineno Makefile \
497                 Documentation/Makefile \
498                 config.log config.h config.h.in~ aclocal.m4 \
499                 configure autom4te.cache/ config/
500
501 $(CLEANDIRS):
502         @echo "Cleaning $(patsubst clean-%,%,$@)"
503         $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst clean-%,%,$@) clean
504
505 install: $(libs) $(progs_install) $(INSTALLDIRS)
506         $(INSTALL) -m755 -d $(DESTDIR)$(bindir)
507         $(INSTALL) $(progs_install) $(DESTDIR)$(bindir)
508         $(INSTALL) fsck.btrfs $(DESTDIR)$(bindir)
509         # btrfsck is a link to btrfs in the src tree, make it so for installed file as well
510         $(LN_S) -f btrfs $(DESTDIR)$(bindir)/btrfsck
511         $(INSTALL) -m755 -d $(DESTDIR)$(libdir)
512         $(INSTALL) $(libs) $(DESTDIR)$(libdir)
513         cp -a $(lib_links) $(DESTDIR)$(libdir)
514         $(INSTALL) -m755 -d $(DESTDIR)$(incdir)
515         $(INSTALL) -m644 $(headers) $(DESTDIR)$(incdir)
516 ifneq ($(udevdir),)
517         $(INSTALL) -m755 -d $(DESTDIR)$(udevruledir)
518         $(INSTALL) -m644 $(udev_rules) $(DESTDIR)$(udevruledir)
519 endif
520
521 install-static: $(progs_static) $(INSTALLDIRS)
522         $(INSTALL) -m755 -d $(DESTDIR)$(bindir)
523         $(INSTALL) $(progs_static) $(DESTDIR)$(bindir)
524         # btrfsck is a link to btrfs in the src tree, make it so for installed file as well
525         $(LN_S) -f btrfs.static $(DESTDIR)$(bindir)/btrfsck.static
526
527 $(INSTALLDIRS):
528         @echo "Making install in $(patsubst install-%,%,$@)"
529         $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst install-%,%,$@) install
530
531 uninstall:
532         $(Q)$(MAKE) $(MAKEOPTS) -C Documentation uninstall
533         cd $(DESTDIR)$(incdir); $(RM) -f -- $(headers)
534         $(RMDIR) -p --ignore-fail-on-non-empty -- $(DESTDIR)$(incdir)
535         cd $(DESTDIR)$(libdir); $(RM) -f -- $(lib_links) $(libs)
536         cd $(DESTDIR)$(bindir); $(RM) -f -- btrfsck fsck.btrfs $(progs_install)
537
538 ifneq ($(MAKECMDGOALS),clean)
539 -include $(objects:.o=.o.d) $(cmds_objects:.o=.o.d) $(subst .btrfs,, $(filter-out btrfsck.o.d, $(progs:=.o.d)))
540 endif