1 #******************************************************************************
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)
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.
18 # Copyright (c) 2014-2019 Ramon Santamaria (@raysan5)
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.
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:
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.
33 # 2. Altered source versions must be plainly marked as such, and must not
34 # be misrepresented as being the original software.
36 # 3. This notice may not be removed or altered from any source distribution.
38 #******************************************************************************
40 # Please read the wiki to know how to compile raylib, because there are different methods.
41 # https://github.com/raysan5/raylib/wiki
43 .PHONY: all clean install uninstall
45 # Define required raylib variables
46 RAYLIB_VERSION = 3.7.0
47 RAYLIB_API_VERSION = 370
49 # Define raylib source code path
50 RAYLIB_SRC_PATH ?= ../src
52 # Define output directory for compiled library, defaults to src directory
53 # NOTE: If externally provided, make sure directory exists
54 RAYLIB_RELEASE_PATH ?= $(RAYLIB_SRC_PATH)
56 # Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
57 RAYLIB_LIBTYPE ?= STATIC
59 # Build mode for library: DEBUG or RELEASE
60 RAYLIB_BUILD_MODE ?= RELEASE
62 # Build output name for the library
63 RAYLIB_LIB_NAME ?= raylib
65 # Define resource file for DLL properties
66 RAYLIB_RES_FILE ?= ./raylib.dll.rc.data
68 # Define raylib platform
69 # Options: PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
70 PLATFORM ?= PLATFORM_DESKTOP
72 # Include raylib modules on compilation
73 # NOTE: Some programs like tools could not require those modules
74 RAYLIB_MODULE_AUDIO ?= TRUE
75 RAYLIB_MODULE_MODELS ?= TRUE
76 RAYLIB_MODULE_RAYGUI ?= FALSE
77 RAYLIB_MODULE_PHYSAC ?= FALSE
79 RAYLIB_MODULE_RAYGUI_PATH ?= $(RAYLIB_SRC_PATH)/../../raygui/src
80 RAYLIB_MODULE_PHYSAC_PATH ?= $(RAYLIB_SRC_PATH)
82 # Use external GLFW library instead of rglfw module
83 # TODO: Review usage of examples on Linux.
84 USE_EXTERNAL_GLFW ?= FALSE
86 # Use Wayland display server protocol on Linux desktop
87 # by default it uses X11 windowing system
88 USE_WAYLAND_DISPLAY ?= FALSE
90 # Use cross-compiler for PLATFORM_RPI
91 ifeq ($(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
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").
102 ROOT = $(shell whoami)
104 # By default we suppose we are working on Windows
105 HOST_PLATFORM_OS ?= WINDOWS
107 # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
108 ifeq ($(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
114 UNAMEOS = $(shell uname)
115 ifeq ($(UNAMEOS),Linux)
118 ifeq ($(UNAMEOS),FreeBSD)
121 ifeq ($(UNAMEOS),OpenBSD)
124 ifeq ($(UNAMEOS),NetBSD)
127 ifeq ($(UNAMEOS),DragonFly)
130 ifeq ($(UNAMEOS),Darwin)
135 ifeq ($(PLATFORM),PLATFORM_RPI)
136 UNAMEOS = $(shell uname)
137 ifeq ($(UNAMEOS),Linux)
141 ifeq ($(PLATFORM),PLATFORM_DRM)
142 UNAMEOS = $(shell uname)
143 ifeq ($(UNAMEOS),Linux)
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.
151 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
152 ifeq ($(PLATFORM_OS),LINUX)
154 RAYLIB_SRC_PATH = $(realpath $(RAYLIB_PREFIX))
158 ifeq ($(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)
168 ifeq ($(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
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
181 ANDROID_NDK ?= /usr/lib/android/ndk
182 ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64
185 # NOTE: Sysroot can also be reference from $(ANDROID_NDK)/sysroot
186 ANDROID_SYSROOT ?= $(ANDROID_TOOLCHAIN)/sysroot
188 ifeq ($(ANDROID_ARCH),arm)
189 ANDROID_ARCH_NAME = armeabi-v7a
191 ifeq ($(ANDROID_ARCH),arm64)
192 ANDROID_ARCH_NAME = arm64-v8a
194 ifeq ($(ANDROID_ARCH),x86)
195 ANDROID_ARCH_NAME = i686
197 ifeq ($(ANDROID_ARCH),x86_64)
198 ANDROID_ARCH_NAME = x86_64
203 # Define raylib graphics api depending on selected platform
204 ifeq ($(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
210 ifeq ($(PLATFORM),PLATFORM_RPI)
211 # On RPI OpenGL ES 2.0 must be used
212 GRAPHICS = GRAPHICS_API_OPENGL_ES2
214 ifeq ($(PLATFORM),PLATFORM_DRM)
215 # On DRM OpenGL ES 2.0 must be used
216 GRAPHICS = GRAPHICS_API_OPENGL_ES2
218 ifeq ($(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
222 ifeq ($(PLATFORM),PLATFORM_ANDROID)
223 # By default use OpenGL ES 2.0 on Android
224 GRAPHICS = GRAPHICS_API_OPENGL_ES2
227 # Define default C compiler and archiver to pack library
231 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
232 ifeq ($(PLATFORM_OS),OSX)
233 # OSX default compiler
235 GLFW_OSX = -x objective-c
237 ifeq ($(PLATFORM_OS),BSD)
238 # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler
242 ifeq ($(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
250 ifeq ($(PLATFORM),PLATFORM_WEB)
251 # HTML5 emscripten compiler
255 ifeq ($(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
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
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
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
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)
286 CFLAGS += -Wall -D_DEFAULT_SOURCE -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing
288 ifeq ($(PLATFORM), PLATFORM_WEB)
294 ifeq ($(PLATFORM_OS), LINUX)
298 ifeq ($(RAYLIB_BUILD_MODE),DEBUG)
300 ifeq ($(PLATFORM),PLATFORM_WEB)
301 CFLAGS += -s ASSERTIONS=1 --profiling
304 ifeq ($(RAYLIB_BUILD_MODE),RELEASE)
305 ifeq ($(PLATFORM),PLATFORM_WEB)
308 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
311 ifeq ($(PLATFORM),PLATFORM_ANDROID)
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
321 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
322 CFLAGS += -Werror=implicit-function-declaration
324 ifeq ($(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
338 ifeq ($(PLATFORM),PLATFORM_ANDROID)
339 # Compiler flags for arquitecture
340 ifeq ($(ANDROID_ARCH),arm)
341 CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
343 ifeq ($(ANDROID_ARCH),arm64)
344 CFLAGS += -target aarch64 -mfix-cortex-a53-835769
346 ifeq ($(ANDROID_ARCH), x86)
347 CFLAGS += -march=i686
349 ifeq ($(ANDROID_ARCH), x86_64)
350 CFLAGS += -march=x86-64
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
361 # Define required compilation flags for raylib SHARED lib
362 ifeq ($(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
368 ifeq ($(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
374 # Use Wayland display on Linux desktop
375 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
376 ifeq ($(PLATFORM_OS), LINUX)
377 ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
378 CFLAGS += -D_GLFW_WAYLAND
385 # Define include paths for required headers
386 # NOTE: Several external required libraries (stb and others)
387 INCLUDE_PATHS = -I. -Iexternal/glfw/include -Iexternal/glfw/deps/mingw
389 ifeq ($(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)
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
401 # Define additional directories containing required header files
402 ifeq ($(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
408 ifeq ($(PLATFORM),PLATFORM_DRM)
409 # DRM required libraries
410 INCLUDE_PATHS += -I/usr/include/libdrm
412 ifeq ($(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)
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
422 ifeq ($(ANDROID_ARCH),arm64)
423 INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/aarch64-linux-android
425 ifeq ($(ANDROID_ARCH),x86)
426 INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/i686-linux-android
428 ifeq ($(ANDROID_ARCH),x86_64)
429 INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/x86_64-linux-android
433 # Define linker options
434 ifeq ($(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
444 LDLIBS += -llog -landroid -lEGL -lGLESv2 -lOpenSLES -lc -lm
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))
453 # Define object required on compilation
460 ifeq ($(PLATFORM),PLATFORM_DESKTOP)
461 ifeq ($(USE_EXTERNAL_GLFW),FALSE)
465 ifeq ($(RAYLIB_MODULE_MODELS),TRUE)
468 ifeq ($(RAYLIB_MODULE_AUDIO),TRUE)
471 ifeq ($(RAYLIB_MODULE_RAYGUI),TRUE)
474 ifeq ($(RAYLIB_MODULE_PHYSAC),TRUE)
478 ifeq ($(PLATFORM),PLATFORM_ANDROID)
479 OBJS += android_native_app_glue.o
482 # Default target entry
485 # Compile raylib library
486 # NOTE: Release directory is created if not exist
488 ifeq ($(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)!"
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!"
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
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
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
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
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
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
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)!"
557 # Compile all modules with their prerequisites
559 # Compile core module
560 core.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)
563 # Compile rglfw module
565 $(CC) $(GLFW_OSX) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS)
567 # Compile shapes module
568 shapes.o : shapes.c raylib.h rlgl.h
569 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS)
571 # Compile textures module
572 textures.o : textures.c raylib.h rlgl.h utils.h
573 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS)
575 # Compile text module
576 text.o : text.c raylib.h utils.h
577 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS)
579 # Compile utils module
580 utils.o : utils.c utils.h
581 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM)
583 # Compile models module
584 models.o : models.c raylib.h rlgl.h raymath.h
585 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS)
587 # Compile audio module
588 raudio.o : raudio.c raylib.h
589 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM)
591 # Compile raygui module
592 # NOTE: raygui header should be distributed with raylib.h
593 raygui.o : raygui.c raygui.h gui_textbox_extended.h ricons.h
594 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -DRAYGUI_IMPLEMENTATION
596 echo '#define RAYGUI_IMPLEMENTATION' > raygui.c
597 echo '#include "$(RAYLIB_MODULE_RAYGUI_PATH)/raygui.h"' >> raygui.c
599 # Compile physac module
600 # NOTE: physac header should be distributed with raylib.h
601 physac.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
606 # Compile android_native_app_glue module
607 android_native_app_glue.o : $(NATIVE_APP_GLUE)/android_native_app_glue.c
608 $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
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.
623 # RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths.
624 DESTDIR ?= /usr/local
625 RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib
626 # RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files.
627 RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include
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)
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
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!"
656 @echo "This function currently works on GNU/Linux systems. Add yours today (^;"
659 @echo "Error: Root permissions needed for installation. Try sudo make install"
662 # Remove raylib dev files installed on the system
663 # TODO: see 'install' target.
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.
676 rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.a
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!"
684 @echo "This function currently works on GNU/Linux systems. Add yours today (^;"
687 @echo "Error: Root permissions needed for uninstallation. Try sudo make uninstall"
692 ifeq ($(PLATFORM_OS),WINDOWS)
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
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*
701 ifeq ($(PLATFORM),PLATFORM_ANDROID)
702 rm -rf $(ANDROID_TOOLCHAIN) $(NATIVE_APP_GLUE)/android_native_app_glue.o
704 @echo "removed all generated files!"