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.

204 lines
6.9 KiB

  1. #**************************************************************************************************
  2. #
  3. # raylib - Basic Game
  4. #
  5. # makefile to compile basic 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. .PHONY: all clean
  26. # define raylib platform to compile for
  27. # possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB
  28. # WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop()
  29. PLATFORM ?= PLATFORM_DESKTOP
  30. # determine PLATFORM_OS in case PLATFORM_DESKTOP selected
  31. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  32. # No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows
  33. ifeq ($(OS),Windows_NT)
  34. PLATFORM_OS=WINDOWS
  35. LIBPATH=win32
  36. else
  37. UNAMEOS:=$(shell uname)
  38. ifeq ($(UNAMEOS),Linux)
  39. PLATFORM_OS=LINUX
  40. LIBPATH=linux
  41. else
  42. ifeq ($(UNAMEOS),Darwin)
  43. PLATFORM_OS=OSX
  44. LIBPATH=osx
  45. endif
  46. endif
  47. endif
  48. endif
  49. # define compiler: gcc for C program, define as g++ for C++
  50. ifeq ($(PLATFORM),PLATFORM_WEB)
  51. # define emscripten compiler
  52. CC = emcc
  53. else
  54. ifeq ($(PLATFORM_OS),OSX)
  55. # define llvm compiler for mac
  56. CC = clang
  57. else
  58. # define default gcc compiler
  59. CC = gcc
  60. endif
  61. endif
  62. # define compiler flags:
  63. # -O2 defines optimization level
  64. # -Wall turns on most, but not all, compiler warnings
  65. # -std=c99 use standard C from 1999 revision
  66. ifeq ($(PLATFORM),PLATFORM_RPI)
  67. CFLAGS = -O2 -Wall -std=gnu99 -fgnu89-inline
  68. else
  69. CFLAGS = -O2 -Wall -std=c99
  70. endif
  71. ifeq ($(PLATFORM),PLATFORM_WEB)
  72. CFLAGS = -O1 -Wall -std=c99 -s USE_GLFW=3 --preload-file resources --shell-file ../../templates/web_shell/shell.html
  73. #-s ASSERTIONS=1 # to check for memory allocation errors (-O1 disables it)
  74. #-s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
  75. #-s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
  76. endif
  77. #CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
  78. # define any directories containing required header files
  79. ifeq ($(PLATFORM),PLATFORM_RPI)
  80. INCLUDES = -I. -I../../src -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads
  81. endif
  82. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  83. # add standard directories for GNU/Linux
  84. ifeq ($(PLATFORM_OS),LINUX)
  85. INCLUDES = -I. -I../src -I/usr/local/include/raylib/
  86. else
  87. INCLUDES = -I. -I../../src -IC:/raylib/raylib/src
  88. # external libraries headers
  89. # GLFW3
  90. INCLUDES += -I../../external/glfw3/include
  91. # OpenAL Soft
  92. INCLUDES += -I../../external/openal_soft/include
  93. endif
  94. endif
  95. # define library paths containing required libs
  96. ifeq ($(PLATFORM),PLATFORM_RPI)
  97. LFLAGS = -L. -L../../src -L/opt/vc/lib
  98. endif
  99. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  100. # add standard directories for GNU/Linux
  101. ifeq ($(PLATFORM_OS),LINUX)
  102. LFLAGS = -L. -L../../src
  103. else
  104. LFLAGS = -L. -L../../src
  105. ifeq ($(PLATFORM_OS),WINDOWS)
  106. LFLAGS += -LC:/raylib/raylib/src
  107. endif
  108. # external libraries to link with
  109. # GLFW3
  110. LFLAGS += -L../../external/glfw3/lib/$(LIBPATH)
  111. ifneq ($(PLATFORM_OS),OSX)
  112. # OpenAL Soft
  113. LFLAGS += -L../../external/openal_soft/lib/$(LIBPATH)
  114. endif
  115. endif
  116. endif
  117. # define any libraries to link into executable
  118. # if you want to link libraries (libname.so or libname.a), use the -lname
  119. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  120. ifeq ($(PLATFORM_OS),LINUX)
  121. # libraries for Debian GNU/Linux desktop compiling
  122. # requires the following packages:
  123. # libglfw3-dev libopenal-dev libegl1-mesa-dev
  124. LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -pthread -ldl -lX11 \
  125. -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
  126. else
  127. ifeq ($(PLATFORM_OS),OSX)
  128. # libraries for OS X 10.9 desktop compiling
  129. # requires the following packages:
  130. # libglfw3-dev libopenal-dev libegl1-mesa-dev
  131. LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAl -framework Cocoa
  132. else
  133. # libraries for Windows desktop compiling
  134. # NOTE: GLFW3 and OpenAL Soft libraries should be installed
  135. LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32
  136. endif
  137. endif
  138. endif
  139. ifeq ($(PLATFORM),PLATFORM_RPI)
  140. # libraries for Raspberry Pi compiling
  141. # NOTE: OpenAL Soft library should be installed (libopenal1 package)
  142. LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal
  143. endif
  144. ifeq ($(PLATFORM),PLATFORM_WEB)
  145. # NOTE: Set the correct path to libraylib.bc
  146. LIBS = ../../src/libraylib.bc
  147. endif
  148. # define additional parameters and flags for windows
  149. ifeq ($(PLATFORM_OS),WINDOWS)
  150. # resources file contains windows exe icon
  151. # -Wl,--subsystem,windows hides the console window
  152. WINFLAGS = C:/raylib/raylib/src/resources -Wl,--subsystem,windows
  153. endif
  154. ifeq ($(PLATFORM),PLATFORM_WEB)
  155. EXT = .html
  156. endif
  157. # typing 'make' will invoke the default target entry called 'all',
  158. # in this case, the 'default' target entry is basic_game
  159. all: basic_game
  160. # compile template - basic_game
  161. basic_game: basic_game.c
  162. $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
  163. # clean everything
  164. clean:
  165. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  166. ifeq ($(PLATFORM_OS),OSX)
  167. find . -type f -perm +ugo+x -delete
  168. rm -f *.o
  169. else
  170. ifeq ($(PLATFORM_OS),LINUX)
  171. find . -type f -executable -delete
  172. rm -f *.o
  173. else
  174. del *.o *.exe
  175. endif
  176. endif
  177. endif
  178. ifeq ($(PLATFORM),PLATFORM_RPI)
  179. find . -type f -executable -delete
  180. rm -f *.o
  181. endif
  182. ifeq ($(PLATFORM),PLATFORM_WEB)
  183. del *.o *.html *.js
  184. endif
  185. @echo Cleaning done
  186. # instead of defining every module one by one, we can define a pattern
  187. # this pattern below will automatically compile every module defined on $(OBJS)
  188. #%.exe : %.c
  189. # $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM)