From 26194d77b2f4c16ff8aeaf698476b54849d3d7da Mon Sep 17 00:00:00 2001 From: Gustav Louw Date: Sun, 23 Sep 2018 12:40:16 -0700 Subject: [PATCH] cleaner makefile --- .gitignore | 6 +----- Makefile | 61 +++++++++--------------------------------------------- 2 files changed, 11 insertions(+), 56 deletions(-) diff --git a/.gitignore b/.gitignore index c9676c4..92bd5a3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,2 @@ -*.o -*.d gel -*.cachegrind -*.callgrind -gel-1.0.zip +obj/ diff --git a/Makefile b/Makefile index 04b4f0a..085e6e2 100644 --- a/Makefile +++ b/Makefile @@ -1,59 +1,18 @@ -CC = gcc - -NAME = gel +BIN = gel -SRCS = main.c +CFLAGS = -std=c99 -Wall -Wextra -pedantic -Ofast -flto -march=native -# CompSpec defined in windows environment. -ifdef ComSpec - BIN = $(NAME).exe -else - BIN = $(NAME) -endif +LDFLAGS = -lm -lSDL2 -lSDL2_image -CFLAGS = -ifdef ComSpec - CFLAGS += -I ../SDL2-2.0.7/i686-w64-mingw32/include - CFLAGS += -I ../SDL2-2.0.7/i686-w64-mingw32/include/SDL2 -endif -CFLAGS += -std=c99 -CFLAGS += -Wshadow -Wall -Wpedantic -Wextra -Wdouble-promotion -CFLAGS += -g -CFLAGS += -Ofast -march=native -CFLAGS += -flto - -LDFLAGS = -ifdef ComSpec - LDFLAGS += -L..\SDL2-2.0.7\i686-w64-mingw32\lib - LDFLAGS += -lmingw32 - LDFLAGS += -lSDL2main -endif -LDFLAGS += -lSDL2 -lm -lSDL2_image +CC = gcc -ifdef ComSpec - RM = del /F /Q - MV = ren -else - RM = rm -f - MV = mv -f -endif +SRC = main.c -# Link. -$(BIN): $(SRCS:.c=.o) - $(CC) $(CFLAGS) $(SRCS:.c=.o) $(LDFLAGS) -o $(BIN) +all: + $(CC) $(CFLAGS) $(LDFLAGS) $(SRC) -o $(BIN) -# Compile. -%.o : %.c - $(CC) $(CFLAGS) -MMD -MP -MT $@ -MF $*.td -c $< - @$(RM) $*.d - @$(MV) $*.td $*.d -%.d: ; --include *.d +run: + ./$(BIN) clean: - $(RM) vgcore.* - $(RM) cachegrind.out.* - $(RM) callgrind.out.* - $(RM) $(BIN) - $(RM) $(SRCS:.c=.o) - $(RM) $(SRCS:.c=.d) + rm -f $(BIN)