Makefile 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #
  2. # m3dview/Makefile
  3. #
  4. # Copyright (C) 2019 bzt (bztsrc@gitlab)
  5. #
  6. # Permission is hereby granted, free of charge, to any person
  7. # obtaining a copy of this software and associated documentation
  8. # files (the "Software"), to deal in the Software without
  9. # restriction, including without limitation the rights to use, copy,
  10. # modify, merge, publish, distribute, sublicense, and/or sell copies
  11. # of the Software, and to permit persons to whom the Software is
  12. # furnished to do so, subject to the following conditions:
  13. #
  14. # The above copyright notice and this permission notice shall be
  15. # included in all copies or substantial portions of the Software.
  16. #
  17. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  20. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  21. # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  22. # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  24. # DEALINGS IN THE SOFTWARE.
  25. #
  26. # --- set according to your configuration ---
  27. MINGWSDL = ../..
  28. # -------------------------------------------
  29. CFLAGS = -I ../ -ansi -pedantic -Wall -Wextra
  30. LIBS =
  31. SRCS = viewer.c
  32. TARGET = m3dview
  33. ifeq ($(DRIVER),)
  34. ifneq ("$(wildcard /Library/Frameworks/GLFW*)","")
  35. DRIVER = APPLE_GLFW
  36. else
  37. ifneq ("$(wildcard /Library/Frameworks/GLUT*)","")
  38. DRIVER = APPLE_GLUT
  39. else
  40. ifneq ("$(wildcard /Library/Frameworks/SDL*)","")
  41. DRIVER = APPLE_SDL
  42. else
  43. ifneq ("$(wildcard /usr/include/GLFW/glfw*.h)","")
  44. DRIVER = MINGW_GLFW
  45. else
  46. ifneq ("$(wildcard /usr/include/GL/glut.h)","")
  47. DRIVER = MINGW_GLUT
  48. else
  49. ifneq ("$(wildcard /usr/include/SDL2/SDL.h)","")
  50. DRIVER = MINGW_SDL
  51. else
  52. ifneq ("$(wildcard $(MINGWSDL)/i686-w64-mingw32/include/SDL2/SDL.h)","")
  53. DRIVER = MINGW_SDL
  54. CFLAGS += -I$(MINGWSDL)/i686-w64-mingw32/include/SDL2 -L../../i686-w64-mingw32/lib
  55. endif
  56. endif
  57. endif
  58. endif
  59. endif
  60. endif
  61. endif
  62. endif
  63. ifeq ($(DRIVER),APPLE_GLFW)
  64. SRCS += glfw.c
  65. CFLAGS += -I/usr/include/OpenGL -I/usr/include/GLFW -I/Library/Frameworks/OpenGL.framework/Headers -I/Library/Frameworks/GLFW.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -DGL_SILENCE_DEPRECATION -Wno-comment
  66. LIBS = -F/Library/Frameworks -F/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks -framework OpenGL -framework GLFW
  67. endif
  68. ifeq ($(DRIVER), APPLE_GLUT)
  69. SRCS += glut.c
  70. CFLAGS += -I/usr/include/OpenGL -I/usr/include/GLUT -I/Library/Frameworks/OpenGL.framework/Headers -I/Library/Frameworks/GLUT.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -DGL_SILENCE_DEPRECATION -Wno-comment
  71. LIBS = -F/Library/Frameworks -F/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks -framework OpenGL -framework GLUT
  72. endif
  73. ifeq ($(DRIVER), APPLE_SDL)
  74. SRCS += sdl.c
  75. CFLAGS += -I/usr/include/OpenGL -I/usr/include/SDL2 -I/Library/Frameworks/OpenGL.framework/Headers -I/Library/Frameworks/SDL2.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -DGL_SILENCE_DEPRECATION -Wno-comment
  76. LIBS = -F/Library/Frameworks -F/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks -framework OpenGL -framework SDL2
  77. endif
  78. ifeq ($(DRIVER), MINGW_GLFW)
  79. SRCS += glfw.c
  80. CFLAGS += -I/usr/include/GL -I/usr/include/GLFW
  81. LIBS = -lGL -lglfw
  82. endif
  83. ifeq ($(DRIVER), MINGW_GLUT)
  84. SRCS += glut.c
  85. CFLAGS += -I/usr/include/GL
  86. LIBS = -lGL -lglut
  87. endif
  88. ifeq ($(DRIVER), MINGW_SDL)
  89. SRCS += sdl.c
  90. ifeq ($(PREVIEW), 1)
  91. CFLAGS += -I/usr/include/GL -I/usr/include/SDL2 -DPREVIEW=1
  92. LIBS = -lGL -lSDL2 -lSDL2_image -lSDL2_gfx
  93. else
  94. CFLAGS += -I/usr/include/GL -I/usr/include/SDL2
  95. ifeq ("$(wildcard /usr/lib/libGL*)","")
  96. LIBS = -lopengl32 -lcomdlg32 -lSDL2
  97. else
  98. LIBS = -lGL -lSDL2
  99. endif
  100. endif
  101. endif
  102. ifneq ($(PROFILING),)
  103. CFLAGS += -g -DPROFILING
  104. endif
  105. all: $(TARGET)
  106. $(TARGET): $(SRCS) viewer.h ../m3d.h
  107. ifneq ("$(LIBS)","")
  108. $(CC) $(CFLAGS) $(SRCS) -o $@ $(LIBS)
  109. else
  110. @echo "Unable to detect ui framework. Install glfw, glut or sdl2"
  111. endif
  112. clean:
  113. rm *.o $(TARGET) $(TARGET).exe 2>/dev/null || true