You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

691 lines
24 KiB

3 years ago
9 months ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
7 months ago
3 years ago
2 years ago
WARNING: `rcore` module split per-platform **BIG CHANGE** (#3388) * Submodules (#3311) * Check in current state * Add submodules to Makefile and clean up some imports * Start moving InitGraphicsDeivce * Move android_main and CloseWindow() out of rcore * Move WindowShouldClose out of rcore * Move IsWindowHidden out of rcore * Move IsWindowMinimized out of rcore * Move IsWindowMaximized, IsWindowFocused and IsWindowResized out of rcore * Move ToggleFullscreen out of rcore * Move MaximizeWindow, MinimizeWindow and RestoreWindow out of rcore * Move 13 functions out of rcore: ToggleBorderlessWindowed SetWindowState ClearWindowState SetWindowIcon SetWindowIcons SetWindowTitle SetWindowPosition SetWindowMonitor SetWindowMinSize SetWindowMaxSize SetWindowSize SetWindowOpacity SetWindowFocused * Minor clean up, revert makefile change, include submodules directly in rcore * Fix makefile comment * Remove rcore.h from Makefile * Remove debug include * Move 18 functions from rcore to submodules GetWindowHandle GetMonitorCount GetCurrentMonitor GetMonitorPosition GetMonitorWidth GetMonitorHeight GetMonitorPhysicalHeight GetMonitorRefreshRate GetWindowPosition GetWindowScaleDPI GetMonitorName SetClipboardText GetClipboardText ShowCursor HideCursor EnableCursor DisableCursor GetTime * Move TakeScreenshot, OpenURL, GetGamepadName out of rcore into submodules * remove debugging #defines * Move GetMonitorPhysicalWidth from rcore to submodule * Move GetGamepadAxisCount from rcore * Move SetGamepadMappings out of rcore * Move GetMouseX, GetMouseY, GetMousePosition out of rcore * Move SetMousePosition out of rcore * Move GetMouseWheelMove out of rcore * Move the last functions out of rcore * Move shared function defs and some global var to rcore.h * Clean up rcore.c and rcore.h a little more * Remove unnecessary #define --------- Co-authored-by: MichaelFiber <michael@cubeofb.org> * REVIEWED: `PLATFORM_DESKTOP` Windows building * Revert "REVIEWED: `PLATFORM_DESKTOP` Windows building" This reverts commit 71a12171f768eb25053ef908732b4ce8fdf802f7. * Reviewed Windows building * [split] Fix compilation for web (and desktop) (#3329) * Fix compilation for web * Remove EM_ASM_INT from core_input_gestures_web example * Fix raymath undefined symbols for desktop and web * Remove raylib_opengl_interop from examples Makefile * Revert previous commit (8651c78) * Fix TraceLog for web and desktop * [split] `rcore`, `rcore_web` and `rcore_desktop` changes (batch 2) (#3334) * Fix formatting * Reapply commit 9d230d7 (#3305) that was missing * Reapplies commits 719365f (#3309) and 8a1779b (#3312) that were missing * Reapply commit 5c9cc3f (#3323) that was missing * Reapply commit a2b3b1e that was missing * Revert commit cef25c6 to fix macro redefined warning * Move rcore.h #include to after config.h to fix macro redefinitions warnings * [split] `rcore`, `web`, `desktop`, `android` changes (batch 3) (#3338) * First pass to remove unneeded platform macros for web * Second pass to remove unneeded platform macros for web * Move GetTouchX, GetTouchY, GetTouchPosition from rcore to web, desktop, android * Move SetMouseCursor from rcore to android, desktop, web * [split] `rcore`, `web`, `desktop`, `android` changes (batch 4) (#3343) * Fix ToggleBorderlessWindowed duplicated glfwSetWindowSize calls * First pass to remove unneeded platform macros for android * Second pass to remove unneeded platform macros for android * Remove unneeded platform macros for desktop * Relocate GetGamepadName and update SetGamepadMappings on android, desktop, web * Add missing comment to web * [split] `rcore`, `web`, `desktop`, `android` changes (batch 5) (#3345) * Move SetExitKey from core to android, desktop, web * Move some callbacks from core to desktop and web * Relocate emscripten callbacks on web * Relocate android callbacks on android * Revert "Relocate android callbacks on android" This reverts commit bbdbecc01ea7f871dae56019724386e73611c69c. * Updates UnloadVrStereoConfig on rcore * Update SetClipboardText on android * Fix screenMin/Max default values for android * [split] `rcore`, `drm` changes (#3347) * Tweak makefiles for PLATFORM_DRM and move rcore_drm's dependencies to rcore.h * Move drm functions to rcore_drm.c * Fix a typo in rcore.c * Add SetExitKey to rcore_drm.c --------- Co-authored-by: MichaelFiber <michael@cubeofb.org> * Fix compilation for android (#3360) * Fix android include (#3364) * Reviewed platform split #3313 - Added file headers info - Added TRACELOG message for unimplemented functions - Reviewed code formatting and organization - Several code tweaks * REVIEWED: `GetDirectoryPath()` --------- Co-authored-by: MichaelFiber <42419558+michaelfiber@users.noreply.github.com> Co-authored-by: MichaelFiber <michael@cubeofb.org> Co-authored-by: ubkp <118854183+ubkp@users.noreply.github.com>
1 year ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
7 months ago
  1. #**************************************************************************************************
  2. #
  3. # raylib makefile for multiple platforms
  4. #
  5. # This file supports building raylib examples for the following platforms:
  6. #
  7. # > PLATFORM_DESKTOP
  8. # - Defaults to PLATFORM_DESKTOP_GLFW
  9. # > PLATFORM_DESKTOP_GFLW (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_WEB:
  24. # - HTML5 (WebAssembly)
  25. # > PLATFORM_DRM:
  26. # - Raspberry Pi 0-5 (DRM/KMS)
  27. # - Linux DRM subsystem (KMS mode)
  28. # > PLATFORM_ANDROID:
  29. # - Android (ARM, ARM64)
  30. #
  31. # Copyright (c) 2013-2024 Ramon Santamaria (@raysan5)
  32. #
  33. # This software is provided "as-is", without any express or implied warranty. In no event
  34. # will the authors be held liable for any damages arising from the use of this software.
  35. #
  36. # Permission is granted to anyone to use this software for any purpose, including commercial
  37. # applications, and to alter it and redistribute it freely, subject to the following restrictions:
  38. #
  39. # 1. The origin of this software must not be misrepresented; you must not claim that you
  40. # wrote the original software. If you use this software in a product, an acknowledgment
  41. # in the product documentation would be appreciated but is not required.
  42. #
  43. # 2. Altered source versions must be plainly marked as such, and must not be misrepresented
  44. # as being the original software.
  45. #
  46. # 3. This notice may not be removed or altered from any source distribution.
  47. #
  48. #**************************************************************************************************
  49. .PHONY: all clean
  50. # Define required environment variables
  51. #------------------------------------------------------------------------------------------------
  52. # Define target platform: PLATFORM_DESKTOP, PLATFORM_DESKTOP_SDL, PLATFORM_DRM, PLATFORM_ANDROID, PLATFORM_WEB
  53. PLATFORM ?= PLATFORM_DESKTOP
  54. ifeq ($(PLATFORM), PLATFORM_DESKTOP)
  55. TARGET_PLATFORM = PLATFORM_DESKTOP_GLFW
  56. else
  57. TARGET_PLATFORM = $(PLATFORM)
  58. endif
  59. # Define required raylib variables
  60. PROJECT_NAME ?= raylib_examples
  61. RAYLIB_VERSION ?= 5.5.0
  62. RAYLIB_PATH ?= ..
  63. # Define raylib source code path
  64. RAYLIB_SRC_PATH ?= ../src
  65. # Locations of raylib.h and libraylib.a/libraylib.so
  66. # NOTE: Those variables are only used for PLATFORM_OS: LINUX, BSD
  67. DESTDIR ?= /usr/local
  68. RAYLIB_INCLUDE_PATH ?= $(DESTDIR)/include
  69. RAYLIB_LIB_PATH ?= $(DESTDIR)/lib
  70. # Library type compilation: STATIC (.a) or SHARED (.so/.dll)
  71. RAYLIB_LIBTYPE ?= STATIC
  72. # Build mode for project: DEBUG or RELEASE
  73. BUILD_MODE ?= RELEASE
  74. # Use external GLFW library instead of rglfw module
  75. USE_EXTERNAL_GLFW ?= FALSE
  76. # PLATFORM_DESKTOP_SDL: It requires SDL library to be provided externally
  77. # WARNING: Library is not included in raylib, it MUST be configured by users
  78. SDL_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/include
  79. SDL_LIBRARY_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/lib
  80. # Use Wayland display server protocol on Linux desktop (by default it uses X11 windowing system)
  81. # NOTE: This variable is only used for PLATFORM_OS: LINUX
  82. USE_WAYLAND_DISPLAY ?= FALSE
  83. # PLATFORM_WEB: Default properties
  84. BUILD_WEB_ASYNCIFY ?= TRUE
  85. BUILD_WEB_SHELL ?= $(RAYLIB_PATH)/src/minshell.html
  86. BUILD_WEB_HEAP_SIZE ?= 134217728
  87. BUILD_WEB_RESOURCES ?= TRUE
  88. BUILD_WEB_RESOURCES_PATH ?= $(dir $<)resources@resources
  89. # Determine PLATFORM_OS when required
  90. ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW PLATFORM_WEB))
  91. # No uname.exe on MinGW!, but OS=Windows_NT on Windows!
  92. # ifeq ($(UNAME),Msys) -> Windows
  93. ifeq ($(OS),Windows_NT)
  94. PLATFORM_OS = WINDOWS
  95. else
  96. UNAMEOS = $(shell uname)
  97. ifeq ($(UNAMEOS),Linux)
  98. PLATFORM_OS = LINUX
  99. endif
  100. ifeq ($(UNAMEOS),FreeBSD)
  101. PLATFORM_OS = BSD
  102. endif
  103. ifeq ($(UNAMEOS),OpenBSD)
  104. PLATFORM_OS = BSD
  105. endif
  106. ifeq ($(UNAMEOS),NetBSD)
  107. PLATFORM_OS = BSD
  108. endif
  109. ifeq ($(UNAMEOS),DragonFly)
  110. PLATFORM_OS = BSD
  111. endif
  112. ifeq ($(UNAMEOS),Darwin)
  113. PLATFORM_OS = OSX
  114. endif
  115. endif
  116. endif
  117. ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
  118. UNAMEOS = $(shell uname)
  119. ifeq ($(UNAMEOS),Linux)
  120. PLATFORM_OS = LINUX
  121. endif
  122. endif
  123. # RAYLIB_PATH adjustment for LINUX platform
  124. # TODO: Do we really need this?
  125. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  126. ifeq ($(PLATFORM_OS),LINUX)
  127. RAYLIB_PREFIX ?= ..
  128. RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX))
  129. endif
  130. endif
  131. # Default path for raylib on Raspberry Pi
  132. ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
  133. RAYLIB_PATH ?= /home/pi/raylib
  134. endif
  135. # Define raylib release directory for compiled library
  136. RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src
  137. ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
  138. ifeq ($(PLATFORM_OS),WINDOWS)
  139. # Emscripten required variables
  140. EMSDK_PATH ?= C:/emsdk
  141. EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/upstream/emscripten
  142. CLANG_PATH = $(EMSDK_PATH)/upstream/bin
  143. PYTHON_PATH = $(EMSDK_PATH)/python/3.9.2-1_64bit
  144. NODE_PATH = $(EMSDK_PATH)/node/14.15.5_64bit/bin
  145. export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH):$$(PATH)
  146. endif
  147. endif
  148. # Define default C compiler: CC
  149. #------------------------------------------------------------------------------------------------
  150. CC = gcc
  151. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  152. ifeq ($(PLATFORM_OS),OSX)
  153. # OSX default compiler
  154. CC = clang
  155. endif
  156. ifeq ($(PLATFORM_OS),BSD)
  157. # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler
  158. CC = clang
  159. endif
  160. endif
  161. ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
  162. # HTML5 emscripten compiler
  163. # WARNING: To compile to HTML5, code must be redesigned
  164. # to use emscripten.h and emscripten_set_main_loop()
  165. CC = emcc
  166. endif
  167. # Define default make program: MAKE
  168. #------------------------------------------------------------------------------------------------
  169. MAKE ?= make
  170. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  171. ifeq ($(PLATFORM_OS),WINDOWS)
  172. MAKE = mingw32-make
  173. endif
  174. endif
  175. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  176. MAKE = mingw32-make
  177. endif
  178. ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
  179. MAKE = emmake make
  180. endif
  181. # Define compiler flags: CFLAGS
  182. #------------------------------------------------------------------------------------------------
  183. # -O1 defines optimization level
  184. # -g include debug information on compilation
  185. # -s strip unnecessary data from build
  186. # -Wall turns on most, but not all, compiler warnings
  187. # -std=c99 defines C language mode (standard C from 1999 revision)
  188. # -std=gnu99 defines C language mode (GNU C from 1999 revision)
  189. # -Wno-missing-braces ignore invalid warning (GCC bug 53119)
  190. # -Wno-unused-value ignore unused return values of some functions (i.e. fread())
  191. # -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
  192. CFLAGS = -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result
  193. ifeq ($(BUILD_MODE),DEBUG)
  194. CFLAGS += -g -D_DEBUG
  195. ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
  196. CFLAGS += -sASSERTIONS=1 --profiling
  197. endif
  198. else
  199. ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
  200. ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
  201. CFLAGS += -O3
  202. else
  203. CFLAGS += -Os
  204. endif
  205. else
  206. CFLAGS += -O2
  207. endif
  208. endif
  209. # Additional flags for compiler (if desired)
  210. # -Wextra enables some extra warning flags that are not enabled by -Wall
  211. # -Wmissing-prototypes warn if a global function is defined without a previous prototype declaration
  212. # -Wstrict-prototypes warn if a function is declared or defined without specifying the argument types
  213. # -Werror=implicit-function-declaration catch function calls without prior declaration
  214. #CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
  215. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  216. ifeq ($(PLATFORM_OS),LINUX)
  217. ifeq ($(RAYLIB_LIBTYPE),STATIC)
  218. CFLAGS += -D_DEFAULT_SOURCE
  219. endif
  220. ifeq ($(RAYLIB_LIBTYPE),SHARED)
  221. # Explicitly enable runtime link to libraylib.so
  222. CFLAGS += -Wl,-rpath,$(RAYLIB_RELEASE_PATH)
  223. endif
  224. endif
  225. endif
  226. ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
  227. CFLAGS += -std=gnu99 -DEGL_NO_X11
  228. endif
  229. # Define include paths for required headers: INCLUDE_PATHS
  230. # NOTE: Some external/extras libraries could be required (stb, easings...)
  231. #------------------------------------------------------------------------------------------------
  232. INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external
  233. # Define additional directories containing required header files
  234. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  235. ifeq ($(PLATFORM_OS),BSD)
  236. INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH)
  237. endif
  238. ifeq ($(PLATFORM_OS),LINUX)
  239. INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH)
  240. endif
  241. endif
  242. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
  243. INCLUDE_PATHS += -I$(SDL_INCLUDE_PATH)
  244. endif
  245. ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
  246. INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH)
  247. INCLUDE_PATHS += -I/usr/include/libdrm
  248. endif
  249. # Include GLFW required for examples/others/rlgl_standalone.c
  250. ifeq ($(USE_EXTERNAL_GLFW),FALSE)
  251. all others: INCLUDE_PATHS += -I$(RAYLIB_PATH)/src/external/glfw/include
  252. endif
  253. # Define library paths containing required libs: LDFLAGS
  254. #------------------------------------------------------------------------------------------------
  255. LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
  256. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  257. ifeq ($(PLATFORM_OS),WINDOWS)
  258. # NOTE: The resource .rc file contains windows executable icon and properties
  259. LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data
  260. # -Wl,--subsystem,windows hides the console window
  261. ifeq ($(BUILD_MODE), RELEASE)
  262. LDFLAGS += -Wl,--subsystem,windows
  263. endif
  264. endif
  265. ifeq ($(PLATFORM_OS),LINUX)
  266. LDFLAGS += -L$(RAYLIB_LIB_PATH)
  267. endif
  268. ifeq ($(PLATFORM_OS),BSD)
  269. LDFLAGS += -Lsrc -L$(RAYLIB_LIB_PATH)
  270. endif
  271. endif
  272. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
  273. ifeq ($(PLATFORM_OS),WINDOWS)
  274. # NOTE: The resource .rc file contains windows executable icon and properties
  275. LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data
  276. # -Wl,--subsystem,windows hides the console window
  277. ifeq ($(BUILD_MODE), RELEASE)
  278. LDFLAGS += -Wl,--subsystem,windows
  279. endif
  280. endif
  281. LDFLAGS += -L$(SDL_LIBRARY_PATH)
  282. endif
  283. ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
  284. # -Os # size optimization
  285. # -O2 # optimization level 2, if used, also set --memory-init-file 0
  286. # -sUSE_GLFW=3 # Use glfw3 library (context/input management)
  287. # -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL!
  288. # -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB)
  289. # -sUSE_PTHREADS=1 # multithreading support
  290. # -sWASM=0 # disable Web Assembly, emitted by default
  291. # -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS
  292. # -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data
  293. # -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off)
  294. # -sGL_ENABLE_GET_PROC_ADDRESS # enable using the *glGetProcAddress() family of functions, required for extensions loading
  295. # --profiling # include information for code profiling
  296. # --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
  297. # --preload-file resources # specify a resources folder for data compilation
  298. # --source-map-base # allow debugging in browser with source map
  299. LDFLAGS += -sUSE_GLFW=3 -sTOTAL_MEMORY=$(BUILD_WEB_HEAP_SIZE) -sFORCE_FILESYSTEM=1
  300. # Build using asyncify
  301. ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
  302. LDFLAGS += -sASYNCIFY
  303. endif
  304. # Add resources building if required
  305. ifeq ($(BUILD_WEB_RESOURCES),TRUE)
  306. LDFLAGS += --preload-file $(BUILD_WEB_RESOURCES_PATH)
  307. endif
  308. # Add debug mode flags if required
  309. ifeq ($(BUILD_MODE),DEBUG)
  310. LDFLAGS += -sASSERTIONS=1 --profiling
  311. endif
  312. # Define a custom shell .html and output extension
  313. LDFLAGS += --shell-file $(BUILD_WEB_SHELL)
  314. EXT = .html
  315. # NOTE: Simple raylib examples are compiled to be interpreter with asyncify, that way,
  316. # we can compile same code for ALL platforms with no change required, but, working on bigger
  317. # projects, code needs to be refactored to avoid a blocking while() loop, moving Update and Draw
  318. # logic to a self contained function: UpdateDrawFrame(), check core_basic_window_web.c for reference.
  319. endif
  320. # Define libraries required on linking: LDLIBS
  321. # NOTE: To link libraries (lib<name>.so or lib<name>.a), use -l<name>
  322. #------------------------------------------------------------------------------------------------
  323. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  324. ifeq ($(PLATFORM_OS),WINDOWS)
  325. # Libraries for Windows desktop compilation
  326. # NOTE: WinMM library required to set high-res timer resolution
  327. LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm
  328. endif
  329. ifeq ($(PLATFORM_OS),LINUX)
  330. # Libraries for Debian GNU/Linux desktop compiling
  331. # NOTE: Required packages: libegl1-mesa-dev
  332. LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt
  333. # On X11 requires also below libraries
  334. LDLIBS += -lX11
  335. # NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
  336. #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
  337. # On Wayland windowing system, additional libraries requires
  338. ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
  339. LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
  340. endif
  341. # Explicit link to libc
  342. ifeq ($(RAYLIB_LIBTYPE),SHARED)
  343. LDLIBS += -lc
  344. endif
  345. # NOTE: On ARM 32bit arch, miniaudio requires atomics library
  346. LDLIBS += -latomic
  347. endif
  348. ifeq ($(PLATFORM_OS),OSX)
  349. # Libraries for OSX 10.9 desktop compiling
  350. # NOTE: Required packages: libopenal-dev libegl1-mesa-dev
  351. LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo
  352. endif
  353. ifeq ($(PLATFORM_OS),BSD)
  354. # Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
  355. # NOTE: Required packages: mesa-libs
  356. LDLIBS = -lraylib -lGL -lpthread -lm
  357. # On XWindow requires also below libraries
  358. LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
  359. endif
  360. ifeq ($(USE_EXTERNAL_GLFW),TRUE)
  361. # NOTE: It could require additional packages installed: libglfw3-dev
  362. LDLIBS += -lglfw
  363. endif
  364. endif
  365. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
  366. ifeq ($(PLATFORM_OS),WINDOWS)
  367. # Libraries for Windows desktop compilation
  368. LDLIBS = -lraylib -lSDL2 -lSDL2main -lopengl32 -lgdi32
  369. endif
  370. ifeq ($(PLATFORM_OS),LINUX)
  371. # Libraries for Debian GNU/Linux desktop compiling
  372. # NOTE: Required packages: libegl1-mesa-dev
  373. LDLIBS = -lraylib -lSDL2 -lSDL2main -lGL -lm -lpthread -ldl -lrt
  374. # On X11 requires also below libraries
  375. LDLIBS += -lX11
  376. # NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
  377. #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
  378. # On Wayland windowing system, additional libraries requires
  379. ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
  380. LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
  381. endif
  382. # Explicit link to libc
  383. ifeq ($(RAYLIB_LIBTYPE),SHARED)
  384. LDLIBS += -lc
  385. endif
  386. # NOTE: On ARM 32bit arch, miniaudio requires atomics library
  387. LDLIBS += -latomic
  388. endif
  389. endif
  390. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
  391. ifeq ($(PLATFORM_OS),WINDOWS)
  392. # Libraries for Windows desktop compilation
  393. LDLIBS = ..\src\libraylib.a -lgdi32 -lwinmm -lopengl32
  394. endif
  395. ifeq ($(PLATFORM_OS),LINUX)
  396. # Libraries for Debian GNU/Linux desktop compipling
  397. # NOTE: Required packages: libegl1-mesa-dev
  398. LDLIBS = ../src/libraylib.a -lGL -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -lm -lpthread -ldl -lrt
  399. # Explicit link to libc
  400. ifeq ($(RAYLIB_LIBTYPE),SHARED)
  401. LDLIBS += -lc
  402. endif
  403. # NOTE: On ARM 32bit arch, miniaudio requires atomics library
  404. LDLIBS += -latomic
  405. endif
  406. ifeq ($(PLATFORM_OS),OSX)
  407. # Libraries for Debian GNU/Linux desktop compiling
  408. # NOTE: Required packages: libegl1-mesa-dev
  409. LDLIBS = ../src/libraylib.a -lm
  410. LDLIBS += -framework Foundation -framework AppKit -framework OpenGL -framework CoreVideo
  411. endif
  412. endif
  413. ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
  414. # Libraries for DRM compiling
  415. # NOTE: Required packages: libasound2-dev (ALSA)
  416. LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lgbm -ldrm -ldl -latomic
  417. endif
  418. ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
  419. # Libraries for web (HTML5) compiling
  420. LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.a
  421. endif
  422. # Define source code object files required
  423. #------------------------------------------------------------------------------------------------
  424. CORE = \
  425. core/core_2d_camera \
  426. core/core_2d_camera_mouse_zoom \
  427. core/core_2d_camera_platformer \
  428. core/core_2d_camera_split_screen \
  429. core/core_3d_camera_first_person \
  430. core/core_3d_camera_free \
  431. core/core_3d_camera_mode \
  432. core/core_3d_camera_split_screen \
  433. core/core_3d_picking \
  434. core/core_automation_events \
  435. core/core_basic_screen_manager \
  436. core/core_basic_window \
  437. core/core_basic_window_web \
  438. core/core_custom_frame_control \
  439. core/core_custom_logging \
  440. core/core_drop_files \
  441. core/core_input_gamepad \
  442. core/core_input_gamepad_info \
  443. core/core_input_gestures \
  444. core/core_input_gestures_web \
  445. core/core_input_keys \
  446. core/core_input_mouse \
  447. core/core_input_mouse_wheel \
  448. core/core_input_multitouch \
  449. core/core_input_virtual_controls \
  450. core/core_loading_thread \
  451. core/core_random_sequence \
  452. core/core_random_values \
  453. core/core_scissor_test \
  454. core/core_smooth_pixelperfect \
  455. core/core_storage_values \
  456. core/core_vr_simulator \
  457. core/core_window_flags \
  458. core/core_window_letterbox \
  459. core/core_window_should_close \
  460. core/core_world_screen
  461. SHAPES = \
  462. shapes/shapes_basic_shapes \
  463. shapes/shapes_bouncing_ball \
  464. shapes/shapes_collision_area \
  465. shapes/shapes_colors_palette \
  466. shapes/shapes_draw_circle_sector \
  467. shapes/shapes_draw_rectangle_rounded \
  468. shapes/shapes_draw_ring \
  469. shapes/shapes_easings_ball_anim \
  470. shapes/shapes_easings_box_anim \
  471. shapes/shapes_easings_rectangle_array \
  472. shapes/shapes_following_eyes \
  473. shapes/shapes_lines_bezier \
  474. shapes/shapes_logo_raylib \
  475. shapes/shapes_logo_raylib_anim \
  476. shapes/shapes_rectangle_scaling \
  477. shapes/shapes_splines_drawing \
  478. shapes/shapes_top_down_lights
  479. TEXTURES = \
  480. textures/textures_background_scrolling \
  481. textures/textures_blend_modes \
  482. textures/textures_bunnymark \
  483. textures/textures_draw_tiled \
  484. textures/textures_fog_of_war \
  485. textures/textures_gif_player \
  486. textures/textures_image_channel \
  487. textures/textures_image_drawing \
  488. textures/textures_image_generation \
  489. textures/textures_image_kernel \
  490. textures/textures_image_loading \
  491. textures/textures_image_processing \
  492. textures/textures_image_rotate \
  493. textures/textures_image_text \
  494. textures/textures_logo_raylib \
  495. textures/textures_mouse_painting \
  496. textures/textures_npatch_drawing \
  497. textures/textures_particles_blending \
  498. textures/textures_polygon \
  499. textures/textures_raw_data \
  500. textures/textures_sprite_anim \
  501. textures/textures_sprite_button \
  502. textures/textures_sprite_explosion \
  503. textures/textures_srcrec_dstrec \
  504. textures/textures_textured_curve \
  505. textures/textures_to_image
  506. TEXT = \
  507. text/text_codepoints_loading \
  508. text/text_draw_3d \
  509. text/text_font_filters \
  510. text/text_font_loading \
  511. text/text_font_sdf \
  512. text/text_font_spritefont \
  513. text/text_format_text \
  514. text/text_input_box \
  515. text/text_raylib_fonts \
  516. text/text_rectangle_bounds \
  517. text/text_unicode \
  518. text/text_writing_anim
  519. MODELS = \
  520. models/models_animation \
  521. models/models_billboard \
  522. models/models_bone_socket \
  523. models/models_box_collisions \
  524. models/models_cubicmap \
  525. models/models_draw_cube_texture \
  526. models/models_first_person_maze \
  527. models/models_geometric_shapes \
  528. models/models_heightmap \
  529. models/models_loading \
  530. models/models_loading_gltf \
  531. models/models_loading_m3d \
  532. models/models_loading_vox \
  533. models/models_mesh_generation \
  534. models/models_mesh_picking \
  535. models/models_orthographic_projection \
  536. models/models_point_rendering \
  537. models/models_rlgl_solar_system \
  538. models/models_skybox \
  539. models/models_waving_cubes \
  540. models/models_yaw_pitch_roll \
  541. models/models_gpu_skinning
  542. SHADERS = \
  543. shaders/shaders_basic_lighting \
  544. shaders/shaders_basic_pbr \
  545. shaders/shaders_custom_uniform \
  546. shaders/shaders_deferred_render \
  547. shaders/shaders_eratosthenes \
  548. shaders/shaders_fog \
  549. shaders/shaders_hot_reloading \
  550. shaders/shaders_hybrid_render \
  551. shaders/shaders_julia_set \
  552. shaders/shaders_lightmap \
  553. shaders/shaders_mesh_instancing \
  554. shaders/shaders_model_shader \
  555. shaders/shaders_multi_sample2d \
  556. shaders/shaders_palette_switch \
  557. shaders/shaders_postprocessing \
  558. shaders/shaders_raymarching \
  559. shaders/shaders_shadowmap \
  560. shaders/shaders_shapes_textures \
  561. shaders/shaders_simple_mask \
  562. shaders/shaders_spotlight \
  563. shaders/shaders_texture_drawing \
  564. shaders/shaders_texture_outline \
  565. shaders/shaders_texture_tiling \
  566. shaders/shaders_texture_waves \
  567. shaders/shaders_write_depth \
  568. shaders/shaders_vertex_displacement
  569. AUDIO = \
  570. audio/audio_mixed_processor \
  571. audio/audio_module_playing \
  572. audio/audio_music_stream \
  573. audio/audio_raw_stream \
  574. audio/audio_sound_loading \
  575. audio/audio_sound_multi \
  576. audio/audio_stream_effects
  577. OTHERS = \
  578. others/easings_testbed \
  579. others/embedded_files_loading \
  580. others/raylib_opengl_interop \
  581. others/raymath_vector_angle \
  582. others/rlgl_compute_shader \
  583. others/rlgl_standalone
  584. CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
  585. # Define processes to execute
  586. #------------------------------------------------------------------------------------------------
  587. # Default target entry
  588. all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO) $(OTHERS)
  589. core: $(CORE)
  590. shapes: $(SHAPES)
  591. textures: $(TEXTURES)
  592. text: $(TEXT)
  593. models: $(MODELS)
  594. shaders: $(SHADERS)
  595. audio: $(AUDIO)
  596. others: $(OTHERS)
  597. # Generic compilation pattern
  598. # NOTE: Examples must be ready for Android compilation!
  599. %: %.c
  600. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  601. $(MAKE) -f Makefile.Android PROJECT_NAME=$@ PROJECT_SOURCE_FILES=$<
  602. else ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
  603. $(MAKE) -f Makefile.Web $@
  604. else
  605. $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -D$(TARGET_PLATFORM)
  606. endif
  607. # Clean everything
  608. clean:
  609. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  610. ifeq ($(PLATFORM_OS),WINDOWS)
  611. del *.o *.exe /s
  612. endif
  613. ifeq ($(PLATFORM_OS),LINUX)
  614. find . -type f -executable -delete
  615. rm -fv *.o
  616. endif
  617. ifeq ($(PLATFORM_OS),OSX)
  618. find . -type f -perm +ugo+x -delete
  619. rm -f *.o
  620. endif
  621. endif
  622. ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
  623. find . -type f -executable -delete
  624. rm -fv *.o
  625. endif
  626. ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
  627. ifeq ($(PLATFORM_OS),WINDOWS)
  628. del *.wasm *.html *.js *.data
  629. else
  630. rm -f */*.wasm */*.html */*.js */*.data
  631. endif
  632. endif
  633. @echo Cleaning done