Debian Codegraph @

projects/VSCode/Makefile

raw symbols SCIP
1 #**************************************************************************************************
2 #
3 # raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
4 #
5 # Copyright (c) 2013-2019 Ramon Santamaria (@raysan5)
6 #
7 # This software is provided "as-is", without any express or implied warranty. In no event
8 # will the authors be held liable for any damages arising from the use of this software.
9 #
10 # Permission is granted to anyone to use this software for any purpose, including commercial
11 # applications, and to alter it and redistribute it freely, subject to the following restrictions:
12 #
13 # 1. The origin of this software must not be misrepresented; you must not claim that you
14 # wrote the original software. If you use this software in a product, an acknowledgment
15 # in the product documentation would be appreciated but is not required.
16 #
17 # 2. Altered source versions must be plainly marked as such, and must not be misrepresented
18 # as being the original software.
19 #
20 # 3. This notice may not be removed or altered from any source distribution.
21 #
22 #**************************************************************************************************
23
24 .PHONY: all clean
25
26 # Define required raylib variables
27 PROJECT_NAME ?= game
28 RAYLIB_VERSION ?= 5.1-dev
29 RAYLIB_PATH ?= ..\..
30
31 # Define compiler path on Windows
32 COMPILER_PATH ?= C:/raylib/w64devkit/bin
33
34 # Define default options
35 # One of PLATFORM_DESKTOP, PLATFORM_ANDROID, PLATFORM_WEB
36 PLATFORM ?= PLATFORM_DESKTOP
37
38 # Locations of your newly installed library and associated headers. See ../src/Makefile
39 # On Linux, if you have installed raylib but cannot compile the examples, check that
40 # the *_INSTALL_PATH values here are the same as those in src/Makefile or point to known locations.
41 # To enable system-wide compile-time and runtime linking to libraylib.so, run ../src/$ sudo make install RAYLIB_LIBTYPE_SHARED.
42 # To enable compile-time linking to a special version of libraylib.so, change these variables here.
43 # To enable runtime linking to a special version of libraylib.so, see EXAMPLE_RUNTIME_PATH below.
44 # If there is a libraylib in both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, at runtime,
45 # the library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over the one at RAYLIB_INSTALL_PATH.
46 # RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths.
47 DESTDIR ?= /usr/local
48 RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib
49 # RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files.
50 RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include
51
52 # Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
53 RAYLIB_LIBTYPE ?= STATIC
54
55 # Build mode for project: DEBUG or RELEASE
56 BUILD_MODE ?= RELEASE
57
58 # Use external GLFW library instead of rglfw module
59 # TODO: Review usage on Linux. Target version of choice. Switch on -lglfw or -lglfw3
60 USE_EXTERNAL_GLFW ?= FALSE
61
62 # Use Wayland display server protocol on Linux desktop
63 # by default it uses X11 windowing system
64 USE_WAYLAND_DISPLAY ?= FALSE
65
66 # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
67 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
68 # No uname.exe on MinGW!, but OS=Windows_NT on Windows!
69 # ifeq ($(UNAME),Msys) -> Windows
70 ifeq ($(OS),Windows_NT)
71 PLATFORM_OS=WINDOWS
72 export PATH := $(COMPILER_PATH):$(PATH)
73 else
74 UNAMEOS=$(shell uname)
75 ifeq ($(UNAMEOS),Linux)
76 PLATFORM_OS=LINUX
77 endif
78 ifeq ($(UNAMEOS),FreeBSD)
79 PLATFORM_OS=BSD
80 endif
81 ifeq ($(UNAMEOS),OpenBSD)
82 PLATFORM_OS=BSD
83 endif
84 ifeq ($(UNAMEOS),NetBSD)
85 PLATFORM_OS=BSD
86 endif
87 ifeq ($(UNAMEOS),DragonFly)
88 PLATFORM_OS=BSD
89 endif
90 ifeq ($(UNAMEOS),Darwin)
91 PLATFORM_OS=OSX
92 endif
93 endif
94 endif
95 ifeq ($(PLATFORM),PLATFORM_RPI)
96 UNAMEOS=$(shell uname)
97 ifeq ($(UNAMEOS),Linux)
98 PLATFORM_OS=LINUX
99 endif
100 endif
101
102 # RAYLIB_PATH adjustment for different platforms.
103 # If using GNU make, we can get the full path to the top of the tree. Windows? BSD?
104 # Required for ldconfig or other tools that do not perform path expansion.
105 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
106 ifeq ($(PLATFORM_OS),LINUX)
107 RAYLIB_PREFIX ?= ..
108 RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX))
109 endif
110 endif
111 # Default path for raylib on Raspberry Pi, if installed in different path, update it!
112 # This is not currently used by src/Makefile. Not sure of its origin or usage. Refer to wiki.
113 # TODO: update install: target in src/Makefile for RPI, consider relation to LINUX.
114 ifeq ($(PLATFORM),PLATFORM_RPI)
115 RAYLIB_PATH ?= /home/pi/raylib
116 endif
117
118 ifeq ($(PLATFORM),PLATFORM_WEB)
119 # Emscripten required variables
120 EMSDK_PATH ?= C:/raylib/emsdk
121 EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/upstream/emscripten
122 CLANG_PATH = $(EMSDK_PATH)/upstream/bin
123 PYTHON_PATH = $(EMSDK_PATH)/python/3.13.3_64bit
124 NODE_PATH = $(EMSDK_PATH)/node/22.16.0_64bit/bin
125 export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH):$$(PATH)
126 endif
127
128 # Define raylib release directory for compiled library.
129 # RAYLIB_RELEASE_PATH points to provided binaries or your freshly built version
130 RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src
131
132 # EXAMPLE_RUNTIME_PATH embeds a custom runtime location of libraylib.so or other desired libraries
133 # into each example binary compiled with RAYLIB_LIBTYPE=SHARED. It defaults to RAYLIB_RELEASE_PATH
134 # so that these examples link at runtime with your version of libraylib.so in ../release/libs/linux
135 # without formal installation from ../src/Makefile. It aids portability and is useful if you have
136 # multiple versions of raylib, have raylib installed to a non-standard location, or want to
137 # bundle libraylib.so with your game. Change it to your liking.
138 # NOTE: If, at runtime, there is a libraylib.so at both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH,
139 # The library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over RAYLIB_INSTALL_PATH,
140 # Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH)
141 # To see the result, run readelf -d core/core_basic_window; looking at the RPATH or RUNPATH attribute.
142 # To see which libraries a built example is linking to, ldd core/core_basic_window;
143 # Look for libraylib.so.1 => $(RAYLIB_INSTALL_PATH)/libraylib.so.1 or similar listing.
144 EXAMPLE_RUNTIME_PATH ?= $(RAYLIB_RELEASE_PATH)
145
146 # Define default C compiler: gcc
147 # NOTE: define g++ compiler if using C++
148 CC = gcc
149
150 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
151 ifeq ($(PLATFORM_OS),OSX)
152 # OSX default compiler
153 CC = clang
154 endif
155 ifeq ($(PLATFORM_OS),BSD)
156 # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler
157 CC = clang
158 endif
159 endif
160 ifeq ($(PLATFORM),PLATFORM_RPI)
161 ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
162 # Define RPI cross-compiler
163 #CC = armv6j-hardfloat-linux-gnueabi-gcc
164 CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc
165 endif
166 endif
167 ifeq ($(PLATFORM),PLATFORM_WEB)
168 # HTML5 emscripten compiler
169 # WARNING: To compile to HTML5, code must be redesigned
170 # to use emscripten.h and emscripten_set_main_loop()
171 CC = emcc
172 endif
173
174 # Define default make program: Mingw32-make
175 MAKE = mingw32-make
176
177 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
178 ifeq ($(PLATFORM_OS),LINUX)
179 MAKE = make
180 endif
181 ifeq ($(PLATFORM_OS),OSX)
182 MAKE = make
183 endif
184 endif
185
186 # Define compiler flags:
187 # -O0 defines optimization level (no optimization, better for debugging)
188 # -O1 defines optimization level
189 # -g include debug information on compilation
190 # -s strip unnecessary data from build -> do not use in debug builds
191 # -Wall turns on most, but not all, compiler warnings
192 # -std=c99 defines C language mode (standard C from 1999 revision)
193 # -std=gnu99 defines C language mode (GNU C from 1999 revision)
194 # -Wno-missing-braces ignore invalid warning (GCC bug 53119)
195 # -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
196 CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces
197
198 ifeq ($(BUILD_MODE),DEBUG)
199 CFLAGS += -g -O0
200 else
201 CFLAGS += -s -O1
202 endif
203
204 # Additional flags for compiler (if desired)
205 #CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
206 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
207 ifeq ($(PLATFORM_OS),WINDOWS)
208 # resource file contains windows executable icon and properties
209 # -Wl,--subsystem,windows hides the console window
210 CFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data -Wl,--subsystem,windows
211 endif
212 ifeq ($(PLATFORM_OS),LINUX)
213 ifeq ($(RAYLIB_LIBTYPE),STATIC)
214 CFLAGS += -D_DEFAULT_SOURCE
215 endif
216 ifeq ($(RAYLIB_LIBTYPE),SHARED)
217 # Explicitly enable runtime link to libraylib.so
218 CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH)
219 endif
220 endif
221 endif
222 ifeq ($(PLATFORM),PLATFORM_RPI)
223 CFLAGS += -std=gnu99
224 endif
225 ifeq ($(PLATFORM),PLATFORM_WEB)
226 # -Os # size optimization
227 # -O2 # optimization level 2, if used, also set --memory-init-file 0
228 # -sUSE_GLFW=3 # Use glfw3 library (context/input management)
229 # -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL!
230 # -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB)
231 # -sUSE_PTHREADS=1 # multithreading support
232 # -sWASM=0 # disable Web Assembly, emitted by default
233 # -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS
234 # -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data
235 # -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off)
236 # -sMINIFY_HTML=0 # minify generated html from shell.html
237 # --profiling # include information for code profiling
238 # --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
239 # --preload-file resources # specify a resources folder for data compilation
240 # --source-map-base # allow debugging in browser with source map
241 # --shell-file shell.html # define a custom shell .html and output extension
242 CFLAGS += -Os -sUSE_GLFW=3 -sTOTAL_MEMORY=16777216 --preload-file resources -sMINIFY_HTML=0
243 ifeq ($(BUILD_MODE), DEBUG)
244 CFLAGS += -sASSERTIONS=1 --profiling
245 endif
246
247 # Define a custom shell .html and output extension
248 CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html
249 EXT = .html
250 endif
251
252 # Define include paths for required headers
253 # NOTE: Several external required libraries (stb and others)
254 INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external
255
256 # Define additional directories containing required header files
257 ifeq ($(PLATFORM),PLATFORM_RPI)
258 # RPI required libraries
259 INCLUDE_PATHS += -I/opt/vc/include
260 INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux
261 INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads
262 endif
263 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
264 ifeq ($(PLATFORM_OS),BSD)
265 # Consider -L$(RAYLIB_H_INSTALL_PATH)
266 INCLUDE_PATHS += -I/usr/local/include
267 endif
268 ifeq ($(PLATFORM_OS),LINUX)
269 # Reset everything.
270 # Precedence: immediately local, installed version, raysan5 provided libs -I$(RAYLIB_H_INSTALL_PATH) -I$(RAYLIB_PATH)/release/include
271 INCLUDE_PATHS = -I$(RAYLIB_H_INSTALL_PATH) -isystem. -isystem$(RAYLIB_PATH)/src -isystem$(RAYLIB_PATH)/release/include -isystem$(RAYLIB_PATH)/src/external
272 endif
273 endif
274
275 # Define library paths containing required libs.
276 LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
277
278 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
279 ifeq ($(PLATFORM_OS),BSD)
280 # Consider -L$(RAYLIB_INSTALL_PATH)
281 LDFLAGS += -L. -Lsrc -L/usr/local/lib
282 endif
283 ifeq ($(PLATFORM_OS),LINUX)
284 # Reset everything.
285 # Precedence: immediately local, installed version, raysan5 provided libs
286 LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH)
287 endif
288 endif
289
290 ifeq ($(PLATFORM),PLATFORM_RPI)
291 LDFLAGS += -L/opt/vc/lib
292 endif
293
294 # Define any libraries required on linking
295 # if you want to link libraries (libname.so or libname.a), use the -lname
296 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
297 ifeq ($(PLATFORM_OS),WINDOWS)
298 # Libraries for Windows desktop compilation
299 # NOTE: WinMM library required to set high-res timer resolution
300 LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm
301 endif
302 ifeq ($(PLATFORM_OS),LINUX)
303 # Libraries for Debian GNU/Linux desktop compiling
304 # NOTE: Required packages: libegl1-mesa-dev
305 LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt
306
307 # On X11 requires also below libraries
308 LDLIBS += -lX11
309 # NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
310 #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
311
312 # On Wayland windowing system, additional libraries requires
313 ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
314 LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
315 endif
316 # Explicit link to libc
317 ifeq ($(RAYLIB_LIBTYPE),SHARED)
318 LDLIBS += -lc
319 endif
320 endif
321 ifeq ($(PLATFORM_OS),OSX)
322 # Libraries for OSX 10.9 desktop compiling
323 # NOTE: Required packages: libopenal-dev libegl1-mesa-dev
324 LDLIBS = -lraylib -framework OpenGL -framework OpenAL -framework Cocoa -framework IOKit
325 endif
326 ifeq ($(PLATFORM_OS),BSD)
327 # Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
328 # NOTE: Required packages: mesa-libs
329 LDLIBS = -lraylib -lGL -lpthread -lm
330
331 # On XWindow requires also below libraries
332 LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
333 endif
334 ifeq ($(USE_EXTERNAL_GLFW),TRUE)
335 # NOTE: It could require additional packages installed: libglfw3-dev
336 LDLIBS += -lglfw
337 endif
338 endif
339 ifeq ($(PLATFORM),PLATFORM_RPI)
340 # Libraries for Raspberry Pi compiling
341 # NOTE: Required packages: libasound2-dev (ALSA)
342 LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl
343 endif
344 ifeq ($(PLATFORM),PLATFORM_WEB)
345 # Libraries for web (HTML5) compiling
346 LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.web.a
347 endif
348
349 # Define a recursive wildcard function
350 rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
351
352 # Define all source files required
353 SRC_DIR = src
354 OBJ_DIR = obj
355
356 # Define all object files from source files
357 SRC = $(call rwildcard, ./, *.c, *.h)
358 #OBJS = $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
359 OBJS = $(patsubst %.c,%.o,$(filter %.c,$(SRC)))
360
361 # For Android platform we call a custom Makefile.Android
362 ifeq ($(PLATFORM),PLATFORM_ANDROID)
363 MAKEFILE_PARAMS = -f Makefile.Android
364 export PROJECT_NAME
365 export SRC_DIR
366 else
367 MAKEFILE_PARAMS = $(PROJECT_NAME)
368 endif
369
370 # Default target entry
371 # NOTE: We call this Makefile target or Makefile.Android target
372 all:
373 $(MAKE) $(MAKEFILE_PARAMS)
374
375 # Project target defined by PROJECT_NAME
376 $(PROJECT_NAME): $(OBJS)
377 $(CC) -o $(PROJECT_NAME)$(EXT) $(OBJS) $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
378
379 # Compile source files
380 # NOTE: This pattern will compile every module defined on $(OBJS)
381 #%.o: %.c
382 $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
383 $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM)
384
385 # Clean everything
386 clean:
387 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
388 ifeq ($(PLATFORM_OS),WINDOWS)
389 del *.o *.exe /s
390 endif
391 ifeq ($(PLATFORM_OS),LINUX)
392 find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -fv
393 endif
394 ifeq ($(PLATFORM_OS),OSX)
395 find . -type f -perm +ugo+x -delete
396 rm -f *.o
397 endif
398 endif
399 ifeq ($(PLATFORM),PLATFORM_RPI)
400 find . -type f -executable -delete
401 rm -fv *.o
402 endif
403 ifeq ($(PLATFORM),PLATFORM_WEB)
404 del *.o *.html *.js
405 endif
406 @echo Cleaning done
407