aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile30
1 files changed, 20 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index a93df76..05f2fed 100644
--- a/Makefile
+++ b/Makefile
@@ -1,25 +1,35 @@
+RM = rm -f
+MKDIR = mkdir -p
+
CXX = g++
-CXXFLAGS = --std=c++14 -g -O0 -Wall
+CXXFLAGS = --std=c++14 -O3 -Wall
LDLIBS = -lsfml-graphics -lsfml-window -lsfml-system
-SOURCE_DIR = src/
-OBJECTS_DIR= obj/
+SOURCE_DIR = src
+OBJECT_DIR= build
OBJS = main.o State.o Game.o Global.o Enemy1.o Enemy2.o Enemy3.o Powerup.o Entity.o Player.o
-OBJECTS = $(addprefix $(OBJECTS_DIR),$(OBJS))
+OBJECTS = $(addprefix $(OBJECT_DIR)/,$(OBJS))
TARGET = sfml-rpg
-all: $(TARGET)
+.PHONY: all compile clean
+
+all: compile
+
+$(OBJECT_DIR)/%.o: $(SOURCE_DIR)/%.cpp
+ $(CXX) $(CXXFLAGS) -MMD -MP -c $< -o $@
$(TARGET): $(OBJECTS)
$(CXX) $(CXXFLAGS) $(OBJECTS) -o $(TARGET) $(LDLIBS)
-$(OBJECTS_DIR)%.o: $(SOURCE_DIR)%.cpp
- $(MKDIR_P) $(dir $@)
- $(CXX) $(CXXFLAGS) -c $< -o $@
+compile:
+ $(MKDIR) $(OBJECT_DIR)
+ $(MAKE) $(TARGET)
+
+run: compile
+ ./$(TARGET)
clean:
$(RM) $(OBJECTS) sfml-rpg
-RM = rm -f
-MKDIR_P = mkdir -p
+-include $(OBJECTS:.o=.d)