Makefile 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876
  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 ?= $(RAYLIB_SRC_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 # Uncomment to use OpenGL 1.1
  212. #GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1
  213. #GRAPHICS = GRAPHICS_API_OPENGL_43 # Uncomment to use OpenGL 4.3
  214. #GRAPHICS = GRAPHICS_API_OPENGL_ES2 # Uncomment to use OpenGL ES 2.0 (ANGLE)
  215. endif
  216. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
  217. GRAPHICS ?= GRAPHICS_API_OPENGL_33
  218. endif
  219. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
  220. GRAPHICS ?= GRAPHICS_API_OPENGL_33
  221. #GRAPHICS = GRAPHICS_API_OPENGL_11 # Uncomment to use OpenGL 1.1
  222. #GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1
  223. #GRAPHICS = GRAPHICS_API_OPENGL_43 # Uncomment to use OpenGL 4.3
  224. #GRAPHICS = GRAPHICS_API_OPENGL_ES2 # Uncomment to use OpenGL ES 2.0 (ANGLE)
  225. endif
  226. ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
  227. # On DRM OpenGL ES 2.0 must be used
  228. GRAPHICS = GRAPHICS_API_OPENGL_ES2
  229. endif
  230. ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
  231. # On HTML5 OpenGL ES 2.0 is used, emscripten translates it to WebGL 1.0
  232. GRAPHICS = GRAPHICS_API_OPENGL_ES2
  233. #GRAPHICS = GRAPHICS_API_OPENGL_ES3
  234. endif
  235. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  236. # By default use OpenGL ES 2.0 on Android
  237. GRAPHICS = GRAPHICS_API_OPENGL_ES2
  238. endif
  239. # Define default C compiler and archiver to pack library: CC, AR
  240. #------------------------------------------------------------------------------------------------
  241. CC = gcc
  242. AR = ar
  243. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  244. ifeq ($(PLATFORM_OS),OSX)
  245. # OSX default compiler
  246. CC = clang
  247. GLFW_OSX = -x objective-c
  248. endif
  249. ifeq ($(PLATFORM_OS),BSD)
  250. # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler
  251. CC = clang
  252. endif
  253. endif
  254. ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
  255. ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
  256. # Define RPI cross-compiler
  257. #CC = armv6j-hardfloat-linux-gnueabi-gcc
  258. CC = $(RPI_TOOLCHAIN)/bin/$(RPI_TOOLCHAIN_NAME)-gcc
  259. AR = $(RPI_TOOLCHAIN)/bin/$(RPI_TOOLCHAIN_NAME)-ar
  260. endif
  261. endif
  262. ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
  263. # HTML5 emscripten compiler
  264. CC = emcc
  265. AR = emar
  266. endif
  267. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  268. # Android toolchain (must be provided for desired architecture and compiler)
  269. ifeq ($(ANDROID_ARCH),arm)
  270. CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-androideabi$(ANDROID_API_VERSION)-clang
  271. endif
  272. ifeq ($(ANDROID_ARCH),arm64)
  273. CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-android$(ANDROID_API_VERSION)-clang
  274. endif
  275. ifeq ($(ANDROID_ARCH),x86)
  276. CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-android$(ANDROID_API_VERSION)-clang
  277. endif
  278. ifeq ($(ANDROID_ARCH),x86_64)
  279. CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-android$(ANDROID_API_VERSION)-clang
  280. endif
  281. # It seems from Android NDK r22 onwards we need to use llvm-ar
  282. AR = $(ANDROID_TOOLCHAIN)/bin/llvm-ar
  283. endif
  284. # Define compiler flags: CFLAGS
  285. #------------------------------------------------------------------------------------------------
  286. # -O1 defines optimization level
  287. # -g include debug information on compilation
  288. # -s strip unnecessary data from build --> linker
  289. # -Wall turns on most, but not all, compiler warnings
  290. # -std=c99 defines C language mode (standard C from 1999 revision)
  291. # -std=gnu99 defines C language mode (GNU C from 1999 revision)
  292. # -Wno-missing-braces ignore invalid warning (GCC bug 53119)
  293. # -Wno-unused-value ignore unused return values of some functions (i.e. fread())
  294. # -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
  295. # -D_GNU_SOURCE access to lots of nonstandard GNU/Linux extension functions
  296. # -Werror=pointer-arith catch unportable code that does direct arithmetic on void pointers
  297. # -fno-strict-aliasing jar_xm.h does shady stuff (breaks strict aliasing)
  298. CFLAGS = -Wall -D_GNU_SOURCE -D$(TARGET_PLATFORM) -D$(GRAPHICS) -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing
  299. ifneq ($(RAYLIB_CONFIG_FLAGS), NONE)
  300. CFLAGS += -DEXTERNAL_CONFIG_FLAGS $(RAYLIB_CONFIG_FLAGS)
  301. endif
  302. ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
  303. # NOTE: When using multi-threading in the user code, it requires -pthread enabled
  304. CFLAGS += -std=gnu99
  305. else
  306. CFLAGS += -std=c99
  307. endif
  308. ifeq ($(PLATFORM_OS), LINUX)
  309. CFLAGS += -fPIC
  310. endif
  311. ifeq ($(RAYLIB_BUILD_MODE),DEBUG)
  312. CFLAGS += -g -D_DEBUG
  313. endif
  314. ifeq ($(RAYLIB_BUILD_MODE),RELEASE)
  315. ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
  316. CFLAGS += -Os
  317. endif
  318. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  319. CFLAGS += -O1
  320. endif
  321. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  322. CFLAGS += -O2
  323. endif
  324. endif
  325. # Additional flags for compiler (if desired)
  326. # -Wextra enables some extra warning flags that are not enabled by -Wall
  327. # -Wmissing-prototypes warn if a global function is defined without a previous prototype declaration
  328. # -Wstrict-prototypes warn if a function is declared or defined without specifying the argument types
  329. # -Werror=implicit-function-declaration catch function calls without prior declaration
  330. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  331. CFLAGS += -Werror=implicit-function-declaration
  332. endif
  333. ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
  334. # -Os # size optimization
  335. # -O2 # optimization level 2, if used, also set --memory-init-file 0
  336. # -sUSE_GLFW=3 # Use glfw3 library (context/input management)
  337. # -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL!
  338. # -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB)
  339. # -sUSE_PTHREADS=1 # multithreading support
  340. # -sWASM=0 # disable Web Assembly, emitted by default
  341. # -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS
  342. # -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data
  343. # -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off)
  344. # -sMINIFY_HTML=0 # minify generated html from shell.html
  345. # --profiling # include information for code profiling
  346. # --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
  347. # --preload-file resources # specify a resources folder for data compilation
  348. # --source-map-base # allow debugging in browser with source map
  349. # --shell-file shell.html # define a custom shell .html and output extension
  350. ifeq ($(RAYLIB_BUILD_MODE),DEBUG)
  351. CFLAGS += -sASSERTIONS=1 --profiling
  352. endif
  353. endif
  354. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  355. # Compiler flags for arquitecture
  356. ifeq ($(ANDROID_ARCH),arm)
  357. CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
  358. endif
  359. ifeq ($(ANDROID_ARCH),arm64)
  360. CFLAGS += -target aarch64 -mfix-cortex-a53-835769
  361. endif
  362. ifeq ($(ANDROID_ARCH),x86)
  363. CFLAGS += -march=i686
  364. endif
  365. ifeq ($(ANDROID_ARCH),x86_64)
  366. CFLAGS += -march=x86-64
  367. endif
  368. # Compilation functions attributes options
  369. CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIE -fPIC
  370. # Compiler options for the linker
  371. # -Werror=format-security
  372. CFLAGS += -Wa,--noexecstack -Wformat -no-canonical-prefixes
  373. # Preprocessor macro definitions
  374. CFLAGS += -D__ANDROID__ -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION)
  375. endif
  376. # Define required compilation flags for raylib SHARED lib
  377. ifeq ($(RAYLIB_LIBTYPE),SHARED)
  378. # make sure code is compiled as position independent
  379. # BE CAREFUL: It seems that for gcc -fpic is not the same as -fPIC
  380. # MinGW32 just doesn't need -fPIC, it shows warnings
  381. CFLAGS += -fPIC -DBUILD_LIBTYPE_SHARED
  382. # hide all symbols by default, so RLAPI can expose them
  383. ifeq ($(PLATFORM_OS),$(filter $(PLATFORM_OS), LINUX BSD OSX))
  384. CFLAGS += -fvisibility=hidden
  385. endif
  386. endif
  387. ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
  388. # without EGL_NO_X11 eglplatform.h tears Xlib.h in which tears X.h in
  389. # which contains a conflicting type Font
  390. CFLAGS += -DEGL_NO_X11
  391. CFLAGS += -Werror=implicit-function-declaration
  392. endif
  393. # Use Wayland display on Linux desktop
  394. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  395. ifeq ($(PLATFORM_OS), LINUX)
  396. ifeq ($(GLFW_LINUX_ENABLE_X11),TRUE)
  397. CFLAGS += -D_GLFW_X11
  398. endif
  399. ifeq ($(GLFW_LINUX_ENABLE_WAYLAND),TRUE)
  400. CFLAGS += -D_GLFW_WAYLAND
  401. LDFLAGS += $(shell pkg-config wayland-client wayland-cursor wayland-egl xkbcommon --libs)
  402. WL_PROTOCOLS_DIR := external/glfw/deps/wayland
  403. wl_generate = \
  404. $(eval protocol=$(1)) \
  405. $(eval basename=$(2)) \
  406. $(shell wayland-scanner client-header $(protocol) $(RAYLIB_SRC_PATH)/$(basename).h) \
  407. $(shell wayland-scanner private-code $(protocol) $(RAYLIB_SRC_PATH)/$(basename)-code.h)
  408. $(call wl_generate, $(WL_PROTOCOLS_DIR)/wayland.xml, wayland-client-protocol)
  409. $(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-shell.xml, xdg-shell-client-protocol)
  410. $(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-decoration-unstable-v1.xml, xdg-decoration-unstable-v1-client-protocol)
  411. $(call wl_generate, $(WL_PROTOCOLS_DIR)/viewporter.xml, viewporter-client-protocol)
  412. $(call wl_generate, $(WL_PROTOCOLS_DIR)/relative-pointer-unstable-v1.xml, relative-pointer-unstable-v1-client-protocol)
  413. $(call wl_generate, $(WL_PROTOCOLS_DIR)/pointer-constraints-unstable-v1.xml, pointer-constraints-unstable-v1-client-protocol)
  414. $(call wl_generate, $(WL_PROTOCOLS_DIR)/fractional-scale-v1.xml, fractional-scale-v1-client-protocol)
  415. $(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-activation-v1.xml, xdg-activation-v1-client-protocol)
  416. $(call wl_generate, $(WL_PROTOCOLS_DIR)/idle-inhibit-unstable-v1.xml, idle-inhibit-unstable-v1-client-protocol)
  417. endif
  418. endif
  419. endif
  420. CFLAGS += $(CUSTOM_CFLAGS)
  421. # Define include paths for required headers: INCLUDE_PATHS
  422. # NOTE: Several external required libraries (stb and others)
  423. #------------------------------------------------------------------------------------------------
  424. INCLUDE_PATHS = -I. $(EXTRA_INCLUDE_PATHS)
  425. # Define additional directories containing required header files
  426. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  427. INCLUDE_PATHS += -Iexternal/glfw/include
  428. ifeq ($(PLATFORM_OS),BSD)
  429. INCLUDE_PATHS += -I/usr/local/include -I/usr/pkg/include -I/usr/X11R7/include
  430. endif
  431. endif
  432. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
  433. INCLUDE_PATHS += -I$(SDL_INCLUDE_PATH)
  434. endif
  435. ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
  436. INCLUDE_PATHS += -Iexternal/glfw/include
  437. endif
  438. ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
  439. INCLUDE_PATHS += -I/usr/include/libdrm
  440. ifeq ($(USE_RPI_CROSSCOMPILER), TRUE)
  441. INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/usr/include
  442. INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include
  443. endif
  444. endif
  445. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  446. NATIVE_APP_GLUE = $(ANDROID_NDK)/sources/android/native_app_glue
  447. # Include android_native_app_glue.h
  448. INCLUDE_PATHS += -I$(NATIVE_APP_GLUE)
  449. # Android required libraries
  450. INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include
  451. ifeq ($(ANDROID_ARCH),arm)
  452. INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/arm-linux-androideabi
  453. endif
  454. ifeq ($(ANDROID_ARCH),arm64)
  455. INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/aarch64-linux-android
  456. endif
  457. ifeq ($(ANDROID_ARCH),x86)
  458. INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/i686-linux-android
  459. endif
  460. ifeq ($(ANDROID_ARCH),x86_64)
  461. INCLUDE_PATHS += -I$(ANDROID_SYSROOT)/usr/include/x86_64-linux-android
  462. endif
  463. endif
  464. # Define library paths containing required libs: LDFLAGS
  465. # NOTE: This is only required for dynamic library generation
  466. #------------------------------------------------------------------------------------------------
  467. LDFLAGS = $(CUSTOM_LDFLAGS) -L. -L$(RAYLIB_RELEASE_PATH)
  468. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  469. ifeq ($(PLATFORM_OS),WINDOWS)
  470. ifneq ($(CC), tcc)
  471. LDFLAGS += -Wl,--out-implib,$(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME)dll.a
  472. endif
  473. endif
  474. ifeq ($(PLATFORM_OS),OSX)
  475. LDFLAGS += -compatibility_version $(RAYLIB_API_VERSION) -current_version $(RAYLIB_VERSION)
  476. endif
  477. ifeq ($(PLATFORM_OS),LINUX)
  478. LDFLAGS += -Wl,-soname,lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
  479. endif
  480. ifeq ($(PLATFORM_OS),BSD)
  481. 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
  482. endif
  483. endif
  484. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
  485. LDFLAGS += -Wl,-soname,lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
  486. LDFLAGS += -L$(SDL_LIBRARY_PATH)
  487. endif
  488. ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
  489. LDFLAGS += -Wl,-soname,lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
  490. ifeq ($(USE_RPI_CROSSCOMPILER), TRUE)
  491. LDFLAGS += -L$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/lib -L$(RPI_TOOLCHAIN_SYSROOT)/usr/lib
  492. endif
  493. endif
  494. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  495. LDFLAGS += -Wl,-soname,libraylib.$(RAYLIB_API_VERSION).so -Wl,--exclude-libs,libatomic.a
  496. LDFLAGS += -Wl,--build-id -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings
  497. # Force linking of library module to define symbol
  498. LDFLAGS += -u ANativeActivity_onCreate
  499. # Library paths containing required libs
  500. LDFLAGS += -Lsrc
  501. # Avoid unresolved symbol pointing to external main()
  502. LDFLAGS += -Wl,-undefined,dynamic_lookup
  503. endif
  504. # Define libraries required on linking: LDLIBS
  505. # NOTE: This is only required for dynamic library generation
  506. #------------------------------------------------------------------------------------------------
  507. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  508. ifeq ($(PLATFORM_OS),WINDOWS)
  509. ifeq ($(CC), tcc)
  510. LDLIBS = -lopengl32 -lgdi32 -lwinmm -lshell32
  511. else
  512. LDLIBS = -static-libgcc -lopengl32 -lgdi32 -lwinmm
  513. endif
  514. endif
  515. ifeq ($(PLATFORM_OS),LINUX)
  516. LDLIBS = -lGL -lc -lm -lpthread -ldl -lrt
  517. ifeq ($(GLFW_LINUX_ENABLE_X11),TRUE)
  518. LDLIBS += -lX11
  519. endif
  520. # TODO: On ARM 32bit arch, miniaudio requires atomics library
  521. #LDLIBS += -latomic
  522. endif
  523. ifeq ($(PLATFORM_OS),OSX)
  524. LDLIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo
  525. endif
  526. ifeq ($(PLATFORM_OS),BSD)
  527. LDLIBS = -lGL -lpthread
  528. endif
  529. ifeq ($(USE_EXTERNAL_GLFW),TRUE)
  530. # Check the version name. If GLFW3 was built manually, it may have produced
  531. # a static library known as libglfw3.a. In that case, the name should be -lglfw3
  532. LDLIBS = -lglfw
  533. endif
  534. endif
  535. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
  536. ifeq ($(PLATFORM_OS),WINDOWS)
  537. LDLIBS = -static-libgcc -lopengl32 -lgdi32
  538. endif
  539. ifeq ($(PLATFORM_OS),LINUX)
  540. LDLIBS = -lGL -lc -lm -lpthread -ldl -lrt
  541. ifeq ($(USE_WAYLAND_DISPLAY),FALSE)
  542. LDLIBS += -lX11
  543. endif
  544. endif
  545. LDLIBS += $(SDL_LIBRARIES)
  546. endif
  547. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
  548. ifeq ($(PLATFORM_OS),WINDOWS)
  549. # Libraries for Windows desktop compilation
  550. LDLIBS = -lgdi32 -lwinmm -lopengl32
  551. endif
  552. ifeq ($(PLATFORM_OS),LINUX)
  553. # Libraries for Debian GNU/Linux desktop compipling
  554. # NOTE: Required packages: libegl1-mesa-dev
  555. LDLIBS = -lGL -lX11 -lXrandr -lXinerama -lXi -lXcursor -lm -lpthread -ldl -lrt
  556. # Explicit link to libc
  557. ifeq ($(RAYLIB_LIBTYPE),SHARED)
  558. LDLIBS += -lc
  559. endif
  560. # NOTE: On ARM 32bit arch, miniaudio requires atomics library
  561. LDLIBS += -latomic
  562. endif
  563. ifeq ($(PLATFORM_OS),OSX)
  564. # Libraries for Debian MacOS desktop compiling
  565. # NOTE: Required packages: libegl1-mesa-dev
  566. LDLIBS += -lm -framework Foundation -framework AppKit -framework OpenGL -framework CoreVideo
  567. endif
  568. endif
  569. ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
  570. LDLIBS = -lGLESv2 -lEGL -ldrm -lgbm -lpthread -lrt -lm -ldl
  571. ifeq ($(RAYLIB_MODULE_AUDIO),TRUE)
  572. LDLIBS += -latomic
  573. endif
  574. endif
  575. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  576. LDLIBS = -llog -landroid -lEGL -lGLESv2 -lOpenSLES -lc -lm
  577. endif
  578. # Define source code object files required
  579. #------------------------------------------------------------------------------------------------
  580. OBJS = rcore.o \
  581. rshapes.o \
  582. rtextures.o \
  583. rtext.o \
  584. utils.o
  585. ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
  586. ifeq ($(USE_EXTERNAL_GLFW),FALSE)
  587. OBJS += rglfw.o
  588. endif
  589. endif
  590. ifeq ($(RAYLIB_MODULE_MODELS),TRUE)
  591. OBJS += rmodels.o
  592. endif
  593. ifeq ($(RAYLIB_MODULE_AUDIO),TRUE)
  594. OBJS += raudio.o
  595. endif
  596. ifeq ($(RAYLIB_MODULE_RAYGUI),TRUE)
  597. OBJS += raygui.o
  598. endif
  599. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  600. OBJS += android_native_app_glue.o
  601. endif
  602. # Define processes to execute
  603. #------------------------------------------------------------------------------------------------
  604. # Default target entry
  605. all: raylib
  606. # Compile raylib library
  607. # NOTE: Release directory is created if not exist
  608. raylib: $(OBJS)
  609. ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
  610. # Compile raylib libray for web
  611. #$(CC) $(OBJS) -r -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc
  612. $(AR) rcs $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).web.a $(OBJS)
  613. @echo "raylib library generated (lib$(RAYLIB_LIB_NAME).web.a)!"
  614. else
  615. ifeq ($(RAYLIB_LIBTYPE),SHARED)
  616. ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW))
  617. ifeq ($(PLATFORM_OS),WINDOWS)
  618. # NOTE: Linking with provided resource file
  619. $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/$(RAYLIB_LIB_NAME).dll $(OBJS) $(RAYLIB_RES_FILE) $(LDFLAGS) $(LDLIBS)
  620. @echo "raylib dynamic library ($(RAYLIB_LIB_NAME).dll) and import library (lib$(RAYLIB_LIB_NAME)dll.a) generated!"
  621. endif
  622. ifeq ($(PLATFORM_OS),LINUX)
  623. # Compile raylib shared library version $(RAYLIB_VERSION).
  624. # WARNING: you should type "make clean" before doing this target
  625. $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) $(OBJS) $(LDFLAGS) $(LDLIBS)
  626. @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION)) in $(RAYLIB_RELEASE_PATH)!"
  627. cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
  628. cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so
  629. endif
  630. ifeq ($(PLATFORM_OS),OSX)
  631. $(CC) -dynamiclib -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib $(OBJS) $(LDFLAGS) $(LDLIBS)
  632. install_name_tool -id "@rpath/lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).dylib" $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib
  633. @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib)!"
  634. cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).dylib
  635. cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib lib$(RAYLIB_LIB_NAME).dylib
  636. endif
  637. ifeq ($(PLATFORM_OS),BSD)
  638. # WARNING: you should type "gmake clean" before doing this target
  639. $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so $(OBJS) $(LDFLAGS) $(LDLIBS)
  640. @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so)!"
  641. cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).so
  642. cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).so
  643. endif
  644. endif
  645. ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
  646. # Compile raylib shared library version $(RAYLIB_VERSION).
  647. # WARNING: you should type "make clean" before doing this target
  648. $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) $(OBJS) $(LDFLAGS) $(LDLIBS)
  649. @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION)) in $(RAYLIB_RELEASE_PATH)!"
  650. cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
  651. cd $(RAYLIB_RELEASE_PATH) && ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so
  652. endif
  653. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  654. $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so $(OBJS) $(LDFLAGS) $(LDLIBS)
  655. @echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so)!"
  656. # WARNING: symbolic links creation on Windows should be done using mklink command, no ln available
  657. ifeq ($(HOST_PLATFORM_OS),LINUX)
  658. cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).so
  659. cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).so lib$(RAYLIB_LIB_NAME).so
  660. endif
  661. endif
  662. else
  663. # Compile raylib static library version $(RAYLIB_VERSION)
  664. # WARNING: You should type "make clean" before doing this target.
  665. $(AR) rcs $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(OBJS)
  666. @echo "raylib static library generated (lib$(RAYLIB_LIB_NAME).a) in $(RAYLIB_RELEASE_PATH)!"
  667. endif
  668. endif
  669. # Compile all modules with their prerequisites
  670. # Prerequisites of core module
  671. rcore.o : platforms/*.c
  672. # Compile core module
  673. rcore.o : rcore.c raylib.h rlgl.h utils.h raymath.h rcamera.h rgestures.h
  674. $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
  675. # Compile rglfw module
  676. rglfw.o : rglfw.c
  677. $(CC) $(GLFW_OSX) -c $< $(CFLAGS) $(INCLUDE_PATHS)
  678. # Compile shapes module
  679. rshapes.o : rshapes.c raylib.h rlgl.h
  680. $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
  681. # Compile textures module
  682. rtextures.o : rtextures.c raylib.h rlgl.h utils.h
  683. $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
  684. # Compile text module
  685. rtext.o : rtext.c raylib.h utils.h
  686. $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
  687. # Compile utils module
  688. utils.o : utils.c utils.h
  689. $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
  690. # Compile models module
  691. rmodels.o : rmodels.c raylib.h rlgl.h raymath.h
  692. $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
  693. # Compile audio module
  694. raudio.o : raudio.c raylib.h
  695. $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
  696. # Compile raygui module
  697. # NOTE: raygui header should be distributed with raylib.h
  698. raygui.o : raygui.c
  699. $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
  700. raygui.c:
  701. ifeq ($(PLATFORM_SHELL), cmd)
  702. @echo #define RAYGUI_IMPLEMENTATION > raygui.c
  703. @echo #include "$(RAYLIB_MODULE_RAYGUI_PATH)/raygui.h" >> raygui.c
  704. else
  705. @echo "#define RAYGUI_IMPLEMENTATION" > raygui.c
  706. @echo "#include \"$(RAYLIB_MODULE_RAYGUI_PATH)/raygui.h\"" >> raygui.c
  707. endif
  708. # Compile android_native_app_glue module
  709. android_native_app_glue.o : $(NATIVE_APP_GLUE)/android_native_app_glue.c
  710. $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
  711. # Install generated and needed files to desired directories.
  712. # On GNU/Linux and BSDs, there are some standard directories that contain extra
  713. # libraries and header files. These directories (often /usr/local/lib and
  714. # /usr/local/include) are for libraries that are installed manually
  715. # (without a package manager). We'll use /usr/local/lib/raysan5 and /usr/local/include/raysan5
  716. # for our -L and -I specification to simplify management of the raylib source package.
  717. # Customize these locations if you like but don't forget to pass them to make
  718. # for compilation and enable runtime linking with -rpath, LD_LIBRARY_PATH, or ldconfig.
  719. # HINT: Add -L$(RAYLIB_INSTALL_PATH) -I$(RAYLIB_H_INSTALL_PATH) to your own makefiles.
  720. # See below and ../examples/Makefile for more information.
  721. # RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths.
  722. DESTDIR ?= /usr/local
  723. RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib
  724. # RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files.
  725. RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include
  726. install :
  727. ifeq ($(ROOT),root)
  728. ifeq ($(PLATFORM_OS),LINUX)
  729. # Attention! You are root, writing files to $(RAYLIB_INSTALL_PATH)
  730. # and $(RAYLIB_H_INSTALL_PATH). Consult this Makefile for more information.
  731. # Prepare the environment as needed.
  732. mkdir --parents --verbose $(RAYLIB_INSTALL_PATH)
  733. mkdir --parents --verbose $(RAYLIB_H_INSTALL_PATH)
  734. ifeq ($(RAYLIB_LIBTYPE),SHARED)
  735. # Installing raylib to $(RAYLIB_INSTALL_PATH).
  736. cp --update --verbose $(RAYLIB_RELEASE_PATH)/libraylib.so.$(RAYLIB_VERSION) $(RAYLIB_INSTALL_PATH)/lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION)
  737. cd $(RAYLIB_INSTALL_PATH); ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_VERSION) lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION)
  738. cd $(RAYLIB_INSTALL_PATH); ln -fsv lib$(RAYLIB_LIB_NAME).so.$(RAYLIB_API_VERSION) lib$(RAYLIB_LIB_NAME).so
  739. # Uncomment to update the runtime linker cache with RAYLIB_INSTALL_PATH.
  740. # Not necessary if later embedding RPATH in your executable. See examples/Makefile.
  741. ldconfig $(RAYLIB_INSTALL_PATH)
  742. else
  743. # Installing raylib to $(RAYLIB_INSTALL_PATH).
  744. cp --update --verbose $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_INSTALL_PATH)/lib$(RAYLIB_LIB_NAME).a
  745. endif
  746. # Copying raylib development files to $(RAYLIB_H_INSTALL_PATH).
  747. cp --update raylib.h $(RAYLIB_H_INSTALL_PATH)/raylib.h
  748. cp --update raymath.h $(RAYLIB_H_INSTALL_PATH)/raymath.h
  749. cp --update rlgl.h $(RAYLIB_H_INSTALL_PATH)/rlgl.h
  750. @echo "raylib development files installed/updated!"
  751. else
  752. @echo "This function currently works on GNU/Linux systems. Add yours today (^;"
  753. endif
  754. else
  755. @echo "Error: Root permissions needed for installation. Try sudo make install"
  756. endif
  757. # Remove raylib dev files installed on the system
  758. # NOTE: see 'install' target.
  759. uninstall :
  760. ifeq ($(ROOT),root)
  761. # WARNING: You are root, about to delete items from $(RAYLIB_INSTALL_PATH).
  762. # and $(RAYLIB_H_INSTALL_PATH). Please confirm each item.
  763. ifeq ($(PLATFORM_OS),LINUX)
  764. ifeq ($(RAYLIB_LIBTYPE),SHARED)
  765. rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so
  766. rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so.$(RAYLIB_API_VERSION)
  767. rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so.$(RAYLIB_VERSION)
  768. # Uncomment to clean up the runtime linker cache. See install target.
  769. ldconfig
  770. else
  771. rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.a
  772. endif
  773. rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raylib.h
  774. rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raymath.h
  775. rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/rlgl.h
  776. @echo "raylib development files removed!"
  777. else
  778. @echo "This function currently works on GNU/Linux systems. Add yours today (^;"
  779. endif
  780. else
  781. @echo "Error: Root permissions needed for uninstallation. Try sudo make uninstall"
  782. endif
  783. .PHONY: clean_shell_cmd clean_shell_sh
  784. # Clean everything
  785. clean: clean_shell_$(PLATFORM_SHELL)
  786. @echo "removed all generated files!"
  787. clean_shell_sh:
  788. rm -fv *.o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so* raygui.c $(RAYLIB_RELEASE_PATH)/*-protocol.h $(RAYLIB_RELEASE_PATH)/*-protocol-code.h
  789. ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
  790. rm -fv $(NATIVE_APP_GLUE)/android_native_app_glue.o
  791. endif
  792. # Set specific target variable
  793. clean_shell_cmd: SHELL=cmd
  794. clean_shell_cmd:
  795. del *.o /s
  796. cd $(RAYLIB_RELEASE_PATH) & \
  797. del lib$(RAYLIB_LIB_NAME).a /s & \
  798. del lib$(RAYLIB_LIB_NAME)dll.a /s & \
  799. del $(RAYLIB_LIB_NAME).dll /s & \
  800. del raygui.c /s & \