github.com/Konstantin8105/c4go@v0.0.0-20240505174241-768bb1c65a51/tests/raylib/Makefile (about) 1 #****************************************************************************** 2 # 3 # raylib makefile 4 # 5 # Platforms supported: 6 # PLATFORM_DESKTOP: Windows (Win32, Win64) 7 # PLATFORM_DESKTOP: Linux (i386, x64) 8 # PLATFORM_DESKTOP: OSX/macOS (arm64, x86_64) 9 # PLATFORM_DESKTOP: FreeBSD, OpenBSD, NetBSD, DragonFly 10 # PLATFORM_ANDROID: Android (arm, i686, arm64, x86_64) 11 # PLATFORM_RPI: Raspberry Pi (deprecated - RPI OS Buster only) 12 # PLATFORM_DRM: Linux native mode, including Raspberry Pi (RPI OS Bullseye) 13 # PLATFORM_WEB: HTML5 (Chrome, Firefox) 14 # 15 # Many thanks to Milan Nikolic (@gen2brain) for implementing Android platform pipeline. 16 # Many thanks to Emanuele Petriglia for his contribution on GNU/Linux pipeline. 17 # 18 # Copyright (c) 2013-2022 Ramon Santamaria (@raysan5) 19 # 20 # This software is provided "as-is", without any express or implied warranty. In no event 21 # will the authors be held liable for any damages arising from the use of this software. 22 # 23 # Permission is granted to anyone to use this software for any purpose, including commercial 24 # applications, and to alter it and redistribute it freely, subject to the following restrictions: 25 # 26 # 1. The origin of this software must not be misrepresented; you must not claim that you 27 # wrote the original software. If you use this software in a product, an acknowledgment 28 # in the product documentation would be appreciated but is not required. 29 # 30 # 2. Altered source versions must be plainly marked as such, and must not be misrepresented 31 # as being the original software. 32 # 33 # 3. This notice may not be removed or altered from any source distribution. 34 # 35 #************************************************************************************************** 36 37 # NOTE: Highly recommended to read the raylib Wiki to know how to compile raylib for different platforms 38 # https://github.com/raysan5/raylib/wiki 39 40 .PHONY: all clean install uninstall 41 42 # Define required environment variables 43 #------------------------------------------------------------------------------------------------ 44 # Define target platform: PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_DRM, PLATFORM_ANDROID, PLATFORM_WEB 45 PLATFORM ?= PLATFORM_DESKTOP 46 47 # Define required raylib variables 48 RAYLIB_VERSION = 4.2.0 49 RAYLIB_API_VERSION = 420 50 51 # Define raylib source code path 52 RAYLIB_SRC_PATH ?= ../src 53 54 # Define output directory for compiled library, defaults to src directory 55 # NOTE: If externally provided, make sure directory exists 56 RAYLIB_RELEASE_PATH ?= $(RAYLIB_SRC_PATH) 57 58 # Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) 59 RAYLIB_LIBTYPE ?= STATIC 60 61 # Build mode for library: DEBUG or RELEASE 62 RAYLIB_BUILD_MODE ?= RELEASE 63 64 # Build output name for the library 65 RAYLIB_LIB_NAME ?= raylib 66 67 # Define resource file for DLL properties 68 RAYLIB_RES_FILE ?= ./raylib.dll.rc.data 69 70 # Define external config flags 71 # NOTE: It will override config.h flags with the provided ones, 72 # if NONE, default config.h flags are used 73 RAYLIB_CONFIG_FLAGS ?= NONE 74 75 # To define additional cflags: Use make CUSTOM_CFLAGS="" 76 77 # Include raylib modules on compilation 78 # NOTE: Some programs like tools could not require those modules 79 RAYLIB_MODULE_AUDIO ?= TRUE 80 RAYLIB_MODULE_MODELS ?= TRUE 81 RAYLIB_MODULE_RAYGUI ?= FALSE 82 RAYLIB_MODULE_PHYSAC ?= FALSE 83 84 # NOTE: Additional libraries have been moved to their own repos: 85 # raygui: https://github.com/raysan5/raygui 86 # physac: https://github.com/raysan5/physac 87 RAYLIB_MODULE_RAYGUI_PATH ?= $(RAYLIB_SRC_PATH)/../../raygui/src 88 RAYLIB_MODULE_PHYSAC_PATH ?= $(RAYLIB_SRC_PATH)/../../physac/src 89 90 # Use external GLFW library instead of rglfw module 91 USE_EXTERNAL_GLFW ?= FALSE 92 93 # Use Wayland display server protocol on Linux desktop (by default it uses X11 windowing system) 94 # NOTE: This variable is only used for PLATFORM_OS: LINUX 95 USE_WAYLAND_DISPLAY ?= FALSE 96 97 # Use cross-compiler for PLATFORM_RPI 98 ifeq ($(PLATFORM),PLATFORM_RPI) 99 USE_RPI_CROSS_COMPILER ?= FALSE 100 ifeq ($(USE_RPI_CROSS_COMPILER),TRUE) 101 RPI_TOOLCHAIN ?= C:/SysGCC/Raspberry 102 RPI_TOOLCHAIN_SYSROOT ?= $(RPI_TOOLCHAIN)/arm-linux-gnueabihf/sysroot 103 endif 104 endif 105 106 # Determine if the file has root access (only required to install raylib) 107 # "whoami" prints the name of the user that calls him (so, if it is the root user, "whoami" prints "root") 108 ROOT = $(shell whoami) 109 110 # By default we suppose we are working on Windows 111 HOST_PLATFORM_OS ?= WINDOWS 112 PLATFORM_OS ?= WINDOWS 113 114 # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected 115 ifeq ($(PLATFORM),PLATFORM_DESKTOP) 116 # No uname.exe on MinGW!, but OS=Windows_NT on Windows! 117 # ifeq ($(UNAME),Msys) -> Windows 118 ifeq ($(OS),Windows_NT) 119 PLATFORM_OS = WINDOWS 120 ifndef PLATFORM_SHELL 121 PLATFORM_SHELL = cmd 122 endif 123 else 124 UNAMEOS = $(shell uname) 125 ifeq ($(UNAMEOS),Linux) 126 PLATFORM_OS = LINUX 127 endif 128 ifeq ($(UNAMEOS),FreeBSD) 129 PLATFORM_OS = BSD 130 endif 131 ifeq ($(UNAMEOS),OpenBSD) 132 PLATFORM_OS = BSD 133 endif 134 ifeq ($(UNAMEOS),NetBSD) 135 PLATFORM_OS = BSD 136 endif 137 ifeq ($(UNAMEOS),DragonFly) 138 PLATFORM_OS = BSD 139 endif 140 ifeq ($(UNAMEOS),Darwin) 141 PLATFORM_OS = OSX 142 endif 143 ifndef PLATFORM_SHELL 144 PLATFORM_SHELL = sh 145 endif 146 endif 147 endif 148 ifeq ($(PLATFORM),PLATFORM_RPI) 149 UNAMEOS = $(shell uname) 150 ifeq ($(UNAMEOS),Linux) 151 PLATFORM_OS = LINUX 152 endif 153 ifndef PLATFORM_SHELL 154 PLATFORM_SHELL = sh 155 endif 156 endif 157 ifeq ($(PLATFORM),PLATFORM_DRM) 158 UNAMEOS = $(shell uname) 159 ifeq ($(UNAMEOS),Linux) 160 PLATFORM_OS = LINUX 161 endif 162 ifndef PLATFORM_SHELL 163 PLATFORM_SHELL = sh 164 endif 165 endif 166 ifeq ($(PLATFORM),PLATFORM_WEB) 167 ifeq ($(OS),Windows_NT) 168 PLATFORM_OS = WINDOWS 169 ifndef PLATFORM_SHELL 170 PLATFORM_SHELL = cmd 171 endif 172 else 173 UNAMEOS = $(shell uname) 174 ifeq ($(UNAMEOS),Linux) 175 PLATFORM_OS = LINUX 176 endif 177 ifndef PLATFORM_SHELL 178 PLATFORM_SHELL = sh 179 endif 180 endif 181 endif 182 183 ifeq ($(PLATFORM),PLATFORM_WEB) 184 ifeq ($(PLATFORM_OS), WINDOWS) 185 # Emscripten required variables 186 EMSDK_PATH ?= C:/emsdk 187 EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/upstream/emscripten 188 CLANG_PATH := $(EMSDK_PATH)/upstream/bin 189 PYTHON_PATH := $(EMSDK_PATH)/python/3.9.2-1_64bit 190 NODE_PATH := $(EMSDK_PATH)/node/14.15.5_64bit/bin 191 export PATH := $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:/raylib/MinGW/bin;$(PATH) 192 endif 193 endif 194 195 ifeq ($(PLATFORM),PLATFORM_ANDROID) 196 # Android architecture 197 # Starting at 2019 using arm64 is mandatory for published apps, 198 # Starting on August 2020, minimum required target API is Android 10 (API level 29) 199 ANDROID_ARCH ?= arm64 200 ANDROID_API_VERSION ?= 29 201 202 # Android required path variables 203 # NOTE: Starting with Android NDK r21, no more toolchain generation is required, NDK is the toolchain on itself 204 ifeq ($(OS),Windows_NT) 205 ANDROID_NDK ?= C:/android-ndk 206 ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/windows-x86_64 207 else 208 ANDROID_NDK ?= /usr/lib/android/ndk 209 ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64 210 endif 211 212 # NOTE: Sysroot can also be reference from $(ANDROID_NDK)/sysroot 213 ANDROID_SYSROOT ?= $(ANDROID_TOOLCHAIN)/sysroot 214 215 ifeq ($(ANDROID_ARCH),arm) 216 ANDROID_COMPILER_ARCH = armv7a 217 endif 218 ifeq ($(ANDROID_ARCH),arm64) 219 ANDROID_COMPILER_ARCH = aarch64 220 endif 221 ifeq ($(ANDROID_ARCH),x86) 222 ANDROID_COMPILER_ARCH = i686 223 endif 224 ifeq ($(ANDROID_ARCH),x86_64) 225 ANDROID_COMPILER_ARCH = x86_64 226 endif 227 228 endif 229 230 # Define raylib graphics api depending on selected platform 231 ifeq ($(PLATFORM),PLATFORM_DESKTOP) 232 # By default use OpenGL 3.3 on desktop platforms 233 GRAPHICS ?= GRAPHICS_API_OPENGL_33 234 #GRAPHICS = GRAPHICS_API_OPENGL_11 # Uncomment to use OpenGL 1.1 235 #GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1 236 endif 237 ifeq ($(PLATFORM),PLATFORM_RPI) 238 # On RPI OpenGL ES 2.0 must be used 239 GRAPHICS = GRAPHICS_API_OPENGL_ES2 240 endif 241 ifeq ($(PLATFORM),PLATFORM_DRM) 242 # On DRM OpenGL ES 2.0 must be used 243 GRAPHICS = GRAPHICS_API_OPENGL_ES2 244 endif 245 ifeq ($(PLATFORM),PLATFORM_WEB) 246 # On HTML5 OpenGL ES 2.0 is used, emscripten translates it to WebGL 1.0 247 GRAPHICS = GRAPHICS_API_OPENGL_ES2 248 endif 249 ifeq ($(PLATFORM),PLATFORM_ANDROID) 250 # By default use OpenGL ES 2.0 on Android 251 GRAPHICS = GRAPHICS_API_OPENGL_ES2 252 endif 253 254 # Define default C compiler and archiver to pack library: CC, AR 255 #------------------------------------------------------------------------------------------------ 256 CC = gcc 257 AR = ar 258 259 ifeq ($(PLATFORM),PLATFORM_DESKTOP) 260 ifeq ($(PLATFORM_OS),OSX) 261 # OSX default compiler 262 CC = clang 263 GLFW_OSX = -x objective-c 264 endif 265 ifeq ($(PLATFORM_OS),BSD) 266 # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler 267 CC = clang 268 endif 269 endif 270 ifeq ($(PLATFORM),PLATFORM_RPI) 271 ifeq ($(USE_RPI_CROSS_COMPILER),TRUE) 272 # Define RPI cross-compiler 273 #CC = armv6j-hardfloat-linux-gnueabi-gcc 274 CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc 275 AR = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-ar 276 endif 277 endif 278 ifeq ($(PLATFORM),PLATFORM_WEB) 279 # HTML5 emscripten compiler 280 CC = emcc 281 AR = emar 282 endif 283 ifeq ($(PLATFORM),PLATFORM_ANDROID) 284 # Android toolchain (must be provided for desired architecture and compiler) 285 ifeq ($(ANDROID_ARCH),arm) 286 CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-androideabi$(ANDROID_API_VERSION)-clang 287 endif 288 ifeq ($(ANDROID_ARCH),arm64) 289 CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-android$(ANDROID_API_VERSION)-clang 290 endif 291 ifeq ($(ANDROID_ARCH),x86) 292 CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-android$(ANDROID_API_VERSION)-clang 293 endif 294 ifeq ($(ANDROID_ARCH),x86_64) 295 CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-android$(ANDROID_API_VERSION)-clang 296 endif 297 # It seems from Android NDK r22 onwards we need to use llvm-ar 298 AR = $(ANDROID_TOOLCHAIN)/bin/llvm-ar 299 endif 300 301 # Define compiler flags: CFLAGS 302 #------------------------------------------------------------------------------------------------ 303 # -O1 defines optimization level 304 # -g include debug information on compilation 305 # -s strip unnecessary data from build --> linker 306 # -Wall turns on most, but not all, compiler warnings 307 # -std=c99 defines C language mode (standard C from 1999 revision) 308 # -std=gnu99 defines C language mode (GNU C from 1999 revision) 309 # -Wno-missing-braces ignore invalid warning (GCC bug 53119) 310 # -Wno-unused-value ignore unused return values of some functions (i.e. fread()) 311 # -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec 312 # -D_GNU_SOURCE access to lots of nonstandard GNU/Linux extension functions 313 # -Werror=pointer-arith catch unportable code that does direct arithmetic on void pointers 314 # -fno-strict-aliasing jar_xm.h does shady stuff (breaks strict aliasing) 315 CFLAGS = -Wall -D_GNU_SOURCE -D$(PLATFORM) -D$(GRAPHICS) -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing $(CUSTOM_CFLAGS) 316 317 ifneq ($(RAYLIB_CONFIG_FLAGS), NONE) 318 CFLAGS += -DEXTERNAL_CONFIG_FLAGS $(RAYLIB_CONFIG_FLAGS) 319 endif 320 321 ifeq ($(PLATFORM), PLATFORM_WEB) 322 # NOTE: When using multi-threading in the user code, it requires -pthread enabled 323 CFLAGS += -std=gnu99 324 else 325 CFLAGS += -std=c99 326 endif 327 328 ifeq ($(PLATFORM_OS), LINUX) 329 CFLAGS += -fPIC 330 endif 331 332 ifeq ($(RAYLIB_BUILD_MODE),DEBUG) 333 CFLAGS += -g -D_DEBUG 334 endif 335 336 ifeq ($(RAYLIB_BUILD_MODE),RELEASE) 337 ifeq ($(PLATFORM),PLATFORM_WEB) 338 CFLAGS += -Os 339 endif 340 ifeq ($(PLATFORM),PLATFORM_DESKTOP) 341 CFLAGS += -O1 342 endif 343 ifeq ($(PLATFORM),PLATFORM_ANDROID) 344 CFLAGS += -O2 345 endif 346 endif 347 348 # Additional flags for compiler (if desired) 349 # -Wextra enables some extra warning flags that are not enabled by -Wall 350 # -Wmissing-prototypes warn if a global function is defined without a previous prototype declaration 351 # -Wstrict-prototypes warn if a function is declared or defined without specifying the argument types 352 # -Werror=implicit-function-declaration catch function calls without prior declaration 353 ifeq ($(PLATFORM),PLATFORM_DESKTOP) 354 CFLAGS += -Werror=implicit-function-declaration 355 endif 356 ifeq ($(PLATFORM),PLATFORM_WEB) 357 # -Os # size optimization 358 # -O2 # optimization level 2, if used, also set --memory-init-file 0 359 # -s USE_GLFW=3 # Use glfw3 library (context/input management) -> Only for linker! 360 # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! 361 # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) 362 # -s USE_PTHREADS=1 # multithreading support 363 # -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data 364 # -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) 365 # --profiling # include information for code profiling 366 # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) 367 # --preload-file resources # specify a resources folder for data compilation 368 ifeq ($(RAYLIB_BUILD_MODE),DEBUG) 369 CFLAGS += -s ASSERTIONS=1 --profiling 370 endif 371 endif 372 ifeq ($(PLATFORM),PLATFORM_ANDROID) 373 # Compiler flags for arquitecture 374 ifeq ($(ANDROID_ARCH),arm) 375 CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 376 endif 377 ifeq ($(ANDROID_ARCH),arm64) 378 CFLAGS += -target aarch64 -mfix-cortex-a53-835769 379 endif 380 ifeq ($(ANDROID_ARCH),x86) 381 CFLAGS += -march=i686 382 endif 383 ifeq ($(ANDROID_ARCH),x86_64) 384 CFLAGS += -march=x86-64 385 endif 386 # Compilation functions attributes options 387 CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIE -fPIC 388 # Compiler options for the linker 389 # -Werror=format-security 390 CFLAGS += -Wa,--noexecstack -Wformat -no-canonical-prefixes 391 # Preprocessor macro definitions 392 CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION) -DMAL_NO_OSS 393 endif 394 395 # Define required compilation flags for raylib SHARED lib 396 ifeq ($(RAYLIB_LIBTYPE),SHARED) 397 # make sure code is compiled as position independent 398 # BE CAREFUL: It seems that for gcc -fpic is not the same as -fPIC 399 # MinGW32 just doesn't need -fPIC, it shows warnings 400 CFLAGS += -fPIC -DBUILD_LIBTYPE_SHARED 401 endif 402 ifeq ($(PLATFORM),PLATFORM_DRM) 403 # without EGL_NO_X11 eglplatform.h tears Xlib.h in which tears X.h in 404 # which contains a conflicting type Font 405 CFLAGS += -DEGL_NO_X11 406 endif 407 # Use Wayland display on Linux desktop 408 ifeq ($(PLATFORM),PLATFORM_DESKTOP) 409 ifeq ($(PLATFORM_OS), LINUX) 410 ifeq ($(USE_WAYLAND_DISPLAY),TRUE) 411 CFLAGS += -D_GLFW_WAYLAND 412 endif 413 endif 414 endif 415 416 # Define include paths for required headers: INCLUDE_PATHS 417 # NOTE: Several external required libraries (stb and others) 418 #------------------------------------------------------------------------------------------------ 419 INCLUDE_PATHS = -I. -Iexternal/glfw/include -Iexternal/glfw/deps/mingw 420 421 # Define additional directories containing required header files 422 ifeq ($(PLATFORM),PLATFORM_DESKTOP) 423 ifeq ($(PLATFORM_OS),BSD) 424 INCLUDE_PATHS += -I/usr/local/include 425 endif 426 endif 427 ifeq ($(PLATFORM),PLATFORM_RPI) 428 INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include 429 INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include/interface/vmcs_host/linux 430 INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include/interface/vcos/pthreads 431 endif 432 ifeq ($(PLATFORM),PLATFORM_DRM) 433 INCLUDE_PATHS += -I/usr/include/libdrm 434 endif 435 ifeq ($(PLATFORM),PLATFORM_ANDROID) 436 NATIVE_APP_GLUE = $(ANDROID_NDK)/sources/android/native_app_glue 437 # Include android_native_app_glue.h 438 INCLUDE_PATHS += -I$(NATIVE_APP_GLUE) 439 440 # Android required libraries 441 INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include 442 ifeq ($(ANDROID_ARCH),arm) 443 INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/arm-linux-androideabi 444 endif 445 ifeq ($(ANDROID_ARCH),arm64) 446 INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/aarch64-linux-android 447 endif 448 ifeq ($(ANDROID_ARCH),x86) 449 INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/i686-linux-android 450 endif 451 ifeq ($(ANDROID_ARCH),x86_64) 452 INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/x86_64-linux-android 453 endif 454 endif 455 456 # Define library paths containing required libs: LDFLAGS 457 # NOTE: This is only required for dynamic library generation 458 #------------------------------------------------------------------------------------------------ 459 LDFLAGS = $(CUSTOM_LDFLAGS) -L. -L$(RAYLIB_RELEASE_PATH) 460 461 ifeq ($(PLATFORM),PLATFORM_DESKTOP) 462 ifeq ($(PLATFORM_OS),WINDOWS) 463 ifneq ($(CC), tcc) 464 LDFLAGS += -Wl,--out-implib,$(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME)dll.a 465 endif 466 endif 467 ifeq ($(PLATFORM_OS),OSX) 468 LDFLAGS += -compatibility_version $(RAYLIB_API_VERSION) -current_version $(RAYLIB_VERSION) 469 endif 470 ifeq ($(PLATFORM_OS),LINUX) 471 LDFLAGS += -Wl,-soname,lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) 472 endif 473 ifeq ($(PLATFORM_OS),BSD) 474 LDFLAGS += -Wl,-soname,lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).so -Lsrc -L/usr/local/lib 475 endif 476 endif 477 ifeq ($(PLATFORM),PLATFORM_RPI) 478 LDFLAGS += -Wl,-soname,lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) -L$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/lib 479 endif 480 ifeq ($(PLATFORM),PLATFORM_DRM) 481 LDFLAGS += -Wl,-soname,lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) 482 endif 483 ifeq ($(PLATFORM),PLATFORM_ANDROID) 484 LDFLAGS += -Wl,-soname,libraylib.$(API_VERSION).so -Wl,--exclude-libs,libatomic.a 485 LDFLAGS += -Wl,--build-id -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings 486 # Force linking of library module to define symbol 487 LDFLAGS += -u ANativeActivity_onCreate 488 # Library paths containing required libs 489 LDFLAGS += -Lsrc 490 # Avoid unresolved symbol pointing to external main() 491 LDFLAGS += -Wl,-undefined,dynamic_lookup 492 endif 493 494 # Define libraries required on linking: LDLIBS 495 # NOTE: This is only required for dynamic library generation 496 #------------------------------------------------------------------------------------------------ 497 ifeq ($(PLATFORM),PLATFORM_DESKTOP) 498 ifeq ($(PLATFORM_OS),WINDOWS) 499 ifeq ($(CC), tcc) 500 LDLIBS = -lopengl32 -lgdi32 -lwinmm -lshell32 501 else 502 LDLIBS = -static-libgcc -lopengl32 -lgdi32 -lwinmm 503 endif 504 endif 505 ifeq ($(PLATFORM_OS),LINUX) 506 LDLIBS = -lGL -lc -lm -lpthread -ldl -lrt 507 ifeq ($(USE_WAYLAND_DISPLAY),FALSE) 508 LDLIBS += -lX11 509 endif 510 # TODO: On ARM 32bit arch, miniaudio requires atomics library 511 #LDLIBS += -latomic 512 endif 513 ifeq ($(PLATFORM_OS),OSX) 514 LDLIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo 515 endif 516 ifeq ($(PLATFORM_OS),BSD) 517 LDLIBS = -lGL -lpthread 518 endif 519 ifeq ($(USE_EXTERNAL_GLFW),TRUE) 520 # Check the version name. If GLFW3 was built manually, it may have produced 521 # a static library known as libglfw3.a. In that case, the name should be -lglfw3 522 LDLIBS = -lglfw 523 endif 524 endif 525 ifeq ($(PLATFORM),PLATFORM_RPI) 526 LDLIBS = -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl 527 ifeq ($(RAYLIB_MODULE_AUDIO),TRUE) 528 LDLIBS += -latomic 529 endif 530 endif 531 ifeq ($(PLATFORM),PLATFORM_DRM) 532 LDLIBS = -lGLESv2 -lEGL -ldrm -lgbm -lpthread -lrt -lm -ldl 533 ifeq ($(RAYLIB_MODULE_AUDIO),TRUE) 534 LDLIBS += -latomic 535 endif 536 endif 537 ifeq ($(PLATFORM),PLATFORM_ANDROID) 538 LDLIBS = -llog -landroid -lEGL -lGLESv2 -lOpenSLES -lc -lm 539 endif 540 541 # Define source code object files required 542 #------------------------------------------------------------------------------------------------ 543 OBJS = rcore.o \ 544 rshapes.o \ 545 rtextures.o \ 546 rtext.o \ 547 utils.o 548 549 ifeq ($(PLATFORM),PLATFORM_DESKTOP) 550 ifeq ($(USE_EXTERNAL_GLFW),FALSE) 551 OBJS += rglfw.o 552 endif 553 endif 554 ifeq ($(RAYLIB_MODULE_MODELS),TRUE) 555 OBJS += rmodels.o 556 endif 557 ifeq ($(RAYLIB_MODULE_AUDIO),TRUE) 558 OBJS += raudio.o 559 endif 560 ifeq ($(RAYLIB_MODULE_RAYGUI),TRUE) 561 OBJS += raygui.o 562 endif 563 ifeq ($(RAYLIB_MODULE_PHYSAC),TRUE) 564 OBJS += physac.o 565 endif 566 567 ifeq ($(PLATFORM),PLATFORM_ANDROID) 568 OBJS += android_native_app_glue.o 569 endif 570 571 # Define processes to execute 572 #------------------------------------------------------------------------------------------------ 573 # Default target entry 574 all: raylib 575 576 # Compile raylib library 577 # NOTE: Release directory is created if not exist 578 raylib: $(OBJS) 579 ifeq ($(PLATFORM),PLATFORM_WEB) 580 # Compile raylib libray for web 581 #$(CC) $(OBJS) -r -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc 582 $(AR) rcs $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(OBJS) 583 @echo "raylib library generated (lib$(RAYLIB_LIB_NAME).a)!" 584 else 585 ifeq ($(RAYLIB_LIBTYPE),SHARED) 586 ifeq ($(PLATFORM),PLATFORM_DESKTOP) 587 ifeq ($(PLATFORM_OS),WINDOWS) 588 # NOTE: Linking with provided resource file 589 $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/$(RAYLIB_LIB_NAME).dll $(OBJS) $(RAYLIB_RES_FILE) $(LDFLAGS) $(LDLIBS) 590 @echo "raylib dynamic library ($(RAYLIB_LIB_NAME).dll) and import library (lib$(RAYLIB_LIB_NAME)dll.a) generated!" 591 endif 592 ifeq ($(PLATFORM_OS),LINUX) 593 # Compile raylib shared library version $(RAYLIB_VERSION). 594 # WARNING: you should type "make clean" before doing this target 595 $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) $(OBJS) $(LDFLAGS) $(LDLIBS) 596 @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION)) in $(RAYLIB_RELEASE_PATH)!" 597 cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) 598 cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so 599 endif 600 ifeq ($(PLATFORM_OS),OSX) 601 $(CC) -dynamiclib -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib $(OBJS) $(LDFLAGS) $(LDLIBS) 602 install_name_tool -id "@rpath/lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).dylib" $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib 603 @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib)!" 604 cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).dylib 605 cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib lib$(RAYLIB_LIB_NAME).dylib 606 endif 607 ifeq ($(PLATFORM_OS),BSD) 608 # WARNING: you should type "gmake clean" before doing this target 609 $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so $(OBJS) $(LDFLAGS) $(LDLIBS) 610 @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so)!" 611 cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).so 612 cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).so 613 endif 614 endif 615 ifeq ($(PLATFORM),PLATFORM_RPI) 616 # Compile raylib shared library version $(RAYLIB_VERSION). 617 # WARNING: you should type "make clean" before doing this target 618 $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) $(OBJS) $(LDFLAGS) $(LDLIBS) 619 @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION)) in $(RAYLIB_RELEASE_PATH)!" 620 cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) 621 cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so 622 endif 623 ifeq ($(PLATFORM),PLATFORM_DRM) 624 # Compile raylib shared library version $(RAYLIB_VERSION). 625 # WARNING: you should type "make clean" before doing this target 626 $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) $(OBJS) $(LDFLAGS) $(LDLIBS) 627 @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION)) in $(RAYLIB_RELEASE_PATH)!" 628 cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) 629 cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so 630 endif 631 ifeq ($(PLATFORM),PLATFORM_ANDROID) 632 $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so $(OBJS) $(LDFLAGS) $(LDLIBS) 633 @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so)!" 634 # WARNING: symbolic links creation on Windows should be done using mklink command, no ln available 635 ifeq ($(HOST_PLATFORM_OS),LINUX) 636 cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).so 637 cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).so 638 endif 639 endif 640 else 641 # Compile raylib static library version $(RAYLIB_VERSION) 642 # WARNING: You should type "make clean" before doing this target. 643 $(AR) rcs $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(OBJS) 644 @echo "raylib static library generated (lib$(RAYLIB_LIB_NAME).a) in $(RAYLIB_RELEASE_PATH)!" 645 endif 646 endif 647 648 # Compile all modules with their prerequisites 649 650 # Compile core module 651 rcore.o : rcore.c raylib.h rlgl.h utils.h raymath.h rcamera.h rgestures.h 652 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) 653 654 # Compile rglfw module 655 rglfw.o : rglfw.c 656 $(CC) $(GLFW_OSX) -c $< $(CFLAGS) $(INCLUDE_PATHS) 657 658 # Compile shapes module 659 rshapes.o : rshapes.c raylib.h rlgl.h 660 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) 661 662 # Compile textures module 663 rtextures.o : rtextures.c raylib.h rlgl.h utils.h 664 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) 665 666 # Compile text module 667 rtext.o : rtext.c raylib.h utils.h 668 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) 669 670 # Compile utils module 671 utils.o : utils.c utils.h 672 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) 673 674 # Compile models module 675 rmodels.o : rmodels.c raylib.h rlgl.h raymath.h 676 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) 677 678 # Compile audio module 679 raudio.o : raudio.c raylib.h 680 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) 681 682 # Compile raygui module 683 # NOTE: raygui header should be distributed with raylib.h 684 raygui.o : raygui.c 685 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) 686 raygui.c: 687 ifeq ($(PLATFORM_SHELL), cmd) 688 @echo #define RAYGUI_IMPLEMENTATION > raygui.c 689 @echo #include "$(RAYLIB_MODULE_RAYGUI_PATH)/raygui.h" >> raygui.c 690 else 691 @echo "#define RAYGUI_IMPLEMENTATION" > raygui.c 692 @echo "#include \"$(RAYLIB_MODULE_RAYGUI_PATH)/raygui.h\"" >> raygui.c 693 endif 694 695 # Compile physac module 696 # NOTE: physac header should be distributed with raylib.h 697 physac.o : physac.c 698 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) 699 physac.c: 700 ifeq ($(PLATFORM_SHELL), cmd) 701 @echo #define PHYSAC_IMPLEMENTATION > physac.c 702 @echo #include "$(RAYLIB_MODULE_PHYSAC_PATH)/physac.h" >> physac.c 703 else 704 @echo "#define PHYSAC_IMPLEMENTATION" > physac.c 705 @echo "#include \"$(RAYLIB_MODULE_PHYSAC_PATH)/physac.h\"" >> physac.c 706 endif 707 # Compile android_native_app_glue module 708 android_native_app_glue.o : $(NATIVE_APP_GLUE)/android_native_app_glue.c 709 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) 710 711 712 # Install generated and needed files to desired directories. 713 # On GNU/Linux and BSDs, there are some standard directories that contain extra 714 # libraries and header files. These directories (often /usr/local/lib and 715 # /usr/local/include) are for libraries that are installed manually 716 # (without a package manager). We'll use /usr/local/lib/raysan5 and /usr/local/include/raysan5 717 # for our -L and -I specification to simplify management of the raylib source package. 718 # Customize these locations if you like but don't forget to pass them to make 719 # for compilation and enable runtime linking with -rpath, LD_LIBRARY_PATH, or ldconfig. 720 # HINT: Add -L$(RAYLIB_INSTALL_PATH) -I$(RAYLIB_H_INSTALL_PATH) to your own makefiles. 721 # See below and ../examples/Makefile for more information. 722 723 # RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths. 724 DESTDIR ?= /usr/local 725 RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib 726 # RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files. 727 RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include 728 729 install : 730 ifeq ($(ROOT),root) 731 ifeq ($(PLATFORM_OS),LINUX) 732 # Attention! You are root, writing files to $(RAYLIB_INSTALL_PATH) 733 # and $(RAYLIB_H_INSTALL_PATH). Consult this Makefile for more information. 734 # Prepare the environment as needed. 735 mkdir --parents --verbose $(RAYLIB_INSTALL_PATH) 736 mkdir --parents --verbose $(RAYLIB_H_INSTALL_PATH) 737 ifeq ($(RAYLIB_LIBTYPE),SHARED) 738 # Installing raylib to $(RAYLIB_INSTALL_PATH). 739 cp --update --verbose $(RAYLIB_RELEASE_PATH)/libraylib.so.$(RAYLIB_VERSION) $(RAYLIB_INSTALL_PATH)/lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) 740 cd $(RAYLIB_INSTALL_PATH); ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) 741 cd $(RAYLIB_INSTALL_PATH); ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so 742 # Uncomment to update the runtime linker cache with RAYLIB_INSTALL_PATH. 743 # Not necessary if later embedding RPATH in your executable. See examples/Makefile. 744 ldconfig $(RAYLIB_INSTALL_PATH) 745 else 746 # Installing raylib to $(RAYLIB_INSTALL_PATH). 747 cp --update --verbose $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_INSTALL_PATH)/lib$(RAYLIB_LIB_NAME).a 748 endif 749 # Copying raylib development files to $(RAYLIB_H_INSTALL_PATH). 750 cp --update raylib.h $(RAYLIB_H_INSTALL_PATH)/raylib.h 751 cp --update raymath.h $(RAYLIB_H_INSTALL_PATH)/raymath.h 752 cp --update rlgl.h $(RAYLIB_H_INSTALL_PATH)/rlgl.h 753 @echo "raylib development files installed/updated!" 754 else 755 @echo "This function currently works on GNU/Linux systems. Add yours today (^;" 756 endif 757 else 758 @echo "Error: Root permissions needed for installation. Try sudo make install" 759 endif 760 761 # Remove raylib dev files installed on the system 762 # NOTE: see 'install' target. 763 uninstall : 764 ifeq ($(ROOT),root) 765 # WARNING: You are root, about to delete items from $(RAYLIB_INSTALL_PATH). 766 # and $(RAYLIB_H_INSTALL_PATH). Please confirm each item. 767 ifeq ($(PLATFORM_OS),LINUX) 768 ifeq ($(RAYLIB_LIBTYPE),SHARED) 769 rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so 770 rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so.$(RAYLIB_API_VERSION) 771 rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so.$(RAYLIB_VERSION) 772 # Uncomment to clean up the runtime linker cache. See install target. 773 ldconfig 774 else 775 rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.a 776 endif 777 rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raylib.h 778 rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raymath.h 779 rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/rlgl.h 780 @echo "raylib development files removed!" 781 else 782 @echo "This function currently works on GNU/Linux systems. Add yours today (^;" 783 endif 784 else 785 @echo "Error: Root permissions needed for uninstallation. Try sudo make uninstall" 786 endif 787 788 .PHONY: clean_shell_cmd clean_shell_sh 789 790 # Clean everything 791 clean: clean_shell_$(PLATFORM_SHELL) 792 @echo "removed all generated files!" 793 794 clean_shell_sh: 795 rm -fv *.o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so* 796 ifeq ($(PLATFORM),PLATFORM_ANDROID) 797 rm -fv $(NATIVE_APP_GLUE)/android_native_app_glue.o 798 endif 799 800 # Set specific target variable 801 clean_shell_cmd: SHELL=cmd 802 clean_shell_cmd: 803 del *.o /s 804 cd $(RAYLIB_RELEASE_PATH) & \ 805 del lib$(RAYLIB_LIB_NAME).a /s & \ 806 del lib$(RAYLIB_LIB_NAME)dll.a /s & \ 807 del $(RAYLIB_LIB_NAME).dll /s