Makefile 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #
  2. # Cross Platform Makefile
  3. # Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X
  4. #
  5. # Important: This is a "null backend" application, with no visible output or interaction!
  6. # This is used for testing purpose and continuous integration, and has little use for end-user.
  7. #
  8. # Options
  9. WITH_EXTRA_WARNINGS ?= 0
  10. WITH_FREETYPE ?= 0
  11. EXE = example_null
  12. IMGUI_DIR = ../..
  13. SOURCES = main.cpp
  14. SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
  15. OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
  16. UNAME_S := $(shell uname -s)
  17. CXXFLAGS += -std=c++11 -I$(IMGUI_DIR)
  18. CXXFLAGS += -g -Wall -Wformat
  19. LIBS =
  20. # We use the WITH_EXTRA_WARNINGS flag on our CI setup to eagerly catch zealous warnings
  21. ifeq ($(WITH_EXTRA_WARNINGS), 1)
  22. CXXFLAGS += -Wno-zero-as-null-pointer-constant -Wno-double-promotion -Wno-variadic-macros
  23. endif
  24. # We use the WITH_FREETYPE flag on our CI setup to test compiling misc/freetype/imgui_freetype.cpp
  25. # (only supported on Linux, and note that the imgui_freetype code currently won't be executed)
  26. ifeq ($(WITH_FREETYPE), 1)
  27. SOURCES += $(IMGUI_DIR)/misc/freetype/imgui_freetype.cpp
  28. CXXFLAGS += $(shell pkg-config --cflags freetype2)
  29. LIBS += $(shell pkg-config --libs freetype2)
  30. endif
  31. ##---------------------------------------------------------------------
  32. ## BUILD FLAGS PER PLATFORM
  33. ##---------------------------------------------------------------------
  34. ifeq ($(UNAME_S), Linux) #LINUX
  35. ECHO_MESSAGE = "Linux"
  36. ifeq ($(WITH_EXTRA_WARNINGS), 1)
  37. CXXFLAGS += -Wextra -Wpedantic
  38. ifeq ($(shell $(CXX) -v 2>&1 | grep -c "clang version"), 1)
  39. CXXFLAGS += -Wshadow -Wsign-conversion
  40. endif
  41. endif
  42. CFLAGS = $(CXXFLAGS)
  43. endif
  44. ifeq ($(UNAME_S), Darwin) #APPLE
  45. ECHO_MESSAGE = "Mac OS X"
  46. ifeq ($(WITH_EXTRA_WARNINGS), 1)
  47. CXXFLAGS += -Weverything -Wno-reserved-id-macro -Wno-c++98-compat-pedantic -Wno-padded -Wno-poison-system-directories
  48. endif
  49. CFLAGS = $(CXXFLAGS)
  50. endif
  51. ifeq ($(OS), Windows_NT)
  52. ECHO_MESSAGE = "MinGW"
  53. ifeq ($(WITH_EXTRA_WARNINGS), 1)
  54. CXXFLAGS += -Wextra -Wpedantic
  55. endif
  56. LIBS += -limm32
  57. CFLAGS = $(CXXFLAGS)
  58. endif
  59. ##---------------------------------------------------------------------
  60. ## BUILD RULES
  61. ##---------------------------------------------------------------------
  62. %.o:%.cpp
  63. $(CXX) $(CXXFLAGS) -c -o $@ $<
  64. %.o:$(IMGUI_DIR)/%.cpp
  65. $(CXX) $(CXXFLAGS) -c -o $@ $<
  66. %.o:$(IMGUI_DIR)/backends/%.cpp
  67. $(CXX) $(CXXFLAGS) -c -o $@ $<
  68. %.o:$(IMGUI_DIR)/misc/freetype/%.cpp
  69. $(CXX) $(CXXFLAGS) -c -o $@ $<
  70. all: $(EXE)
  71. @echo Build complete for $(ECHO_MESSAGE)
  72. $(EXE): $(OBJS)
  73. $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
  74. clean:
  75. rm -f $(EXE) $(OBJS)