3 # all all main tools and the shared library
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
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 # tsan - enable thread 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
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
34 # CHECKER static checker binary to be called (default: sparse)
35 # CHECKER_FLAGS flags to pass to CHECKER, can override CFLAGS
38 # Export all variables to sub-makes by default
42 ifneq ($(MAKEFILE_INC_INCLUDED
),yes
)
43 $(error Makefile.inc not generated
, please configure first
)
47 CSCOPE_CMD
:= cscope
-u
-b
-c
-q
49 include Makefile.extrawarn
54 DEBUG_CFLAGS_DEFAULT
= -O0
-U_FORTIFY_SOURCE
-ggdb3
55 DEBUG_CFLAGS_INTERNAL
=
58 DEBUG_LDFLAGS_DEFAULT
=
59 DEBUG_LDFLAGS_INTERNAL
=
62 ABSTOPDIR
= $(shell pwd
)
66 CFLAGS
= $(SUBST_CFLAGS
) \
69 -DBTRFS_FLAT_INCLUDES \
71 -fno-strict-aliasing \
74 -I
$(TOPDIR
)/kernel-lib \
75 -I
$(TOPDIR
)/libbtrfsutil \
77 $(DEBUG_CFLAGS_INTERNAL
) \
80 LIBBTRFSUTIL_CFLAGS
= $(SUBST_CFLAGS
) \
85 -I
$(TOPDIR
)/libbtrfsutil \
89 LDFLAGS
= $(SUBST_LDFLAGS
) \
90 -rdynamic
-L
$(TOPDIR
) \
91 $(DEBUG_LDFLAGS_INTERNAL
) \
95 LIBBTRFS_LIBS
= $(LIBS_BASE
)
97 # Static compilation flags
98 STATIC_CFLAGS
= $(CFLAGS
) -ffunction-sections
-fdata-sections
99 STATIC_LDFLAGS
= -static
-Wl
,--gc-sections
100 STATIC_LIBS
= $(STATIC_LIBS_BASE
)
102 # don't use FORTIFY with sparse because glibc with FORTIFY can
103 # generate so many sparse errors that sparse stops parsing,
104 # which masks real errors that we want to see.
105 # Note: additional flags might get added per-target later
107 check_defs
:= .cc-defines.h
108 CHECKER_FLAGS
:= -include $(check_defs
) -D__CHECKER__ \
109 -D__CHECK_ENDIAN__
-Wbitwise
-Wuninitialized
-Wshadow
-Wundef \
110 -U_FORTIFY_SOURCE
-Wdeclaration-after-statement
-Wdefault-bitfield-sign
112 objects
= ctree.o disk-io.o kernel-lib
/radix-tree.o extent-tree.o print-tree.o \
113 root-tree.o dir-item.o file-item.o inode-item.o inode-map.o \
114 extent-cache.o extent_io.o volumes.o utils.o repair.o \
115 qgroup.o free-space-cache.o kernel-lib
/list_sort.o props.o \
116 kernel-shared
/ulist.o qgroup-verify.o backref.o string-table.o task-utils.o \
117 inode.o file.o find-root.o free-space-tree.o help.o send-dump.o \
118 fsfeatures.o kernel-lib
/tables.o kernel-lib
/raid56.o transaction.o
119 cmds_objects
= cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \
120 cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \
121 cmds-quota.o cmds-qgroup.o cmds-replace.o
check/main.o \
122 cmds-restore.o cmds-rescue.o chunk-recover.o super-recover.o \
123 cmds-property.o cmds-fi-usage.o cmds-inspect-dump-tree.o \
124 cmds-inspect-dump-super.o cmds-inspect-tree-stats.o cmds-fi-du.o \
125 mkfs
/common.o
check/mode-common.o
check/mode-lowmem.o
126 libbtrfs_objects
= send-stream.o send-utils.o kernel-lib
/rbtree.o btrfs-list.o \
127 kernel-lib
/crc32c.o messages.o \
128 uuid-tree.o utils-lib.o rbtree-utils.o
129 libbtrfs_headers
= send-stream.h send-utils.h send.h kernel-lib
/rbtree.h btrfs-list.h \
130 kernel-lib
/crc32c.h kernel-lib
/list.h kerncompat.h \
131 kernel-lib
/radix-tree.h kernel-lib
/sizes.h kernel-lib
/raid56.h \
132 extent-cache.h extent_io.h ioctl.h ctree.h btrfsck.h version.h
133 libbtrfsutil_major
:= $(shell sed
-rn
's/^\#define BTRFS_UTIL_VERSION_MAJOR ([0-9])+$$/\1/p' libbtrfsutil
/btrfsutil.h
)
134 libbtrfsutil_minor
:= $(shell sed
-rn
's/^\#define BTRFS_UTIL_VERSION_MINOR ([0-9])+$$/\1/p' libbtrfsutil
/btrfsutil.h
)
135 libbtrfsutil_patch
:= $(shell sed
-rn
's/^\#define BTRFS_UTIL_VERSION_PATCH ([0-9])+$$/\1/p' libbtrfsutil
/btrfsutil.h
)
136 libbtrfsutil_version
:= $(libbtrfsutil_major
).
$(libbtrfsutil_minor
).
$(libbtrfsutil_patch
)
137 libbtrfsutil_objects
= libbtrfsutil
/errors.o libbtrfsutil
/filesystem.o \
138 libbtrfsutil
/subvolume.o libbtrfsutil
/qgroup.o \
140 convert_objects
= convert
/main.o convert
/common.o convert
/source-fs.o \
141 convert
/source-ext2.o convert
/source-reiserfs.o
142 mkfs_objects
= mkfs
/main.o mkfs
/common.o mkfs
/rootdir.o
143 image_objects
= image
/main.o image
/sanitize.o
144 all_objects
= $(objects
) $(cmds_objects
) $(libbtrfs_objects
) $(convert_objects
) \
145 $(mkfs_objects
) $(image_objects
) $(libbtrfsutil_objects
)
147 udev_rules
= 64-btrfs-dm.rules
149 ifeq ("$(origin V)", "command line")
156 ifeq ($(BUILD_VERBOSE
),1)
164 ifeq ("$(origin D)", "command line")
165 DEBUG_CFLAGS_INTERNAL
= $(DEBUG_CFLAGS_DEFAULT
) $(DEBUG_CFLAGS
)
166 DEBUG_LDFLAGS_INTERNAL
= $(DEBUG_LDFLAGS_DEFAULT
) $(DEBUG_LDFLAGS
)
169 ifneq (,$(findstring verbose
,$(D
)))
170 DEBUG_CFLAGS_INTERNAL
+= -DDEBUG_VERBOSE_ERROR
=1
173 ifneq (,$(findstring trace
,$(D
)))
174 DEBUG_CFLAGS_INTERNAL
+= -DDEBUG_TRACE_ON_ERROR
=1
177 ifneq (,$(findstring abort
,$(D
)))
178 DEBUG_CFLAGS_INTERNAL
+= -DDEBUG_ABORT_ON_ERROR
=1
181 ifneq (,$(findstring all,$(D
)))
182 DEBUG_CFLAGS_INTERNAL
+= -DDEBUG_VERBOSE_ERROR
=1
183 DEBUG_CFLAGS_INTERNAL
+= -DDEBUG_TRACE_ON_ERROR
=1
184 DEBUG_CFLAGS_INTERNAL
+= -DDEBUG_ABORT_ON_ERROR
=1
187 ifneq (,$(findstring asan
,$(D
)))
188 DEBUG_CFLAGS_INTERNAL
+= -fsanitize
=address
189 DEBUG_LDFLAGS_INTERNAL
+= -fsanitize
=address
-lasan
192 ifneq (,$(findstring tsan
,$(D
)))
193 DEBUG_CFLAGS_INTERNAL
+= -fsanitize
=thread
-fPIC
194 DEBUG_LDFLAGS_INTERNAL
+= -fsanitize
=thread
-ltsan
-pie
197 ifneq (,$(findstring ubsan
,$(D
)))
198 DEBUG_CFLAGS_INTERNAL
+= -fsanitize
=undefined
199 DEBUG_LDFLAGS_INTERNAL
+= -fsanitize
=undefined
-lubsan
202 ifneq (,$(findstring bcheck
,$(D
)))
203 DEBUG_CFLAGS_INTERNAL
+= -DDEBUG_BUILD_CHECKS
206 MAKEOPTS
= --no-print-directory Q
=$(Q
)
208 # build all by default
209 progs
= $(progs_install
) btrfsck btrfs-corrupt-block
211 # install only selected
212 progs_install
= btrfs mkfs.btrfs btrfs-map-logical btrfs-image \
213 btrfs-find-root btrfstune \
216 # other tools, not built by default
217 progs_extra
= btrfs-fragments
219 progs_static
= $(foreach p
,$(progs
),$(p
).static
)
221 ifneq ($(DISABLE_BTRFSCONVERT
),1)
222 progs_install
+= btrfs-convert
225 # external libs required by various binaries; for btrfs-foo,
226 # specify btrfs_foo_libs = <list of libs>; see $($(subst...)) rules below
227 btrfs_convert_cflags
= -DBTRFSCONVERT_EXT2
=$(BTRFSCONVERT_EXT2
)
228 btrfs_convert_cflags
+= -DBTRFSCONVERT_REISERFS
=$(BTRFSCONVERT_REISERFS
)
229 btrfs_fragments_libs
= -lgd
-lpng
-ljpeg
-lfreetype
230 cmds_restore_cflags
= -DBTRFSRESTORE_ZSTD
=$(BTRFSRESTORE_ZSTD
)
232 CHECKER_FLAGS
+= $(btrfs_convert_cflags
)
234 # collect values of the variables above
235 standalone_deps
= $(foreach dep
,$(patsubst %,%_objects
,$(subst -,_
,$(filter btrfs-
%, $(progs
) $(progs_extra
)))),$($(dep
)))
238 BUILDDIRS
= $(patsubst %,build-
%,$(SUBDIRS
))
239 INSTALLDIRS
= $(patsubst %,install-
%,$(SUBDIRS
))
240 CLEANDIRS
= $(patsubst %,clean-
%,$(SUBDIRS
))
242 ifneq ($(DISABLE_DOCUMENTATION
),1)
243 BUILDDIRS
+= build-Documentation
244 INSTALLDIRS
+= install-Documentation
249 .PHONY
: $(INSTALLDIRS
)
252 .PHONY
: all install clean
255 # Create all the static targets
256 static_objects
= $(patsubst %.o
, %.static.o
, $(objects
))
257 static_cmds_objects
= $(patsubst %.o
, %.static.o
, $(cmds_objects
))
258 static_libbtrfs_objects
= $(patsubst %.o
, %.static.o
, $(libbtrfs_objects
))
259 static_libbtrfsutil_objects
= $(patsubst %.o
, %.static.o
, $(libbtrfsutil_objects
))
260 static_convert_objects
= $(patsubst %.o
, %.static.o
, $(convert_objects
))
261 static_mkfs_objects
= $(patsubst %.o
, %.static.o
, $(mkfs_objects
))
262 static_image_objects
= $(patsubst %.o
, %.static.o
, $(image_objects
))
264 libs_shared
= libbtrfs.so
.0.1 libbtrfsutil.so.
$(libbtrfsutil_version
)
265 libs_static
= libbtrfs.a libbtrfsutil.a
266 libs
= $(libs_shared
) $(libs_static
)
267 lib_links
= libbtrfs.so
.0 libbtrfs.so libbtrfsutil.so.
$(libbtrfsutil_major
) libbtrfsutil.so
269 # make C=1 to enable sparse
271 # We're trying to use sparse against glibc headers which go wild
272 # trying to use internal compiler macros to test features. We
273 # copy gcc's and give them to sparse. But not __SIZE_TYPE__
274 # 'cause sparse defines that one.
276 dummy
:= $(shell $(CC
) -dM
-E
-x c
- < /dev
/null | \
277 grep
-v __SIZE_TYPE__
> $(check_defs
))
287 $(Q
)$(CC
) -MM
-MG
-MF
$@
-MT
$(@
:.o.d
=.o
) -MT
$(@
:.o.d
=.static.o
) -MT
$@
$(CFLAGS
) $<
290 # Pick from per-file variables, btrfs_*_cflags
293 @
$(check_echo
) " [SP] $<"
294 $(Q
)$(check) $(CFLAGS
) $(CHECKER_FLAGS
) $<
296 $(Q
)$(CC
) $(CFLAGS
) -c
$< -o
$@
$($(subst -,_
,$(@
:%.o
=%)-cflags)) \
297 $($(subst -,_
,btrfs-
$(@
:%/$(notdir $@
)=%)-cflags))
301 $(Q
)$(CC
) $(STATIC_CFLAGS
) -c
$< -o
$@
$($(subst -,_
,$(@
:%.static.o
=%)-cflags)) \
302 $($(subst -,_
,btrfs-
$(@
:%/$(notdir $@
)=%)-cflags))
304 all: $(progs
) $(libs
) $(lib_links
) $(BUILDDIRS
)
305 ifeq ($(PYTHON_BINDINGS
),1)
306 all: libbtrfsutil_python
308 $(SUBDIRS
): $(BUILDDIRS
)
310 @echo
"Making all in $(patsubst build-%,%,$@)"
311 $(Q
)$(MAKE
) $(MAKEOPTS
) -C
$(patsubst build-
%,%,$@
)
313 test-convert
: btrfs btrfs-convert
314 @echo
" [TEST] convert-tests.sh"
315 $(Q
)bash tests
/convert-tests.sh
317 test-check
: test-fsck
318 test-fsck
: btrfs btrfs-image btrfs-corrupt-block mkfs.btrfs btrfstune
319 @echo
" [TEST] fsck-tests.sh"
320 $(Q
)bash tests
/fsck-tests.sh
322 test-misc
: btrfs btrfs-image btrfs-corrupt-block mkfs.btrfs btrfstune fssum \
323 btrfs-find-root btrfs-select-super btrfs-convert
324 @echo
" [TEST] misc-tests.sh"
325 $(Q
)bash tests
/misc-tests.sh
327 test-mkfs
: btrfs mkfs.btrfs
328 @echo
" [TEST] mkfs-tests.sh"
329 $(Q
)bash tests
/mkfs-tests.sh
331 test-fuzz
: btrfs btrfs-image
332 @echo
" [TEST] fuzz-tests.sh"
333 $(Q
)bash tests
/fuzz-tests.sh
335 test-cli
: btrfs mkfs.btrfs
336 @echo
" [TEST] cli-tests.sh"
337 $(Q
)bash tests
/cli-tests.sh
340 @echo
"Cleaning tests"
341 $(Q
)bash tests
/clean-tests.sh
344 @tmpdest
=`mktemp --tmpdir -d btrfs-inst.XXXXXX` && \
345 echo
"Test installation to $$tmpdest" && \
346 $(MAKE
) $(MAKEOPTS
) DESTDIR
=$$tmpdest install && \
347 $(RM
) -rf
-- $$tmpdest
349 test: test-fsck test-mkfs test-misc test-cli test-convert test-fuzz
351 testsuite
: btrfs-corrupt-block fssum
352 @echo
"Export tests as a package"
353 $(Q
)cd tests
&& .
/export-testsuite.sh
355 ifeq ($(PYTHON_BINDINGS
),1)
356 test-libbtrfsutil
: libbtrfsutil_python mkfs.btrfs
357 $(Q
)cd libbtrfsutil
/python
; \
358 LD_LIBRARY_PATH
=..
/..
$(PYTHON
) -m unittest discover
-v tests
360 .PHONY
: test-libbtrfsutil
362 test: test-libbtrfsutil
366 # NOTE: For static compiles, you need to have all the required libs
367 # static equivalent available
369 static
: $(progs_static
)
371 version.h
: version.h.in configure.ac
373 $(Q
)bash .
/config.status
--silent
$@
375 mktables
: kernel-lib
/mktables.c
377 $(Q
)$(CC
) $(CFLAGS
) $< -o
$@
379 # the target can be regenerated manually using mktables, but a local copy is
380 # kept so the build process is simpler
383 $(Q
).
/mktables
> $@ ||
($(RM
) -f
$@
&& exit
1)
385 libbtrfs.so
.0.1: $(libbtrfs_objects
)
387 $(Q
)$(CC
) $(CFLAGS
) $^
$(LDFLAGS
) $(LIBBTRFS_LIBS
) \
388 -shared
-Wl
,-soname
,libbtrfs.so
.0 -o
$@
390 libbtrfs.a
: $(libbtrfs_objects
)
394 libbtrfs.so
.0 libbtrfs.so
: libbtrfs.so
.0.1
398 libbtrfsutil
/%.o
: libbtrfsutil
/%.c
400 $(Q
)$(CC
) $(LIBBTRFSUTIL_CFLAGS
) -o
$@
-c
$< -o
$@
402 libbtrfsutil.so.
$(libbtrfsutil_version
): $(libbtrfsutil_objects
)
404 $(Q
)$(CC
) $(LIBBTRFSUTIL_CFLAGS
) $(libbtrfsutil_objects
) \
405 -shared
-Wl
,-soname
,libbtrfsutil.so.
$(libbtrfsutil_major
) -o
$@
407 libbtrfsutil.a
: $(libbtrfsutil_objects
)
411 libbtrfsutil.so.
$(libbtrfsutil_major
) libbtrfsutil.so
: libbtrfsutil.so.
$(libbtrfsutil_version
)
415 ifeq ($(PYTHON_BINDINGS
),1)
416 libbtrfsutil_python
: libbtrfsutil.so.
$(libbtrfsutil_major
) libbtrfsutil.so libbtrfsutil
/btrfsutil.h
417 @echo
" [PY] libbtrfsutil"
418 $(Q
)cd libbtrfsutil
/python
; \
419 CFLAGS
= LDFLAGS
= $(PYTHON
) setup.py
$(SETUP_PY_Q
) build_ext
-i build
421 .PHONY
: libbtrfsutil_python
424 # keep intermediate files from the below implicit rules around
425 .PRECIOUS
: $(addsuffix .o
,$(progs
))
427 # Make any btrfs-foo out of btrfs-foo.o, with appropriate libs.
428 # The $($(subst...)) bits below takes the btrfs_*_libs definitions above and
429 # turns them into a list of libraries to link against if they exist
431 # For static variants, use an extra $(subst) to get rid of the ".static"
432 # from the target name before translating to list of libs
434 btrfs-
%.static
: btrfs-
%.static.o
$(static_objects
) $(patsubst %.o
,%.static.o
,$(standalone_deps
)) $(static_libbtrfs_objects
)
436 $(Q
)$(CC
) -o
$@
$@.o
$(static_objects
) \
437 $(patsubst %.o
, %.static.o
, $($(subst -,_
,$(subst .static
,,$@
)-objects
))) \
438 $(static_libbtrfs_objects
) $(STATIC_LDFLAGS
) \
439 $($(subst -,_
,$(subst .static
,,$@
)-libs
)) $(STATIC_LIBS
)
441 btrfs-
%: btrfs-
%.o
$(objects
) $(standalone_deps
) $(libs_static
)
443 $(Q
)$(CC
) -o
$@
$(objects
) $@.o \
444 $($(subst -,_
,$@
-objects
)) \
446 $(LDFLAGS
) $(LIBS
) $($(subst -,_
,$@
-libs
))
448 btrfs
: btrfs.o
$(objects
) $(cmds_objects
) $(libs_static
)
450 $(Q
)$(CC
) -o
$@
$^
$(LDFLAGS
) $(LIBS
) $(LIBS_COMP
)
452 btrfs.static
: btrfs.static.o
$(static_objects
) $(static_cmds_objects
) $(static_libbtrfs_objects
) $(static_libbtrfsutil_objects
)
454 $(Q
)$(CC
) -o
$@
$^
$(STATIC_LDFLAGS
) $(STATIC_LIBS
) $(STATIC_LIBS_COMP
)
456 # For backward compatibility, 'btrfs' changes behaviour to fsck if it's named 'btrfsck'
459 $(Q
)$(LN_S
) -f btrfs btrfsck
461 btrfsck.static
: btrfs.static
465 mkfs.btrfs
: $(mkfs_objects
) $(objects
) $(libs_static
)
467 $(Q
)$(CC
) -o
$@
$^
$(LDFLAGS
) $(LIBS
)
469 mkfs.btrfs.static
: $(static_mkfs_objects
) $(static_objects
) $(static_libbtrfs_objects
)
471 $(Q
)$(CC
) -o
$@
$^
$(STATIC_LDFLAGS
) $(STATIC_LIBS
)
473 btrfstune
: btrfstune.o
$(objects
) $(libs_static
)
475 $(Q
)$(CC
) -o
$@
$^
$(LDFLAGS
) $(LIBS
)
477 btrfstune.static
: btrfstune.static.o
$(static_objects
) $(static_libbtrfs_objects
)
479 $(Q
)$(CC
) -o
$@
$^
$(STATIC_LDFLAGS
) $(STATIC_LIBS
)
481 btrfs-image
: $(image_objects
) $(objects
) $(libs_static
)
483 $(Q
)$(CC
) -o
$@
$^
$(LDFLAGS
) $(LIBS
) $(LIBS_COMP
)
485 btrfs-image.static
: $(static_image_objects
) $(static_objects
) $(static_libbtrfs_objects
)
487 $(Q
)$(CC
) -o
$@
$^
$(STATIC_LDFLAGS
) $(STATIC_LIBS
) $(STATIC_LIBS_COMP
)
489 btrfs-convert
: $(convert_objects
) $(objects
) $(libs_static
)
491 $(Q
)$(CC
) -o
$@
$^
$(LDFLAGS
) $(btrfs_convert_libs
) $(LIBS
)
493 btrfs-convert.static
: $(static_convert_objects
) $(static_objects
) $(static_libbtrfs_objects
)
495 $(Q
)$(CC
) -o
$@
$^
$(STATIC_LDFLAGS
) $(btrfs_convert_libs
) $(STATIC_LIBS
)
497 dir-test
: dir-test.o
$(objects
) $(libs
)
499 $(Q
)$(CC
) -o
$@
$^
$(LDFLAGS
) $(LIBS
)
501 quick-test
: quick-test.o
$(objects
) $(libs
)
503 $(Q
)$(CC
) -o
$@
$^
$(LDFLAGS
) $(LIBS
)
505 ioctl-test.o
: ioctl-test.c ioctl.h kerncompat.h ctree.h
507 $(Q
)$(CC
) $(CFLAGS
) -c
$< -o
$@
509 ioctl-test-32.o
: ioctl-test.c ioctl.h kerncompat.h ctree.h
511 $(Q
)$(CC
) $(CFLAGS
) -m32
-c
$< -o
$@
513 ioctl-test-64.o
: ioctl-test.c ioctl.h kerncompat.h ctree.h
515 $(Q
)$(CC
) $(CFLAGS
) -m64
-c
$< -o
$@
517 ioctl-test
: ioctl-test.o
519 $(Q
)$(CC
) $(CFLAGS
) -o
$@
$< $(LDFLAGS
)
520 @echo
" ?[PAHOLE] $@.pahole"
521 -$(Q
)pahole
$@
> $@.pahole
523 ioctl-test-32
: ioctl-test-32.o
525 $(Q
)$(CC
) -m32
-o
$@
$< $(LDFLAGS
)
526 @echo
" ?[PAHOLE] $@.pahole"
527 -$(Q
)pahole
$@
> $@.pahole
529 ioctl-test-64
: ioctl-test-64.o
531 $(Q
)$(CC
) -m64
-o
$@
$< $(LDFLAGS
)
532 @echo
" ?[PAHOLE] $@.pahole"
533 -$(Q
)pahole
$@
> $@.pahole
535 test-ioctl
: ioctl-test ioctl-test-32 ioctl-test-64
536 @echo
" [TEST/ioctl]"
537 $(Q
).
/ioctl-test
> ioctl-test.log
538 $(Q
).
/ioctl-test-32
> ioctl-test-32.log
539 $(Q
).
/ioctl-test-64
> ioctl-test-64.log
541 library-test
: library-test.c libbtrfs.so
542 @echo
" [TEST PREP] $@"$(eval TMPD
=$(shell mktemp
-d
))
543 $(Q
)mkdir
-p
$(TMPD
)/include/btrfs
&& \
544 cp
$(libbtrfs_headers
) $(TMPD
)/include/btrfs
&& \
545 cd
$(TMPD
) && $(CC
) -I
$(TMPD
)/include -o
$@
$(addprefix $(ABSTOPDIR
)/,$^
) -Wl
,-rpath
=$(ABSTOPDIR
) -lbtrfs
546 @echo
" [TEST RUN] $@"
547 $(Q
)cd
$(TMPD
) && .
/$@
548 @echo
" [TEST CLEAN] $@"
549 $(Q
)$(RM
) -rf
-- $(TMPD
)
551 library-test.static
: library-test.c
$(libs_static
)
552 @echo
" [TEST PREP] $@"$(eval TMPD
=$(shell mktemp
-d
))
553 $(Q
)mkdir
-p
$(TMPD
)/include/btrfs
&& \
554 cp
$(libbtrfs_headers
) $(TMPD
)/include/btrfs
&& \
555 cd
$(TMPD
) && $(CC
) -I
$(TMPD
)/include -o
$@
$(addprefix $(ABSTOPDIR
)/,$^
) $(STATIC_LDFLAGS
) $(STATIC_LIBS
)
556 @echo
" [TEST RUN] $@"
557 $(Q
)cd
$(TMPD
) && .
/$@
558 @echo
" [TEST CLEAN] $@"
559 $(Q
)$(RM
) -rf
-- $(TMPD
)
561 fssum
: tests
/fssum.c tests
/sha224-256.c
563 $(Q
)$(CC
) $(CFLAGS
) -o
$@
$^
$(LDFLAGS
)
565 test-build
: test-build-pre test-build-real
568 $(MAKE
) $(MAKEOPTS
) clean-all
573 $(MAKE
) $(MAKEOPTS
) library-test
574 -$(MAKE
) $(MAKEOPTS
) library-test.static
575 $(MAKE
) $(MAKEOPTS
) -j
8 all
576 -$(MAKE
) $(MAKEOPTS
) -j
8 static
577 $(MAKE
) $(MAKEOPTS
) -j
8 $(progs_extra
)
580 $(Q
)$(MAKE
) $(MAKEOPTS
) -C Documentation
583 @echo
" [TAGS] $(TAGS_CMD)"
584 $(Q
)$(TAGS_CMD
) *.
[ch
] image
/*.
[ch
] convert
/*.
[ch
] mkfs
/*.
[ch
] \
585 check/*.
[ch
] kernel-lib
/*.
[ch
] kernel-shared
/*.
[ch
] \
589 @echo
" [CSCOPE] $(CSCOPE_CMD)"
590 $(Q
)ls
-1 *.
[ch
] image
/*.
[ch
] convert
/*.
[ch
] mkfs
/*.
[ch
] check/*.
[ch
] \
591 kernel-lib
/*.
[ch
] kernel-shared
/*.
[ch
] libbtrfsutil
/*.
[ch
] \
595 clean-all
: clean clean-doc clean-gen
599 $(Q
)$(RM
) -f
-- $(progs
) *.o
*.o.d \
600 kernel-lib
/*.o kernel-lib
/*.o.d \
601 kernel-shared
/*.o kernel-shared
/*.o.d \
602 image
/*.o image
/*.o.d \
603 convert
/*.o convert
/*.o.d \
604 mkfs
/*.o mkfs
/*.o.d
check/*.o
check/*.o.d \
605 dir-test ioctl-test quick-test library-test library-test-static \
606 mktables btrfs.static mkfs.btrfs.static fssum \
608 $(libs
) $(lib_links
) \
609 $(progs_static
) $(progs_extra
) \
610 libbtrfsutil
/*.o libbtrfsutil
/*.o.d
611 ifeq ($(PYTHON_BINDINGS
),1)
612 $(Q
)cd libbtrfsutil
/python
; \
613 $(PYTHON
) setup.py
$(SETUP_PY_Q
) clean -a
617 @echo
"Cleaning Documentation"
618 $(Q
)$(MAKE
) $(MAKEOPTS
) -C Documentation
clean
621 @echo
"Cleaning Generated Files"
622 $(Q
)$(RM
) -rf
-- version.h config.status config.cache connfig.log \
623 configure.lineno config.status.lineno Makefile.inc \
624 Documentation
/Makefile
tags \
625 cscope.files cscope.out cscope.in.out cscope.po.out \
626 config.log config.h config.h.in~ aclocal.m4 \
627 configure autom4te.cache
/ config
/
630 @echo
"Cleaning $(patsubst clean-%,%,$@)"
631 $(Q
)$(MAKE
) $(MAKEOPTS
) -C
$(patsubst clean-
%,%,$@
) clean
633 install: $(libs
) $(progs_install
) $(INSTALLDIRS
)
634 $(INSTALL
) -m755
-d
$(DESTDIR
)$(bindir)
635 $(INSTALL
) $(progs_install
) $(DESTDIR
)$(bindir)
636 $(INSTALL
) fsck.btrfs
$(DESTDIR
)$(bindir)
637 # btrfsck is a link to btrfs in the src tree, make it so for installed file as well
638 $(LN_S
) -f btrfs
$(DESTDIR
)$(bindir)/btrfsck
639 $(INSTALL
) -m755
-d
$(DESTDIR
)$(libdir)
640 $(INSTALL
) $(libs
) $(DESTDIR
)$(libdir)
641 cp
-d
$(lib_links
) $(DESTDIR
)$(libdir)
642 $(INSTALL
) -m755
-d
$(DESTDIR
)$(incdir
)/btrfs
643 $(INSTALL
) -m644
$(libbtrfs_headers
) $(DESTDIR
)$(incdir
)/btrfs
644 $(INSTALL
) -m644 libbtrfsutil
/btrfsutil.h
$(DESTDIR
)$(incdir
)
646 $(INSTALL
) -m755
-d
$(DESTDIR
)$(udevruledir
)
647 $(INSTALL
) -m644
$(udev_rules
) $(DESTDIR
)$(udevruledir
)
650 ifeq ($(PYTHON_BINDINGS
),1)
651 install_python
: libbtrfsutil_python
652 $(Q
)cd libbtrfsutil
/python
; \
653 $(PYTHON
) setup.py
install --skip-build
$(if
$(DESTDIR
),--root
$(DESTDIR
)) --prefix $(prefix)
655 .PHONY
: install_python
658 install-static
: $(progs_static
) $(INSTALLDIRS
)
659 $(INSTALL
) -m755
-d
$(DESTDIR
)$(bindir)
660 $(INSTALL
) $(progs_static
) $(DESTDIR
)$(bindir)
661 # btrfsck is a link to btrfs in the src tree, make it so for installed file as well
662 $(LN_S
) -f btrfs.static
$(DESTDIR
)$(bindir)/btrfsck.static
665 @echo
"Making install in $(patsubst install-%,%,$@)"
666 $(Q
)$(MAKE
) $(MAKEOPTS
) -C
$(patsubst install-
%,%,$@
) install
669 $(Q
)$(MAKE
) $(MAKEOPTS
) -C Documentation
uninstall
670 cd
$(DESTDIR
)$(incdir
)/btrfs
; $(RM
) -f
-- $(libbtrfs_headers
)
671 $(RMDIR
) -p
--ignore-fail-on-non-empty
-- $(DESTDIR
)$(incdir
)/btrfs
672 cd
$(DESTDIR
)$(incdir
); $(RM
) -f
-- btrfsutil.h
673 cd
$(DESTDIR
)$(libdir); $(RM
) -f
-- $(lib_links
) $(libs
)
674 cd
$(DESTDIR
)$(bindir); $(RM
) -f
-- btrfsck fsck.btrfs
$(progs_install
)
676 ifneq ($(MAKECMDGOALS
),clean)
677 -include $(all_objects
:.o
=.o.d
) $(subst .btrfs
,, $(filter-out btrfsck.o.d
, $(progs
:=.o.d
)))