You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

325 lines
11 KiB

пре 10 година
пре 10 година
пре 10 година
пре 7 година
пре 10 година
пре 7 година
пре 10 година
пре 7 година
пре 10 година
пре 7 година
пре 10 година
пре 10 година
пре 7 година
пре 7 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 7 година
пре 7 година
пре 7 година
пре 7 година
пре 10 година
пре 7 година
пре 7 година
пре 7 година
пре 7 година
пре 7 година
пре 7 година
пре 6 година
пре 7 година
пре 10 година
пре 10 година
пре 7 година
пре 10 година
пре 7 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 7 година
пре 10 година
пре 10 година
  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 ?= just_do
  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=FREEBSD
  54. endif
  55. ifeq ($(UNAMEOS),Darwin)
  56. PLATFORM_OS=OSX
  57. endif
  58. endif
  59. endif
  60. ifeq ($(PLATFORM),PLATFORM_RPI)
  61. UNAMEOS=$(shell uname)
  62. ifeq ($(UNAMEOS),Linux)
  63. PLATFORM_OS=LINUX
  64. endif
  65. endif
  66. ifeq ($(PLATFORM),PLATFORM_WEB)
  67. # Emscripten required variables
  68. EMSDK_PATH = C:/emsdk
  69. EMSCRIPTEN_VERSION = 1.37.28
  70. CLANG_VERSION=e1.37.28_64bit
  71. PYTHON_VERSION=2.7.5.3_64bit
  72. NODE_VERSION=4.1.1_64bit
  73. 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)
  74. EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
  75. endif
  76. RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs
  77. # Define raylib release directory for compiled library
  78. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  79. ifeq ($(PLATFORM_OS),WINDOWS)
  80. RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32
  81. endif
  82. ifeq ($(PLATFORM_OS),LINUX)
  83. RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/linux
  84. endif
  85. ifeq ($(PLATFORM_OS),OSX)
  86. RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/osx
  87. endif
  88. ifeq ($(PLATFORM_OS),FREEBSD)
  89. RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/freebsd
  90. endif
  91. endif
  92. ifeq ($(PLATFORM),PLATFORM_RPI)
  93. RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/rpi
  94. endif
  95. ifeq ($(PLATFORM),PLATFORM_WEB)
  96. RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/html5
  97. endif
  98. # Define default C compiler: gcc
  99. # NOTE: define g++ compiler if using C++
  100. CC = gcc
  101. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  102. ifeq ($(PLATFORM_OS),OSX)
  103. # OSX default compiler
  104. CC = clang
  105. endif
  106. ifeq ($(PLATFORM_OS),FREEBSD)
  107. # FreeBSD default compiler
  108. CC = clang
  109. endif
  110. endif
  111. ifeq ($(PLATFORM),PLATFORM_RPI)
  112. ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
  113. # Define RPI cross-compiler
  114. #CC = armv6j-hardfloat-linux-gnueabi-gcc
  115. CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc
  116. endif
  117. endif
  118. ifeq ($(PLATFORM),PLATFORM_WEB)
  119. # HTML5 emscripten compiler
  120. CC = emcc
  121. endif
  122. # Define default make program: Mingw32-make
  123. MAKE = mingw32-make
  124. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  125. ifeq ($(PLATFORM_OS),LINUX)
  126. MAKE = make
  127. endif
  128. endif
  129. # Define compiler flags:
  130. # -O1 defines optimization level
  131. # -g enable debugging
  132. # -s strip unnecessary data from build
  133. # -Wall turns on most, but not all, compiler warnings
  134. # -std=c99 defines C language mode (standard C from 1999 revision)
  135. # -std=gnu99 defines C language mode (GNU C from 1999 revision)
  136. # -Wno-missing-braces ignore invalid warning (GCC bug 53119)
  137. # -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
  138. CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces
  139. # Additional flags for compiler (if desired)
  140. #CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
  141. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  142. ifeq ($(PLATFORM_OS),WINDOWS)
  143. # resources file contains windows exe icon
  144. # -Wl,--subsystem,windows hides the console window
  145. CFLAGS += $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows
  146. endif
  147. ifeq ($(PLATFORM_OS),LINUX)
  148. CFLAGS += -no-pie -D_DEFAULT_SOURCE
  149. endif
  150. endif
  151. ifeq ($(PLATFORM),PLATFORM_RPI)
  152. CFLAGS += -std=gnu99
  153. endif
  154. ifeq ($(PLATFORM),PLATFORM_WEB)
  155. # -O2 # if used, also set --memory-init-file 0
  156. # --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
  157. # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
  158. # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
  159. # -s USE_PTHREADS=1 # multithreading support
  160. # -s WASM=1 # support Web Assembly (https://github.com/kripken/emscripten/wiki/WebAssembly)
  161. # --preload-file resources # specify a resources folder for data compilation
  162. CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 --profiling --preload-file resources
  163. # Define a custom shell .html and output extension
  164. CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
  165. EXT = .html
  166. endif
  167. # Define include paths for required headers
  168. # NOTE: Several external required libraries (stb and others)
  169. INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/release/include -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external
  170. # Define additional directories containing required header files
  171. ifeq ($(PLATFORM),PLATFORM_RPI)
  172. # RPI requried libraries
  173. INCLUDE_PATHS += -I/opt/vc/include
  174. INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux
  175. INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads
  176. endif
  177. # Define library paths containing required libs
  178. LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
  179. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  180. ifeq ($(PLATFORM_OS),FREEBSD)
  181. INCLUDE_PATHS += -I/usr/local/include
  182. LDFLAGS += -L. -Lsrc -L/usr/local/lib
  183. endif
  184. endif
  185. ifeq ($(PLATFORM),PLATFORM_RPI)
  186. LDFLAGS += -L/opt/vc/lib
  187. endif
  188. # Define any libraries required on linking
  189. # if you want to link libraries (libname.so or libname.a), use the -lname
  190. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  191. ifeq ($(PLATFORM_OS),WINDOWS)
  192. # Libraries for Windows desktop compilation
  193. LDLIBS = -lraylib -lopengl32 -lgdi32
  194. endif
  195. ifeq ($(PLATFORM_OS),LINUX)
  196. # Libraries for Debian GNU/Linux desktop compiling
  197. # NOTE: Required packages: libegl1-mesa-dev
  198. LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt
  199. # On X11 requires also below libraries
  200. LDLIBS += -lX11
  201. # NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
  202. #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
  203. # On Wayland windowing system, additional libraries requires
  204. ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
  205. LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
  206. endif
  207. endif
  208. ifeq ($(PLATFORM_OS),OSX)
  209. # Libraries for OSX 10.9 desktop compiling
  210. # NOTE: Required packages: libopenal-dev libegl1-mesa-dev
  211. LDLIBS = -lraylib -framework OpenGL -framework OpenAL -framework Cocoa
  212. endif
  213. ifeq ($(PLATFORM_OS),FREEBSD)
  214. # Libraries for FreeBSD desktop compiling
  215. # NOTE: Required packages: mesa-libs
  216. LDLIBS = -lraylib -lGL -lpthread -lm
  217. # On XWindow requires also below libraries
  218. LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
  219. endif
  220. ifeq ($(USE_EXTERNAL_GLFW),TRUE)
  221. # NOTE: It could require additional packages installed: libglfw3-dev
  222. LDLIBS += -lglfw
  223. endif
  224. endif
  225. ifeq ($(PLATFORM),PLATFORM_RPI)
  226. # Libraries for Raspberry Pi compiling
  227. # NOTE: Required packages: libasound2-dev (ALSA)
  228. LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl
  229. endif
  230. ifeq ($(PLATFORM),PLATFORM_WEB)
  231. # Libraries for web (HTML5) compiling
  232. LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc
  233. endif
  234. # Define all source files required
  235. PROJECT_SOURCE_FILES ?= just_do.c \
  236. screens/screen_logo.c \
  237. screens/screen_level00.c \
  238. screens/screen_level01.c \
  239. screens/screen_level02.c \
  240. screens/screen_level03.c \
  241. screens/screen_level04.c \
  242. screens/screen_level05.c \
  243. screens/screen_level06.c \
  244. screens/screen_level07.c \
  245. screens/screen_level08.c \
  246. screens/screen_level09.c
  247. # Define all object files from source files
  248. OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES))
  249. # For Android platform we call a custom Makefile.Android
  250. ifeq ($(PLATFORM),PLATFORM_ANDROID)
  251. MAKEFILE_PARAMS = -f Makefile.Android
  252. export PROJECT_NAME
  253. export PROJECT_SOURCE_FILES
  254. else
  255. MAKEFILE_PARAMS = $(PROJECT_NAME)
  256. endif
  257. # Default target entry
  258. # NOTE: We call this Makefile target or Makefile.Android target
  259. all:
  260. $(MAKE) $(MAKEFILE_PARAMS)
  261. # Project target defined by PROJECT_NAME
  262. $(PROJECT_NAME): $(OBJS)
  263. $(CC) -o $(PROJECT_NAME)$(EXT) $(OBJS) $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
  264. # Compile source files
  265. # NOTE: This pattern will compile every module defined on $(OBJS)
  266. %.o: %.c
  267. $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM)
  268. # Clean everything
  269. clean:
  270. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  271. ifeq ($(PLATFORM_OS),WINDOWS)
  272. del *.o *.exe /s
  273. endif
  274. ifeq ($(PLATFORM_OS),LINUX)
  275. 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
  276. endif
  277. ifeq ($(PLATFORM_OS),OSX)
  278. find . -type f -perm +ugo+x -delete
  279. rm -f *.o
  280. endif
  281. endif
  282. ifeq ($(PLATFORM),PLATFORM_RPI)
  283. find . -type f -executable -delete
  284. rm -f *.o
  285. endif
  286. ifeq ($(PLATFORM),PLATFORM_WEB)
  287. del *.o *.html *.js
  288. endif
  289. @echo Cleaning done