From 8e95c29f1fec9b73859b71fe5e7538a2b17e4d82 Mon Sep 17 00:00:00 2001 From: Oxore Date: Fri, 1 Dec 2017 02:34:09 +0300 Subject: Make make to put all object files into "build" directory --- Makefile | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) (limited to 'Makefile') 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 -- cgit v1.2.3