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