-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
51 lines (40 loc) · 1.26 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
SRCS = btree.c dir.c mkapfs.c object.c spaceman.c super.c
OBJS = $(SRCS:.c=.o)
DEPS = $(SRCS:.c=.d)
LIBDIR = ../lib
LIBRARY = $(LIBDIR)/libapfs.a
DESTDIR ?= ~
BINDIR = /bin
MANDIR = /share/man/man8
SPARSE_VERSION := $(shell sparse --version 2>/dev/null)
GIT_COMMIT = $(shell git describe --always HEAD | tail -c 9)
override CFLAGS += -Wall -Wno-address-of-packed-member -fno-strict-aliasing -I$(CURDIR)/../include
mkapfs: $(OBJS) $(LIBRARY)
@echo ' Linking...'
@$(CC) $(CFLAGS) $(LDFLAGS) -o mkapfs $(OBJS) $(LIBRARY)
@echo ' Build complete'
# Build the common libraries
$(LIBRARY): FORCE
@echo ' Building libraries...'
@$(MAKE) -C $(LIBDIR) --silent --no-print-directory
@echo ' Library build complete'
FORCE:
%.o: %.c
@echo ' Compiling $<...'
@$(CC) $(CFLAGS) -o $@ -MMD -MP -c $<
ifdef SPARSE_VERSION
@sparse $(CFLAGS) $<
endif
mkapfs.o super.o: version.h
version.h: FORCE
@printf '#define GIT_COMMIT\t"%s"\n' $(GIT_COMMIT) > version.h
-include $(DEPS)
clean:
rm -f $(OBJS) $(DEPS) mkapfs version.h
install:
install -d $(DESTDIR)$(BINDIR)
install -t $(DESTDIR)$(BINDIR) mkapfs
ln -fs -T mkapfs $(DESTDIR)$(BINDIR)/mkfs.apfs
install -d $(DESTDIR)$(MANDIR)
install -m 644 -t $(DESTDIR)$(MANDIR) mkapfs.8
ln -fs -T mkapfs.8 $(DESTDIR)$(MANDIR)/mkfs.apfs.8