From f102a33bda6998380ecee9c03db60a346debaff5 Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Sun, 28 Oct 2012 19:51:27 +0000 Subject: [PATCH] Make use of implicit makefile rules and GCC's makefile generation so that header changes trigger rebuilds. Refactor common elements into Makefile.common. --- .gitignore | 3 +++ Makefile | 21 +++------------------ Makefile.common | 25 +++++++++++++++++++++++++ Makefile.x86 | 20 +++----------------- 4 files changed, 34 insertions(+), 35 deletions(-) create mode 100644 Makefile.common diff --git a/.gitignore b/.gitignore index 49bb7c60a..74eebcd8f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,8 @@ *.la *.a +# Dependency makefiles +*.d + #Compiled executable emulationstation diff --git a/Makefile b/Makefile index e2d60fd53..53af27c2b 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,4 @@ -CC=g++ -CFLAGS=-c -Wall -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/usr/include/freetype2 -I/usr/include/SDL -I/usr/include -D_RPI_ -LDFLAGS=-L/opt/vc/lib -lbcm_host -lEGL -lGLESv2 -lfreetype -lSDL -lboost_system -lboost_filesystem -lfreeimage -lSDL_mixer -SRCSOURCES=main.cpp Renderer.cpp Renderer_init.cpp Font.cpp Renderer_draw_gl.cpp GuiComponent.cpp InputManager.cpp SystemData.cpp GameData.cpp FolderData.cpp XMLReader.cpp MathExp.cpp components/GuiGameList.cpp components/GuiInputConfig.cpp components/GuiImage.cpp components/GuiMenu.cpp components/GuiTheme.cpp components/GuiFastSelect.cpp components/GuiBox.cpp components/GuiAnimation.cpp AudioManager.cpp Sound.cpp pugiXML/pugixml.cpp -SOURCES=$(addprefix src/,$(SRCSOURCES)) -OBJECTS=$(SOURCES:.cpp=.o) -EXECUTABLE=emulationstation - -all: $(SOURCES) $(EXECUTABLE) - -$(EXECUTABLE): $(OBJECTS) - $(CC) $(OBJECTS) $(LDFLAGS) -o $@ - -.cpp.o: - $(CC) $(CFLAGS) $< -o $@ - -clean: - rm -rf src/*o src/components/*o $(EXECUTABLE) +CPPFLAGS=-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/usr/include/freetype2 -I/usr/include/SDL -D_RPI_ +LIBS=-L/opt/vc/lib -lbcm_host -lEGL -lGLESv2 -lfreetype -lSDL -lboost_system -lboost_filesystem -lfreeimage -lSDL_mixer +include Makefile.common diff --git a/Makefile.common b/Makefile.common new file mode 100644 index 000000000..4bdd59808 --- /dev/null +++ b/Makefile.common @@ -0,0 +1,25 @@ +CXX=g++ +CXXFLAGS=-Wall -g -O2 +LDFLAGS= + +SRC_SOURCES=AudioManager.cpp FolderData.cpp Font.cpp GameData.cpp GuiComponent.cpp InputManager.cpp main.cpp MathExp.cpp Renderer.cpp Renderer_draw_gl.cpp Renderer_init.cpp Sound.cpp SystemData.cpp XMLReader.cpp components/GuiAnimation.cpp components/GuiBox.cpp components/GuiFastSelect.cpp components/GuiGameList.cpp components/GuiImage.cpp components/GuiInputConfig.cpp components/GuiMenu.cpp components/GuiTheme.cpp pugiXML/pugixml.cpp +SOURCES=$(addprefix src/,$(SRC_SOURCES)) +OBJECTS=$(SOURCES:.cpp=.o) +DEPS=$(SOURCES:.cpp=.d) +EXECUTABLE=emulationstation + +all: $(EXECUTABLE) + +$(EXECUTABLE): $(DEPS) $(OBJECTS) + $(CXX) -o $@ $(LDFLAGS) $(OBJECTS) $(LIBS) + +include $(wildcard src/*.d src/components/*.d src/pugiXML/*.d) + +%.d: %.cpp + $(SHELL) -ec '$(CXX) -M $(CPPFLAGS) $< | tr -d "\\\\\n" | sed -e "s|$(*F).o|$(*D)/& $@|" -e "s|: \(.*\)|: \$$\(wildcard \1\)|" > $@' + +.PHONY: clean + +clean: + rm -f src/*.[do] src/components/*.[do] src/pugiXML/*.[do] $(EXECUTABLE) + diff --git a/Makefile.x86 b/Makefile.x86 index 03fcd59ae..1217a1f00 100644 --- a/Makefile.x86 +++ b/Makefile.x86 @@ -1,18 +1,4 @@ -CC=g++ -CFLAGS=-c -Wall -I/usr/include/freetype2 -I/usr/include/SDL -I/usr/include -D_DESKTOP_ -g -LDFLAGS=-lGL -lfreetype -lSDL -lboost_system -lboost_filesystem -lfreeimage -lSDL_mixer -SRCSOURCES=main.cpp Renderer.cpp Renderer_init.cpp Font.cpp Renderer_draw_gl.cpp GuiComponent.cpp InputManager.cpp SystemData.cpp GameData.cpp FolderData.cpp XMLReader.cpp MathExp.cpp components/GuiGameList.cpp components/GuiInputConfig.cpp components/GuiImage.cpp components/GuiMenu.cpp components/GuiTheme.cpp components/GuiFastSelect.cpp components/GuiBox.cpp components/GuiAnimation.cpp Sound.cpp AudioManager.cpp pugiXML/pugixml.cpp -SOURCES=$(addprefix src/,$(SRCSOURCES)) -OBJECTS=$(SOURCES:.cpp=.o) -EXECUTABLE=emulationstation +CPPFLAGS=-I/usr/include/freetype2 -I/usr/include/SDL -D_DESKTOP_ +LIBS=-lGL -lfreetype -lSDL -lboost_system -lboost_filesystem -lfreeimage -lSDL_mixer -all: $(SOURCES) $(EXECUTABLE) - -$(EXECUTABLE): $(OBJECTS) - $(CC) $(OBJECTS) $(LDFLAGS) -o $@ - -.cpp.o: - $(CC) $(CFLAGS) $< -o $@ - -clean: - rm -rf src/*o src/components/*o $(EXECUTABLE) +include Makefile.common