Examples: Makefile: Tweaks so they are more consistent with each others. Added -g./opt/local includes for MacPorts on Mac OS X. (#297)

This commit is contained in:
omar 2019-04-07 23:02:07 +02:00
parent 1295205cd4
commit 42423d5ea4
5 changed files with 93 additions and 69 deletions

View File

@ -19,39 +19,46 @@ SOURCES = main.cpp
SOURCES += ../imgui_impl_glfw.cpp ../imgui_impl_opengl2.cpp
SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
UNAME_S := $(shell uname -s)
CXXFLAGS = -I../ -I../../
CXXFLAGS += -g -Wall -Wformat
LIBS =
##---------------------------------------------------------------------
## BUILD FLAGS PER PLATFORM
##---------------------------------------------------------------------
ifeq ($(UNAME_S), Linux) #LINUX
ECHO_MESSAGE = "Linux"
LIBS = -lGL `pkg-config --static --libs glfw3`
LIBS += -lGL `pkg-config --static --libs glfw3`
CXXFLAGS = -I../ -I../../ `pkg-config --cflags glfw3`
CXXFLAGS += -Wall -Wformat
CXXFLAGS += `pkg-config --cflags glfw3`
CFLAGS = $(CXXFLAGS)
endif
ifeq ($(UNAME_S), Darwin) #APPLE
ECHO_MESSAGE = "Mac OS X"
LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
#LIBS += -L/usr/local/lib -lglfw3
LIBS += -L/usr/local/lib -lglfw
LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
LIBS += -L/usr/local/lib -L/opt/local/lib
#LIBS += -lglfw3
LIBS += -lglfw
CXXFLAGS = -I../ -I../../ -I/usr/local/include
CXXFLAGS += -Wall -Wformat
CXXFLAGS += -I/usr/local/include -I/opt/local/include
CFLAGS = $(CXXFLAGS)
endif
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
ECHO_MESSAGE = "Windows"
LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
ECHO_MESSAGE = "MinGW"
LIBS += -lglfw3 -lgdi32 -lopengl32 -limm32
CXXFLAGS = -I../ -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
CXXFLAGS += -Wall -Wformat
CFLAGS = $(CXXFLAGS)
CXXFLAGS += -I../libs/gl3w `pkg-config --cflags glfw3`
CFLAGS = $(CXXFLAGS)
endif
##---------------------------------------------------------------------
## BUILD RULES
##---------------------------------------------------------------------
%.o:%.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<

View File

@ -21,13 +21,17 @@ SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
UNAME_S := $(shell uname -s)
CXXFLAGS = -I../ -I../../
CXXFLAGS += -g -Wall -Wformat
LIBS =
##---------------------------------------------------------------------
## OPENGL LOADER
##---------------------------------------------------------------------
## Using OpenGL loader: gl3w [default]
SOURCES += ../libs/gl3w/GL/gl3w.c
CXXFLAGS = -I../libs/gl3w
CXXFLAGS += -I../libs/gl3w
## Using OpenGL loader: glew
## (This assumes a system-wide installation)
@ -44,31 +48,29 @@ CXXFLAGS = -I../libs/gl3w
ifeq ($(UNAME_S), Linux) #LINUX
ECHO_MESSAGE = "Linux"
LIBS = -lGL `pkg-config --static --libs glfw3`
LIBS += -lGL `pkg-config --static --libs glfw3`
CXXFLAGS += -I../ -I../../ `pkg-config --cflags glfw3`
CXXFLAGS += -Wall -Wformat
CXXFLAGS += `pkg-config --cflags glfw3`
CFLAGS = $(CXXFLAGS)
endif
ifeq ($(UNAME_S), Darwin) #APPLE
ECHO_MESSAGE = "Mac OS X"
LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
#LIBS += -L/usr/local/lib -lglfw3
LIBS += -L/usr/local/lib -lglfw
LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
LIBS += -L/usr/local/lib -L/opt/local/lib
#LIBS += -lglfw3
LIBS += -lglfw
CXXFLAGS += -I../ -I../../ -I/usr/local/include
CXXFLAGS += -Wall -Wformat
CXXFLAGS += -I/usr/local/include -I/opt/local/include
CFLAGS = $(CXXFLAGS)
endif
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
ECHO_MESSAGE = "Windows"
LIBS = -lglfw3 -lgdi32 -lopengl32 -limm32
ECHO_MESSAGE = "MinGW"
LIBS += -lglfw3 -lgdi32 -lopengl32 -limm32
CXXFLAGS += -I../ -I../../ `pkg-config --cflags glfw3`
CXXFLAGS += -Wall -Wformat
CFLAGS = $(CXXFLAGS)
CXXFLAGS += `pkg-config --cflags glfw3`
CFLAGS = $(CXXFLAGS)
endif
##---------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
#
# Cross Platform Makefile
# Compatible with Ubuntu 14.04.1 and Mac OS X
# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X
#
# Linux:
# apt-get install freeglut3-dev
@ -14,37 +14,40 @@ SOURCES = main.cpp
SOURCES += ../imgui_impl_glut.cpp ../imgui_impl_opengl2.cpp
SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
UNAME_S := $(shell uname -s)
CXXFLAGS = -I../ -I../../
CXXFLAGS += -g -Wall -Wformat
LIBS =
##---------------------------------------------------------------------
## BUILD FLAGS PER PLATFORM
##---------------------------------------------------------------------
ifeq ($(UNAME_S), Linux) #LINUX
ECHO_MESSAGE = "Linux"
LIBS = -lGL -lglut
CXXFLAGS = -I ../ -I../..
CXXFLAGS += -Wall -Wformat
LIBS += -lGL -lglut
CFLAGS = $(CXXFLAGS)
endif
ifeq ($(UNAME_S), Darwin) #APPLE
ECHO_MESSAGE = "Mac OS X"
LIBS = -framework OpenGL -framework GLUT
LIBS += -framework OpenGL -framework GLUT
LIBS += -L/usr/local/lib -L/opt/local/lib
CXXFLAGS = -I .. -I../..
CXXFLAGS += -Wall -Wformat
CXXFLAGS += -I/usr/local/include -I/opt/local/include
CFLAGS = $(CXXFLAGS)
endif
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
ECHO_MESSAGE = "Windows"
LIBS = -lgdi32 -lopengl32 -limm32 -lglut
CXXFLAGS = -I ../ -I../../
CXXFLAGS += -Wall -Wformat
CFLAGS = $(CXXFLAGS)
ECHO_MESSAGE = "MinGW"
LIBS += -lgdi32 -lopengl32 -limm32 -lglut
CFLAGS = $(CXXFLAGS)
endif
##---------------------------------------------------------------------
## BUILD RULES
##---------------------------------------------------------------------
%.o:%.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<

View File

@ -15,40 +15,49 @@
#CXX = clang++
EXE = example_sdl_opengl2
SOURCES = main.cpp ../imgui_impl_sdl.cpp ../imgui_impl_opengl2.cpp
SOURCES = main.cpp
SOURCES += ../imgui_impl_sdl.cpp ../imgui_impl_opengl2.cpp
SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
UNAME_S := $(shell uname -s)
CXXFLAGS = -I../ -I../../
CXXFLAGS += -g -Wall -Wformat
LIBS =
##---------------------------------------------------------------------
## BUILD FLAGS PER PLATFORM
##---------------------------------------------------------------------
ifeq ($(UNAME_S), Linux) #LINUX
ECHO_MESSAGE = "Linux"
LIBS = -lGL -ldl `sdl2-config --libs`
LIBS += -lGL -ldl `sdl2-config --libs`
CXXFLAGS = -I ../ -I../../ `sdl2-config --cflags`
CXXFLAGS += -Wall -Wformat
CXXFLAGS += `sdl2-config --cflags`
CFLAGS = $(CXXFLAGS)
endif
ifeq ($(UNAME_S), Darwin) #APPLE
ECHO_MESSAGE = "Mac OS X"
LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs`
LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs`
LIBS += -L/usr/local/lib -L/opt/local/lib
CXXFLAGS = -I ../ -I../../ -I/usr/local/include `sdl2-config --cflags`
CXXFLAGS += -Wall -Wformat
CXXFLAGS += `sdl2-config --cflags`
CXXFLAGS += -I/usr/local/include -I/opt/local/include
CFLAGS = $(CXXFLAGS)
endif
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
ECHO_MESSAGE = "Windows"
LIBS = -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2`
ECHO_MESSAGE = "MinGW"
LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2`
CXXFLAGS = -I ../ -I../../ `pkg-config --cflags sdl2`
CXXFLAGS += -Wall -Wformat
CFLAGS = $(CXXFLAGS)
CXXFLAGS += `pkg-config --cflags sdl2`
CFLAGS = $(CXXFLAGS)
endif
##---------------------------------------------------------------------
## BUILD RULES
##---------------------------------------------------------------------
%.o:%.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<

View File

@ -21,13 +21,17 @@ SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
UNAME_S := $(shell uname -s)
CXXFLAGS = -I../ -I../../
CXXFLAGS += -g -Wall -Wformat
LIBS =
##---------------------------------------------------------------------
## OPENGL LOADER
##---------------------------------------------------------------------
## Using OpenGL loader: gl3w [default]
SOURCES += ../libs/gl3w/GL/gl3w.c
CXXFLAGS = -I../libs/gl3w
CXXFLAGS += -I../libs/gl3w
## Using OpenGL loader: glew
## (This assumes a system-wide installation)
@ -44,28 +48,27 @@ CXXFLAGS = -I../libs/gl3w
ifeq ($(UNAME_S), Linux) #LINUX
ECHO_MESSAGE = "Linux"
LIBS = -lGL -ldl `sdl2-config --libs`
LIBS += -lGL -ldl `sdl2-config --libs`
CXXFLAGS = -I../ -I../../ -I../libs/gl3w `sdl2-config --cflags`
CXXFLAGS += -Wall -Wformat
CXXFLAGS += -I../libs/gl3w `sdl2-config --cflags`
CFLAGS = $(CXXFLAGS)
endif
ifeq ($(UNAME_S), Darwin) #APPLE
ECHO_MESSAGE = "Mac OS X"
LIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs`
LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs`
LIBS += -L/usr/local/lib -L/opt/local/lib
CXXFLAGS = -I../ -I../../ -I../libs/gl3w -I/usr/local/include `sdl2-config --cflags`
CXXFLAGS += -Wall -Wformat
CXXFLAGS += -I../libs/gl3w `sdl2-config --cflags`
CXXFLAGS += -I/usr/local/include -I/opt/local/include
CFLAGS = $(CXXFLAGS)
endif
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
ECHO_MESSAGE = "Windows"
LIBS = -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2`
ECHO_MESSAGE = "MinGW"
LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2`
CXXFLAGS = -I../ -I../../ -I../libs/gl3w `pkg-config --cflags sdl2`
CXXFLAGS += -Wall -Wformat
CXXFLAGS += -I../libs/gl3w `pkg-config --cflags sdl2`
CFLAGS = $(CXXFLAGS)
endif