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.

191 regels
6.4 KiB

  1. #**************************************************************************************************
  2. #
  3. # raylib - Simple Game
  4. #
  5. # makefile to compile simple 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. # typing 'make' will invoke the first target entry in the file,
  143. # in this case, the 'default' target entry is simple_game
  144. default: simple_game
  145. # compile template - simple_game
  146. simple_game: simple_game.c screens.o
  147. $(CC) -o $@$(EXT) $< screens.o $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
  148. # compile screens
  149. screens.o: screens.c
  150. $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
  151. # clean everything
  152. clean:
  153. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  154. ifeq ($(PLATFORM_OS),OSX)
  155. find . -type f -perm +ugo+x -delete
  156. rm -f *.o
  157. else
  158. ifeq ($(PLATFORM_OS),LINUX)
  159. 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
  160. else
  161. del *.o *.exe
  162. endif
  163. endif
  164. endif
  165. ifeq ($(PLATFORM),PLATFORM_RPI)
  166. find . -type f -executable -delete
  167. rm -f *.o
  168. endif
  169. ifeq ($(PLATFORM),PLATFORM_WEB)
  170. del *.o *.html *.js
  171. endif
  172. @echo Cleaning done
  173. # instead of defining every module one by one, we can define a pattern
  174. # this pattern below will automatically compile every module defined on $(OBJS)
  175. #%.exe : %.c
  176. # $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM)