2
0

Makefile 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894
  1. #******************************************************************************
  2. #
  3. # raylib makefile
  4. #
  5. # This file supports building raylib library for the following platforms:
  6. #
  7. # > PLATFORM_DESKTOP
  8. # - Defaults to PLATFORM_DESKTOP_GLFW
  9. # > PLATFORM_DESKTOP_GLFW (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. # Many thanks to Milan Nikolic (@gen2brain) for implementing Android platform pipeline.
  34. # Many thanks to Emanuele Petriglia for his contribution on GNU/Linux pipeline.
  35. #
  36. # Copyright (c) 2013-2025 Ramon Santamaria (@raysan5)
  37. #
  38. # This software is provided "as-is", without any express or implied warranty. In no event
  39. # will the authors be held liable for any damages arising from the use of this software.
  40. #
  41. # Permission is granted to anyone to use this software for any purpose, including commercial
  42. # applications, and to alter it and redistribute it freely, subject to the following restrictions:
  43. #
  44. # 1. The origin of this software must not be misrepresented; you must not claim that you
  45. # wrote the original software. If you use this software in a product, an acknowledgment
  46. # in the product documentation would be appreciated but is not required.
  47. #
  48. # 2. Altered source versions must be plainly marked as such, and must not be misrepresented
  49. # as being the original software.
  50. #
  51. # 3. This notice may not be removed or altered from any source distribution.
  52. #
  53. #**************************************************************************************************
  54. # NOTE: Highly recommended to read the raylib Wiki to know how to compile raylib for different platforms
  55. # https://github.com/raysan5/raylib/wiki
  56. .PHONY: all clean install uninstall
  57. # Define required environment variables
  58. #------------------------------------------------------------------------------------------------
  59. # Define target platform
  60. PLATFORM ?= PLATFORM_DESKTOP
  61. ifeq ($(PLATFORM), PLATFORM_DESKTOP)
  62. TARGET_PLATFORM = PLATFORM_DESKTOP_GLFW
  63. else
  64. TARGET_PLATFORM = $(PLATFORM)
  65. endif
  66. # Define required raylib variables
  67. RAYLIB_VERSION = 5.5.0
  68. RAYLIB_API_VERSION = 550
  69. # Define raylib source code path
  70. RAYLIB_SRC_PATH ?= ../src
  71. # Define output directory for compiled library, defaults to src directory
  72. # NOTE: If externally provided, make sure directory exists
  73. RAYLIB_RELEASE_PATH ?= ../
  74. # Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
  75. RAYLIB_LIBTYPE ?= STATIC
  76. # Build mode for library: DEBUG or RELEASE
  77. RAYLIB_BUILD_MODE ?= RELEASE
  78. # Build output name for the library
  79. RAYLIB_LIB_NAME ?= raylib
  80. # Define resource file for DLL properties
  81. RAYLIB_RES_FILE ?= ./raylib.dll.rc.data
  82. # Define external config flags
  83. # NOTE: It will override config.h flags with the provided ones,
  84. # if NONE, default config.h flags are used
  85. RAYLIB_CONFIG_FLAGS ?= NONE
  86. # To define additional cflags: Use make CUSTOM_CFLAGS=""
  87. # Include raylib modules on compilation
  88. # NOTE: Some programs like tools could not require those modules
  89. RAYLIB_MODULE_AUDIO ?= TRUE
  90. RAYLIB_MODULE_MODELS ?= TRUE
  91. RAYLIB_MODULE_RAYGUI ?= FALSE
  92. # NOTE: Additional libraries have been moved to their own repos:
  93. # raygui: https://github.com/raysan5/raygui
  94. RAYLIB_MODULE_RAYGUI_PATH ?= $(RAYLIB_SRC_PATH)/../../raygui/src
  95. # Use external GLFW library instead of rglfw module
  96. USE_EXTERNAL_GLFW ?= FALSE
  97. # Enable support for X11 by default on Linux when using GLFW
  98. # NOTE: Wayland is disabled by default, only enable if you are sure
  99. GLFW_LINUX_ENABLE_WAYLAND ?= FALSE
  100. GLFW_LINUX_ENABLE_X11 ?= TRUE
  101. # PLATFORM_DESKTOP_SDL: It requires SDL library to be provided externally
  102. # WARNING: Library is not included in raylib, it MUST be configured by users
  103. SDL_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/include
  104. SDL_LIBRARY_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/lib
  105. SDL_LIBRARIES ?= -lSDL2 -lSDL2main
  106. # Determine if the file has root access (only required to install raylib)
  107. # "whoami" prints the name of the user that calls him (so, if it is the root user, "whoami" prints "root")
  108. ROOT = $(shell whoami)
  109. # By default we suppose we are working on Windows
  110. HOST_PLATFORM_OS ?= WINDOWS
  111. PLATFORM_OS ?= WINDOWS
  112. # Determine PLATFORM_OS when required
  113. ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW PLATFORM_WEB PLATFORM_WEB_RGFW PLATFORM_ANDROID))
  114. # No uname.exe on MinGW!, but OS=Windows_NT on Windows!
  115. # ifeq ($(UNAME),Msys) -> Windows
  116. ifeq ($(OS),Windows_NT)
  117. PLATFORM_OS = WINDOWS
  118. ifndef PLATFORM_SHELL
  119. PLATFORM_SHELL = cmd
  120. endif
  121. else
  122. UNAMEOS = $(shell uname)
  123. ifeq ($(UNAMEOS),Linux)
  124. PLATFORM_OS = LINUX
  125. endif
  126. ifeq ($(UNAMEOS),FreeBSD)
  127. PLATFORM_OS = BSD
  128. endif
  129. ifeq ($(UNAMEOS),OpenBSD)
  130. PLATFORM_OS = BSD
  131. endif
  132. ifeq ($(UNAMEOS),NetBSD)
  133. PLATFORM_OS = BSD
  134. endif
  135. ifeq ($(UNAMEOS),DragonFly)
  136. PLATFORM_OS = BSD
  137. endif
  138. ifeq ($(UNAMEOS),Darwin)
  139. PLATFORM_OS = OSX
  140. endif
  141. ifndef PLATFORM_SHELL
  142. PLATFORM_SHELL = sh
  143. endif
  144. endif
  145. endif
  146. ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
  147. UNAMEOS = $(shell uname)
  148. ifeq ($(UNAMEOS),Linux)
  149. PLATFORM_OS = LINUX
  150. endif
  151. ifndef PLATFORM_SHELL
  152. PLATFORM_SHELL = sh
  153. endif
  154. endif
  155. ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
  156. ifeq ($(PLATFORM_OS),LINUX)
  157. ifndef PLATFORM_SHELL
  158. PLATFORM_SHELL = sh
  159. endif
  160. endif
  161. endif
  162. ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
  163. ifeq ($(PLATFORM_OS), WINDOWS)
  164. # Emscripten required variables
  165. EMSDK_PATH ?= C:/raylib/emsdk
  166. EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/upstream/emscripten
  167. CLANG_PATH := $(EMSDK_PATH)/upstream/bin
  168. PYTHON_PATH := $(EMSDK_PATH)/python/3.9.2-nuget_64bit
  169. NODE_PATH := $(EMSDK_PATH)/node/20.18.0_64bit/bin
  170. export PATH := $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:/raylib/MinGW/bin;$(PATH)
  171. endif
  172. endif
  173. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  174. # Android architecture
  175. # Starting at 2019 using arm64 is mandatory for published apps,
  176. # Starting on August 2020, minimum required target API is Android 10 (API level 29)
  177. ANDROID_ARCH ?= arm64
  178. ANDROID_API_VERSION ?= 29
  179. # Android required path variables
  180. # NOTE: Starting with Android NDK r21, no more toolchain generation is required, NDK is the toolchain on itself
  181. ifeq ($(OS),Windows_NT)
  182. ANDROID_NDK ?= C:/android-ndk
  183. ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/windows-x86_64
  184. else
  185. ANDROID_NDK ?= /usr/lib/android/ndk
  186. ifeq ($(PLATFORM_OS), OSX)
  187. ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/darwin-x86_64
  188. else
  189. ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64
  190. endif
  191. endif
  192. # NOTE: Sysroot can also be reference from $(ANDROID_NDK)/sysroot
  193. ANDROID_SYSROOT ?= $(ANDROID_TOOLCHAIN)/sysroot
  194. ifeq ($(ANDROID_ARCH),arm)
  195. ANDROID_COMPILER_ARCH = armv7a
  196. endif
  197. ifeq ($(ANDROID_ARCH),arm64)
  198. ANDROID_COMPILER_ARCH = aarch64
  199. endif
  200. ifeq ($(ANDROID_ARCH),x86)
  201. ANDROID_COMPILER_ARCH = i686
  202. endif
  203. ifeq ($(ANDROID_ARCH),x86_64)
  204. ANDROID_COMPILER_ARCH = x86_64
  205. endif
  206. endif
  207. # Define raylib graphics api depending on selected platform
  208. # NOTE: By default use OpenGL 3.3 on desktop platforms
  209. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  210. GRAPHICS ?= GRAPHICS_API_OPENGL_33
  211. #GRAPHICS = GRAPHICS_API_OPENGL_11_SOFTWARE # Uncomment to use software rendering
  212. #GRAPHICS = GRAPHICS_API_OPENGL_11 # Uncomment to use OpenGL 1.1
  213. #GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1
  214. #GRAPHICS = GRAPHICS_API_OPENGL_43 # Uncomment to use OpenGL 4.3
  215. #GRAPHICS = GRAPHICS_API_OPENGL_ES2 # Uncomment to use OpenGL ES 2.0 (ANGLE)
  216. endif
  217. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
  218. GRAPHICS ?= GRAPHICS_API_OPENGL_33
  219. endif
  220. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
  221. GRAPHICS ?= GRAPHICS_API_OPENGL_33
  222. #GRAPHICS = GRAPHICS_API_OPENGL_11_SOFTWARE # Uncomment to use software rendering
  223. #GRAPHICS = GRAPHICS_API_OPENGL_11 # Uncomment to use OpenGL 1.1
  224. #GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1
  225. #GRAPHICS = GRAPHICS_API_OPENGL_43 # Uncomment to use OpenGL 4.3
  226. #GRAPHICS = GRAPHICS_API_OPENGL_ES2 # Uncomment to use OpenGL ES 2.0 (ANGLE)
  227. endif
  228. ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
  229. # On DRM OpenGL ES 2.0 must be used
  230. GRAPHICS = GRAPHICS_API_OPENGL_ES2
  231. endif
  232. ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
  233. # On HTML5 OpenGL ES 2.0 is used, emscripten translates it to WebGL 1.0
  234. GRAPHICS = GRAPHICS_API_OPENGL_ES2
  235. #GRAPHICS = GRAPHICS_API_OPENGL_ES3
  236. endif
  237. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  238. # By default use OpenGL ES 2.0 on Android
  239. GRAPHICS = GRAPHICS_API_OPENGL_ES2
  240. endif
  241. # Define default C compiler and archiver to pack library: CC, AR
  242. #------------------------------------------------------------------------------------------------
  243. CC = gcc
  244. AR = ar
  245. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  246. ifeq ($(PLATFORM_OS),OSX)
  247. # OSX default compiler
  248. CC = clang
  249. GLFW_OSX = -x objective-c
  250. endif
  251. ifeq ($(PLATFORM_OS),BSD)
  252. # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler
  253. CC = clang
  254. endif
  255. endif
  256. ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
  257. ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
  258. # Define RPI cross-compiler
  259. #CC = armv6j-hardfloat-linux-gnueabi-gcc
  260. CC = $(RPI_TOOLCHAIN)/bin/$(RPI_TOOLCHAIN_NAME)-gcc
  261. AR = $(RPI_TOOLCHAIN)/bin/$(RPI_TOOLCHAIN_NAME)-ar
  262. endif
  263. endif
  264. ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
  265. # HTML5 emscripten compiler
  266. CC = emcc
  267. AR = emar
  268. endif
  269. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  270. # Android toolchain (must be provided for desired architecture and compiler)
  271. ifeq ($(ANDROID_ARCH),arm)
  272. CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-androideabi$(ANDROID_API_VERSION)-clang
  273. endif
  274. ifeq ($(ANDROID_ARCH),arm64)
  275. CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-android$(ANDROID_API_VERSION)-clang
  276. endif
  277. ifeq ($(ANDROID_ARCH),x86)
  278. CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-android$(ANDROID_API_VERSION)-clang
  279. endif
  280. ifeq ($(ANDROID_ARCH),x86_64)
  281. CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-android$(ANDROID_API_VERSION)-clang
  282. endif
  283. # It seems from Android NDK r22 onwards we need to use llvm-ar
  284. AR = $(ANDROID_TOOLCHAIN)/bin/llvm-ar
  285. endif
  286. # Define compiler flags: CFLAGS
  287. #------------------------------------------------------------------------------------------------
  288. # -O1 defines optimization level
  289. # -g include debug information on compilation
  290. # -s strip unnecessary data from build --> linker
  291. # -Wall turns on most, but not all, compiler warnings
  292. # -std=c99 defines C language mode (standard C from 1999 revision)
  293. # -std=gnu99 defines C language mode (GNU C from 1999 revision)
  294. # -Wno-missing-braces ignore invalid warning (GCC bug 53119)
  295. # -Wno-unused-value ignore unused return values of some functions (i.e. fread())
  296. # -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
  297. # -D_GNU_SOURCE access to lots of nonstandard GNU/Linux extension functions
  298. # -Werror=pointer-arith catch unportable code that does direct arithmetic on void pointers
  299. # -fno-strict-aliasing jar_xm.h does shady stuff (breaks strict aliasing)
  300. CFLAGS = -Wall -D_GNU_SOURCE -D$(TARGET_PLATFORM) -D$(GRAPHICS) -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing
  301. ifneq ($(RAYLIB_CONFIG_FLAGS), NONE)
  302. CFLAGS += -DEXTERNAL_CONFIG_FLAGS $(RAYLIB_CONFIG_FLAGS)
  303. endif
  304. ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
  305. # NOTE: When using multi-threading in the user code, it requires -pthread enabled
  306. CFLAGS += -std=gnu99
  307. else
  308. CFLAGS += -std=c99
  309. endif
  310. ifeq ($(PLATFORM_OS), LINUX)
  311. CFLAGS += -fPIC
  312. endif
  313. ifeq ($(PLATFORM_OS),WINDOWS)
  314. CFLAGS += -DUNICODE
  315. endif
  316. ifeq ($(RAYLIB_BUILD_MODE),DEBUG)
  317. CFLAGS += -g -D_DEBUG
  318. endif
  319. ifeq ($(RAYLIB_BUILD_MODE),RELEASE)
  320. ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
  321. CFLAGS += -Os
  322. endif
  323. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  324. CFLAGS += -O1
  325. endif
  326. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  327. CFLAGS += -O2
  328. endif
  329. endif
  330. # Additional flags for compiler (if desired)
  331. # -Wextra enables some extra warning flags that are not enabled by -Wall
  332. # -Wmissing-prototypes warn if a global function is defined without a previous prototype declaration
  333. # -Wstrict-prototypes warn if a function is declared or defined without specifying the argument types
  334. # -Werror=implicit-function-declaration catch function calls without prior declaration
  335. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  336. CFLAGS += -Werror=implicit-function-declaration
  337. endif
  338. ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
  339. # -Os # size optimization
  340. # -O2 # optimization level 2, if used, also set --memory-init-file 0
  341. # -sUSE_GLFW=3 # Use glfw3 library (context/input management)
  342. # -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL!
  343. # -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB)
  344. # -sUSE_PTHREADS=1 # multithreading support
  345. # -sWASM=0 # disable Web Assembly, emitted by default
  346. # -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS
  347. # -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data
  348. # -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off)
  349. # -sMINIFY_HTML=0 # minify generated html from shell.html
  350. # --profiling # include information for code profiling
  351. # --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
  352. # --preload-file resources # specify a resources folder for data compilation
  353. # --source-map-base # allow debugging in browser with source map
  354. # --shell-file shell.html # define a custom shell .html and output extension
  355. ifeq ($(RAYLIB_BUILD_MODE),DEBUG)
  356. CFLAGS += --profiling
  357. endif
  358. endif
  359. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  360. # Compiler flags for arquitecture
  361. ifeq ($(ANDROID_ARCH),arm)
  362. CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
  363. endif
  364. ifeq ($(ANDROID_ARCH),arm64)
  365. CFLAGS += -target aarch64 -mfix-cortex-a53-835769
  366. endif
  367. ifeq ($(ANDROID_ARCH),x86)
  368. CFLAGS += -march=i686
  369. endif
  370. ifeq ($(ANDROID_ARCH),x86_64)
  371. CFLAGS += -march=x86-64
  372. endif
  373. # Compilation functions attributes options
  374. CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIE -fPIC
  375. # Compiler options for the linker
  376. # -Werror=format-security
  377. CFLAGS += -Wa,--noexecstack -Wformat -no-canonical-prefixes
  378. # Preprocessor macro definitions
  379. CFLAGS += -D__ANDROID__ -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION)
  380. endif
  381. # Define required compilation flags for raylib SHARED lib
  382. ifeq ($(RAYLIB_LIBTYPE),SHARED)
  383. # make sure code is compiled as position independent
  384. # BE CAREFUL: It seems that for gcc -fpic is not the same as -fPIC
  385. # MinGW32 just doesn't need -fPIC, it shows warnings
  386. CFLAGS += -fPIC -DBUILD_LIBTYPE_SHARED
  387. # hide all symbols by default, so RLAPI can expose them
  388. ifeq ($(PLATFORM_OS),$(filter $(PLATFORM_OS), LINUX BSD OSX))
  389. CFLAGS += -fvisibility=hidden
  390. endif
  391. endif
  392. ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
  393. # without EGL_NO_X11 eglplatform.h tears Xlib.h in which tears X.h in
  394. # which contains a conflicting type Font
  395. CFLAGS += -DEGL_NO_X11
  396. CFLAGS += -Werror=implicit-function-declaration
  397. endif
  398. # Use Wayland display on Linux desktop
  399. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  400. ifeq ($(PLATFORM_OS), LINUX)
  401. ifeq ($(GLFW_LINUX_ENABLE_X11),TRUE)
  402. CFLAGS += -D_GLFW_X11
  403. endif
  404. ifeq ($(GLFW_LINUX_ENABLE_WAYLAND),TRUE)
  405. CFLAGS += -D_GLFW_WAYLAND
  406. LDFLAGS += $(shell pkg-config wayland-client wayland-cursor wayland-egl xkbcommon --libs)
  407. WL_PROTOCOLS_DIR := external/glfw/deps/wayland
  408. wl_generate = \
  409. $(eval protocol=$(1)) \
  410. $(eval basename=$(2)) \
  411. $(shell wayland-scanner client-header $(protocol) $(RAYLIB_SRC_PATH)/$(basename).h) \
  412. $(shell wayland-scanner private-code $(protocol) $(RAYLIB_SRC_PATH)/$(basename)-code.h)
  413. $(call wl_generate, $(WL_PROTOCOLS_DIR)/wayland.xml, wayland-client-protocol)
  414. $(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-shell.xml, xdg-shell-client-protocol)
  415. $(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-decoration-unstable-v1.xml, xdg-decoration-unstable-v1-client-protocol)
  416. $(call wl_generate, $(WL_PROTOCOLS_DIR)/viewporter.xml, viewporter-client-protocol)
  417. $(call wl_generate, $(WL_PROTOCOLS_DIR)/relative-pointer-unstable-v1.xml, relative-pointer-unstable-v1-client-protocol)
  418. $(call wl_generate, $(WL_PROTOCOLS_DIR)/pointer-constraints-unstable-v1.xml, pointer-constraints-unstable-v1-client-protocol)
  419. $(call wl_generate, $(WL_PROTOCOLS_DIR)/fractional-scale-v1.xml, fractional-scale-v1-client-protocol)
  420. $(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-activation-v1.xml, xdg-activation-v1-client-protocol)
  421. $(call wl_generate, $(WL_PROTOCOLS_DIR)/idle-inhibit-unstable-v1.xml, idle-inhibit-unstable-v1-client-protocol)
  422. endif
  423. endif
  424. endif
  425. CFLAGS += $(CUSTOM_CFLAGS)
  426. # Define include paths for required headers: INCLUDE_PATHS
  427. # NOTE: Several external required libraries (stb and others)
  428. #------------------------------------------------------------------------------------------------
  429. INCLUDE_PATHS = -I. $(EXTRA_INCLUDE_PATHS)
  430. # Define additional directories containing required header files
  431. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  432. INCLUDE_PATHS += -Iexternal/glfw/include
  433. ifeq ($(PLATFORM_OS),BSD)
  434. INCLUDE_PATHS += -I/usr/local/include -I/usr/pkg/include -I/usr/X11R7/include
  435. endif
  436. endif
  437. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
  438. INCLUDE_PATHS += -I$(SDL_INCLUDE_PATH)
  439. endif
  440. ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
  441. INCLUDE_PATHS += -Iexternal/glfw/include
  442. endif
  443. ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
  444. INCLUDE_PATHS += -I/usr/include/libdrm
  445. ifeq ($(USE_RPI_CROSSCOMPILER), TRUE)
  446. INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/usr/include
  447. INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include
  448. endif
  449. endif
  450. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  451. NATIVE_APP_GLUE = $(ANDROID_NDK)/sources/android/native_app_glue
  452. # Include android_native_app_glue.h
  453. INCLUDE_PATHS += -I$(NATIVE_APP_GLUE)
  454. # Android required libraries
  455. INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include
  456. ifeq ($(ANDROID_ARCH),arm)
  457. INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/arm-linux-androideabi
  458. endif
  459. ifeq ($(ANDROID_ARCH),arm64)
  460. INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/aarch64-linux-android
  461. endif
  462. ifeq ($(ANDROID_ARCH),x86)
  463. INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/i686-linux-android
  464. endif
  465. ifeq ($(ANDROID_ARCH),x86_64)
  466. INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/x86_64-linux-android
  467. endif
  468. endif
  469. # Define library paths containing required libs: LDFLAGS
  470. # NOTE: This is only required for dynamic library generation
  471. #------------------------------------------------------------------------------------------------
  472. LDFLAGS = $(CUSTOM_LDFLAGS) -L. -L$(RAYLIB_RELEASE_PATH)
  473. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  474. ifeq ($(PLATFORM_OS),WINDOWS)
  475. ifneq ($(CC), tcc)
  476. LDFLAGS += -Wl,--out-implib,$(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME)dll.a
  477. endif
  478. endif
  479. ifeq ($(PLATFORM_OS),OSX)
  480. LDFLAGS += -compatibility_version $(RAYLIB_API_VERSION) -current_version $(RAYLIB_VERSION)
  481. endif
  482. ifeq ($(PLATFORM_OS),LINUX)
  483. LDFLAGS += -Wl,-soname,lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
  484. endif
  485. ifeq ($(PLATFORM_OS),BSD)
  486. LDFLAGS += -Wl,-soname,lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).so -Lsrc -L/usr/local/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib
  487. endif
  488. endif
  489. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
  490. LDFLAGS += -Wl,-soname,lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
  491. LDFLAGS += -L$(SDL_LIBRARY_PATH)
  492. endif
  493. ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
  494. ifeq ($(RAYLIB_BUILD_MODE),DEBUG)
  495. LDFLAGS += -sASSERTIONS=1
  496. endif
  497. endif
  498. ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
  499. LDFLAGS += -Wl,-soname,lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
  500. ifeq ($(USE_RPI_CROSSCOMPILER), TRUE)
  501. LDFLAGS += -L$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/lib -L$(RPI_TOOLCHAIN_SYSROOT)/usr/lib
  502. endif
  503. endif
  504. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  505. LDFLAGS += -Wl,-soname,libraylib.$(RAYLIB_API_VERSION).so -Wl,--exclude-libs,libatomic.a
  506. LDFLAGS += -Wl,--build-id -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings
  507. # Force linking of library module to define symbol
  508. LDFLAGS += -u ANativeActivity_onCreate
  509. # Library paths containing required libs
  510. LDFLAGS += -Lsrc
  511. # Avoid unresolved symbol pointing to external main()
  512. LDFLAGS += -Wl,-undefined,dynamic_lookup
  513. endif
  514. # Define libraries required on linking: LDLIBS
  515. # NOTE: This is only required for dynamic library generation
  516. #------------------------------------------------------------------------------------------------
  517. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  518. ifeq ($(PLATFORM_OS),WINDOWS)
  519. ifeq ($(CC), tcc)
  520. LDLIBS = -lopengl32 -lgdi32 -lwinmm -lshell32
  521. else
  522. LDLIBS = -static-libgcc -lopengl32 -lgdi32 -lwinmm
  523. endif
  524. endif
  525. ifeq ($(PLATFORM_OS),LINUX)
  526. LDLIBS = -lGL -lc -lm -lpthread -ldl -lrt
  527. ifeq ($(GLFW_LINUX_ENABLE_X11),TRUE)
  528. LDLIBS += -lX11
  529. endif
  530. # TODO: On ARM 32bit arch, miniaudio requires atomics library
  531. #LDLIBS += -latomic
  532. endif
  533. ifeq ($(PLATFORM_OS),OSX)
  534. LDLIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo
  535. endif
  536. ifeq ($(PLATFORM_OS),BSD)
  537. LDLIBS = -lGL -lpthread
  538. endif
  539. ifeq ($(USE_EXTERNAL_GLFW),TRUE)
  540. # Check the version name. If GLFW3 was built manually, it may have produced
  541. # a static library known as libglfw3.a. In that case, the name should be -lglfw3
  542. LDLIBS = -lglfw
  543. endif
  544. endif
  545. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
  546. ifeq ($(PLATFORM_OS),WINDOWS)
  547. LDLIBS = -static-libgcc -lopengl32 -lgdi32
  548. endif
  549. ifeq ($(PLATFORM_OS),LINUX)
  550. LDLIBS = -lGL -lc -lm -lpthread -ldl -lrt
  551. ifeq ($(USE_WAYLAND_DISPLAY),FALSE)
  552. LDLIBS += -lX11
  553. endif
  554. endif
  555. LDLIBS += $(SDL_LIBRARIES)
  556. endif
  557. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
  558. ifeq ($(PLATFORM_OS),WINDOWS)
  559. # Libraries for Windows desktop compilation
  560. LDLIBS = -lgdi32 -lwinmm -lopengl32
  561. endif
  562. ifeq ($(PLATFORM_OS),LINUX)
  563. # Libraries for Debian GNU/Linux desktop compipling
  564. # NOTE: Required packages: libegl1-mesa-dev
  565. LDLIBS = -lGL -lX11 -lXrandr -lXinerama -lXi -lXcursor -lm -lpthread -ldl -lrt
  566. # Explicit link to libc
  567. ifeq ($(RAYLIB_LIBTYPE),SHARED)
  568. LDLIBS += -lc
  569. endif
  570. # NOTE: On ARM 32bit arch, miniaudio requires atomics library
  571. LDLIBS += -latomic
  572. endif
  573. ifeq ($(PLATFORM_OS),OSX)
  574. # Libraries for Debian MacOS desktop compiling
  575. # NOTE: Required packages: libegl1-mesa-dev
  576. LDLIBS += -lm -framework Foundation -framework AppKit -framework IOKit -framework OpenGL -framework CoreVideo
  577. endif
  578. endif
  579. ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
  580. LDLIBS = -lGLESv2 -lEGL -ldrm -lgbm -lpthread -lrt -lm -ldl
  581. ifeq ($(RAYLIB_MODULE_AUDIO),TRUE)
  582. LDLIBS += -latomic
  583. endif
  584. endif
  585. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_WIN32)
  586. LDLIBS = -lgdi32 -lwinmm -lopengl32 -lshcore
  587. endif
  588. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  589. LDLIBS = -llog -landroid -lEGL -lGLESv2 -lOpenSLES -lc -lm
  590. endif
  591. # Define source code object files required
  592. #------------------------------------------------------------------------------------------------
  593. OBJS = rcore.o \
  594. rshapes.o \
  595. rtextures.o \
  596. rtext.o \
  597. utils.o
  598. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  599. ifeq ($(USE_EXTERNAL_GLFW),FALSE)
  600. OBJS += rglfw.o
  601. endif
  602. endif
  603. ifeq ($(RAYLIB_MODULE_MODELS),TRUE)
  604. OBJS += rmodels.o
  605. endif
  606. ifeq ($(RAYLIB_MODULE_AUDIO),TRUE)
  607. OBJS += raudio.o
  608. endif
  609. ifeq ($(RAYLIB_MODULE_RAYGUI),TRUE)
  610. OBJS += raygui.o
  611. endif
  612. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  613. OBJS += android_native_app_glue.o
  614. endif
  615. # Define processes to execute
  616. #------------------------------------------------------------------------------------------------
  617. # Default target entry
  618. all: raylib
  619. # Compile raylib library
  620. # NOTE: Release directory is created if not exist
  621. raylib: $(OBJS)
  622. ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
  623. # Compile raylib libray for web
  624. #$(CC) $(OBJS) -r -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc
  625. ifeq ($(RAYLIB_LIBTYPE),SHARED)
  626. @echo "WARNING: $(TARGET_PLATFORM) does not support SHARED libraries. Generating STATIC library."
  627. endif
  628. $(AR) rcs $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).web.a $(OBJS)
  629. @echo "raylib library generated (lib$(RAYLIB_LIB_NAME).web.a)!"
  630. else
  631. ifeq ($(RAYLIB_LIBTYPE),SHARED)
  632. ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW))
  633. ifeq ($(PLATFORM_OS),WINDOWS)
  634. # NOTE: Linking with provided resource file
  635. $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/$(RAYLIB_LIB_NAME).dll $(OBJS) $(RAYLIB_RES_FILE) $(LDFLAGS) $(LDLIBS)
  636. @echo "raylib dynamic library ($(RAYLIB_LIB_NAME).dll) and import library (lib$(RAYLIB_LIB_NAME)dll.a) generated!"
  637. endif
  638. ifeq ($(PLATFORM_OS),LINUX)
  639. # Compile raylib shared library version $(RAYLIB_VERSION).
  640. # WARNING: you should type "make clean" before doing this target
  641. $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) $(OBJS) $(LDFLAGS) $(LDLIBS)
  642. @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION)) in $(RAYLIB_RELEASE_PATH)!"
  643. cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
  644. cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so
  645. endif
  646. ifeq ($(PLATFORM_OS),OSX)
  647. $(CC) -dynamiclib -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib $(OBJS) $(LDFLAGS) $(LDLIBS)
  648. install_name_tool -id "@rpath/lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).dylib" $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib
  649. @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib)!"
  650. cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).dylib
  651. cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib lib$(RAYLIB_LIB_NAME).dylib
  652. endif
  653. ifeq ($(PLATFORM_OS),BSD)
  654. # WARNING: you should type "gmake clean" before doing this target
  655. $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so $(OBJS) $(LDFLAGS) $(LDLIBS)
  656. @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so)!"
  657. cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).so
  658. cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).so
  659. endif
  660. endif
  661. ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
  662. # Compile raylib shared library version $(RAYLIB_VERSION).
  663. # WARNING: you should type "make clean" before doing this target
  664. $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) $(OBJS) $(LDFLAGS) $(LDLIBS)
  665. @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION)) in $(RAYLIB_RELEASE_PATH)!"
  666. cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
  667. cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so
  668. endif
  669. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  670. $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so $(OBJS) $(LDFLAGS) $(LDLIBS)
  671. @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so)!"
  672. # WARNING: symbolic links creation on Windows should be done using mklink command, no ln available
  673. ifeq ($(HOST_PLATFORM_OS),LINUX)
  674. cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).so
  675. cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).so
  676. endif
  677. endif
  678. else
  679. # Compile raylib static library version $(RAYLIB_VERSION)
  680. # WARNING: You should type "make clean" before doing this target.
  681. $(AR) rcs $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(OBJS)
  682. @echo "raylib static library generated (lib$(RAYLIB_LIB_NAME).a) in $(RAYLIB_RELEASE_PATH)!"
  683. endif
  684. endif
  685. # Compile all modules with their prerequisites
  686. # Prerequisites of core module
  687. rcore.o : platforms/*.c
  688. # Compile core module
  689. rcore.o : rcore.c raylib.h rlgl.h utils.h raymath.h rcamera.h rgestures.h
  690. $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
  691. # Compile rglfw module
  692. rglfw.o : rglfw.c
  693. $(CC) $(GLFW_OSX) -c $< $(CFLAGS) $(INCLUDE_PATHS) -U_GNU_SOURCE
  694. # Compile shapes module
  695. rshapes.o : rshapes.c raylib.h rlgl.h
  696. $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
  697. # Compile textures module
  698. rtextures.o : rtextures.c raylib.h rlgl.h utils.h
  699. $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
  700. # Compile text module
  701. rtext.o : rtext.c raylib.h utils.h
  702. $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
  703. # Compile utils module
  704. utils.o : utils.c utils.h
  705. $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
  706. # Compile models module
  707. rmodels.o : rmodels.c raylib.h rlgl.h raymath.h
  708. $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
  709. # Compile audio module
  710. raudio.o : raudio.c raylib.h
  711. $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
  712. # Compile raygui module
  713. # NOTE: raygui header should be distributed with raylib.h
  714. raygui.o : raygui.c
  715. $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
  716. raygui.c:
  717. ifeq ($(PLATFORM_SHELL), cmd)
  718. @echo #define RAYGUI_IMPLEMENTATION > raygui.c
  719. @echo #include "$(RAYLIB_MODULE_RAYGUI_PATH)/raygui.h" >> raygui.c
  720. else
  721. @echo "#define RAYGUI_IMPLEMENTATION" > raygui.c
  722. @echo "#include \"$(RAYLIB_MODULE_RAYGUI_PATH)/raygui.h\"" >> raygui.c
  723. endif
  724. # Compile android_native_app_glue module
  725. android_native_app_glue.o : $(NATIVE_APP_GLUE)/android_native_app_glue.c
  726. $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
  727. # Install generated and needed files to desired directories.
  728. # On GNU/Linux and BSDs, there are some standard directories that contain extra
  729. # libraries and header files. These directories (often /usr/local/lib and
  730. # /usr/local/include) are for libraries that are installed manually
  731. # (without a package manager). We'll use /usr/local/lib/raysan5 and /usr/local/include/raysan5
  732. # for our -L and -I specification to simplify management of the raylib source package.
  733. # Customize these locations if you like but don't forget to pass them to make
  734. # for compilation and enable runtime linking with -rpath, LD_LIBRARY_PATH, or ldconfig.
  735. # HINT: Add -L$(RAYLIB_INSTALL_PATH) -I$(RAYLIB_H_INSTALL_PATH) to your own makefiles.
  736. # See below and ../examples/Makefile for more information.
  737. # RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths.
  738. DESTDIR ?= /usr/local
  739. RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib
  740. # RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files.
  741. RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include
  742. install :
  743. ifeq ($(ROOT),root)
  744. ifeq ($(PLATFORM_OS),LINUX)
  745. # Attention! You are root, writing files to $(RAYLIB_INSTALL_PATH)
  746. # and $(RAYLIB_H_INSTALL_PATH). Consult this Makefile for more information.
  747. # Prepare the environment as needed.
  748. mkdir --parents --verbose $(RAYLIB_INSTALL_PATH)
  749. mkdir --parents --verbose $(RAYLIB_H_INSTALL_PATH)
  750. ifeq ($(RAYLIB_LIBTYPE),SHARED)
  751. # Installing raylib to $(RAYLIB_INSTALL_PATH).
  752. cp --update --verbose $(RAYLIB_RELEASE_PATH)/libraylib.so.$(RAYLIB_VERSION) $(RAYLIB_INSTALL_PATH)/lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION)
  753. cd $(RAYLIB_INSTALL_PATH); ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
  754. cd $(RAYLIB_INSTALL_PATH); ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so
  755. # Uncomment to update the runtime linker cache with RAYLIB_INSTALL_PATH.
  756. # Not necessary if later embedding RPATH in your executable. See examples/Makefile.
  757. ldconfig $(RAYLIB_INSTALL_PATH)
  758. else
  759. # Installing raylib to $(RAYLIB_INSTALL_PATH).
  760. cp --update --verbose $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_INSTALL_PATH)/lib$(RAYLIB_LIB_NAME).a
  761. endif
  762. # Copying raylib development files to $(RAYLIB_H_INSTALL_PATH).
  763. cp --update raylib.h $(RAYLIB_H_INSTALL_PATH)/raylib.h
  764. cp --update raymath.h $(RAYLIB_H_INSTALL_PATH)/raymath.h
  765. cp --update rlgl.h $(RAYLIB_H_INSTALL_PATH)/rlgl.h
  766. @echo "raylib development files installed/updated!"
  767. else
  768. @echo "This function currently works on GNU/Linux systems. Add yours today (^;"
  769. endif
  770. else
  771. @echo "ERROR: Root permissions needed for installation. Try sudo make install" && exit 1
  772. endif
  773. # Remove raylib dev files installed on the system
  774. # NOTE: see 'install' target.
  775. uninstall :
  776. ifeq ($(ROOT),root)
  777. # WARNING: You are root, about to delete items from $(RAYLIB_INSTALL_PATH).
  778. # and $(RAYLIB_H_INSTALL_PATH). Please confirm each item.
  779. ifeq ($(PLATFORM_OS),LINUX)
  780. ifeq ($(RAYLIB_LIBTYPE),SHARED)
  781. rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so
  782. rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so.$(RAYLIB_API_VERSION)
  783. rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so.$(RAYLIB_VERSION)
  784. # Uncomment to clean up the runtime linker cache. See install target.
  785. ldconfig
  786. else
  787. rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.a
  788. endif
  789. rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raylib.h
  790. rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raymath.h
  791. rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/rlgl.h
  792. @echo "raylib development files removed!"
  793. else
  794. @echo "This function currently works on GNU/Linux systems. Add yours today (^;"
  795. endif
  796. else
  797. @echo "ERROR: Root permissions needed for uninstallation. Try sudo make uninstall" && exit 1
  798. endif
  799. .PHONY: clean_shell_cmd clean_shell_sh
  800. # Clean everything
  801. clean: clean_shell_$(PLATFORM_SHELL)
  802. @echo "removed all generated files!"
  803. clean_shell_sh:
  804. rm -fv *.o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).web.a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so* raygui.c $(RAYLIB_RELEASE_PATH)/*-protocol.h $(RAYLIB_RELEASE_PATH)/*-protocol-code.h
  805. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  806. rm -fv $(NATIVE_APP_GLUE)/android_native_app_glue.o
  807. endif
  808. # Set specific target variable
  809. clean_shell_cmd: SHELL=cmd
  810. clean_shell_cmd:
  811. del *.o /s
  812. cd $(RAYLIB_RELEASE_PATH) & \
  813. del lib$(RAYLIB_LIB_NAME).a /s & \
  814. del lib$(RAYLIB_LIB_NAME).web.a /s & \
  815. del lib$(RAYLIB_LIB_NAME)dll.a /s & \
  816. del $(RAYLIB_LIB_NAME).dll /s & \
  817. del raygui.c /s & \