This repository was archived by the owner on Aug 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
59 lines (47 loc) · 1.29 KB
/
Makefile
File metadata and controls
59 lines (47 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Compilers and options
CC=gcc
CPPFLAGS= `pkg-config --cflags sdl` -MMD
CFLAGS= -Wall -Wextra -std=c99 -pedantic -O2
LDFLAGS=
LDLIBS=`pkg-config --libs sdl2` -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer -lm
# make -> Build the project
# make remove -> Remove .o .d and exe
# make clean -> Remove .o only
# make remdep -> Remove .d only
# ========== NO TOUCHY UNDER THE LINEY ========== #
# Directories
SRCDIR = src
OBJDIR = obj
BINDIR = bin
# Target
TARGET = main
# Sources
SOURCES := $(wildcard $(SRCDIR)/*.c)
INCLUDES := $(wildcard $(SRCDIR)/*.h)
DEPENDS := $(wildcard $(OBJDIR)/*.d)
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
rm = rm -f
all: makedirs $(BINDIR)/$(TARGET)
$(BINDIR)/$(TARGET): $(OBJECTS)
@$(CC) $(OBJECTS) $(LDLIBS) -o $@
@echo "Linking complete!"
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
@$(CC) $(CFLAGS) -c $< -o $@
@echo -e "[\e[42mOK\e[0m] Compiled "$<""
makedirs:
@mkdir -p $(OBJDIR)
@mkdir -p $(BINDIR)
@echo -e "[\e[42mOK\e[0m] Created directories : $(BINDIR) $(OBJDIR)"
.PHONEY: remove
remove:
$(rm) $(OBJECTS)
@echo -e "[\e[42mOK\e[0m] Cleanup complete!"
.PHONEY: clean
clean: remove
$(rm) $(BINDIR)/$(TARGET)
@echo -e "[\e[42mOK\e[0m] Executable removed!"
.PHONEY: remdep
remdep:
$(rm) $(DEPENDS)
@echo "Dependencies removed!"
# END