-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
38 lines (32 loc) · 822 Bytes
/
Makefile
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
COMPILER = gcc
CFLAGS = -g -O2 -MMD -MP -Wall -Wextra -Winit-self -Wno-missing-field-initializers
ifeq "$(shell getconf LONG_BIT)" "64"
LDFLAGS =
else
LDFLAGS =
endif
LIBS = -lSDL2 -lm
INCLUDE = -I./src
TARGET = ./bin/$(shell basename `readlink -f .`)
SRCDIR = ./src
ifeq "$(strip $(SRCDIR))" ""
SRCDIR = .
endif
SOURCES = $(wildcard $(SRCDIR)/*.c)
OBJDIR = ./obj
ifeq "$(strip $(OBJDIR))" ""
OBJDIR = .
endif
OBJECTS = $(addprefix $(OBJDIR)/, $(notdir $(SOURCES:.c=.o)))
DEPENDS = $(OBJECTS:.o=.d)
$(TARGET): $(OBJECTS) $(LIBS)
-mkdir -p ./bin
$(COMPILER) -o $@ $^ $(LDFLAGS)
$(OBJDIR)/%.o: $(SRCDIR)/%.c
-mkdir -p $(OBJDIR)
$(COMPILER) $(CFLAGS) $(INCLUDE) -o $@ -c $<
build: $(TARGET)
all: clean $(TARGET)
clean:
-rm -f $(OBJECTS) $(DEPENDS) $(TARGET)
-include $(DEPENDS)