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 raid6.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 cmds-replace.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 ifeq ("$(origin V)", "command line")
30 ifeq ($(BUILD_VERBOSE),1)
36 MAKEOPTS = --no-print-directory Q=$(Q)
38 progs = btrfsctl mkfs.btrfs btrfs-debug-tree btrfs-show btrfs-vol btrfsck \
39 btrfs btrfs-map-logical btrfs-image btrfs-zero-log btrfs-convert \
40 btrfs-find-root btrfs-restore btrfstune btrfs-show-super
42 # make C=1 to enable sparse
44 check = sparse $(CHECKFLAGS)
52 $(Q)$(CC) $(DEPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c $<
55 all: version.h $(progs) manpages
60 btrfs: $(objects) btrfs.o help.o $(cmds_objects)
62 $(Q)$(CC) $(CFLAGS) -o btrfs btrfs.o help.o $(cmds_objects) \
63 $(objects) $(LDFLAGS) $(LIBS) -lpthread
65 calc-size: $(objects) calc-size.o
67 $(Q)$(CC) $(CFLAGS) -o calc-size calc-size.o $(objects) $(LDFLAGS) $(LIBS)
69 btrfs-find-root: $(objects) find-root.o
71 $(Q)$(CC) $(CFLAGS) -o btrfs-find-root find-root.o $(objects) $(LDFLAGS) $(LIBS)
73 btrfs-restore: $(objects) restore.o
75 $(Q)$(CC) $(CFLAGS) -o btrfs-restore restore.o $(objects) $(LDFLAGS) $(LIBS) $(RESTORE_LIBS)
77 btrfsctl: $(objects) btrfsctl.o
79 $(Q)$(CC) $(CFLAGS) -o btrfsctl btrfsctl.o $(objects) $(LDFLAGS) $(LIBS)
81 btrfs-vol: $(objects) btrfs-vol.o
83 $(Q)$(CC) $(CFLAGS) -o btrfs-vol btrfs-vol.o $(objects) $(LDFLAGS) $(LIBS)
85 btrfs-show: $(objects) btrfs-show.o
87 $(Q)$(CC) $(CFLAGS) -o btrfs-show btrfs-show.o $(objects) $(LDFLAGS) $(LIBS)
89 btrfsck: $(objects) btrfsck.o
91 $(Q)$(CC) $(CFLAGS) -o btrfsck btrfsck.o $(objects) $(LDFLAGS) $(LIBS)
93 mkfs.btrfs: $(objects) mkfs.o
95 $(Q)$(CC) $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS) -lblkid
97 btrfs-debug-tree: $(objects) debug-tree.o
99 $(Q)$(CC) $(CFLAGS) -o btrfs-debug-tree $(objects) debug-tree.o $(LDFLAGS) $(LIBS)
101 btrfs-zero-log: $(objects) btrfs-zero-log.o
103 $(Q)$(CC) $(CFLAGS) -o btrfs-zero-log $(objects) btrfs-zero-log.o $(LDFLAGS) $(LIBS)
105 btrfs-show-super: $(objects) btrfs-show-super.o
107 $(Q)$(CC) $(CFLAGS) -o btrfs-show-super $(objects) btrfs-show-super.o $(LDFLAGS) $(LIBS)
109 btrfs-select-super: $(objects) btrfs-select-super.o
111 $(Q)$(CC) $(CFLAGS) -o btrfs-select-super $(objects) btrfs-select-super.o $(LDFLAGS) $(LIBS)
113 btrfstune: $(objects) btrfstune.o
115 $(Q)$(CC) $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(LDFLAGS) $(LIBS)
117 btrfs-map-logical: $(objects) btrfs-map-logical.o
119 $(Q)$(CC) $(CFLAGS) -o btrfs-map-logical $(objects) btrfs-map-logical.o $(LDFLAGS) $(LIBS)
121 btrfs-corrupt-block: $(objects) btrfs-corrupt-block.o
123 $(Q)$(CC) $(CFLAGS) -o btrfs-corrupt-block $(objects) btrfs-corrupt-block.o $(LDFLAGS) $(LIBS)
125 btrfs-image: $(objects) btrfs-image.o
127 $(Q)$(CC) $(CFLAGS) -o btrfs-image $(objects) btrfs-image.o -lpthread -lz $(LDFLAGS) $(LIBS)
129 dir-test: $(objects) dir-test.o
131 $(Q)$(CC) $(CFLAGS) -o dir-test $(objects) dir-test.o $(LDFLAGS) $(LIBS)
133 quick-test: $(objects) quick-test.o
135 $(Q)$(CC) $(CFLAGS) -o quick-test $(objects) quick-test.o $(LDFLAGS) $(LIBS)
137 btrfs-convert: $(objects) convert.o
139 $(Q)$(CC) $(CFLAGS) -o btrfs-convert $(objects) convert.o -lext2fs -lcom_err $(LDFLAGS) $(LIBS)
141 ioctl-test: $(objects) ioctl-test.o
143 $(Q)$(CC) $(CFLAGS) -o ioctl-test $(objects) ioctl-test.o $(LDFLAGS) $(LIBS)
146 $(Q)$(MAKE) $(MAKEOPTS) -C man
149 cd man; $(MAKE) install
153 $(Q)rm -f $(progs) cscope.out *.o .*.d btrfs-convert btrfs-image btrfs-select-super \
154 btrfs-zero-log btrfstune dir-test ioctl-test quick-test version.h
155 $(Q)$(MAKE) $(MAKEOPTS) -C man $@
157 install: $(progs) install-man
158 $(INSTALL) -m755 -d $(DESTDIR)$(bindir)
159 $(INSTALL) $(progs) $(DESTDIR)$(bindir)