Skip to content

Commit

Permalink
cleaner makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
glouw committed Sep 23, 2018
1 parent 255dae5 commit 26194d7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 56 deletions.
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
*.o
*.d
gel
*.cachegrind
*.callgrind
gel-1.0.zip
obj/
61 changes: 10 additions & 51 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 26194d7

Please sign in to comment.