-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (57 loc) · 1.81 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# directory with header files
HEADERDIR = includes
# directory with source files
SRCDIR = src
# temp directory with object files
OBJDIR = obj
# c compiler flags
CFLAGS = -g -Wall -I$(HEADERDIR) -DFUSE_USE_VERSION=26 `pkg-config fuse --cflags`
# c++ compiler flags
CPPFLAGS = -std=gnu++11 -g -Wall -I$(HEADERDIR) -DFUSE_USE_VERSION=26 `pkg-config fuse --cflags`
# linker flags
LINKFLAGS = -g -Wall
#LINKFLAGS = -Wall -L/usr/local/lib -losxfuse
# libraries
LIBS = `pkg-config fuse --libs`
# all targets in project TODO: add new targets here (and add objects and link target)
TARGETS = mount.myfs
# object files for target mount.myfs TODO: add new object files here
MOUNT_MYFS_OBJS = $(OBJDIR)/blockdevice.o \
$(OBJDIR)/myfs.o \
$(OBJDIR)/wrap.o \
$(OBJDIR)/mount.myfs.o
# build all targets
all: $(TARGETS)
# link target mount.myfs
mount.myfs: obj $(MOUNT_MYFS_OBJS)
g++ $(LINKFLAGS) -o $@ $(MOUNT_MYFS_OBJS) $(LIBS)
# clean by removing object dir
clean:
rm -rf $(OBJDIR)
# make object directory
$(OBJDIR):
mkdir -p $(OBJDIR)
# compile c++ files with header dependency
$(OBJDIR)/%.o : $(SRCDIR)/%.cpp $(HEADERDIR)/*.h
g++ -c $(CPPFLAGS) -o $@ $<
# compile c file with header dependency
$(OBJDIR)/%.o : $(SRCDIR)/%.c $(HEADERDIR)/*.h
gcc -c $(CFLAGS) -o $@ $<
########## TESTING ##########
# directory with test source files
TSRCDIR = unittests
# object files for target unittests TODO: add new object files here
UNITTEST_OBJS = $(OBJDIR)/main.o \
$(OBJDIR)/blockdevice.o \
$(OBJDIR)/test-blockdevice.o \
$(OBJDIR)/myfs.o \
$(OBJDIR)/test-myfs.o \
$(OBJDIR)/helper.o
# test targets
TTARGETS = unittests
# compile test files without header dependency
$(OBJDIR)/%.o : $(TSRCDIR)/%.cpp
g++ -c $(CPPFLAGS) -o $@ $<
# link target testing
unittest: obj $(UNITTEST_OBJS)
g++ $(LINKFLAGS) -o $@ $(UNITTEST_OBJS) $(LIBS)