Makefile 26 KB

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