-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
59 lines (43 loc) · 1.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
#---------------------------------------------------------------------------------------------------
# System Programming I/O Lab Spring 2024
#
# Makefile
#
# GNU make documentation: https://www.gnu.org/software/make/manual/make.html
#
# You shouldn't have to modify anything in this Makefile unless you add new source files.
#
#--- variable declarations
# directories
SRC_DIR=src
OBJ_DIR=obj
DEP_DIR=.deps
# C compiler and compilation flags
CC=gcc
CFLAGS=-Wall -Wno-stringop-truncation -O2 -g
CFLAGS_HDT=-Wall -Wno-stringop-truncation -O2
DEPFLAGS=-MMD -MP -MT $@ -MF $(DEP_DIR)/$*.d
# make sure SOURCES includes ALL source files required to compile the project
SOURCES=dirtree.c
TARGET=dirtree
# derived variables
OBJECTS=$(SOURCES:%.c=$(OBJ_DIR)/%.o)
DEPS=$(SOURCES:%.c=$(DEP_DIR)/%.d)
#--- rules
.PHONY: doc
all: $(TARGET)
$(TARGET): $(OBJECTS)
$(CC) $(CFLAGS) -o $@ $^
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(DEP_DIR) $(OBJ_DIR)
$(CC) $(CFLAGS) $(DEPFLAGS) -o $@ -c $<
$(DEP_DIR):
@mkdir -p $(DEP_DIR)
$(OBJ_DIR):
@mkdir -p $(OBJ_DIR)
-include $(DEPS)
doc: $(SOURES:%.c=$(SRC_DIR)/%.c) $(wildcard $(SOURCES:%.c=$(SRC_DIR)/%.h))
doxygen doc/Doxyfile
clean:
rm -rf $(OBJ_DIR) $(DEP_DIR)
mrproper: clean
rm -rf $(TARGET) doc/html