2 AM_CFLAGS = -Wall -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2
4 objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \
5 root-tree.o dir-item.o file-item.o inode-item.o \
6 inode-map.o crc32c.o rbtree.o extent-cache.o extent_io.o \
7 volumes.o utils.o btrfs-list.o btrfslabel.o repair.o \
8 send-stream.o send-utils.o qgroup.o
9 cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \
10 cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \
11 cmds-quota.o cmds-qgroup.o
13 CHECKFLAGS= -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise \
14 -Wuninitialized -Wshadow -Wundef
15 DEPFLAGS = -Wp,-MMD,$(@D)/.$(@F).d,-MT,$@
19 bindir = $(prefix)/bin
23 progs = btrfsctl mkfs.btrfs btrfs-debug-tree btrfs-show btrfs-vol btrfsck \
24 btrfs btrfs-map-logical btrfs-image btrfs-zero-log btrfs-convert \
25 btrfs-find-root btrfs-restore btrfstune
27 # make C=1 to enable sparse
29 check = sparse $(CHECKFLAGS)
36 $(CC) $(DEPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c $<
39 all: version $(progs) manpages
44 btrfs: $(objects) btrfs.o help.o common.o $(cmds_objects)
45 $(CC) $(CFLAGS) -o btrfs btrfs.o help.o common.o $(cmds_objects) \
46 $(objects) $(LDFLAGS) $(LIBS) -lpthread
48 calc-size: $(objects) calc-size.o
49 $(CC) $(CFLAGS) -o calc-size calc-size.o $(objects) $(LDFLAGS) $(LIBS)
51 btrfs-find-root: $(objects) find-root.o
52 $(CC) $(CFLAGS) -o btrfs-find-root find-root.o $(objects) $(LDFLAGS) $(LIBS)
54 btrfs-restore: $(objects) restore.o
55 $(CC) $(CFLAGS) -o btrfs-restore restore.o $(objects) $(LDFLAGS) $(LIBS) $(RESTORE_LIBS)
57 btrfsctl: $(objects) btrfsctl.o
58 $(CC) $(CFLAGS) -o btrfsctl btrfsctl.o $(objects) $(LDFLAGS) $(LIBS)
60 btrfs-vol: $(objects) btrfs-vol.o
61 $(CC) $(CFLAGS) -o btrfs-vol btrfs-vol.o $(objects) $(LDFLAGS) $(LIBS)
63 btrfs-show: $(objects) btrfs-show.o
64 $(CC) $(CFLAGS) -o btrfs-show btrfs-show.o $(objects) $(LDFLAGS) $(LIBS)
66 btrfsck: $(objects) btrfsck.o
67 $(CC) $(CFLAGS) -o btrfsck btrfsck.o $(objects) $(LDFLAGS) $(LIBS)
69 mkfs.btrfs: $(objects) mkfs.o
70 $(CC) $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS)
72 btrfs-debug-tree: $(objects) debug-tree.o
73 $(CC) $(CFLAGS) -o btrfs-debug-tree $(objects) debug-tree.o $(LDFLAGS) $(LIBS)
75 btrfs-zero-log: $(objects) btrfs-zero-log.o
76 $(CC) $(CFLAGS) -o btrfs-zero-log $(objects) btrfs-zero-log.o $(LDFLAGS) $(LIBS)
78 btrfs-select-super: $(objects) btrfs-select-super.o
79 $(CC) $(CFLAGS) -o btrfs-select-super $(objects) btrfs-select-super.o $(LDFLAGS) $(LIBS)
81 btrfstune: $(objects) btrfstune.o
82 $(CC) $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(LDFLAGS) $(LIBS)
84 btrfs-map-logical: $(objects) btrfs-map-logical.o
85 $(CC) $(CFLAGS) -o btrfs-map-logical $(objects) btrfs-map-logical.o $(LDFLAGS) $(LIBS)
87 btrfs-corrupt-block: $(objects) btrfs-corrupt-block.o
88 $(CC) $(CFLAGS) -o btrfs-corrupt-block $(objects) btrfs-corrupt-block.o $(LDFLAGS) $(LIBS)
90 btrfs-image: $(objects) btrfs-image.o
91 $(CC) $(CFLAGS) -o btrfs-image $(objects) btrfs-image.o -lpthread -lz $(LDFLAGS) $(LIBS)
93 dir-test: $(objects) dir-test.o
94 $(CC) $(CFLAGS) -o dir-test $(objects) dir-test.o $(LDFLAGS) $(LIBS)
96 quick-test: $(objects) quick-test.o
97 $(CC) $(CFLAGS) -o quick-test $(objects) quick-test.o $(LDFLAGS) $(LIBS)
99 btrfs-convert: $(objects) convert.o
100 $(CC) $(CFLAGS) -o btrfs-convert $(objects) convert.o -lext2fs -lcom_err $(LDFLAGS) $(LIBS)
102 ioctl-test: $(objects) ioctl-test.o
103 $(CC) $(CFLAGS) -o ioctl-test $(objects) ioctl-test.o $(LDFLAGS) $(LIBS)
109 cd man; $(MAKE) install
112 rm -f $(progs) cscope.out *.o .*.d btrfs-convert btrfs-image btrfs-select-super \
113 btrfs-zero-log btrfstune dir-test ioctl-test quick-test version.h
114 cd man; $(MAKE) clean
116 install: $(progs) install-man
117 $(INSTALL) -m755 -d $(DESTDIR)$(bindir)
118 $(INSTALL) $(progs) $(DESTDIR)$(bindir)