Fix uninitialized variables, and use -O so gcc starts checking for them
[btrfs-progs-unstable.git] / Makefile
blob287ce5abd576c5031590a79afc7c10b8a4d082bf
1 CC=gcc
2 AM_CFLAGS = -Wall -fno-strict-aliasing -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 hash.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
9 CHECKFLAGS=-D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise \
10 -Wuninitialized -Wshadow -Wundef
11 DEPFLAGS = -Wp,-MMD,$(@D)/.$(@F).d,-MT,$@
13 INSTALL= install
14 prefix ?= /usr/local
15 bindir = $(prefix)/bin
16 LIBS=-luuid
18 progs = btrfsctl btrfsck mkfs.btrfs debug-tree btrfs-show btrfs-vol
20 # make C=1 to enable sparse
21 ifdef C
22 check=sparse $(CHECKFLAGS)
23 else
24 check=ls
25 endif
27 .c.o:
28 $(check) $<
29 $(CC) $(DEPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c $<
32 all: $(progs)
34 btrfsctl: $(objects) btrfsctl.o
35 gcc $(CFLAGS) -o btrfsctl btrfsctl.o $(objects) $(LDFLAGS) $(LIBS)
37 btrfs-vol: $(objects) btrfs-vol.o
38 gcc $(CFLAGS) -o btrfs-vol btrfs-vol.o $(objects) $(LDFLAGS) $(LIBS)
40 btrfs-show: $(objects) btrfs-show.o
41 gcc $(CFLAGS) -o btrfs-show btrfs-show.o $(objects) $(LDFLAGS) $(LIBS)
43 btrfsck: $(objects) btrfsck.o bit-radix.o
44 gcc $(CFLAGS) -o btrfsck btrfsck.o $(objects) bit-radix.o $(LDFLAGS) $(LIBS)
46 mkfs.btrfs: $(objects) mkfs.o
47 gcc $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS)
49 debug-tree: $(objects) debug-tree.o
50 gcc $(CFLAGS) -o debug-tree $(objects) debug-tree.o $(LDFLAGS) $(LIBS)
52 dir-test: $(objects) dir-test.o
53 gcc $(CFLAGS) -o dir-test $(objects) dir-test.o $(LDFLAGS) $(LIBS)
55 quick-test: $(objects) quick-test.o
56 gcc $(CFLAGS) -o quick-test $(objects) quick-test.o $(LDFLAGS) $(LIBS)
58 convert: $(objects) convert.o
59 gcc $(CFLAGS) -o btrfs-convert $(objects) convert.o -lext2fs $(LDFLAGS) $(LIBS)
61 clean :
62 rm -f $(progs) cscope.out *.o .*.d btrfs-convert
64 install: $(progs)
65 $(INSTALL) -m755 -d $(DESTDIR)$(bindir)
66 $(INSTALL) $(progs) $(DESTDIR)$(bindir)
67 if [ -e btrfs-convert ]; then $(INSTALL) btrfs-convert $(DESTDIR)$(bindir); fi
69 -include .*.d