Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

318 строки
11 KiB

8 лет назад
8 лет назад
8 лет назад
8 лет назад
8 лет назад
8 лет назад
6 лет назад
8 лет назад
6 лет назад
6 лет назад
6 лет назад
8 лет назад
8 лет назад
8 лет назад
8 лет назад
8 лет назад
6 лет назад
8 лет назад
8 лет назад
6 лет назад
8 лет назад
8 лет назад
8 лет назад
8 лет назад
8 лет назад
6 лет назад
8 лет назад
8 лет назад
8 лет назад
8 лет назад
8 лет назад
8 лет назад
8 лет назад
8 лет назад
8 лет назад
8 лет назад
  1. #**************************************************************************************************
  2. #
  3. # raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
  4. #
  5. # Copyright (c) 2013-2018 Ramon Santamaria (@raysan5)
  6. #
  7. # This software is provided "as-is", without any express or implied warranty. In no event
  8. # will the authors be held liable for any damages arising from the use of this software.
  9. #
  10. # Permission is granted to anyone to use this software for any purpose, including commercial
  11. # applications, and to alter it and redistribute it freely, subject to the following restrictions:
  12. #
  13. # 1. The origin of this software must not be misrepresented; you must not claim that you
  14. # wrote the original software. If you use this software in a product, an acknowledgment
  15. # in the product documentation would be appreciated but is not required.
  16. #
  17. # 2. Altered source versions must be plainly marked as such, and must not be misrepresented
  18. # as being the original software.
  19. #
  20. # 3. This notice may not be removed or altered from any source distribution.
  21. #
  22. #**************************************************************************************************
  23. .PHONY: all clean
  24. # Define required raylib variables
  25. # WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop()
  26. PLATFORM ?= PLATFORM_DESKTOP
  27. RAYLIB_PATH ?= ..
  28. PROJECT_NAME ?= sample_game
  29. # Default path for raylib on Raspberry Pi, if installed in different path, update it!
  30. ifeq ($(PLATFORM),PLATFORM_RPI)
  31. RAYLIB_PATH ?= /home/pi/raylib
  32. endif
  33. # Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
  34. RAYLIB_LIBTYPE ?= STATIC
  35. # Use external GLFW library instead of rglfw module
  36. USE_EXTERNAL_GLFW ?= FALSE
  37. # Use Wayland display server protocol on Linux desktop
  38. # by default it uses X11 windowing system
  39. USE_WAYLAND_DISPLAY ?= FALSE
  40. # NOTE: On PLATFORM_WEB OpenAL Soft backend is used by default (check raylib/src/Makefile)
  41. # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
  42. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  43. # No uname.exe on MinGW!, but OS=Windows_NT on Windows!
  44. # ifeq ($(UNAME),Msys) -> Windows
  45. ifeq ($(OS),Windows_NT)
  46. PLATFORM_OS=WINDOWS
  47. else
  48. UNAMEOS=$(shell uname)
  49. ifeq ($(UNAMEOS),Linux)
  50. PLATFORM_OS=LINUX
  51. endif
  52. ifeq ($(UNAMEOS),FreeBSD)
  53. PLATFORM_OS=BSD
  54. endif
  55. ifeq ($(UNAMEOS),OpenBSD)
  56. PLATFORM_OS=BSD
  57. endif
  58. ifeq ($(UNAMEOS),NetBSD)
  59. PLATFORM_OS=BSD
  60. endif
  61. ifeq ($(UNAMEOS),DragonFly)
  62. PLATFORM_OS=BSD
  63. endif
  64. ifeq ($(UNAMEOS),Darwin)
  65. PLATFORM_OS=OSX
  66. endif
  67. endif
  68. endif
  69. ifeq ($(PLATFORM),PLATFORM_RPI)
  70. UNAMEOS=$(shell uname)
  71. ifeq ($(UNAMEOS),Linux)
  72. PLATFORM_OS=LINUX
  73. endif
  74. endif
  75. ifeq ($(PLATFORM),PLATFORM_WEB)
  76. # Emscripten required variables
  77. EMSDK_PATH = C:/emsdk
  78. EMSCRIPTEN_VERSION = 1.38.8
  79. CLANG_VERSION = e1.38.8_64bit
  80. PYTHON_VERSION = 2.7.13.1_64bit\python-2.7.13.amd64
  81. NODE_VERSION = 8.9.1_64bit
  82. export PATH = $(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH)
  83. EMSCRIPTEN = $(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
  84. endif
  85. RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs
  86. # Define raylib release directory for compiled library
  87. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  88. ifeq ($(PLATFORM_OS),WINDOWS)
  89. RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32
  90. endif
  91. ifeq ($(PLATFORM_OS),LINUX)
  92. RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/linux
  93. endif
  94. ifeq ($(PLATFORM_OS),OSX)
  95. RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/osx
  96. endif
  97. ifeq ($(PLATFORM_OS),BSD)
  98. RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/bsd
  99. endif
  100. endif
  101. ifeq ($(PLATFORM),PLATFORM_RPI)
  102. RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/rpi
  103. endif
  104. ifeq ($(PLATFORM),PLATFORM_WEB)
  105. RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/html5
  106. endif
  107. # Define default C compiler: gcc
  108. # NOTE: define g++ compiler if using C++
  109. CC = gcc
  110. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  111. ifeq ($(PLATFORM_OS),OSX)
  112. # OSX default compiler
  113. CC = clang
  114. endif
  115. ifeq ($(PLATFORM_OS),BSD)
  116. # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler
  117. CC = clang
  118. endif
  119. endif
  120. ifeq ($(PLATFORM),PLATFORM_RPI)
  121. ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
  122. # Define RPI cross-compiler
  123. #CC = armv6j-hardfloat-linux-gnueabi-gcc
  124. CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc
  125. endif
  126. endif
  127. ifeq ($(PLATFORM),PLATFORM_WEB)
  128. # HTML5 emscripten compiler
  129. CC = emcc
  130. endif
  131. # Define default make program: Mingw32-make
  132. MAKE = mingw32-make
  133. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  134. ifeq ($(PLATFORM_OS),LINUX)
  135. MAKE = make
  136. endif
  137. endif
  138. # Define compiler flags:
  139. # -O1 defines optimization level
  140. # -g enable debugging
  141. # -s strip unnecessary data from build
  142. # -Wall turns on most, but not all, compiler warnings
  143. # -std=c99 defines C language mode (standard C from 1999 revision)
  144. # -std=gnu99 defines C language mode (GNU C from 1999 revision)
  145. # -Wno-missing-braces ignore invalid warning (GCC bug 53119)
  146. # -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
  147. CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces
  148. # Additional flags for compiler (if desired)
  149. #CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
  150. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  151. ifeq ($(PLATFORM_OS),WINDOWS)
  152. # resources file contains windows exe icon
  153. # -Wl,--subsystem,windows hides the console window
  154. CFLAGS += $(RAYLIB_PATH)/raylib.rc.o -Wl,--subsystem,windows
  155. endif
  156. ifeq ($(PLATFORM_OS),LINUX)
  157. CFLAGS += -D_DEFAULT_SOURCE
  158. endif
  159. endif
  160. ifeq ($(PLATFORM),PLATFORM_RPI)
  161. CFLAGS += -std=gnu99
  162. endif
  163. ifeq ($(PLATFORM),PLATFORM_WEB)
  164. # -O2 # if used, also set --memory-init-file 0
  165. # --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
  166. # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
  167. # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
  168. # -s USE_PTHREADS=1 # multithreading support
  169. # -s WASM=1 # support Web Assembly (https://github.com/kripken/emscripten/wiki/WebAssembly)
  170. # --preload-file resources # specify a resources folder for data compilation
  171. CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 --profiling --preload-file resources
  172. # Define a custom shell .html and output extension
  173. CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
  174. EXT = .html
  175. endif
  176. # Define include paths for required headers
  177. # NOTE: Several external required libraries (stb and others)
  178. INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/release/include -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external
  179. # Define additional directories containing required header files
  180. ifeq ($(PLATFORM),PLATFORM_RPI)
  181. # RPI requried libraries
  182. INCLUDE_PATHS += -I/opt/vc/include
  183. INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux
  184. INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads
  185. endif
  186. # Define library paths containing required libs
  187. LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
  188. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  189. ifeq ($(PLATFORM_OS),BSD)
  190. INCLUDE_PATHS += -I/usr/local/include
  191. LDFLAGS += -L. -Lsrc -L/usr/local/lib
  192. endif
  193. endif
  194. ifeq ($(PLATFORM),PLATFORM_RPI)
  195. LDFLAGS += -L/opt/vc/lib
  196. endif
  197. # Define any libraries required on linking
  198. # if you want to link libraries (libname.so or libname.a), use the -lname
  199. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  200. ifeq ($(PLATFORM_OS),WINDOWS)
  201. # Libraries for Windows desktop compilation
  202. LDLIBS = -lraylib -lopengl32 -lgdi32
  203. endif
  204. ifeq ($(PLATFORM_OS),LINUX)
  205. # Libraries for Debian GNU/Linux desktop compiling
  206. # NOTE: Required packages: libegl1-mesa-dev
  207. LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt
  208. # On X11 requires also below libraries
  209. LDLIBS += -lX11
  210. # NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
  211. #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
  212. # On Wayland windowing system, additional libraries requires
  213. ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
  214. LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
  215. endif
  216. endif
  217. ifeq ($(PLATFORM_OS),OSX)
  218. # Libraries for OSX 10.9 desktop compiling
  219. # NOTE: Required packages: libopenal-dev libegl1-mesa-dev
  220. LDLIBS = -lraylib -framework OpenGL -framework OpenAL -framework Cocoa
  221. endif
  222. ifeq ($(PLATFORM_OS),BSD)
  223. # Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
  224. # NOTE: Required packages: mesa-libs
  225. LDLIBS = -lraylib -lGL -lpthread -lm
  226. # On XWindow requires also below libraries
  227. LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
  228. endif
  229. ifeq ($(USE_EXTERNAL_GLFW),TRUE)
  230. # NOTE: It could require additional packages installed: libglfw3-dev
  231. LDLIBS += -lglfw
  232. endif
  233. endif
  234. ifeq ($(PLATFORM),PLATFORM_RPI)
  235. # Libraries for Raspberry Pi compiling
  236. # NOTE: Required packages: libasound2-dev (ALSA)
  237. LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl
  238. endif
  239. ifeq ($(PLATFORM),PLATFORM_WEB)
  240. # Libraries for web (HTML5) compiling
  241. LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc
  242. endif
  243. # Define all source files required
  244. SAMPLES = \
  245. arkanoid \
  246. asteroids \
  247. asteroids_survival \
  248. floppy \
  249. gold_fever \
  250. gorilas \
  251. missile_commander \
  252. pang \
  253. snake \
  254. space_invaders \
  255. tetris \
  256. # typing 'make' will invoke the default target entry
  257. all: $(SAMPLES)
  258. %: %.c
  259. ifeq ($(PLATFORM),PLATFORM_ANDROID)
  260. $(MAKE) -f Makefile.Android PROJECT_NAME=$@ PROJECT_SOURCE_FILES=$<
  261. else
  262. $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
  263. endif
  264. # Clean everything
  265. clean:
  266. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  267. ifeq ($(PLATFORM_OS),WINDOWS)
  268. del *.o *.exe /s
  269. endif
  270. ifeq ($(PLATFORM_OS),LINUX)
  271. find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f
  272. endif
  273. ifeq ($(PLATFORM_OS),OSX)
  274. find . -type f -perm +ugo+x -delete
  275. rm -f *.o
  276. endif
  277. endif
  278. ifeq ($(PLATFORM),PLATFORM_RPI)
  279. find . -type f -executable -delete
  280. rm -f *.o
  281. endif
  282. ifeq ($(PLATFORM),PLATFORM_WEB)
  283. del *.o *.html *.js
  284. endif
  285. @echo Cleaning done