Debian Codegraph @

src/Makefile.msys2.sdl2

raw
1 # File: Makefile.msys2.sdl2
2 # Makefile for compiling Angband with SDL2.
3 #
4 # This makefile requires GNU make.
5 #
6 # This makefile is intended for use with GNU make and mingw in the msys2
7 # environment for Windows (within msys2 run "pacman -S mingw-w64-x86_64-gcc ;
8 # pacman -S make" to install those).
9 #
10 # The video subsystem requires libsdl2, libsdl2-ttf and libsdl2-image
11 # (within msys2 run "pacman -S mingw-w64-x86_64-SDL2 ;
12 # pacman -S mingw-w64-x86_64-SDL2_ttf ; pacman -S mingw-w64-x86_64-SDL2_image"
13 # to install those).
14 #
15 # The sound subsystem requires libsdl2 and libsdl2-mixer (libsdl2 is already
16 # installed for the video subsystem; to install libsdl2-mixer run
17 # "pacman -S mingw-w64-x86_64-SDL2_mixer" in msys2).
18 #
19 # If you want only video (but not sound), use it like this:
20 # (from angband directory)
21 #
22 # cd src
23 # make -f Makefile.msys2.sdl
24 #
25 # To also have SDL2 sound, change the second of those commands to:
26 # make -f Makefile.msys2.sdl2 SOUND=yes
27 #
28
29 # By default, copy the executable to ../ so that
30 # you don't find yourself debugging a stale copy.
31 .PHONY: default
32 default: install
33
34 # Support SDL2 frontend, link all dependencies statically
35 # freetype and harfbuzz has Circular dependency
36 VIDEO_sdl2_cflags := \
37 -DUSE_SDL2 \
38 $(shell sdl2-config --cflags) \
39
40 VIDEO_sdl2_ldflags := \
41 $(shell sdl2-config --static-libs) \
42 -lSDL2_ttf -lSDL2_image \
43 -ltiff \
44 -ljbig \
45 -lLerc \
46 -lzstd \
47 -llzma \
48 -ljxl \
49 -lhwy \
50 -lwebp \
51 -lsharpyuv \
52 -lfreetype \
53 -lharfbuzz \
54 -lDwrite \
55 -lfreetype \
56 -lbrotlidec \
57 -lbrotlicommon \
58 -lgraphite2 \
59 -lpng \
60 -ldeflate \
61 -ljpeg \
62 -lbz2 \
63 -lintl \
64 -lrpcrt4 \
65 -lz \
66 -lVersion \
67 -lstdc++ \
68 -lImm32 \
69 -lhid \
70 -lsetupapi \
71 -lole32 \
72 -loleaut32 \
73 -lwinmm \
74
75 ## Support SDL_mixer for sound
76 ifdef SOUND
77 SOUND_sdl2_cflags := \
78 -DSOUND_SDL2 \
79 -DSOUND \
80 $(shell sdl2-config --cflags) \
81
82 SOUND_sdl2_ldflags := \
83 $(shell sdl2-config --libs) \
84 -lSDL2_mixer \
85 -lmpg123 \
86 -lopusfile \
87 -lopus \
88 -logg \
89 -lshlwapi \
90 -lwinmm
91 endif
92
93 # Compiler to use
94 CC := gcc
95
96 WARNINGS = -W -Wall -Wextra -Wno-unused-parameter \
97 -Wno-missing-field-initializers -Wwrite-strings -Wmissing-prototypes \
98 -Wnested-externs -Wshadow -Wunused-macros
99
100 # Flags to use in compilation
101 CFLAGS := -std=c99 \
102 -g \
103 -O2 \
104 $(WARNINGS) -pedantic \
105 -static \
106 -DUSE_PRIVATE_PATHS \
107 -DHAVE_DIRENT_H \
108 -DMSYS2_ENCODING_WORKAROUND
109
110 # Linker flags
111 LDFLAGS :=
112
113 # Frontends to compile
114 MODULES_cflags := $(VIDEO_sdl2_cflags)
115 MODULES_ldflags := $(VIDEO_sdl2_ldflags)
116 ifdef SOUND
117 MODULES_cflags += $(SOUND_sdl2_cflags)
118 MODULES_ldflags += $(SOUND_sdl2_ldflags)
119 endif
120
121 CFLAGS += $(MODULES_cflags)
122 LDFLAGS += $(MODULES_ldflags)
123
124 # Makefile.inc contains an up-to-date set of object files to compile
125 include Makefile.inc
126
127 #### Targets and objects #####
128
129 # Program name (PROGNAME comes from Makefile.src via Makefile.inc)
130 EXE := $(PROGNAME)
131
132 # Object definitions (BASEOBJS come from Makefile.inc)
133 OBJS := main.o main-sdl2.o $(BASEOBJS)
134
135 ifdef SOUND
136 OBJS += snd-sdl.o
137 endif
138
139 # Build the "Angband" program
140 $(EXE): $(OBJS)
141 @printf "%10s %-20s\n" LINK $@
142 @$(CC) -o $(EXE) $(OBJS) $(CFLAGS) $(LDFLAGS)
143
144 # Install the game.
145 .PHONY: install
146 install: ../$(EXE)
147
148 ../$(EXE): $(EXE)
149 cp $(EXE) ..
150
151 # Clean up old junk
152 .PHONY: clean
153 clean:
154 -rm -f $(OBJS) $(EXE) snd-sdl.o
155
156 # Verify module arguments
157 .PHONY: args
158 args:
159 @echo CFLAGS = $(CFLAGS)
160 @echo "---"
161 @echo LDFLAGS = $(LDFLAGS)
162 @echo "---"
163 @echo MODULES = $(MODULES)
164 @echo "---"
165 @echo INCLUDES = $(INCLUDES)
166
167 # Some file dependencies
168 %.o: %.c
169 @printf "%10s %-20s\n" CC $<
170 @$(CC) -o $@ -c $< $(CFLAGS)