Debian Codegraph @

projects/4coder/Makefile

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