-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
35 lines (25 loc) · 759 Bytes
/
Makefile
File metadata and controls
35 lines (25 loc) · 759 Bytes
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
# Compiler
CXX = g++
# Default executable name
EXEC = grad++
# Source files (excluding demo directory)
SRCS = $(filter-out demos/%.cpp, $(wildcard */*.cpp))
# Object files
OBJS = $(SRCS:.cpp=.o)
# Demo source files (all .cpp files in the demos directory)
DEMO_SRCS = $(wildcard demos/*.cpp)
# Demo executables (replace .cpp with no extension)
DEMO_EXECS = $(patsubst demos/%.cpp,%,$(DEMO_SRCS))
# Default target (build all demo executables)
all: $(DEMO_EXECS)
# Pattern rule for demo executables
%: $(OBJS) demos/%.cpp
$(CXX) $(CXXFLAGS) -o $@ $(OBJS) demos/$@.cpp
# Compile source files to object files
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
# Clean up build files
clean:
rm -f $(OBJS) $(EXEC) $(DEMO_EXECS)
# Phony targets
.PHONY: all clean