2.6 KB、92行 生 Blame 履歴
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
9# Options
10WITH_EXTRA_WARNINGS ?= 0
11WITH_FREETYPE ?= 0
12
13EXE = example_null
14IMGUI_DIR = ../..
15SOURCES = main.cpp
16SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
17OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
18UNAME_S := $(shell uname -s)
19
20CXXFLAGS += -std=c++11 -I$(IMGUI_DIR)
21CXXFLAGS += -g -Wall -Wformat
22LIBS =
23
24# We use the WITH_EXTRA_WARNINGS flag on our CI setup to eagerly catch zealous warnings
25ifeq ($(WITH_EXTRA_WARNINGS), 1)
26 CXXFLAGS += -Wno-zero-as-null-pointer-constant -Wno-double-promotion -Wno-variadic-macros
27endif
28
29# We use the WITH_FREETYPE flag on our CI setup to test compiling misc/freetype/imgui_freetype.cpp
30# (only supported on Linux, and note that the imgui_freetype code currently won't be executed)
31ifeq ($(WITH_FREETYPE), 1)
32 SOURCES += $(IMGUI_DIR)/misc/freetype/imgui_freetype.cpp
33 CXXFLAGS += $(shell pkg-config --cflags freetype2)
34 LIBS += $(shell pkg-config --libs freetype2)
35endif
36
37##---------------------------------------------------------------------
38## BUILD FLAGS PER PLATFORM
39##---------------------------------------------------------------------
40
41ifeq ($(UNAME_S), Linux) #LINUX
42 ECHO_MESSAGE = "Linux"
43 ifeq ($(WITH_EXTRA_WARNINGS), 1)
44 CXXFLAGS += -Wextra -Wpedantic
45 ifeq ($(shell $(CXX) -v 2>&1 | grep -c "clang version"), 1)
46 CXXFLAGS += -Wshadow -Wsign-conversion
47 endif
48 endif
49 CFLAGS = $(CXXFLAGS)
50endif
51
52ifeq ($(UNAME_S), Darwin) #APPLE
53 ECHO_MESSAGE = "Mac OS X"
54 ifeq ($(WITH_EXTRA_WARNINGS), 1)
55 CXXFLAGS += -Weverything -Wno-reserved-id-macro -Wno-c++98-compat-pedantic -Wno-padded -Wno-poison-system-directories
56 endif
57 CFLAGS = $(CXXFLAGS)
58endif
59
60ifeq ($(OS), Windows_NT)
61 ECHO_MESSAGE = "MinGW"
62 ifeq ($(WITH_EXTRA_WARNINGS), 1)
63 CXXFLAGS += -Wextra -Wpedantic
64 endif
65 LIBS += -limm32
66 CFLAGS = $(CXXFLAGS)
67endif
68
69##---------------------------------------------------------------------
70## BUILD RULES
71##---------------------------------------------------------------------
72
73%.o:%.cpp
74 $(CXX) $(CXXFLAGS) -c -o $@ $<
75
76%.o:$(IMGUI_DIR)/%.cpp
77 $(CXX) $(CXXFLAGS) -c -o $@ $<
78
79%.o:$(IMGUI_DIR)/backends/%.cpp
80 $(CXX) $(CXXFLAGS) -c -o $@ $<
81
82%.o:$(IMGUI_DIR)/misc/freetype/%.cpp
83 $(CXX) $(CXXFLAGS) -c -o $@ $<
84
85all: $(EXE)
86 @echo Build complete for $(ECHO_MESSAGE)
87
88$(EXE): $(OBJS)
89 $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
90
91clean:
92 rm -f $(EXE) $(OBJS)