選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

215 行
7.2 KiB

  1. #**************************************************************************************************
  2. #
  3. # raylib - Standard Game
  4. #
  5. # makefile to compile standard game for desktop platforms, Raspberry Pi and HTML5 (emscripten)
  6. #
  7. # Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
  8. #
  9. # This software is provided "as-is", without any express or implied warranty. In no event
  10. # will the authors be held liable for any damages arising from the use of this software.
  11. #
  12. # Permission is granted to anyone to use this software for any purpose, including commercial
  13. # applications, and to alter it and redistribute it freely, subject to the following restrictions:
  14. #
  15. # 1. The origin of this software must not be misrepresented; you must not claim that you
  16. # wrote the original software. If you use this software in a product, an acknowledgment
  17. # in the product documentation would be appreciated but is not required.
  18. #
  19. # 2. Altered source versions must be plainly marked as such, and must not be misrepresented
  20. # as being the original software.
  21. #
  22. # 3. This notice may not be removed or altered from any source distribution.
  23. #
  24. #**************************************************************************************************
  25. # define raylib platform to compile for
  26. # possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB
  27. # WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop()
  28. PLATFORM ?= PLATFORM_DESKTOP
  29. # determine PLATFORM_OS in case PLATFORM_DESKTOP selected
  30. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  31. # No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows
  32. ifeq ($(OS),Windows_NT)
  33. PLATFORM_OS=WINDOWS
  34. LIBPATH=win32
  35. else
  36. UNAMEOS:=$(shell uname)
  37. ifeq ($(UNAMEOS),Linux)
  38. PLATFORM_OS=LINUX
  39. LIBPATH=linux
  40. else
  41. ifeq ($(UNAMEOS),Darwin)
  42. PLATFORM_OS=OSX
  43. LIBPATH=osx
  44. endif
  45. endif
  46. endif
  47. endif
  48. # define compiler: gcc for C program, define as g++ for C++
  49. ifeq ($(PLATFORM),PLATFORM_WEB)
  50. # define emscripten compiler
  51. CC = emcc
  52. else
  53. ifeq ($(PLATFORM_OS),OSX)
  54. # define llvm compiler for mac
  55. CC = clang
  56. else
  57. # define default gcc compiler
  58. CC = gcc
  59. endif
  60. endif
  61. # define compiler flags:
  62. # -O2 defines optimization level
  63. # -Wall turns on most, but not all, compiler warnings
  64. # -std=c99 use standard C from 1999 revision
  65. ifeq ($(PLATFORM),PLATFORM_RPI)
  66. CFLAGS = -O2 -Wall -std=gnu99 -fgnu89-inline
  67. else
  68. CFLAGS = -O2 -Wall -std=c99
  69. endif
  70. ifeq ($(PLATFORM),PLATFORM_WEB)
  71. CFLAGS = -O1 -Wall -std=c99 -s USE_GLFW=3 -s ASSERTIONS=1 --preload-file resources
  72. #-s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
  73. #-s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
  74. endif
  75. #CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
  76. # define any directories containing required header files
  77. ifeq ($(PLATFORM),PLATFORM_RPI)
  78. INCLUDES = -I. -I../../src -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads
  79. else
  80. INCLUDES = -I. -I../../src
  81. # external libraries headers
  82. # GLFW3
  83. INCLUDES += -I../../external/glfw3/include
  84. # GLEW
  85. INCLUDES += -I../../external/glew/include
  86. # OpenAL Soft
  87. INCLUDES += -I../../external/openal_soft/include
  88. endif
  89. # define library paths containing required libs
  90. ifeq ($(PLATFORM),PLATFORM_RPI)
  91. LFLAGS = -L. -L../../src -L/opt/vc/lib
  92. else
  93. LFLAGS = -L. -L../../src
  94. # external libraries to link with
  95. # GLFW3
  96. LFLAGS += -L../../external/glfw3/lib/$(LIBPATH)
  97. ifneq ($(PLATFORM_OS),OSX)
  98. # OpenAL Soft
  99. LFLAGS += -L../../external/openal_soft/lib/$(LIBPATH)
  100. # GLEW
  101. LFLAGS += -L../../external/glew/lib/$(LIBPATH)
  102. endif
  103. endif
  104. # define any libraries to link into executable
  105. # if you want to link libraries (libname.so or libname.a), use the -lname
  106. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  107. ifeq ($(PLATFORM_OS),LINUX)
  108. # libraries for Debian GNU/Linux desktop compiling
  109. # requires the following packages:
  110. # libopenal-dev libglew-dev libegl1-mesa-dev
  111. LIBS = -lraylib -lglfw3 -lGLEW -lGL -lopenal -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -lm -pthread
  112. else
  113. ifeq ($(PLATFORM_OS),OSX)
  114. # libraries for OS X 10.9 desktop compiling
  115. # requires the following packages:
  116. # libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev
  117. LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAl -framework Cocoa
  118. else
  119. # libraries for Windows desktop compiling
  120. # NOTE: GLFW3 and OpenAL Soft libraries should be installed
  121. LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32
  122. endif
  123. endif
  124. endif
  125. ifeq ($(PLATFORM),PLATFORM_RPI)
  126. # libraries for Raspberry Pi compiling
  127. # NOTE: OpenAL Soft library should be installed (libopenal1 package)
  128. LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal
  129. endif
  130. ifeq ($(PLATFORM),PLATFORM_WEB)
  131. LIBS = ../../src/libraylib.bc
  132. endif
  133. # define additional parameters and flags for windows
  134. ifeq ($(PLATFORM_OS),WINDOWS)
  135. # resources file contains windows exe icon
  136. # -Wl,--subsystem,windows hides the console window
  137. WINFLAGS = ../../src/resources -Wl,--subsystem,windows
  138. endif
  139. ifeq ($(PLATFORM),PLATFORM_WEB)
  140. EXT = .html
  141. endif
  142. # define all screen object files required
  143. SCREENS = \
  144. screens/screen_logo.o \
  145. screens/screen_title.o \
  146. screens/screen_options.o \
  147. screens/screen_gameplay.o \
  148. screens/screen_ending.o \
  149. # typing 'make' will invoke the first target entry in the file,
  150. # in this case, the 'default' target entry is standard_game
  151. default: standard_game
  152. # compile template - standard_game
  153. standard_game: standard_game.c $(SCREENS)
  154. $(CC) -o $@$(EXT) $< $(SCREENS) $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
  155. # compile screen LOGO
  156. screens/screen_logo.o: screens/screen_logo.c
  157. $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
  158. # compile screen TITLE
  159. screens/screen_title.o: screens/screen_title.c
  160. $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
  161. # compile screen OPTIONS
  162. screens/screen_options.o: screens/screen_options.c
  163. $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
  164. # compile screen GAMEPLAY
  165. screens/screen_gameplay.o: screens/screen_gameplay.c
  166. $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
  167. # compile screen ENDING
  168. screens/screen_ending.o: screens/screen_ending.c
  169. $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
  170. # clean everything
  171. clean:
  172. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  173. ifeq ($(PLATFORM_OS),OSX)
  174. find . -type f -perm +ugo+x -delete
  175. rm -f *.o
  176. else
  177. ifeq ($(PLATFORM_OS),LINUX)
  178. 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
  179. else
  180. del *.o *.exe
  181. endif
  182. endif
  183. endif
  184. ifeq ($(PLATFORM),PLATFORM_RPI)
  185. find . -type f -executable -delete
  186. rm -f *.o
  187. endif
  188. ifeq ($(PLATFORM),PLATFORM_WEB)
  189. del *.o *.html *.js
  190. endif
  191. @echo Cleaning done
  192. # instead of defining every module one by one, we can define a pattern
  193. # this pattern below will automatically compile every module defined on $(OBJS)
  194. #%.exe : %.c
  195. # $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM)