Debian Codegraph @

examples/example_null/Makefile

raw
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
10 WITH_EXTRA_WARNINGS ?= 0
11 WITH_FREETYPE ?= 0
12
13 EXE = example_null
14 IMGUI_DIR = ../..
15 SOURCES = main.cpp
16 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
17 OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
18 UNAME_S := $(shell uname -s)
19
20 CXXFLAGS += -std=c++11 -I$(IMGUI_DIR)
21 CXXFLAGS += -g -Wall -Wformat
22 LIBS =
23
24 # We use the WITH_EXTRA_WARNINGS flag on our CI setup to eagerly catch zealous warnings
25 ifeq ($(WITH_EXTRA_WARNINGS), 1)
26 CXXFLAGS += -Wno-zero-as-null-pointer-constant -Wno-double-promotion -Wno-variadic-macros
27 endif
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)
31 ifeq ($(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)
35 endif
36
37 ##---------------------------------------------------------------------
38 ## BUILD FLAGS PER PLATFORM
39 ##---------------------------------------------------------------------
40
41 ifeq ($(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)
50 endif
51
52 ifeq ($(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)
58 endif
59
60 ifeq ($(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)
67 endif
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
85 all: $(EXE)
86 @echo Build complete for $(ECHO_MESSAGE)
87
88 $(EXE): $(OBJS)
89 $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
90
91 clean:
92 rm -f $(EXE) $(OBJS)