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.

203 lines
6.8 KiB

  1. #**************************************************************************************************
  2. #
  3. # raylib - Basic Test
  4. #
  5. # makefile to compile basic test 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 -s ASSERTIONS=1 --preload-file resources
  73. #-s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
  74. #-s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
  75. endif
  76. #CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
  77. # define any directories containing required header files
  78. ifeq ($(PLATFORM),PLATFORM_RPI)
  79. INCLUDES = -I. -I../../src -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads
  80. endif
  81. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  82. # add standard directories for GNU/Linux
  83. ifeq ($(PLATFORM_OS),LINUX)
  84. INCLUDES = -I. -I../src -I/usr/local/include/raylib/
  85. else
  86. INCLUDES = -I. -I../../src -IC:/raylib/raylib/src
  87. # external libraries headers
  88. # GLFW3
  89. INCLUDES += -I../../external/glfw3/include
  90. # OpenAL Soft
  91. INCLUDES += -I../../external/openal_soft/include
  92. endif
  93. endif
  94. # define library paths containing required libs
  95. ifeq ($(PLATFORM),PLATFORM_RPI)
  96. LFLAGS = -L. -L../../src -L/opt/vc/lib
  97. endif
  98. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  99. # add standard directories for GNU/Linux
  100. ifeq ($(PLATFORM_OS),LINUX)
  101. LFLAGS = -L. -L../../src
  102. else
  103. LFLAGS = -L. -L../../src
  104. ifeq ($(PLATFORM_OS),WINDOWS)
  105. LFLAGS += -LC:/raylib/raylib/src
  106. endif
  107. # external libraries to link with
  108. # GLFW3
  109. LFLAGS += -L../../external/glfw3/lib/$(LIBPATH)
  110. ifneq ($(PLATFORM_OS),OSX)
  111. # OpenAL Soft
  112. LFLAGS += -L../../external/openal_soft/lib/$(LIBPATH)
  113. endif
  114. endif
  115. endif
  116. # define any libraries to link into executable
  117. # if you want to link libraries (libname.so or libname.a), use the -lname
  118. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  119. ifeq ($(PLATFORM_OS),LINUX)
  120. # libraries for Debian GNU/Linux desktop compiling
  121. # requires the following packages:
  122. # libglfw3-dev libopenal-dev libegl1-mesa-dev
  123. LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -pthread -ldl -lX11 \
  124. -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
  125. else
  126. ifeq ($(PLATFORM_OS),OSX)
  127. # libraries for OS X 10.9 desktop compiling
  128. # requires the following packages:
  129. # libglfw3-dev libopenal-dev libegl1-mesa-dev
  130. LIBS = -lraylib -lglfw3 -framework OpenGL -framework OpenAl -framework Cocoa
  131. else
  132. # libraries for Windows desktop compiling
  133. # NOTE: GLFW3 and OpenAL Soft libraries should be installed
  134. LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32
  135. endif
  136. endif
  137. endif
  138. ifeq ($(PLATFORM),PLATFORM_RPI)
  139. # libraries for Raspberry Pi compiling
  140. # NOTE: OpenAL Soft library should be installed (libopenal1 package)
  141. LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal
  142. endif
  143. ifeq ($(PLATFORM),PLATFORM_WEB)
  144. # just adjust the correct path to libraylib.bc
  145. LIBS = C:/raylib/raylib/src/libraylib.bc
  146. endif
  147. # define additional parameters and flags for windows
  148. ifeq ($(PLATFORM_OS),WINDOWS)
  149. # resources file contains windows exe icon
  150. # -Wl,--subsystem,windows hides the console window
  151. WINFLAGS = C:/raylib/raylib/src/resources -Wl,--subsystem,windows
  152. endif
  153. ifeq ($(PLATFORM),PLATFORM_WEB)
  154. EXT = .html
  155. endif
  156. # typing 'make' will invoke the default target entry called 'all',
  157. # in this case, the 'default' target entry is basic_test
  158. all: basic_test
  159. # compile template - basic_test
  160. basic_test: basic_test.c
  161. $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
  162. # clean everything
  163. clean:
  164. ifeq ($(PLATFORM),PLATFORM_DESKTOP)
  165. ifeq ($(PLATFORM_OS),OSX)
  166. find . -type f -perm +ugo+x -delete
  167. rm -f *.o
  168. else
  169. ifeq ($(PLATFORM_OS),LINUX)
  170. find . -type f -executable -delete
  171. rm -f *.o
  172. else
  173. del *.o *.exe
  174. endif
  175. endif
  176. endif
  177. ifeq ($(PLATFORM),PLATFORM_RPI)
  178. find . -type f -executable -delete
  179. rm -f *.o
  180. endif
  181. ifeq ($(PLATFORM),PLATFORM_WEB)
  182. del *.o *.html *.js
  183. endif
  184. @echo Cleaning done
  185. # instead of defining every module one by one, we can define a pattern
  186. # this pattern below will automatically compile every module defined on $(OBJS)
  187. #%.exe : %.c
  188. # $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM)