Skip to content
Snippets Groups Projects
Commit c3e95509 authored by Filip Strömbäck's avatar Filip Strömbäck
Browse files

Improved makefiles to take dependencies into account.

parent f9ec83ce
Branches
Tags
No related merge requests found
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
bin/ bin/
build/ build/
*.o *.o
*.d
*.aux *.aux
*.fdb_latexmk *.fdb_latexmk
......
CXXFLAGS := -std=c++17 CXXFLAGS := -g -std=c++17
LDFLAGS := -lsfml-graphics -lsfml-window -lsfml-system LDFLAGS := -g -lsfml-graphics -lsfml-window -lsfml-system
SOURCES := $(wildcard *.cpp) SOURCES := $(wildcard *.cpp)
EXECUTABLES := $(patsubst %.cpp,%,$(SOURCES)) EXECUTABLES := $(patsubst %.cpp,%,$(SOURCES))
......
CXXFLAGS := -std=c++17 -Wall -Wextra CXXFLAGS := -g -std=c++17 -Wall -Wextra
LDFLAGS := -lsfml-graphics -lsfml-window -lsfml-system LDFLAGS := -g -lsfml-graphics -lsfml-window -lsfml-system
SOURCES := $(wildcard *.cpp) SOURCES := $(wildcard *.cpp)
OBJECTS := $(patsubst %.cpp,%.o,$(SOURCES)) OBJECTS := $(patsubst %.cpp,%.o,$(SOURCES))
# Note: This makefile is not entirely correct, it does not take header dependencies into account. # Dependencies:
# It is, however, enough to compile the project here, which is the intended use. If you wish to DEPS := $(patsubst %.o,%.d,$(OBJECTS))
# develop the code further, I suggest either mymake or writing a CMake-file. DEPFLAGS := -MMD -MP
all: game all: game
...@@ -14,7 +14,7 @@ pdf: uml.pdf ...@@ -14,7 +14,7 @@ pdf: uml.pdf
.PHONY: clean .PHONY: clean
clean: clean:
rm -f game $(OBJECTS) rm -f game $(OBJECTS) $(DEPS)
find . -name "uml.*" | grep -Ev "(pdf|tex)$$" | xargs rm -f find . -name "uml.*" | grep -Ev "(pdf|tex)$$" | xargs rm -f
uml.pdf: uml.tex uml.pdf: uml.tex
...@@ -24,4 +24,7 @@ game: $(OBJECTS) ...@@ -24,4 +24,7 @@ game: $(OBJECTS)
g++ $(CXXFLAGS) -o game $(OBJECTS) $(LDFLAGS) g++ $(CXXFLAGS) -o game $(OBJECTS) $(LDFLAGS)
$(OBJECTS): %.o: %.cpp $(OBJECTS): %.o: %.cpp
g++ $(CXXFLAGS) -c -o $@ $< g++ $(CXXFLAGS) $(DEPFLAGS) -c -o $@ $<
# Include dependencies
-include $(DEPS)
CXXFLAGS := -std=c++17 -Wall -Wextra CXXFLAGS := -g -std=c++17 -Wall -Wextra
LDFLAGS := -lsfml-graphics -lsfml-window -lsfml-system LDFLAGS := -g -lsfml-graphics -lsfml-window -lsfml-system
SOURCES := $(wildcard *.cpp) SOURCES := $(wildcard *.cpp)
OBJECTS := $(patsubst %.cpp,%.o,$(SOURCES)) OBJECTS := $(patsubst %.cpp,%.o,$(SOURCES))
# Note: This makefile is not entirely correct, it does not take header dependencies into account. # Dependencies:
# It is, however, enough to compile the project here, which is the intended use. If you wish to DEPS := $(patsubst %.o,%.d,$(OBJECTS))
# develop the code further, I suggest either mymake or writing a CMake-file. DEPFLAGS := -MMD -MP
all: game all: game
...@@ -14,7 +14,7 @@ pdf: uml.pdf ...@@ -14,7 +14,7 @@ pdf: uml.pdf
.PHONY: clean .PHONY: clean
clean: clean:
rm -f game $(OBJECTS) rm -f game $(OBJECTS) $(DEPS)
find . -name "uml.*" | grep -Ev "(pdf|tex)$$" | xargs rm -f find . -name "uml.*" | grep -Ev "(pdf|tex)$$" | xargs rm -f
uml.pdf: uml.tex uml.pdf: uml.tex
...@@ -24,4 +24,7 @@ game: $(OBJECTS) ...@@ -24,4 +24,7 @@ game: $(OBJECTS)
g++ $(CXXFLAGS) -o game $(OBJECTS) $(LDFLAGS) g++ $(CXXFLAGS) -o game $(OBJECTS) $(LDFLAGS)
$(OBJECTS): %.o: %.cpp $(OBJECTS): %.o: %.cpp
g++ $(CXXFLAGS) -c -o $@ $< g++ $(CXXFLAGS) $(DEPFLAGS) -c -o $@ $<
# Include dependencies
-include $(DEPS)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment