Make use of implicit makefile rules and GCC's makefile generation so that header changes trigger rebuilds. Refactor common elements into Makefile.common.

This commit is contained in:
James Le Cuirot 2012-10-28 19:51:27 +00:00
parent 35d8afc174
commit f102a33bda
4 changed files with 34 additions and 35 deletions

3
.gitignore vendored
View file

@ -11,5 +11,8 @@
*.la
*.a
# Dependency makefiles
*.d
#Compiled executable
emulationstation

View file

@ -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

25
Makefile.common Normal file
View file

@ -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)

View file

@ -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