Allow install prefix overrides
[platform/upstream/btrfs-progs.git] / Makefile
1 CC=gcc
2 CFLAGS = -g -Wall -fno-strict-aliasing -Werror
3 objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \
4           root-tree.o dir-item.o hash.o file-item.o inode-item.o \
5           inode-map.o \
6 #
7 CHECKFLAGS=-D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise \
8                 -Wuninitialized -Wshadow -Wundef
9
10 INSTALL= install
11 prefix ?= /usr/local
12 bindir = $(prefix)/bin
13
14 progs = btrfsctl btrfsck mkfs.btrfs debug-tree
15
16 # make C=1 to enable sparse
17 ifdef C
18         check=sparse $(CHECKFLAGS)
19 else
20         check=ls
21 endif
22
23 .c.o:
24         $(check) $<
25         $(CC) $(CFLAGS) -c $<
26
27
28 all: $(progs)
29
30 $(progs): depend
31
32 depend:
33         @$(CC) -MM $(ALL_CFLAGS) *.c 1> .depend
34
35 btrfsctl: btrfsctl.o
36         gcc $(CFLAGS) -o btrfsctl btrfsctl.o
37
38 btrfsck: $(objects) btrfsck.o bit-radix.o
39         gcc $(CFLAGS) -o btrfsck btrfsck.o $(objects) bit-radix.o
40
41 mkfs.btrfs: $(objects) mkfs.o
42         gcc $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o -luuid
43
44 debug-tree: $(objects) debug-tree.o
45         gcc $(CFLAGS) -o debug-tree $(objects) debug-tree.o -luuid
46
47 dir-test: $(objects) dir-test.o
48         gcc $(CFLAGS) -o dir-test $(objects) dir-test.o
49
50 quick-test: $(objects) quick-test.o
51         gcc $(CFLAGS) -o quick-test $(objects) quick-test.o
52
53 clean :
54         rm -f $(progs) cscope.out *.o .depend
55
56 install: $(progs)
57         $(INSTALL) -m755 -d $(DESTDIR)$(bindir)
58         $(INSTALL) $(progs) $(DESTDIR)$(bindir)
59
60 ifneq ($(wildcard .depend),)
61 include .depend
62 endif