btrfs-progs: add OPEN_CTREE_INVALIDATE_FST flag
[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 $(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 btrfs-calc-size
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 btrfs-show-super \
183         btrfs-select-super
184
185 progs_extra = btrfs-fragments
186
187 progs_static = $(foreach p,$(progs),$(p).static)
188
189 ifneq ($(DISABLE_BTRFSCONVERT),1)
190 progs_install += btrfs-convert
191 endif
192
193 # external libs required by various binaries; for btrfs-foo,
194 # specify btrfs_foo_libs = <list of libs>; see $($(subst...)) rules below
195 btrfs_convert_libs = @EXT2FS_LIBS@ @COM_ERR_LIBS@
196 btrfs_convert_cflags = -DBTRFSCONVERT_EXT2=$(BTRFSCONVERT_EXT2)
197 btrfs_fragments_libs = -lgd -lpng -ljpeg -lfreetype
198 btrfs_debug_tree_objects = cmds-inspect-dump-tree.o
199 btrfs_show_super_objects = cmds-inspect-dump-super.o
200 btrfs_calc_size_objects = cmds-inspect-tree-stats.o
201
202 # collect values of the variables above
203 standalone_deps = $(foreach dep,$(patsubst %,%_objects,$(subst -,_,$(filter btrfs-%, $(progs)))),$($(dep)))
204
205 SUBDIRS =
206 BUILDDIRS = $(patsubst %,build-%,$(SUBDIRS))
207 INSTALLDIRS = $(patsubst %,install-%,$(SUBDIRS))
208 CLEANDIRS = $(patsubst %,clean-%,$(SUBDIRS))
209
210 ifneq ($(DISABLE_DOCUMENTATION),1)
211 BUILDDIRS += build-Documentation
212 INSTALLDIRS += install-Documentation
213 endif
214
215 .PHONY: $(SUBDIRS)
216 .PHONY: $(BUILDDIRS)
217 .PHONY: $(INSTALLDIRS)
218 .PHONY: $(TESTDIRS)
219 .PHONY: $(CLEANDIRS)
220 .PHONY: all install clean
221
222 # Create all the static targets
223 static_objects = $(patsubst %.o, %.static.o, $(objects))
224 static_cmds_objects = $(patsubst %.o, %.static.o, $(cmds_objects))
225 static_libbtrfs_objects = $(patsubst %.o, %.static.o, $(libbtrfs_objects))
226
227 libs_shared = libbtrfs.so.0.1
228 libs_static = libbtrfs.a
229 libs = $(libs_shared) $(libs_static)
230 lib_links = libbtrfs.so.0 libbtrfs.so
231 headers = $(libbtrfs_headers)
232
233 # make C=1 to enable sparse
234 ifdef C
235         # We're trying to use sparse against glibc headers which go wild
236         # trying to use internal compiler macros to test features.  We
237         # copy gcc's and give them to sparse.  But not __SIZE_TYPE__
238         # 'cause sparse defines that one.
239         #
240         dummy := $(shell $(CC) -dM -E -x c - < /dev/null | \
241                         grep -v __SIZE_TYPE__ > $(check_defs))
242         check = $(CHECKER)
243         check_echo = echo
244 else
245         check = true
246         check_echo = true
247 endif
248
249 %.o.d: %.c
250         $(Q)$(CC) -MD -MM -MG -MF $@ -MT $(@:.o.d=.o) -MT $(@:.o.d=.static.o) -MT $@ $(CFLAGS) $<
251
252 #
253 # Pick from per-file variables, btrfs_*_cflags
254 #
255 .c.o:
256         @$(check_echo) "    [SP]     $<"
257         $(Q)$(check) $(CFLAGS) $(CHECKER_FLAGS) $<
258         @echo "    [CC]     $@"
259         $(Q)$(CC) $(CFLAGS) -c $< -o $@ $($(subst -,_,$(@:%.o=%)-cflags))
260
261 %.static.o: %.c
262         @echo "    [CC]     $@"
263         $(Q)$(CC) $(STATIC_CFLAGS) -c $< -o $@ $($(subst -,_,$(@:%.static.o=%)-cflags))
264
265 all: $(progs) $(BUILDDIRS)
266 $(SUBDIRS): $(BUILDDIRS)
267 $(BUILDDIRS):
268         @echo "Making all in $(patsubst build-%,%,$@)"
269         $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst build-%,%,$@)
270
271 test-convert: btrfs btrfs-convert
272         @echo "    [TEST]   convert-tests.sh"
273         $(Q)bash tests/convert-tests.sh
274
275 test-check: test-fsck
276 test-fsck: btrfs btrfs-image btrfs-corrupt-block btrfs-debug-tree mkfs.btrfs
277         @echo "    [TEST]   fsck-tests.sh"
278         $(Q)bash tests/fsck-tests.sh
279
280 test-misc: btrfs btrfs-image btrfs-corrupt-block btrfs-debug-tree mkfs.btrfs btrfstune
281         @echo "    [TEST]   misc-tests.sh"
282         $(Q)bash tests/misc-tests.sh
283
284 test-mkfs: btrfs mkfs.btrfs
285         @echo "    [TEST]   mkfs-tests.sh"
286         $(Q)bash tests/mkfs-tests.sh
287
288 test-fuzz: btrfs
289         @echo "    [TEST]   fuzz-tests.sh"
290         $(Q)bash tests/fuzz-tests.sh
291
292 test-cli: btrfs
293         @echo "    [TEST]   cli-tests.sh"
294         $(Q)bash tests/cli-tests.sh
295
296 test-clean:
297         @echo "Cleaning tests"
298         $(Q)bash tests/clean-tests.sh
299
300 test-inst: all
301         @tmpdest=`mktemp --tmpdir -d btrfs-inst.XXXXXX` && \
302                 echo "Test installation to $$tmpdest" && \
303                 $(MAKE) DESTDIR=$$tmpdest install && \
304                 $(RM) -rf -- $$tmpdest
305
306 test: test-fsck test-mkfs test-convert test-misc test-fuzz
307
308 #
309 # NOTE: For static compiles, you need to have all the required libs
310 #       static equivalent available
311 #
312 static: $(progs_static)
313
314 version.h: version.sh version.h.in configure.ac
315         @echo "    [SH]     $@"
316         $(Q)bash ./config.status --silent $@
317
318 $(libs_shared): $(libbtrfs_objects) $(lib_links) send.h
319         @echo "    [LD]     $@"
320         $(Q)$(CC) $(CFLAGS) $(libbtrfs_objects) $(LDFLAGS) $(LIBBTRFS_LIBS) \
321                 -shared -Wl,-soname,libbtrfs.so.0 -o libbtrfs.so.0.1
322
323 $(libs_static): $(libbtrfs_objects)
324         @echo "    [AR]     $@"
325         $(Q)$(AR) cr libbtrfs.a $(libbtrfs_objects)
326
327 $(lib_links):
328         @echo "    [LN]     $@"
329         $(Q)$(LN_S) -f libbtrfs.so.0.1 $@
330
331 # keep intermediate files from the below implicit rules around
332 .PRECIOUS: $(addsuffix .o,$(progs))
333
334 # Make any btrfs-foo out of btrfs-foo.o, with appropriate libs.
335 # The $($(subst...)) bits below takes the btrfs_*_libs definitions above and
336 # turns them into a list of libraries to link against if they exist
337 #
338 # For static variants, use an extra $(subst) to get rid of the ".static"
339 # from the target name before translating to list of libs
340
341 btrfs-%.static: $(static_objects) btrfs-%.static.o $(static_libbtrfs_objects) $(patsubst %.o,%.static.o,$(standalone_deps))
342         @echo "    [LD]     $@"
343         $(Q)$(CC) $(STATIC_CFLAGS) -o $@ $@.o $(static_objects) \
344                 $(patsubst %.o, %.static.o, $($(subst -,_,$(subst .static,,$@)-objects))) \
345                 $(static_libbtrfs_objects) $(STATIC_LDFLAGS) \
346                 $($(subst -,_,$(subst .static,,$@)-libs)) $(STATIC_LIBS)
347
348 btrfs-%: $(objects) $(libs_static) btrfs-%.o $(standalone_deps)
349         @echo "    [LD]     $@"
350         $(Q)$(CC) $(CFLAGS) -o $@ $(objects) $@.o \
351                 $($(subst -,_,$@-objects)) \
352                 $(libs_static) \
353                 $(LDFLAGS) $(LIBS) $($(subst -,_,$@-libs))
354
355 btrfs: $(objects) btrfs.o $(cmds_objects) $(libs_static)
356         @echo "    [LD]     $@"
357         $(Q)$(CC) $(CFLAGS) -o btrfs btrfs.o $(cmds_objects) \
358                 $(objects) $(libs_static) $(LDFLAGS) $(LIBS)
359
360 btrfs.static: $(static_objects) btrfs.static.o $(static_cmds_objects) $(static_libbtrfs_objects)
361         @echo "    [LD]     $@"
362         $(Q)$(CC) $(STATIC_CFLAGS) -o btrfs.static btrfs.static.o $(static_cmds_objects) \
363                 $(static_objects) $(static_libbtrfs_objects) $(STATIC_LDFLAGS) $(STATIC_LIBS)
364
365 # For backward compatibility, 'btrfs' changes behaviour to fsck if it's named 'btrfsck'
366 btrfsck: btrfs
367         @echo "    [LN]     $@"
368         $(Q)$(LN_S) -f btrfs btrfsck
369
370 btrfsck.static: btrfs.static
371         @echo "    [LN]     $@"
372         $(Q)$(LN_S) -f $^ $@
373
374 mkfs.btrfs: $(objects) $(libs_static) mkfs.o
375         @echo "    [LD]     $@"
376         $(Q)$(CC) $(CFLAGS) -o mkfs.btrfs $(objects) $(libs_static) mkfs.o $(LDFLAGS) $(LIBS)
377
378 mkfs.btrfs.static: $(static_objects) mkfs.static.o $(static_libbtrfs_objects)
379         @echo "    [LD]     $@"
380         $(Q)$(CC) $(STATIC_CFLAGS) -o mkfs.btrfs.static mkfs.static.o $(static_objects) \
381                 $(static_libbtrfs_objects) $(STATIC_LDFLAGS) $(STATIC_LIBS)
382
383 btrfstune: $(objects) $(libs_static) btrfstune.o
384         @echo "    [LD]     $@"
385         $(Q)$(CC) $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(libs_static) $(LDFLAGS) $(LIBS)
386
387 btrfstune.static: $(static_objects) btrfstune.static.o $(static_libbtrfs_objects)
388         @echo "    [LD]     $@"
389         $(Q)$(CC) $(STATIC_CFLAGS) -o $@ btrfstune.static.o $(static_objects) \
390                 $(static_libbtrfs_objects) $(STATIC_LDFLAGS) $(STATIC_LIBS)
391
392 dir-test: $(objects) $(libs) dir-test.o
393         @echo "    [LD]     $@"
394         $(Q)$(CC) $(CFLAGS) -o dir-test $(objects) $(libs) dir-test.o $(LDFLAGS) $(LIBS)
395
396 quick-test: $(objects) $(libs) quick-test.o
397         @echo "    [LD]     $@"
398         $(Q)$(CC) $(CFLAGS) -o quick-test $(objects) $(libs) quick-test.o $(LDFLAGS) $(LIBS)
399
400 ioctl-test.o: ioctl-test.c ioctl.h kerncompat.h ctree.h
401         @echo "    [CC]   $@"
402         $(Q)$(CC) $(CFLAGS) -c $< -o $@
403
404 ioctl-test-32.o: ioctl-test.c ioctl.h kerncompat.h ctree.h
405         @echo "    [CC32]   $@"
406         $(Q)$(CC) $(CFLAGS) -m32 -c $< -o $@
407
408 ioctl-test-64.o: ioctl-test.c ioctl.h kerncompat.h ctree.h
409         @echo "    [CC64]   $@"
410         $(Q)$(CC) $(CFLAGS) -m64 -c $< -o $@
411
412 ioctl-test: ioctl-test.o
413         @echo "    [LD]   $@"
414         $(Q)$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
415         @echo "   ?[PAHOLE] $@.pahole"
416         -$(Q)pahole $@ > $@.pahole
417
418 ioctl-test-32: ioctl-test-32.o
419         @echo "    [LD32]   $@"
420         $(Q)$(CC) $(CFLAGS) -m32 -o $@ $< $(LDFLAGS)
421         @echo "   ?[PAHOLE] $@.pahole"
422         -$(Q)pahole $@ > $@.pahole
423
424 ioctl-test-64: ioctl-test-64.o
425         @echo "    [LD64]   $@"
426         $(Q)$(CC) $(CFLAGS) -m64 -o $@ $< $(LDFLAGS)
427         @echo "   ?[PAHOLE] $@.pahole"
428         -$(Q)pahole $@ > $@.pahole
429
430 test-ioctl: ioctl-test ioctl-test-32 ioctl-test-64
431         @echo "    [TEST/ioctl]"
432         $(Q)./ioctl-test > ioctl-test.log
433         $(Q)./ioctl-test-32 > ioctl-test-32.log
434         $(Q)./ioctl-test-64 > ioctl-test-64.log
435
436 library-test: $(libs_shared) library-test.o
437         @echo "    [LD]     $@"
438         $(Q)$(CC) $(CFLAGS) -o library-test library-test.o $(LDFLAGS) -lbtrfs
439
440 library-test.static: $(libs_static) library-test.o
441         @echo "    [LD]     $@"
442         $(Q)$(CC) $(CFLAGS) -o library-test-static library-test.o $(LDFLAGS) $(libs_static)
443
444 test-build: test-build-pre test-build-real
445
446 test-build-pre:
447         $(MAKE) clean-all
448         ./autogen.sh
449         ./configure
450
451 test-build-real:
452         $(MAKE) library-test
453         -$(MAKE) library-test.static
454         $(MAKE) -j 8 all
455         -$(MAKE) -j 8 static
456         $(MAKE) -j 8 $(progs_extra)
457
458 manpages:
459         $(Q)$(MAKE) $(MAKEOPTS) -C Documentation
460
461
462 clean-all: clean clean-doc clean-gen
463
464 clean: $(CLEANDIRS)
465         @echo "Cleaning"
466         $(Q)$(RM) -f -- $(progs) cscope.out *.o *.o.d \
467                 kernel-lib/*.o kernel-lib/*.o.d \
468               dir-test ioctl-test quick-test library-test library-test-static \
469               btrfs.static mkfs.btrfs.static \
470               $(check_defs) \
471               $(libs) $(lib_links) \
472               $(progs_static) $(progs_extra)
473
474 clean-doc:
475         @echo "Cleaning Documentation"
476         $(Q)$(MAKE) $(MAKEOPTS) -C Documentation clean
477
478 clean-gen:
479         @echo "Cleaning Generated Files"
480         $(Q)$(RM) -rf -- version.h config.status config.cache connfig.log \
481                 configure.lineno config.status.lineno Makefile \
482                 Documentation/Makefile \
483                 config.log config.h config.h.in~ aclocal.m4 \
484                 configure autom4te.cache/ config/
485
486 $(CLEANDIRS):
487         @echo "Cleaning $(patsubst clean-%,%,$@)"
488         $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst clean-%,%,$@) clean
489
490 install: $(libs) $(progs_install) $(INSTALLDIRS)
491         $(INSTALL) -m755 -d $(DESTDIR)$(bindir)
492         $(INSTALL) $(progs_install) $(DESTDIR)$(bindir)
493         $(INSTALL) fsck.btrfs $(DESTDIR)$(bindir)
494         # btrfsck is a link to btrfs in the src tree, make it so for installed file as well
495         $(LN_S) -f btrfs $(DESTDIR)$(bindir)/btrfsck
496         $(INSTALL) -m755 -d $(DESTDIR)$(libdir)
497         $(INSTALL) $(libs) $(DESTDIR)$(libdir)
498         cp -a $(lib_links) $(DESTDIR)$(libdir)
499         $(INSTALL) -m755 -d $(DESTDIR)$(incdir)
500         $(INSTALL) -m644 $(headers) $(DESTDIR)$(incdir)
501 ifneq ($(udevdir),)
502         $(INSTALL) -m755 -d $(DESTDIR)$(udevruledir)
503         $(INSTALL) -m644 $(udev_rules) $(DESTDIR)$(udevruledir)
504 endif
505
506 install-static: $(progs_static) $(INSTALLDIRS)
507         $(INSTALL) -m755 -d $(DESTDIR)$(bindir)
508         $(INSTALL) $(progs_static) $(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.static $(DESTDIR)$(bindir)/btrfsck.static
511
512 $(INSTALLDIRS):
513         @echo "Making install in $(patsubst install-%,%,$@)"
514         $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst install-%,%,$@) install
515
516 uninstall:
517         $(Q)$(MAKE) $(MAKEOPTS) -C Documentation uninstall
518         cd $(DESTDIR)$(incdir); $(RM) -f -- $(headers)
519         $(RMDIR) -p --ignore-fail-on-non-empty -- $(DESTDIR)$(incdir)
520         cd $(DESTDIR)$(libdir); $(RM) -f -- $(lib_links) $(libs)
521         cd $(DESTDIR)$(bindir); $(RM) -f -- btrfsck fsck.btrfs $(progs_install)
522
523 ifneq ($(MAKECMDGOALS),clean)
524 -include $(objects:.o=.o.d) $(cmds_objects:.o=.o.d) $(subst .btrfs,, $(filter-out btrfsck.o.d, $(progs:=.o.d)))
525 endif