Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

722 рядки
26 KiB

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