-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
50 lines (36 loc) · 1.15 KB
/
Makefile
File metadata and controls
50 lines (36 loc) · 1.15 KB
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
# Makefile for shell project
CXX = g++
CXXFLAGS = -std=c++17 -Wall -Wextra -I./h
TARGET = shell.exe
LDFLAGS =
# Source files
SRCDIR = src
SOURCES = $(SRCDIR)/main.cpp $(SRCDIR)/commands.cpp $(SRCDIR)/executor.cpp $(SRCDIR)/path.cpp
# Object files
OBJDIR = obj
OBJECTS = $(OBJDIR)/main.o $(OBJDIR)/commands.o $(OBJDIR)/executor.o $(OBJDIR)/path.o
# Default target
all: $(OBJDIR) $(TARGET)
# Create object directory
$(OBJDIR):
-mkdir $(OBJDIR)
# Link
$(TARGET): $(OBJECTS)
$(CXX) $(OBJECTS) -o $(TARGET) $(LDFLAGS)
# Compile source files
$(OBJDIR)/main.o: $(SRCDIR)/main.cpp h/commands.h
$(CXX) $(CXXFLAGS) -c $(SRCDIR)/main.cpp -o $(OBJDIR)/main.o
$(OBJDIR)/commands.o: $(SRCDIR)/commands.cpp h/commands.h h/path.h h/executor.h
$(CXX) $(CXXFLAGS) -c $(SRCDIR)/commands.cpp -o $(OBJDIR)/commands.o
$(OBJDIR)/executor.o: $(SRCDIR)/executor.cpp h/executor.h
$(CXX) $(CXXFLAGS) -c $(SRCDIR)/executor.cpp -o $(OBJDIR)/executor.o
$(OBJDIR)/path.o: $(SRCDIR)/path.cpp h/path.h
$(CXX) $(CXXFLAGS) -c $(SRCDIR)/path.cpp -o $(OBJDIR)/path.o
# Clean build files
clean:
rm -rf $(OBJDIR)
rm -f $(TARGET)
# Run the program
run: $(TARGET)
.\$(TARGET)
.PHONY: all clean run