Makefile 24 KB

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