-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
49 lines (37 loc) · 1.09 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
#---------------------------------------------------------------------------------------------------
# Shell Lab Fall 2023 System Programming
#
# Makefile
#
# GNU make documentation: https://www.gnu.org/software/make/manual/make.html
#
# Typically, the only thing you need to modify in this Makefile is the list of source files.
#
#--- variable declarations
# directories
SRC_DIR=src
OBJ_DIR=obj
DEP_DIR=.deps
# C compiler and compilation flags
CC=gcc
CFLAGS=-Wall -O2 -g
DEPFLAGS=-MMD -MP -MT $@ -MF $(DEP_DIR)/$*.d
# make sure SOURCES includes ALL source files required to compile the project
SOURCES=csapsh.c jobcontrol.c parser.c
TARGET=csapsh
# derived variables
OBJECTS=$(SOURCES:%.c=$(OBJ_DIR)/%.o)
DEPS=$(SOURCES:%.c=$(DEP_DIR)/%.d)
#--- rules
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)
clean:
rm -rf $(OBJ_DIR) $(DEP_DIR) $(TARGET)