-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
96 lines (71 loc) · 2.28 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# 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 mkfs.myfs unittest
# object files for target mkfs.myfs TODO: add new object files here
MKFS_MYFS_OBJS = $(OBJDIR)/blockdevice.o \
$(OBJDIR)/RootDirectory.o \
$(OBJDIR)/Superblock.o \
$(OBJDIR)/myfs.o \
$(OBJDIR)/mkfs.myfs.o \
# object files for target mount.myfs TODO: add new object files here
MOUNT_MYFS_OBJS = $(OBJDIR)/blockdevice.o \
$(OBJDIR)/RootDirectory.o \
$(OBJDIR)/Superblock.o \
$(OBJDIR)/myfs.o \
$(OBJDIR)/wrap.o \
$(OBJDIR)/mount.myfs.o
# build all targets
all: $(TARGETS)
# link target mkfs.myfs
mkfs.myfs: obj $(MKFS_MYFS_OBJS)
g++ $(LINKFLAGS) -o $@ $(MKFS_MYFS_OBJS) $(LIBS)
# 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)/Superblock.o \
$(OBJDIR)/blockdevice.o \
$(OBJDIR)/RootDirectory.o \
$(OBJDIR)/test-rootdirectory.o \
$(OBJDIR)/test-superblock.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)