diff options
author | Oxore <oxore@protonmail.com> | 2017-12-01 02:34:09 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2017-12-01 02:34:09 +0300 |
commit | 8e95c29f1fec9b73859b71fe5e7538a2b17e4d82 (patch) | |
tree | 6d6e6d38e38a8b4ef0771d1612ca1ac1359e9f9f | |
parent | ae01c7fc02f17105f9e04af493f4dd8986fbcb8b (diff) |
Make make to put all object files into "build" directory
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 46 |
2 files changed, 34 insertions, 13 deletions
@@ -1,3 +1,4 @@ tetris *.o *.swp +build @@ -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 |