summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile46
1 files changed, 33 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 3d62d6e..b8b76ba 100644
--- a/Makefile
+++ b/Makefile
@@ -1,19 +1,39 @@
CC=gcc
-FILES:=$(wildcard src/*.c)
-FILES:=$(FILES:.c=.o)
+CFLAGS+=-Wall
+CFLAGS+=-std=c11
+CFLAGS+=-O0
+CFLAGS+=-I$(INCLUDE)
+LIBS+=-lcsfml-graphics
+LIBS+=-lcsfml-window
+LIBS+=-lcsfml-system
-CFLAGS += -Wall
-CFLAGS += -std=c99
-CFLAGS += -O0
-CFLAGS += -Iinclude
-LIBS += -lcsfml-graphics
-LIBS += -lcsfml-window
-LIBS += -lcsfml-system
+BUILD:=build
+SRC:=src
+INCLUDE:=include
+SOURCES:=$(wildcard $(SRC)/*.c)
+OBJECTS:=$(patsubst $(SRC)/%.c,$(BUILD)/%.o,$(SOURCES))
-all: tetris
+TARGET:=tetris
-tetris: $(FILES)
- $(CC) -o $@ $^ $(CFLAGS) $(LIBS)
+#======================================================================
+
+all: $(TARGET)
+
+$(TARGET): $(OBJECTS)
+ @echo "Compiling: $@"
+ @$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
+ @echo "Build successfull"
+
+$(OBJECTS): | $(BUILD)
+
+$(BUILD):
+ @mkdir -p $(BUILD)
+
+$(BUILD)/%.o: $(SRC)/%.c
+ @echo "Compiling: $@"
+ @$(CC) -c $(CFLAGS) $(LIBS) -o $@ $<
clean:
- rm -f tetris $(FILES)
+ @rm -rfv $(TARGET) $(BUILD)
+
+.PHONY: all clean