-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathMakefile
90 lines (76 loc) · 1.58 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
CFLAGS = -g -fpack-struct
LIBS =
LDFLAGS =
INCLUDES = ./src/include
SRC_DIR = ./src
OBJ_DIR = ./obj
BUILD_DIR = ./build
DIST_DIR = ./dist
CC = gcc
LD = ld
DEBUGGER = ddd
SRC = thinfat32.c fat32_ui.c tests.c
OBJS = $(SRC:%.c=$(OBJ_DIR)/%.o)
VPATH = $(SRC_DIR)
all: | begin tests end
begin:
@echo
@echo "Starting Build..."
@echo "-----------------"
mkdir -p $(SRC_DIR)
mkdir -p $(OBJ_DIR)
mkdir -p $(BUILD_DIR)
mkdir -p $(DIST_DIR)
@echo
end:
@echo
@echo "Done."
@echo
$(OBJS) : $(OBJ_DIR)/%.o : %.c
@echo
@echo "Compiling C File" $<
@echo "----------------"
$(CC) -I$(INCLUDES) -c $(CFLAGS) $< -o $@
@echo
# tests : CFLAGS += -D TF_DEBUG -D DEBUG
tests : $(OBJS)
@echo
@echo "Creating Test Fixture"
@echo "---------------------"
$(CC) $(CFLAGS) $(OBJS) --output $(BUILD_DIR)/$@ $(LDFLAGS)
@echo
clean :
@echo
@echo "Cleaning the Build"
@echo "------------------"
rm -rf $(OBJS) core $(BUILD_DIR)/* $(DIST_DIR)/fat32.tar.gz
@echo
test : tests
@echo
@echo "Running Tests..."
@echo "----------------"
make rebuild
./build/tests
@echo
dist : clean
tar -cv src scripts Makefile | gzip -c > $(DIST_DIR)/fat32.tar.gz
@echo
#
# Targets for creating and manipulating the test filesystem
#
create:
sudo ./scripts/makefs make
mount:
sudo ./scripts/makefs mount
unmount:
sudo ./scripts/makefs unmount
populate:
sudo ./scripts/makefs populate
rebuild: unmount create mount populate unmount
debug: tests
@echo
@echo "Starting Debugger..."
@echo "--------------------"
$(DEBUGGER) ./build/tests
@echo
.PHONY : begin end clean create mount unmount populate rebuild debug