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

View File

@ -1,6 +1,6 @@
# #
# Cross Platform Makefile # 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: # Linux:
# apt-get install freeglut3-dev # apt-get install freeglut3-dev
@ -10,41 +10,44 @@
#CXX = clang++ #CXX = clang++
EXE = example_glut_opengl2 EXE = example_glut_opengl2
SOURCES = main.cpp SOURCES = main.cpp
SOURCES += ../imgui_impl_glut.cpp ../imgui_impl_opengl2.cpp SOURCES += ../imgui_impl_glut.cpp ../imgui_impl_opengl2.cpp
SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
UNAME_S := $(shell uname -s) UNAME_S := $(shell uname -s)
CXXFLAGS = -I../ -I../../
CXXFLAGS += -g -Wall -Wformat
LIBS =
##---------------------------------------------------------------------
## BUILD FLAGS PER PLATFORM
##---------------------------------------------------------------------
ifeq ($(UNAME_S), Linux) #LINUX ifeq ($(UNAME_S), Linux) #LINUX
ECHO_MESSAGE = "Linux" ECHO_MESSAGE = "Linux"
LIBS = -lGL -lglut LIBS += -lGL -lglut
CXXFLAGS = -I ../ -I../..
CXXFLAGS += -Wall -Wformat
CFLAGS = $(CXXFLAGS) CFLAGS = $(CXXFLAGS)
endif endif
ifeq ($(UNAME_S), Darwin) #APPLE ifeq ($(UNAME_S), Darwin) #APPLE
ECHO_MESSAGE = "Mac OS X" 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 += -I/usr/local/include -I/opt/local/include
CXXFLAGS += -Wall -Wformat
CFLAGS = $(CXXFLAGS) CFLAGS = $(CXXFLAGS)
endif endif
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW) ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
ECHO_MESSAGE = "Windows" ECHO_MESSAGE = "MinGW"
LIBS = -lgdi32 -lopengl32 -limm32 -lglut LIBS += -lgdi32 -lopengl32 -limm32 -lglut
CFLAGS = $(CXXFLAGS)
CXXFLAGS = -I ../ -I../../
CXXFLAGS += -Wall -Wformat
CFLAGS = $(CXXFLAGS)
endif endif
##---------------------------------------------------------------------
## BUILD RULES
##---------------------------------------------------------------------
%.o:%.cpp %.o:%.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $< $(CXX) $(CXXFLAGS) -c -o $@ $<

View File

@ -15,40 +15,49 @@
#CXX = clang++ #CXX = clang++
EXE = example_sdl_opengl2 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 SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
UNAME_S := $(shell uname -s) UNAME_S := $(shell uname -s)
CXXFLAGS = -I../ -I../../
CXXFLAGS += -g -Wall -Wformat
LIBS =
##---------------------------------------------------------------------
## BUILD FLAGS PER PLATFORM
##---------------------------------------------------------------------
ifeq ($(UNAME_S), Linux) #LINUX ifeq ($(UNAME_S), Linux) #LINUX
ECHO_MESSAGE = "Linux" ECHO_MESSAGE = "Linux"
LIBS = -lGL -ldl `sdl2-config --libs` LIBS += -lGL -ldl `sdl2-config --libs`
CXXFLAGS = -I ../ -I../../ `sdl2-config --cflags` CXXFLAGS += `sdl2-config --cflags`
CXXFLAGS += -Wall -Wformat
CFLAGS = $(CXXFLAGS) CFLAGS = $(CXXFLAGS)
endif endif
ifeq ($(UNAME_S), Darwin) #APPLE ifeq ($(UNAME_S), Darwin) #APPLE
ECHO_MESSAGE = "Mac OS X" 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 += `sdl2-config --cflags`
CXXFLAGS += -Wall -Wformat CXXFLAGS += -I/usr/local/include -I/opt/local/include
CFLAGS = $(CXXFLAGS) CFLAGS = $(CXXFLAGS)
endif endif
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW) ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
ECHO_MESSAGE = "Windows" ECHO_MESSAGE = "MinGW"
LIBS = -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2` LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2`
CXXFLAGS = -I ../ -I../../ `pkg-config --cflags sdl2` CXXFLAGS += `pkg-config --cflags sdl2`
CXXFLAGS += -Wall -Wformat CFLAGS = $(CXXFLAGS)
CFLAGS = $(CXXFLAGS)
endif endif
##---------------------------------------------------------------------
## BUILD RULES
##---------------------------------------------------------------------
%.o:%.cpp %.o:%.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $< $(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)))) OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
UNAME_S := $(shell uname -s) UNAME_S := $(shell uname -s)
CXXFLAGS = -I../ -I../../
CXXFLAGS += -g -Wall -Wformat
LIBS =
##--------------------------------------------------------------------- ##---------------------------------------------------------------------
## OPENGL LOADER ## OPENGL LOADER
##--------------------------------------------------------------------- ##---------------------------------------------------------------------
## Using OpenGL loader: gl3w [default] ## Using OpenGL loader: gl3w [default]
SOURCES += ../libs/gl3w/GL/gl3w.c SOURCES += ../libs/gl3w/GL/gl3w.c
CXXFLAGS = -I../libs/gl3w CXXFLAGS += -I../libs/gl3w
## Using OpenGL loader: glew ## Using OpenGL loader: glew
## (This assumes a system-wide installation) ## (This assumes a system-wide installation)
@ -44,28 +48,27 @@ CXXFLAGS = -I../libs/gl3w
ifeq ($(UNAME_S), Linux) #LINUX ifeq ($(UNAME_S), Linux) #LINUX
ECHO_MESSAGE = "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 += -I../libs/gl3w `sdl2-config --cflags`
CXXFLAGS += -Wall -Wformat
CFLAGS = $(CXXFLAGS) CFLAGS = $(CXXFLAGS)
endif endif
ifeq ($(UNAME_S), Darwin) #APPLE ifeq ($(UNAME_S), Darwin) #APPLE
ECHO_MESSAGE = "Mac OS X" 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 += -I../libs/gl3w `sdl2-config --cflags`
CXXFLAGS += -Wall -Wformat CXXFLAGS += -I/usr/local/include -I/opt/local/include
CFLAGS = $(CXXFLAGS) CFLAGS = $(CXXFLAGS)
endif endif
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW) ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
ECHO_MESSAGE = "Windows" ECHO_MESSAGE = "MinGW"
LIBS = -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2` LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2`
CXXFLAGS = -I../ -I../../ -I../libs/gl3w `pkg-config --cflags sdl2` CXXFLAGS += -I../libs/gl3w `pkg-config --cflags sdl2`
CXXFLAGS += -Wall -Wformat
CFLAGS = $(CXXFLAGS) CFLAGS = $(CXXFLAGS)
endif endif