| 1 | #****************************************************************************** |
| 2 | # |
| 3 | # raylib makefile |
| 4 | # |
| 5 | # This file supports building raylib library for the following platforms: |
| 6 | # |
| 7 | # > PLATFORM_DESKTOP |
| 8 | # - Defaults to PLATFORM_DESKTOP_GLFW |
| 9 | # > PLATFORM_DESKTOP_GLFW (GLFW backend): |
| 10 | # - Windows (Win32, Win64) |
| 11 | # - Linux (X11/Wayland desktop mode) |
| 12 | # - macOS/OSX (x64, arm64) |
| 13 | # - FreeBSD, OpenBSD, NetBSD, DragonFly (X11 desktop) |
| 14 | # > PLATFORM_DESKTOP_SDL (SDL backend): |
| 15 | # - Windows (Win32, Win64) |
| 16 | # - Linux (X11/Wayland desktop mode) |
| 17 | # - Others (not tested) |
| 18 | # > PLATFORM_DESKTOP_RGFW (RGFW backend): |
| 19 | # - Windows (Win32, Win64) |
| 20 | # - Linux (X11 desktop mode) |
| 21 | # - macOS/OSX (x64, arm64 (not tested)) |
| 22 | # - Others (not tested) |
| 23 | # > PLATFORM_DESKTOP_WIN32 (native Win32): |
| 24 | # - Windows (Win32, Win64) |
| 25 | # > PLATFORM_WEB (GLFW + Emscripten): |
| 26 | # - HTML5 (WebAssembly) |
| 27 | # > PLATFORM_WEB_EMSCRIPTEN (Emscripten): |
| 28 | # - HTML5 (WebAssembly) |
| 29 | # > PLATFORM_WEB_RGFW (Emscripten): |
| 30 | # - HTML5 (WebAssembly) |
| 31 | # > PLATFORM_DRM (native DRM): |
| 32 | # - Raspberry Pi 0-5 (DRM/KMS) |
| 33 | # - Linux DRM subsystem (KMS mode) |
| 34 | # - Embedded devices (with GPU) |
| 35 | # > PLATFORM_ANDROID (native NDK): |
| 36 | # - Android (ARM, ARM64) |
| 37 | # > PLATFORM_MEMORY |
| 38 | # - Memory framebuffer output, using software renderer, no OS required |
| 39 | # |
| 40 | # Many thanks to Milan Nikolic (@gen2brain) for implementing Android platform pipeline. |
| 41 | # Many thanks to Emanuele Petriglia for his contribution on GNU/Linux pipeline. |
| 42 | # |
| 43 | # Copyright (c) 2013-2026 Ramon Santamaria (@raysan5) |
| 44 | # |
| 45 | # This software is provided "as-is", without any express or implied warranty. In no event |
| 46 | # will the authors be held liable for any damages arising from the use of this software. |
| 47 | # |
| 48 | # Permission is granted to anyone to use this software for any purpose, including commercial |
| 49 | # applications, and to alter it and redistribute it freely, subject to the following restrictions: |
| 50 | # |
| 51 | # 1. The origin of this software must not be misrepresented; you must not claim that you |
| 52 | # wrote the original software. If you use this software in a product, an acknowledgment |
| 53 | # in the product documentation would be appreciated but is not required. |
| 54 | # |
| 55 | # 2. Altered source versions must be plainly marked as such, and must not be misrepresented |
| 56 | # as being the original software. |
| 57 | # |
| 58 | # 3. This notice may not be removed or altered from any source distribution. |
| 59 | # |
| 60 | #************************************************************************************************** |
| 61 | |
| 62 | # NOTE: Highly recommended to read the raylib Wiki to know how to compile raylib for different platforms |
| 63 | # https://github.com/raysan5/raylib/wiki |
| 64 | |
| 65 | .PHONY: all clean install uninstall |
| 66 | |
| 67 | # Define required environment variables |
| 68 | #------------------------------------------------------------------------------------------------ |
| 69 | # Define target platform |
| 70 | PLATFORM ?= PLATFORM_DESKTOP |
| 71 | ifeq ($(PLATFORM), PLATFORM_DESKTOP) |
| 72 | TARGET_PLATFORM = PLATFORM_DESKTOP_GLFW |
| 73 | else |
| 74 | TARGET_PLATFORM = $(PLATFORM) |
| 75 | endif |
| 76 | |
| 77 | # Define required raylib variables |
| 78 | RAYLIB_VERSION = 6.0.0 |
| 79 | RAYLIB_API_VERSION = 600 |
| 80 | |
| 81 | # Define raylib source code path |
| 82 | RAYLIB_SRC_PATH ?= ../src |
| 83 | |
| 84 | # Define output directory for compiled library, defaults to src directory |
| 85 | # NOTE: If externally provided, make sure directory exists |
| 86 | RAYLIB_RELEASE_PATH ?= $(RAYLIB_SRC_PATH) |
| 87 | |
| 88 | # Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) |
| 89 | RAYLIB_LIBTYPE ?= STATIC |
| 90 | |
| 91 | # Build mode for library: DEBUG or RELEASE |
| 92 | RAYLIB_BUILD_MODE ?= RELEASE |
| 93 | |
| 94 | # Build output name for the library |
| 95 | RAYLIB_LIB_NAME ?= raylib |
| 96 | |
| 97 | # Define resource file for DLL properties |
| 98 | RAYLIB_RES_FILE ?= ./raylib.dll.rc.data |
| 99 | |
| 100 | # Define external config flags |
| 101 | # NOTE: It will override config.h flags with the provided ones, |
| 102 | # if NONE, default config.h flags are used |
| 103 | RAYLIB_CONFIG_FLAGS ?= NONE |
| 104 | |
| 105 | # To define additional cflags: Use make CUSTOM_CFLAGS="" |
| 106 | |
| 107 | # Include raylib modules on compilation |
| 108 | # NOTE: Some programs like tools could not require those modules |
| 109 | RAYLIB_MODULE_AUDIO ?= TRUE |
| 110 | RAYLIB_MODULE_MODELS ?= TRUE |
| 111 | RAYLIB_MODULE_RAYGUI ?= FALSE |
| 112 | |
| 113 | # NOTE: Additional libraries have been moved to their own repos: |
| 114 | # raygui: https://github.com/raysan5/raygui |
| 115 | RAYLIB_MODULE_RAYGUI_PATH ?= $(RAYLIB_SRC_PATH)/../../raygui/src |
| 116 | |
| 117 | # Use external GLFW library instead of rglfw module |
| 118 | USE_EXTERNAL_GLFW ?= FALSE |
| 119 | |
| 120 | # Enable support for X11 by default on Linux when using GLFW |
| 121 | # NOTE: Wayland is disabled by default, only enable if you are sure |
| 122 | GLFW_LINUX_ENABLE_WAYLAND ?= FALSE |
| 123 | GLFW_LINUX_ENABLE_X11 ?= TRUE |
| 124 | |
| 125 | # Enable support for X11 by default on Linux when using RGFW |
| 126 | # NOTE: Wayland is disabled by default, only enable if you are sure |
| 127 | RGFW_LINUX_ENABLE_WAYLAND ?= FALSE |
| 128 | RGFW_LINUX_ENABLE_X11 ?= TRUE |
| 129 | |
| 130 | # PLATFORM_DESKTOP_SDL: It requires SDL library to be provided externally |
| 131 | # WARNING: Library is not included in raylib, it MUST be configured by users |
| 132 | SDL_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/include |
| 133 | SDL_LIBRARY_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/lib |
| 134 | SDL_LIBRARIES ?= -lSDL2 -lSDL2main |
| 135 | |
| 136 | # Determine if the file has root access (only required to install raylib) |
| 137 | # "whoami" prints the name of the user that calls him (so, if it is the root user, "whoami" prints "root") |
| 138 | ROOT = $(shell whoami) |
| 139 | |
| 140 | # By default we suppose we are working on Windows |
| 141 | HOST_PLATFORM_OS ?= WINDOWS |
| 142 | PLATFORM_OS ?= WINDOWS |
| 143 | |
| 144 | # Determine PLATFORM_OS when required |
| 145 | ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW PLATFORM_DESKTOP_WIN32 PLATFORM_WEB PLATFORM_WEB_RGFW PLATFORM_ANDROID)) |
| 146 | # No uname.exe on MinGW!, but OS=Windows_NT on Windows! |
| 147 | # ifeq ($(UNAME),Msys) -> Windows |
| 148 | ifeq ($(OS),Windows_NT) |
| 149 | PLATFORM_OS = WINDOWS |
| 150 | ifndef PLATFORM_SHELL |
| 151 | PLATFORM_SHELL = cmd |
| 152 | endif |
| 153 | else |
| 154 | UNAMEOS = $(shell uname) |
| 155 | ifeq ($(UNAMEOS),Linux) |
| 156 | PLATFORM_OS = LINUX |
| 157 | endif |
| 158 | ifeq ($(UNAMEOS),FreeBSD) |
| 159 | PLATFORM_OS = BSD |
| 160 | endif |
| 161 | ifeq ($(UNAMEOS),OpenBSD) |
| 162 | PLATFORM_OS = BSD |
| 163 | endif |
| 164 | ifeq ($(UNAMEOS),NetBSD) |
| 165 | PLATFORM_OS = BSD |
| 166 | endif |
| 167 | ifeq ($(UNAMEOS),DragonFly) |
| 168 | PLATFORM_OS = BSD |
| 169 | endif |
| 170 | ifeq ($(UNAMEOS),Darwin) |
| 171 | PLATFORM_OS = OSX |
| 172 | endif |
| 173 | ifndef PLATFORM_SHELL |
| 174 | PLATFORM_SHELL = sh |
| 175 | endif |
| 176 | endif |
| 177 | endif |
| 178 | ifeq ($(TARGET_PLATFORM),PLATFORM_DRM) |
| 179 | UNAMEOS = $(shell uname) |
| 180 | ifeq ($(UNAMEOS),Linux) |
| 181 | PLATFORM_OS = LINUX |
| 182 | endif |
| 183 | ifndef PLATFORM_SHELL |
| 184 | PLATFORM_SHELL = sh |
| 185 | endif |
| 186 | endif |
| 187 | ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) |
| 188 | ifeq ($(PLATFORM_OS),LINUX) |
| 189 | ifndef PLATFORM_SHELL |
| 190 | PLATFORM_SHELL = sh |
| 191 | endif |
| 192 | endif |
| 193 | endif |
| 194 | |
| 195 | ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) |
| 196 | ifeq ($(PLATFORM_OS), WINDOWS) |
| 197 | # Emscripten required variables |
| 198 | EMSDK_PATH ?= C:/raylib/emsdk |
| 199 | EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/upstream/emscripten |
| 200 | CLANG_PATH := $(EMSDK_PATH)/upstream/bin |
| 201 | PYTHON_PATH := $(EMSDK_PATH)/python/3.13.3_64bit |
| 202 | NODE_PATH := $(EMSDK_PATH)/node/22.16.0_64bit/bin |
| 203 | export PATH := $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:/raylib/MinGW/bin;$(PATH) |
| 204 | endif |
| 205 | endif |
| 206 | |
| 207 | ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID) |
| 208 | # Android architecture |
| 209 | # Starting at 2019 using arm64 is mandatory for published apps, |
| 210 | # Starting on August 2020, minimum required target API is Android 10 (API level 29) |
| 211 | ANDROID_ARCH ?= arm64 |
| 212 | ANDROID_API_VERSION ?= 29 |
| 213 | |
| 214 | # Android required path variables |
| 215 | # NOTE: Starting with Android NDK r21, no more toolchain generation is required, NDK is the toolchain on itself |
| 216 | ifeq ($(OS),Windows_NT) |
| 217 | ANDROID_NDK ?= C:/android-ndk |
| 218 | ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/windows-x86_64 |
| 219 | else |
| 220 | ANDROID_NDK ?= /usr/lib/android/ndk |
| 221 | ifeq ($(PLATFORM_OS), OSX) |
| 222 | ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/darwin-x86_64 |
| 223 | else |
| 224 | ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64 |
| 225 | endif |
| 226 | endif |
| 227 | |
| 228 | # NOTE: Sysroot can also be reference from $(ANDROID_NDK)/sysroot |
| 229 | ANDROID_SYSROOT ?= $(ANDROID_TOOLCHAIN)/sysroot |
| 230 | |
| 231 | ifeq ($(ANDROID_ARCH),arm) |
| 232 | ANDROID_COMPILER_ARCH = armv7a |
| 233 | endif |
| 234 | ifeq ($(ANDROID_ARCH),arm64) |
| 235 | ANDROID_COMPILER_ARCH = aarch64 |
| 236 | endif |
| 237 | ifeq ($(ANDROID_ARCH),x86) |
| 238 | ANDROID_COMPILER_ARCH = i686 |
| 239 | endif |
| 240 | ifeq ($(ANDROID_ARCH),x86_64) |
| 241 | ANDROID_COMPILER_ARCH = x86_64 |
| 242 | endif |
| 243 | endif |
| 244 | |
| 245 | # Define raylib graphics api depending on selected platform |
| 246 | # NOTE: By default use OpenGL 3.3 on desktop platforms |
| 247 | ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW) |
| 248 | GRAPHICS ?= GRAPHICS_API_OPENGL_33 |
| 249 | #GRAPHICS = GRAPHICS_API_OPENGL_SOFTWARE # Uncomment to use software rendering |
| 250 | #GRAPHICS = GRAPHICS_API_OPENGL_11 # Uncomment to use OpenGL 1.1 |
| 251 | #GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1 |
| 252 | #GRAPHICS = GRAPHICS_API_OPENGL_43 # Uncomment to use OpenGL 4.3 |
| 253 | #GRAPHICS = GRAPHICS_API_OPENGL_ES2 # Uncomment to use OpenGL ES 2.0 (ANGLE) |
| 254 | endif |
| 255 | ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL) |
| 256 | GRAPHICS ?= GRAPHICS_API_OPENGL_33 |
| 257 | endif |
| 258 | ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW) |
| 259 | GRAPHICS ?= GRAPHICS_API_OPENGL_33 |
| 260 | #GRAPHICS = GRAPHICS_API_OPENGL_SOFTWARE # Uncomment to use software rendering |
| 261 | #GRAPHICS = GRAPHICS_API_OPENGL_11 # Uncomment to use OpenGL 1.1 |
| 262 | #GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1 |
| 263 | #GRAPHICS = GRAPHICS_API_OPENGL_43 # Uncomment to use OpenGL 4.3 |
| 264 | #GRAPHICS = GRAPHICS_API_OPENGL_ES2 # Uncomment to use OpenGL ES 2.0 (ANGLE) |
| 265 | endif |
| 266 | ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_WIN32) |
| 267 | GRAPHICS ?= GRAPHICS_API_OPENGL_33 |
| 268 | #GRAPHICS = GRAPHICS_API_OPENGL_SOFTWARE # Uncomment to use software rendering |
| 269 | #GRAPHICS = GRAPHICS_API_OPENGL_11 # Uncomment to use OpenGL 1.1 |
| 270 | #GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1 |
| 271 | #GRAPHICS = GRAPHICS_API_OPENGL_43 # Uncomment to use OpenGL 4.3 |
| 272 | #GRAPHICS = GRAPHICS_API_OPENGL_ES2 # Uncomment to use OpenGL ES 2.0 (ANGLE) |
| 273 | endif |
| 274 | ifeq ($(TARGET_PLATFORM),PLATFORM_DRM) |
| 275 | GRAPHICS ?= GRAPHICS_API_OPENGL_ES2 |
| 276 | #GRAPHICS = GRAPHICS_API_OPENGL_SOFTWARE # Uncomment to use software rendering |
| 277 | endif |
| 278 | ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) |
| 279 | # On HTML5 OpenGL ES 2.0 is used, emscripten translates it to WebGL 1.0 |
| 280 | GRAPHICS ?= GRAPHICS_API_OPENGL_ES2 |
| 281 | #GRAPHICS = GRAPHICS_API_OPENGL_ES3 |
| 282 | endif |
| 283 | ifeq ($(TARGET_PLATFORM),PLATFORM_WEB_RGFW) |
| 284 | # On HTML5 OpenGL ES 2.0 is used, emscripten translates it to WebGL 1.0 |
| 285 | GRAPHICS ?= GRAPHICS_API_OPENGL_ES2 |
| 286 | #GRAPHICS = GRAPHICS_API_OPENGL_ES3 |
| 287 | |
| 288 | ifeq ($(GRAPHICS),GRAPHICS_API_OPENGL_SOFTWARE) |
| 289 | $(error WEB_RGFW: Software rendering not supported!) |
| 290 | endif |
| 291 | endif |
| 292 | ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID) |
| 293 | # By default use OpenGL ES 2.0 on Android |
| 294 | GRAPHICS ?= GRAPHICS_API_OPENGL_ES2 |
| 295 | endif |
| 296 | ifeq ($(TARGET_PLATFORM),PLATFORM_MEMORY) |
| 297 | # By default use OpenGL Software |
| 298 | GRAPHICS = GRAPHICS_API_OPENGL_SOFTWARE |
| 299 | endif |
| 300 | |
| 301 | # Define default C compiler and archiver to pack library: CC, AR |
| 302 | #------------------------------------------------------------------------------------------------ |
| 303 | CC = gcc |
| 304 | AR = ar |
| 305 | |
| 306 | ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW) |
| 307 | ifeq ($(PLATFORM_OS),OSX) |
| 308 | # OSX default compiler |
| 309 | CC = clang |
| 310 | GLFW_OSX = -x objective-c |
| 311 | endif |
| 312 | ifeq ($(PLATFORM_OS),BSD) |
| 313 | # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler |
| 314 | CC = clang |
| 315 | endif |
| 316 | endif |
| 317 | ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW) |
| 318 | ifeq ($(PLATFORM_OS),OSX) |
| 319 | # OSX default compiler |
| 320 | CC = clang |
| 321 | GLFW_OSX = -x objective-c |
| 322 | endif |
| 323 | ifeq ($(PLATFORM_OS),BSD) |
| 324 | # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler |
| 325 | CC = clang |
| 326 | endif |
| 327 | endif |
| 328 | ifeq ($(TARGET_PLATFORM),PLATFORM_DRM) |
| 329 | ifeq ($(USE_RPI_CROSSCOMPILER),TRUE) |
| 330 | # Define RPI cross-compiler |
| 331 | #CC = armv6j-hardfloat-linux-gnueabi-gcc |
| 332 | CC = $(RPI_TOOLCHAIN)/bin/$(RPI_TOOLCHAIN_NAME)-gcc |
| 333 | AR = $(RPI_TOOLCHAIN)/bin/$(RPI_TOOLCHAIN_NAME)-ar |
| 334 | endif |
| 335 | endif |
| 336 | ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) |
| 337 | # HTML5 emscripten compiler |
| 338 | CC = emcc |
| 339 | AR = emar |
| 340 | endif |
| 341 | ifeq ($(TARGET_PLATFORM),PLATFORM_WEB_RGFW) |
| 342 | # HTML5 emscripten compiler |
| 343 | CC = emcc |
| 344 | AR = emar |
| 345 | endif |
| 346 | ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID) |
| 347 | # Android toolchain (must be provided for desired architecture and compiler) |
| 348 | ifeq ($(ANDROID_ARCH),arm) |
| 349 | CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-androideabi$(ANDROID_API_VERSION)-clang |
| 350 | endif |
| 351 | ifeq ($(ANDROID_ARCH),arm64) |
| 352 | CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-android$(ANDROID_API_VERSION)-clang |
| 353 | endif |
| 354 | ifeq ($(ANDROID_ARCH),x86) |
| 355 | CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-android$(ANDROID_API_VERSION)-clang |
| 356 | endif |
| 357 | ifeq ($(ANDROID_ARCH),x86_64) |
| 358 | CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-android$(ANDROID_API_VERSION)-clang |
| 359 | endif |
| 360 | # It seems from Android NDK r22 onwards we need to use llvm-ar |
| 361 | AR = $(ANDROID_TOOLCHAIN)/bin/llvm-ar |
| 362 | endif |
| 363 | |
| 364 | # Define compiler flags: CFLAGS |
| 365 | #------------------------------------------------------------------------------------------------ |
| 366 | # -O1 defines optimization level |
| 367 | # -g include debug information on compilation |
| 368 | # -s strip unnecessary data from build --> linker |
| 369 | # -Wall turns on most, but not all, compiler warnings |
| 370 | # -std=c99 defines C language mode (standard C from 1999 revision) |
| 371 | # -std=gnu99 defines C language mode (GNU C from 1999 revision) |
| 372 | # -Wno-missing-braces ignore invalid warning (GCC bug 53119) |
| 373 | # -Wno-unused-value ignore unused return values of some functions (i.e. fread()) |
| 374 | # -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec |
| 375 | # -D_GNU_SOURCE access to lots of nonstandard GNU/Linux extension functions |
| 376 | # -Werror=pointer-arith catch unportable code that does direct arithmetic on void pointers |
| 377 | # -fno-strict-aliasing jar_xm.h does shady stuff (breaks strict aliasing) |
| 378 | CFLAGS = -Wall -D_GNU_SOURCE -D$(TARGET_PLATFORM) -D$(GRAPHICS) -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing |
| 379 | |
| 380 | ifneq ($(RAYLIB_CONFIG_FLAGS), NONE) |
| 381 | CFLAGS += -DEXTERNAL_CONFIG_FLAGS $(RAYLIB_CONFIG_FLAGS) |
| 382 | endif |
| 383 | |
| 384 | ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) |
| 385 | CFLAGS += -std=gnu99 |
| 386 | else |
| 387 | CFLAGS += -std=c99 |
| 388 | endif |
| 389 | |
| 390 | ifeq ($(PLATFORM_OS), LINUX) |
| 391 | CFLAGS += -fPIC |
| 392 | endif |
| 393 | |
| 394 | ifeq ($(PLATFORM_OS),WINDOWS) |
| 395 | CFLAGS += -DUNICODE |
| 396 | endif |
| 397 | |
| 398 | ifeq ($(RAYLIB_BUILD_MODE),DEBUG) |
| 399 | CFLAGS += -g -D_DEBUG |
| 400 | endif |
| 401 | |
| 402 | ifeq ($(RAYLIB_BUILD_MODE),RELEASE) |
| 403 | ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW) |
| 404 | CFLAGS += -O1 |
| 405 | endif |
| 406 | ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) |
| 407 | CFLAGS += -Os |
| 408 | endif |
| 409 | ifeq ($(TARGET_PLATFORM),PLATFORM_WEB_RGFW) |
| 410 | CFLAGS += -Os |
| 411 | endif |
| 412 | ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID) |
| 413 | CFLAGS += -O2 |
| 414 | endif |
| 415 | endif |
| 416 | |
| 417 | # Additional flags for compiler (if desired) |
| 418 | # -Wextra enables some extra warning flags that are not enabled by -Wall |
| 419 | # -Wmissing-prototypes warn if a global function is defined without a previous prototype declaration |
| 420 | # -Wstrict-prototypes warn if a function is declared or defined without specifying the argument types |
| 421 | # -Werror=implicit-function-declaration catch function calls without prior declaration |
| 422 | ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW) |
| 423 | CFLAGS += -Werror=implicit-function-declaration |
| 424 | endif |
| 425 | ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) |
| 426 | ifeq ($(RAYLIB_BUILD_MODE),DEBUG) |
| 427 | CFLAGS += --profiling |
| 428 | endif |
| 429 | endif |
| 430 | ifeq ($(TARGET_PLATFORM),PLATFORM_WEB_RGFW) |
| 431 | ifeq ($(RAYLIB_BUILD_MODE),DEBUG) |
| 432 | CFLAGS += --profiling |
| 433 | endif |
| 434 | endif |
| 435 | ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID) |
| 436 | # Compiler flags for arquitecture |
| 437 | ifeq ($(ANDROID_ARCH),arm) |
| 438 | CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 |
| 439 | endif |
| 440 | ifeq ($(ANDROID_ARCH),arm64) |
| 441 | CFLAGS += -mfix-cortex-a53-835769 |
| 442 | endif |
| 443 | ifeq ($(ANDROID_ARCH),x86) |
| 444 | CFLAGS += -march=i686 |
| 445 | endif |
| 446 | ifeq ($(ANDROID_ARCH),x86_64) |
| 447 | CFLAGS += -march=x86-64 |
| 448 | endif |
| 449 | # Compilation functions attributes options |
| 450 | CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIE -fPIC |
| 451 | # Compiler options for the linker |
| 452 | # -Werror=format-security |
| 453 | CFLAGS += -Wa,--noexecstack -Wformat -no-canonical-prefixes |
| 454 | # Preprocessor macro definitions |
| 455 | CFLAGS += -D__ANDROID__ -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION) |
| 456 | endif |
| 457 | |
| 458 | # Define required compilation flags for raylib SHARED lib |
| 459 | ifeq ($(RAYLIB_LIBTYPE),SHARED) |
| 460 | # make sure code is compiled as position independent |
| 461 | # BE CAREFUL: It seems that for gcc -fpic is not the same as -fPIC |
| 462 | # MinGW32 just doesn't need -fPIC, it shows warnings |
| 463 | CFLAGS += -fPIC -DBUILD_LIBTYPE_SHARED |
| 464 | |
| 465 | # hide all symbols by default, so RLAPI can expose them |
| 466 | ifeq ($(PLATFORM_OS),$(filter $(PLATFORM_OS), LINUX BSD OSX)) |
| 467 | CFLAGS += -fvisibility=hidden |
| 468 | endif |
| 469 | endif |
| 470 | |
| 471 | ifeq ($(TARGET_PLATFORM),PLATFORM_DRM) |
| 472 | # without EGL_NO_X11 eglplatform.h tears Xlib.h in which tears X.h in |
| 473 | # which contains a conflicting type Font |
| 474 | CFLAGS += -DEGL_NO_X11 |
| 475 | CFLAGS += -Werror=implicit-function-declaration |
| 476 | endif |
| 477 | # Use Wayland display on Linux desktop |
| 478 | ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW) |
| 479 | ifeq ($(PLATFORM_OS), LINUX) |
| 480 | ifeq ($(GLFW_LINUX_ENABLE_X11),TRUE) |
| 481 | CFLAGS += -D_GLFW_X11 |
| 482 | endif |
| 483 | ifeq ($(GLFW_LINUX_ENABLE_WAYLAND),TRUE) |
| 484 | CFLAGS += -D_GLFW_WAYLAND |
| 485 | |
| 486 | WL_PROTOCOLS_DIR := external/glfw/deps/wayland |
| 487 | |
| 488 | wl_generate = \ |
| 489 | $(eval protocol=$(1)) \ |
| 490 | $(eval basename=$(2)) \ |
| 491 | $(shell wayland-scanner client-header $(protocol) $(RAYLIB_SRC_PATH)/$(basename).h) \ |
| 492 | $(shell wayland-scanner private-code $(protocol) $(RAYLIB_SRC_PATH)/$(basename)-code.h) |
| 493 | |
| 494 | $(call wl_generate, $(WL_PROTOCOLS_DIR)/wayland.xml, wayland-client-protocol) |
| 495 | $(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-shell.xml, xdg-shell-client-protocol) |
| 496 | $(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-decoration-unstable-v1.xml, xdg-decoration-unstable-v1-client-protocol) |
| 497 | $(call wl_generate, $(WL_PROTOCOLS_DIR)/viewporter.xml, viewporter-client-protocol) |
| 498 | $(call wl_generate, $(WL_PROTOCOLS_DIR)/relative-pointer-unstable-v1.xml, relative-pointer-unstable-v1-client-protocol) |
| 499 | $(call wl_generate, $(WL_PROTOCOLS_DIR)/pointer-constraints-unstable-v1.xml, pointer-constraints-unstable-v1-client-protocol) |
| 500 | $(call wl_generate, $(WL_PROTOCOLS_DIR)/fractional-scale-v1.xml, fractional-scale-v1-client-protocol) |
| 501 | $(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-activation-v1.xml, xdg-activation-v1-client-protocol) |
| 502 | $(call wl_generate, $(WL_PROTOCOLS_DIR)/idle-inhibit-unstable-v1.xml, idle-inhibit-unstable-v1-client-protocol) |
| 503 | endif |
| 504 | endif |
| 505 | endif |
| 506 | # Use Wayland display on Linux desktop |
| 507 | ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW) |
| 508 | ifeq ($(PLATFORM_OS), LINUX) |
| 509 | ifeq ($(RGFW_LINUX_ENABLE_X11),TRUE) |
| 510 | CFLAGS += -DRGFW_X11 -DRGFW_UNIX |
| 511 | endif |
| 512 | ifeq ($(RGFW_LINUX_ENABLE_WAYLAND),TRUE) |
| 513 | CFLAGS += -DRGFW_WAYLAND -DEGLAPIENTRY= |
| 514 | |
| 515 | WL_PROTOCOLS_DIR := external/RGFW/deps/wayland |
| 516 | |
| 517 | wl_generate = \ |
| 518 | $(eval protocol=$(1)) \ |
| 519 | $(eval basename=$(2)) \ |
| 520 | $(shell wayland-scanner client-header $(protocol) $(RAYLIB_SRC_PATH)/$(basename).h) \ |
| 521 | $(shell wayland-scanner private-code $(protocol) $(RAYLIB_SRC_PATH)/$(basename)-code.c) |
| 522 | |
| 523 | $(call wl_generate, $(WL_PROTOCOLS_DIR)/pointer-constraints-unstable-v1.xml, pointer-constraints-unstable-v1-client-protocol) |
| 524 | $(call wl_generate, $(WL_PROTOCOLS_DIR)/pointer-warp-v1.xml, pointer-warp-v1-client-protocol) |
| 525 | $(call wl_generate, $(WL_PROTOCOLS_DIR)/relative-pointer-unstable-v1.xml, relative-pointer-unstable-v1-client-protocol) |
| 526 | $(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-decoration-unstable-v1.xml, xdg-decoration-unstable-v1-client-protocol) |
| 527 | $(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-output-unstable-v1.xml, xdg-output-unstable-v1-client-protocol) |
| 528 | $(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-shell.xml, xdg-shell-client-protocol) |
| 529 | $(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-toplevel-icon-v1.xml, xdg-toplevel-icon-v1-client-protocol) |
| 530 | endif |
| 531 | endif |
| 532 | endif |
| 533 | |
| 534 | CFLAGS += $(CUSTOM_CFLAGS) |
| 535 | |
| 536 | # Define include paths for required headers: INCLUDE_PATHS |
| 537 | # NOTE: Several external required libraries (stb and others) |
| 538 | #------------------------------------------------------------------------------------------------ |
| 539 | INCLUDE_PATHS = -I. $(EXTRA_INCLUDE_PATHS) |
| 540 | |
| 541 | # Define additional directories containing required header files |
| 542 | ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW) |
| 543 | INCLUDE_PATHS += -Iexternal/glfw/include |
| 544 | ifeq ($(PLATFORM_OS),BSD) |
| 545 | INCLUDE_PATHS += -I/usr/local/include -I/usr/pkg/include -I/usr/X11R7/include |
| 546 | endif |
| 547 | endif |
| 548 | ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL) |
| 549 | INCLUDE_PATHS += -I$(SDL_INCLUDE_PATH) |
| 550 | endif |
| 551 | ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) |
| 552 | INCLUDE_PATHS += -Iexternal/glfw/include |
| 553 | endif |
| 554 | ifeq ($(TARGET_PLATFORM),PLATFORM_DRM) |
| 555 | INCLUDE_PATHS += -I/usr/include/libdrm |
| 556 | ifeq ($(USE_RPI_CROSSCOMPILER), TRUE) |
| 557 | INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/usr/include |
| 558 | INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include |
| 559 | endif |
| 560 | endif |
| 561 | ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID) |
| 562 | NATIVE_APP_GLUE = $(ANDROID_NDK)/sources/android/native_app_glue |
| 563 | # Include android_native_app_glue.h |
| 564 | INCLUDE_PATHS += -I$(NATIVE_APP_GLUE) |
| 565 | |
| 566 | # Android required libraries |
| 567 | INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include |
| 568 | ifeq ($(ANDROID_ARCH),arm) |
| 569 | INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/arm-linux-androideabi |
| 570 | endif |
| 571 | ifeq ($(ANDROID_ARCH),arm64) |
| 572 | INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/aarch64-linux-android |
| 573 | endif |
| 574 | ifeq ($(ANDROID_ARCH),x86) |
| 575 | INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/i686-linux-android |
| 576 | endif |
| 577 | ifeq ($(ANDROID_ARCH),x86_64) |
| 578 | INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/x86_64-linux-android |
| 579 | endif |
| 580 | endif |
| 581 | |
| 582 | # Define library paths containing required libs: LDFLAGS |
| 583 | # NOTE: This is only required for dynamic library generation |
| 584 | #------------------------------------------------------------------------------------------------ |
| 585 | LDFLAGS = $(CUSTOM_LDFLAGS) -L. -L$(RAYLIB_RELEASE_PATH) |
| 586 | |
| 587 | ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW PLATFORM_DESKTOP_WIN32)) |
| 588 | ifeq ($(PLATFORM_OS),WINDOWS) |
| 589 | ifneq ($(CC), tcc) |
| 590 | LDFLAGS += -Wl,--out-implib,$(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME)dll.a |
| 591 | endif |
| 592 | endif |
| 593 | ifeq ($(PLATFORM_OS),OSX) |
| 594 | LDFLAGS += -compatibility_version $(RAYLIB_API_VERSION) -current_version $(RAYLIB_VERSION) |
| 595 | endif |
| 596 | ifeq ($(PLATFORM_OS),LINUX) |
| 597 | LDFLAGS += -Wl,-soname,lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) |
| 598 | endif |
| 599 | ifeq ($(PLATFORM_OS),BSD) |
| 600 | LDFLAGS += -Wl,-soname,lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).so -Lsrc -L/usr/local/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib |
| 601 | endif |
| 602 | endif |
| 603 | ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL) |
| 604 | LDFLAGS += -L$(SDL_LIBRARY_PATH) |
| 605 | endif |
| 606 | ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) |
| 607 | ifeq ($(RAYLIB_BUILD_MODE),DEBUG) |
| 608 | LDFLAGS += -sASSERTIONS=1 |
| 609 | endif |
| 610 | endif |
| 611 | ifeq ($(TARGET_PLATFORM),PLATFORM_DRM) |
| 612 | LDFLAGS += -Wl,-soname,lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) |
| 613 | ifeq ($(USE_RPI_CROSSCOMPILER), TRUE) |
| 614 | LDFLAGS += -L$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/lib -L$(RPI_TOOLCHAIN_SYSROOT)/usr/lib |
| 615 | endif |
| 616 | endif |
| 617 | ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID) |
| 618 | LDFLAGS += -Wl,-soname,libraylib.$(RAYLIB_API_VERSION).so -Wl,--exclude-libs,libatomic.a |
| 619 | LDFLAGS += -Wl,--build-id -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings |
| 620 | # Force linking of library module to define symbol |
| 621 | LDFLAGS += -u ANativeActivity_onCreate |
| 622 | # Library paths containing required libs |
| 623 | LDFLAGS += -Lsrc |
| 624 | # Avoid unresolved symbol pointing to external main() |
| 625 | LDFLAGS += -Wl,-undefined,dynamic_lookup |
| 626 | # Wrap fopen at link time so all code (including third-party libs) goes |
| 627 | # through __wrap_fopen, which handles Android APK asset loading |
| 628 | LDFLAGS += -Wl,--wrap=fopen |
| 629 | endif |
| 630 | |
| 631 | # Define libraries required on linking: LDLIBS |
| 632 | # NOTE: This is only required for dynamic library generation |
| 633 | #------------------------------------------------------------------------------------------------ |
| 634 | ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW) |
| 635 | ifeq ($(PLATFORM_OS),WINDOWS) |
| 636 | ifeq ($(CC), tcc) |
| 637 | LDLIBS = -lopengl32 -lgdi32 -lwinmm -lshell32 |
| 638 | else |
| 639 | LDLIBS = -static-libgcc -lopengl32 -lgdi32 -lwinmm |
| 640 | endif |
| 641 | endif |
| 642 | ifeq ($(PLATFORM_OS),LINUX) |
| 643 | LDLIBS = -lGL -lc -lm -lpthread -ldl -lrt |
| 644 | ifeq ($(GLFW_LINUX_ENABLE_X11),TRUE) |
| 645 | LDLIBS += -lX11 |
| 646 | endif |
| 647 | |
| 648 | ifeq ($(GLFW_LINUX_ENABLE_WAYLAND),TRUE) |
| 649 | LDFLAGS += $(shell pkg-config wayland-client wayland-cursor wayland-egl xkbcommon --libs) |
| 650 | endif |
| 651 | # TODO: On ARM 32bit arch, miniaudio requires atomics library |
| 652 | #LDLIBS += -latomic |
| 653 | endif |
| 654 | ifeq ($(PLATFORM_OS),OSX) |
| 655 | LDLIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo |
| 656 | endif |
| 657 | ifeq ($(PLATFORM_OS),BSD) |
| 658 | LDLIBS = -lGL -lpthread |
| 659 | endif |
| 660 | ifeq ($(USE_EXTERNAL_GLFW),TRUE) |
| 661 | # Check the version name. If GLFW3 was built manually, it may have produced |
| 662 | # a static library known as libglfw3.a. In that case, the name should be -lglfw3 |
| 663 | LDLIBS = -lglfw |
| 664 | endif |
| 665 | endif |
| 666 | ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL) |
| 667 | ifeq ($(PLATFORM_OS),WINDOWS) |
| 668 | LDLIBS = -static-libgcc -lopengl32 -lgdi32 |
| 669 | endif |
| 670 | ifeq ($(PLATFORM_OS),LINUX) |
| 671 | LDLIBS = -lGL -lc -lm -lpthread -ldl -lrt |
| 672 | ifeq ($(USE_WAYLAND_DISPLAY),FALSE) |
| 673 | LDLIBS += -lX11 |
| 674 | endif |
| 675 | endif |
| 676 | LDLIBS += $(SDL_LIBRARIES) |
| 677 | endif |
| 678 | ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW) |
| 679 | ifeq ($(PLATFORM_OS),WINDOWS) |
| 680 | # Libraries for Windows desktop compilation |
| 681 | LDLIBS = -lgdi32 -lwinmm -lopengl32 |
| 682 | endif |
| 683 | ifeq ($(PLATFORM_OS),LINUX) |
| 684 | # Libraries for Debian GNU/Linux desktop compipling |
| 685 | # NOTE: Required packages: libegl1-mesa-dev |
| 686 | LDLIBS = -lm |
| 687 | |
| 688 | ifeq ($(RGFW_LINUX_ENABLE_X11),TRUE) |
| 689 | LDLIBS += -lGL -lX11 -lXrandr -lXinerama -lXi -lXcursor -lpthread -ldl -lrt |
| 690 | endif |
| 691 | |
| 692 | ifeq ($(RGFW_LINUX_ENABLE_WAYLAND),TRUE) |
| 693 | LDFLAGS += $(shell pkg-config wayland-client wayland-cursor wayland-egl xkbcommon --libs) |
| 694 | endif |
| 695 | |
| 696 | # Explicit link to libc |
| 697 | ifeq ($(RAYLIB_LIBTYPE),SHARED) |
| 698 | LDLIBS += -lc |
| 699 | endif |
| 700 | |
| 701 | # NOTE: On ARM 32bit arch, miniaudio requires atomics library |
| 702 | LDLIBS += -latomic |
| 703 | endif |
| 704 | ifeq ($(PLATFORM_OS),OSX) |
| 705 | # Libraries for Debian MacOS desktop compiling |
| 706 | # NOTE: Required packages: libegl1-mesa-dev |
| 707 | LDLIBS += -lm -framework Foundation -framework AppKit -framework IOKit -framework OpenGL -framework CoreVideo |
| 708 | endif |
| 709 | endif |
| 710 | ifeq ($(TARGET_PLATFORM),PLATFORM_DRM) |
| 711 | LDLIBS = -ldrm -lgbm -lpthread -lrt -lm -ldl |
| 712 | ifeq ($(GRAPHICS),GRAPHICS_API_OPENGL_ES2) |
| 713 | LDLIBS += -lGLESv2 -lEGL |
| 714 | endif |
| 715 | ifeq ($(RAYLIB_MODULE_AUDIO),TRUE) |
| 716 | LDLIBS += -latomic |
| 717 | endif |
| 718 | endif |
| 719 | ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_WIN32) |
| 720 | LDLIBS = -lgdi32 -lwinmm -lshcore |
| 721 | ifneq ($(GRAPHICS),GRAPHICS_API_OPENGL_SOFTWARE) |
| 722 | LDLIBS += -lopengl32 |
| 723 | endif |
| 724 | endif |
| 725 | ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID) |
| 726 | LDLIBS = -llog -landroid -lEGL -lGLESv2 -lOpenSLES -lc -lm |
| 727 | endif |
| 728 | |
| 729 | # Define source code object files required |
| 730 | #------------------------------------------------------------------------------------------------ |
| 731 | OBJS = rcore.o \ |
| 732 | rshapes.o \ |
| 733 | rtextures.o \ |
| 734 | rtext.o |
| 735 | |
| 736 | ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW) |
| 737 | ifeq ($(USE_EXTERNAL_GLFW),FALSE) |
| 738 | OBJS += rglfw.o |
| 739 | endif |
| 740 | endif |
| 741 | ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW) |
| 742 | ifeq ($(RGFW_LINUX_ENABLE_WAYLAND),TRUE) |
| 743 | PROTOCOL_CODE_FILES = \ |
| 744 | pointer-constraints-unstable-v1-client-protocol-code \ |
| 745 | pointer-warp-v1-client-protocol-code \ |
| 746 | relative-pointer-unstable-v1-client-protocol-code \ |
| 747 | xdg-decoration-unstable-v1-client-protocol-code \ |
| 748 | xdg-output-unstable-v1-client-protocol-code \ |
| 749 | xdg-shell-client-protocol-code \ |
| 750 | xdg-toplevel-icon-v1-client-protocol-code |
| 751 | |
| 752 | PROTO_OBJS = $(addsuffix .o, $(PROTOCOL_CODE_FILES)) |
| 753 | OBJS += $(PROTO_OBJS) |
| 754 | endif |
| 755 | endif |
| 756 | ifeq ($(RAYLIB_MODULE_MODELS),TRUE) |
| 757 | OBJS += rmodels.o |
| 758 | endif |
| 759 | ifeq ($(RAYLIB_MODULE_AUDIO),TRUE) |
| 760 | OBJS += raudio.o |
| 761 | endif |
| 762 | ifeq ($(RAYLIB_MODULE_RAYGUI),TRUE) |
| 763 | OBJS += raygui.o |
| 764 | endif |
| 765 | |
| 766 | ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID) |
| 767 | OBJS += android_native_app_glue.o |
| 768 | endif |
| 769 | |
| 770 | # Define processes to execute |
| 771 | #------------------------------------------------------------------------------------------------ |
| 772 | # Default target entry |
| 773 | all: raylib |
| 774 | |
| 775 | # Compile raylib library |
| 776 | # NOTE: Release directory is created if not exist |
| 777 | raylib: $(OBJS) |
| 778 | ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) |
| 779 | # Compile raylib libray for web |
| 780 | ifeq ($(RAYLIB_LIBTYPE),SHARED) |
| 781 | @echo "WARNING: $(TARGET_PLATFORM) does not support SHARED libraries. Generating STATIC library." |
| 782 | endif |
| 783 | $(AR) rcs $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).web.a $(OBJS) |
| 784 | @echo "raylib library generated (lib$(RAYLIB_LIB_NAME).web.a)!" |
| 785 | else |
| 786 | ifeq ($(RAYLIB_LIBTYPE),SHARED) |
| 787 | ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW)) |
| 788 | ifeq ($(PLATFORM_OS),WINDOWS) |
| 789 | # NOTE: Linking with provided resource file |
| 790 | $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/$(RAYLIB_LIB_NAME).dll $(OBJS) $(RAYLIB_RES_FILE) $(LDFLAGS) $(LDLIBS) |
| 791 | @echo "raylib dynamic library ($(RAYLIB_LIB_NAME).dll) and import library (lib$(RAYLIB_LIB_NAME)dll.a) generated!" |
| 792 | endif |
| 793 | ifeq ($(PLATFORM_OS),LINUX) |
| 794 | # Compile raylib shared library version $(RAYLIB_VERSION). |
| 795 | # WARNING: you should type "make clean" before doing this target |
| 796 | $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) $(OBJS) $(LDFLAGS) $(LDLIBS) |
| 797 | @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION)) in $(RAYLIB_RELEASE_PATH)!" |
| 798 | cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) |
| 799 | cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so |
| 800 | endif |
| 801 | ifeq ($(PLATFORM_OS),OSX) |
| 802 | $(CC) -dynamiclib -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib $(OBJS) $(LDFLAGS) $(LDLIBS) |
| 803 | install_name_tool -id "@rpath/lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).dylib" $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib |
| 804 | @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib)!" |
| 805 | cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).dylib |
| 806 | cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib lib$(RAYLIB_LIB_NAME).dylib |
| 807 | endif |
| 808 | ifeq ($(PLATFORM_OS),BSD) |
| 809 | # WARNING: you should type "gmake clean" before doing this target |
| 810 | $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so $(OBJS) $(LDFLAGS) $(LDLIBS) |
| 811 | @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so)!" |
| 812 | cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).so |
| 813 | cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).so |
| 814 | endif |
| 815 | endif |
| 816 | ifeq ($(TARGET_PLATFORM),PLATFORM_DRM) |
| 817 | # Compile raylib shared library version $(RAYLIB_VERSION). |
| 818 | # WARNING: you should type "make clean" before doing this target |
| 819 | $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) $(OBJS) $(LDFLAGS) $(LDLIBS) |
| 820 | @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION)) in $(RAYLIB_RELEASE_PATH)!" |
| 821 | cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) |
| 822 | cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so |
| 823 | endif |
| 824 | ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID) |
| 825 | $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so $(OBJS) $(LDFLAGS) $(LDLIBS) |
| 826 | @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so)!" |
| 827 | # WARNING: symbolic links creation on Windows should be done using mklink command, no ln available |
| 828 | ifeq ($(HOST_PLATFORM_OS),LINUX) |
| 829 | cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).so |
| 830 | cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).so |
| 831 | endif |
| 832 | endif |
| 833 | else |
| 834 | # Compile raylib static library version $(RAYLIB_VERSION) |
| 835 | # WARNING: You should type "make clean" before doing this target. |
| 836 | $(AR) rcs $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(OBJS) |
| 837 | @echo "raylib static library generated (lib$(RAYLIB_LIB_NAME).a) in $(RAYLIB_RELEASE_PATH)!" |
| 838 | endif |
| 839 | endif |
| 840 | |
| 841 | # Compile all modules with their prerequisites |
| 842 | |
| 843 | # Prerequisites of core module |
| 844 | rcore.o : platforms/*.c |
| 845 | |
| 846 | # Compile core module |
| 847 | rcore.o : rcore.c raylib.h rlgl.h raymath.h rcamera.h rgestures.h |
| 848 | $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) |
| 849 | |
| 850 | # Compile rglfw module |
| 851 | rglfw.o : rglfw.c |
| 852 | $(CC) $(GLFW_OSX) -c $< $(CFLAGS) $(INCLUDE_PATHS) -U_GNU_SOURCE |
| 853 | |
| 854 | # Compile shapes module |
| 855 | rshapes.o : rshapes.c raylib.h rlgl.h |
| 856 | $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) |
| 857 | |
| 858 | # Compile textures module |
| 859 | rtextures.o : rtextures.c raylib.h rlgl.h |
| 860 | $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) |
| 861 | |
| 862 | # Compile text module |
| 863 | rtext.o : rtext.c raylib.h |
| 864 | $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) |
| 865 | |
| 866 | # Compile models module |
| 867 | rmodels.o : rmodels.c raylib.h rlgl.h raymath.h |
| 868 | $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) |
| 869 | |
| 870 | # Compile audio module |
| 871 | raudio.o : raudio.c raylib.h |
| 872 | $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) |
| 873 | |
| 874 | # Compile raygui module |
| 875 | # NOTE: raygui header should be distributed with raylib.h |
| 876 | raygui.o : raygui.c |
| 877 | $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) |
| 878 | raygui.c: |
| 879 | ifeq ($(PLATFORM_SHELL), cmd) |
| 880 | @echo #define RAYGUI_IMPLEMENTATION > raygui.c |
| 881 | @echo #include "$(RAYLIB_MODULE_RAYGUI_PATH)/raygui.h" >> raygui.c |
| 882 | else |
| 883 | @echo "#define RAYGUI_IMPLEMENTATION" > raygui.c |
| 884 | @echo "#include \"$(RAYLIB_MODULE_RAYGUI_PATH)/raygui.h\"" >> raygui.c |
| 885 | endif |
| 886 | |
| 887 | # Compile android_native_app_glue module |
| 888 | android_native_app_glue.o : $(NATIVE_APP_GLUE)/android_native_app_glue.c |
| 889 | $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) |
| 890 | |
| 891 | # Compile Wayland files |
| 892 | ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW) |
| 893 | ifeq ($(RGFW_LINUX_ENABLE_WAYLAND),TRUE) |
| 894 | %-client-protocol-code.o: %-client-protocol-code.c |
| 895 | $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) |
| 896 | |
| 897 | %-client-protocol-code.h: external/RGFW/deps/wayland/%.xml |
| 898 | wayland-scanner private-code $< $@ |
| 899 | endif |
| 900 | endif |
| 901 | |
| 902 | # Install generated and needed files to desired directories. |
| 903 | # On GNU/Linux and BSDs, there are some standard directories that contain extra |
| 904 | # libraries and header files. These directories (often /usr/local/lib and |
| 905 | # /usr/local/include) are for libraries that are installed manually |
| 906 | # (without a package manager). We'll use /usr/local/lib/raysan5 and /usr/local/include/raysan5 |
| 907 | # for our -L and -I specification to simplify management of the raylib source package. |
| 908 | # Customize these locations if you like but don't forget to pass them to make |
| 909 | # for compilation and enable runtime linking with -rpath, LD_LIBRARY_PATH, or ldconfig. |
| 910 | # HINT: Add -L$(RAYLIB_INSTALL_PATH) -I$(RAYLIB_H_INSTALL_PATH) to your own makefiles. |
| 911 | # See below and ../examples/Makefile for more information. |
| 912 | |
| 913 | # RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths. |
| 914 | DESTDIR ?= /usr/local |
| 915 | RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib |
| 916 | # RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files. |
| 917 | RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include |
| 918 | |
| 919 | install : |
| 920 | ifeq ($(ROOT),root) |
| 921 | ifeq ($(PLATFORM_OS),LINUX) |
| 922 | # Attention! You are root, writing files to $(RAYLIB_INSTALL_PATH) |
| 923 | # and $(RAYLIB_H_INSTALL_PATH). Consult this Makefile for more information. |
| 924 | # Prepare the environment as needed. |
| 925 | mkdir --parents --verbose $(RAYLIB_INSTALL_PATH) |
| 926 | mkdir --parents --verbose $(RAYLIB_H_INSTALL_PATH) |
| 927 | ifeq ($(RAYLIB_LIBTYPE),SHARED) |
| 928 | # Installing raylib to $(RAYLIB_INSTALL_PATH). |
| 929 | cp --update --verbose $(RAYLIB_RELEASE_PATH)/libraylib.so.$(RAYLIB_VERSION) $(RAYLIB_INSTALL_PATH)/lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) |
| 930 | cd $(RAYLIB_INSTALL_PATH); ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) |
| 931 | cd $(RAYLIB_INSTALL_PATH); ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so |
| 932 | # Uncomment to update the runtime linker cache with RAYLIB_INSTALL_PATH. |
| 933 | # Not necessary if later embedding RPATH in your executable. See examples/Makefile. |
| 934 | ldconfig $(RAYLIB_INSTALL_PATH) |
| 935 | else |
| 936 | # Installing raylib to $(RAYLIB_INSTALL_PATH). |
| 937 | cp --update --verbose $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_INSTALL_PATH)/lib$(RAYLIB_LIB_NAME).a |
| 938 | endif |
| 939 | # Copying raylib development files to $(RAYLIB_H_INSTALL_PATH). |
| 940 | cp --update raylib.h $(RAYLIB_H_INSTALL_PATH)/raylib.h |
| 941 | cp --update raymath.h $(RAYLIB_H_INSTALL_PATH)/raymath.h |
| 942 | cp --update rcamera.h $(RAYLIB_H_INSTALL_PATH)/rcamera.h |
| 943 | cp --update rlgl.h $(RAYLIB_H_INSTALL_PATH)/rlgl.h |
| 944 | @echo "raylib development files installed/updated!" |
| 945 | else |
| 946 | @echo "This function currently works on GNU/Linux systems. Add yours today (^;" |
| 947 | endif |
| 948 | else |
| 949 | @echo "ERROR: Root permissions needed for installation. Try sudo make install" && exit 1 |
| 950 | endif |
| 951 | |
| 952 | # Remove raylib dev files installed on the system |
| 953 | # NOTE: see 'install' target. |
| 954 | uninstall : |
| 955 | ifeq ($(ROOT),root) |
| 956 | # WARNING: You are root, about to delete items from $(RAYLIB_INSTALL_PATH). |
| 957 | # and $(RAYLIB_H_INSTALL_PATH). Please confirm each item. |
| 958 | ifeq ($(PLATFORM_OS),LINUX) |
| 959 | ifeq ($(RAYLIB_LIBTYPE),SHARED) |
| 960 | rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so |
| 961 | rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so.$(RAYLIB_API_VERSION) |
| 962 | rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so.$(RAYLIB_VERSION) |
| 963 | # Uncomment to clean up the runtime linker cache. See install target. |
| 964 | ldconfig |
| 965 | else |
| 966 | rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.a |
| 967 | endif |
| 968 | rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raylib.h |
| 969 | rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raymath.h |
| 970 | rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/rcamera.h |
| 971 | rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/rlgl.h |
| 972 | @echo "raylib development files removed!" |
| 973 | else |
| 974 | @echo "This function currently works on GNU/Linux systems. Add yours today (^;" |
| 975 | endif |
| 976 | else |
| 977 | @echo "ERROR: Root permissions needed for uninstallation. Try sudo make uninstall" && exit 1 |
| 978 | endif |
| 979 | |
| 980 | .PHONY: clean_shell_cmd clean_shell_sh |
| 981 | |
| 982 | # Clean everything |
| 983 | clean: clean_shell_$(PLATFORM_SHELL) |
| 984 | @echo "removed all generated files!" |
| 985 | |
| 986 | clean_shell_sh: |
| 987 | rm -fv *.o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).web.a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so* raygui.c $(RAYLIB_RELEASE_PATH)/*-protocol.h $(RAYLIB_RELEASE_PATH)/*-protocol-code.h $(RAYLIB_RELEASE_PATH)/*-protocol-code.c |
| 988 | ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID) |
| 989 | rm -fv $(NATIVE_APP_GLUE)/android_native_app_glue.o |
| 990 | endif |
| 991 | |
| 992 | # Set specific target variable |
| 993 | clean_shell_cmd: SHELL=cmd |
| 994 | clean_shell_cmd: |
| 995 | del *.o /s |
| 996 | cd $(RAYLIB_RELEASE_PATH) & \ |
| 997 | del lib$(RAYLIB_LIB_NAME).a /s & \ |
| 998 | del lib$(RAYLIB_LIB_NAME).web.a /s & \ |
| 999 | del lib$(RAYLIB_LIB_NAME)dll.a /s & \ |
| 1000 | del $(RAYLIB_LIB_NAME).dll /s & \ |
| 1001 | del raygui.c /s & \ |