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