-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.sdl
123 lines (91 loc) · 2.8 KB
/
Makefile.sdl
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# vi:syntax=make
ifneq ($(CALLER),MASTER)
include Makefile.inc
endif
# 1. Directories
OBJDIR_SDL := $(OBJDIR)/sdl
DEPDIR_SDL := $(DEPDIR)/sdl
GENDIR_SDL := $(GENDIR)/sdl
# 2. Files
BIN_SDL := $(BINDIR)/$(DSEKAI)
DSEKAI_C_FILES_SDL_ONLY := \
src/main.c \
src/pov.c \
src/scparse.c \
unilayer/src/animate.c \
unilayer/src/input/sdli.c \
unilayer/src/graphics/sdlg.c \
unilayer/src/memory/fakem.c \
unilayer/src/save/file.c
DSEKAI_O_FILES_SDL := \
$(addprefix $(OBJDIR_SDL)/,$(subst .c,.o,$(DSEKAI_C_FILES))) \
$(addprefix $(OBJDIR_SDL)/,$(subst .c,.o,$(DSEKAI_C_FILES_SDL_ONLY))) \
$(addprefix $(OBJDIR_SDL)/,$(subst .c,.o,$(DSEKAI_C_FILES_RES)))
RESEXT_H_SDL := $(GENDIR_SDL)/resext.h
# 1a. Packaging Manifest
SDL_MANIFEST :=
ifeq ($(RESOURCE),FILE)
SDL_MANIFEST += $(DSEKAI_ASSETS_BITMAPS)
endif
ifeq ($(FMT_ASN),TRUE)
SDL_MANIFEST += $(subst .json,.asn,$(DSEKAI_ASSETS_MAPS_JSON))
endif
ifeq ($(FMT_JSON),TRUE)
SDL_MANIFEST += \
$(DSEKAI_ASSETS_MAPS_JSON) \
$(DSEKAI_ASSETS_TILESETS_JSON) \
$(DSEKAI_ASSETS_SCRIPTS)
endif
# 3. Programs
CC_SDL := gcc
LD_SDL := gcc
# 4. Arguments
ifeq ($(BUILD),RELEASE)
DEFINES_DEBUG :=
else
# Assume debug build.
#DEFINES_DEBUG := -DUSE_BACKTRACE -DMEMORY_FAKE_TRACE_LOCKS -DSCRIPT_TRACE
DEFINES_DEBUG := -DUSE_BACKTRACE -DMEMORY_HANDLE_SENTINAL=1234 -DDSEKAI_PROFILER
endif
DEFINES_SDL := \
$(DEFINES_DSEKAI) \
$(DEFINES_DEPTH) \
$(DEFINES_RESOURCE) \
$(DEFINES_DEBUG) \
-DUSE_SOFTWARE_TEXT \
-DSCREEN_SCALE=$(SCREEN_SCALE)
INCLUDES_SDL := \
$(INCLUDES_UNILAYER) \
-I $(GENDIR_SDL)
CFLAGS_SDL := $(CFLAGS_GCC_GENERIC) $(FLAGS_GCC_SANITIZE) $(DEFINES_SDL) $(INCLUDES_SDL) -Werror
LDFLAGS_SDL := $(LDFLAGS_GCC_GENERIC) $(FLAGS_GCC_SANITIZE) -lm
ifeq ($(TRACEWIN),TRUE)
CFLAGS_SDL += -DWINDOW_TRACE
endif
ifeq ("$(SDL_VER)","1")
CFLAGS_SDL += $(shell pkg-config sdl --cflags) -DPLATFORM_SDL1
LDFLAGS_SDL += $(shell pkg-config sdl --libs)
else
CFLAGS_SDL += $(shell pkg-config sdl2 --cflags) -DPLATFORM_SDL2
LDFLAGS_SDL += $(shell pkg-config sdl2 --libs)
endif
# 5. Targets
platform := sdl
platform_upper := SDL
res_gfx := $(DSEKAI_ASSETS_BITMAPS)
$(eval $(RESEXT_H_RULE))
pkg_bin := $(BIN_SDL) $(CONVERT) $(MAP2ASN)
pkg_strip := strip
pkg_name := $(DSEKAI)-$(platform)-$(PKGOS)-$(GIT_HASH)
pkg_reqs := $(SDL_MANIFEST)
$(eval $(PKG_RULE))
$(BIN_SDL): $(DSEKAI_O_FILES_SDL) | $(BINDIR)/$(STAMPFILE)
$(LD_SDL) -o $@ $^ $(LDFLAGS_SDL)
$(OBJDIR_SDL)/%.o: %.c $(RESEXT_H_SDL) | $(DSEKAI_ASSETS_MAPS_JSON)
$(MD) $(dir $@)
$(CC_SDL) $(CFLAGS_SDL) -c -o $@ $(<:%.o=%)
$(DEPDIR_SDL)/%.d: %.c $(RESEXT_H_SDL)
$(MD) $(dir $@)
$(CC_SDL) $(CFLAGS_SDL) -MM $< \
-MT $(subst .c,.o,$(addprefix $(DEPDIR_SDL)/,$<)) -MF $@
#include $(subst $(OBJDIR)/,$(DEPDIR)/,$(DSEKAI_O_FILES_SDL:.o=.d))