forked from zear/Shifty-Pills
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
74 lines (64 loc) · 2.19 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
ifeq ($(PLATFORM), gcw0)
CC := /opt/gcw0-toolchain/usr/bin/mipsel-linux-gcc
STRIP := /opt/gcw0-toolchain/usr/bin/mipsel-linux-strip
SYSROOT := $(shell $(CC) -print-sysroot)
CFLAGS := --std=c89 --pedantic -Wall $(shell $(SYSROOT)/usr/bin/sdl-config --cflags) -DHOME_DIR -DNETWORKING
LDFLAGS := $(shell $(SYSROOT)/usr/bin/sdl-config --libs) -lm
endif
ifeq ($(PLATFORM), bittboy)
CC := arm-linux-gcc
STRIP := arm-linux-strip
SYSROOT := $(shell $(CC) --print-sysroot)
CFLAGS := $(shell $(SYSROOT)/usr/bin/sdl-config --cflags)
CFLAGS += -DHOME_DIR -D_BITTBOY
LDFLAGS := $(shell $(SYSROOT)/usr/bin/sdl-config --libs) -lSDL_mixer -lm
endif
ifeq ($(PLATFORM), macos)
CFLAGS := $(shell sdl-config --cflags)
endif
ifeq ($(PLATFORM), mingw)
CC := i686-w64-mingw32-gcc
STRIP := i686-w64-mingw32-strip
SYSROOT ?= /usr/i686-w64-mingw32
CFLAGS := --std=c89 --pedantic -Wall $(shell $(SYSROOT)/bin/sdl-config --cflags)
LDFLAGS := $(shell $(SYSROOT)/bin/sdl-config --libs) -lm
TARGET := shifty.exe
endif
SRCDIRS = . backend
CC ?= gcc
STRIP ?= strip
TARGET ?= shifty.elf
SYSROOT ?= $(shell $(CC) -print-sysroot)
MACHINE ?= $(shell $(CC) -dumpmachine)
DESTDIR ?= $(SYSROOT)
CFLAGS ?= --std=c89 --pedantic -Wall $(shell sdl-config --cflags) -DHOME_DIR -DNETWORKING
LDFLAGS ?= $(shell sdl-config --libs) -lm
OUTDIR ?= output/$(MACHINE)
ifdef DEBUG
# CFLAGS += -DDEBUG -ggdb3 -Wall
CFLAGS += -ggdb3 -Wextra
OUTDIR := $(OUTDIR)-debug
TARGET := $(TARGET)-debug
else
CFLAGS += -O2
endif
BINDIR := $(OUTDIR)/bin
SRCDIR := src
OBJDIR := $(OUTDIR)/obj
#IGNORED_FILES:= $(SRCDIR)/
SRC := $(filter-out $(IGNORED_FILES),$(foreach dir,$(SRCDIRS),$(sort $(wildcard $(addprefix $(SRCDIR)/,$(dir))/*.c))))
OBJ := $(patsubst $(SRCDIR)/%.c,$(OBJDIR)/%.o,$(SRC))
.PHONY: all clean
all: $(TARGET)
$(TARGET): $(OBJ) | $(BINDIR)
$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $(BINDIR)/$@
ifndef DEBUG
$(STRIP) $(BINDIR)/$@
endif
$(OBJ): $(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR)
mkdir -p $(@D)
$(CC) -c $(CFLAGS) $< -o $@ -I include
$(BINDIR) $(OBJDIR):
mkdir -p $@
clean:
rm -Rf $(OUTDIR)