2 AM_CFLAGS = -Wall -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2
3 CFLAGS = -g -Werror -Os
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 \
10 CHECKFLAGS=-D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise \
11 -Wuninitialized -Wshadow -Wundef
12 DEPFLAGS = -Wp,-MMD,$(@D)/.$(@F).d,-MT,$@
16 bindir = $(prefix)/bin
19 progs = btrfsctl mkfs.btrfs btrfs-debug-tree btrfs-show btrfs-vol btrfsck \
20 btrfs-map-logical btrfs-list btrfs-defrag
22 # make C=1 to enable sparse
24 check=sparse $(CHECKFLAGS)
31 $(CC) $(DEPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c $<
34 all: version $(progs) manpages
39 btrfs-list: $(objects) btrfs-list.o
40 gcc $(CFLAGS) -o btrfs-list btrfs-list.o $(objects) $(LDFLAGS) $(LIBS)
42 btrfs-defrag: $(objects) btrfs-defrag.o
43 gcc $(CFLAGS) -o btrfs-defrag btrfs-defrag.o $(objects) $(LDFLAGS) $(LIBS)
45 btrfsctl: $(objects) btrfsctl.o
46 gcc $(CFLAGS) -o btrfsctl btrfsctl.o $(objects) $(LDFLAGS) $(LIBS)
48 btrfs-vol: $(objects) btrfs-vol.o
49 gcc $(CFLAGS) -o btrfs-vol btrfs-vol.o $(objects) $(LDFLAGS) $(LIBS)
51 btrfs-show: $(objects) btrfs-show.o
52 gcc $(CFLAGS) -o btrfs-show btrfs-show.o $(objects) $(LDFLAGS) $(LIBS)
54 btrfsck: $(objects) btrfsck.o
55 gcc $(CFLAGS) -o btrfsck btrfsck.o $(objects) $(LDFLAGS) $(LIBS)
57 mkfs.btrfs: $(objects) mkfs.o
58 gcc $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS)
60 btrfs-debug-tree: $(objects) debug-tree.o
61 gcc $(CFLAGS) -o btrfs-debug-tree $(objects) debug-tree.o $(LDFLAGS) $(LIBS)
63 btrfstune: $(objects) btrfstune.o
64 gcc $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(LDFLAGS) $(LIBS)
66 btrfs-map-logical: $(objects) btrfs-map-logical.o
67 gcc $(CFLAGS) -o btrfs-map-logical $(objects) btrfs-map-logical.o $(LDFLAGS) $(LIBS)
69 btrfs-image: $(objects) btrfs-image.o
70 gcc $(CFLAGS) -o btrfs-image $(objects) btrfs-image.o -lpthread -lz $(LDFLAGS) $(LIBS)
72 dir-test: $(objects) dir-test.o
73 gcc $(CFLAGS) -o dir-test $(objects) dir-test.o $(LDFLAGS) $(LIBS)
75 quick-test: $(objects) quick-test.o
76 gcc $(CFLAGS) -o quick-test $(objects) quick-test.o $(LDFLAGS) $(LIBS)
78 convert: $(objects) convert.o
79 gcc $(CFLAGS) -o btrfs-convert $(objects) convert.o -lext2fs $(LDFLAGS) $(LIBS)
88 rm -f $(progs) cscope.out *.o .*.d btrfs-convert
91 install: $(progs) install-man
92 $(INSTALL) -m755 -d $(DESTDIR)$(bindir)
93 $(INSTALL) $(progs) $(DESTDIR)$(bindir)
94 if [ -e btrfs-convert ]; then $(INSTALL) btrfs-convert $(DESTDIR)$(bindir); fi