Restructured things a bit, got the makefiles working together more intelligently, added uninstall target, removed build-demos.sh

This commit is contained in:
2011-05-26 03:46:16 +00:00
parent ccca81e04e
commit 8652136f75
32 changed files with 1046 additions and 1054 deletions

View File

@@ -9,51 +9,62 @@ ifndef $(OS)
OS=linux OS=linux
endif endif
LIBNAME=game LIBNAME=sdlgame
PROJECTHOME=$(shell pwd) PROJECTHOME=$(shell pwd)
SDL_CFLAGS=$(shell sdl-config --cflags) SDL_CFLAGS=$(shell sdl-config --cflags)
SDL_LDFLAGS=$(shell sdl-config --static-libs) SDL_LDFLAGS=$(shell sdl-config --static-libs)
LIBDIR=/usr/lib LIBDIR=/usr/lib
HEADERDIR=/usr/include HEADERDIR=/usr/include
ADDL_CFLAGS= ADDL_CFLAGS=
OBJDIR=libsdlgame
EXESUFFIX=
LIBSUFFIX=
ifeq "$(OS)" "mingw32" ifeq "$(OS)" "mingw32"
ADDL_CFLAGS=-mwindows ADDL_CFLAGS=-mwindows
EXESUFFIX=".exe"
LIBSUFFIX=".a"
endif endif
ifeq "$(CFG)" "Debug" ifeq "$(CFG)" "Debug"
OUTDIR=Debug OUTDIR=Debug
LIBTARGET=lib$(LIBNAME)-dbg LIBTARGET=lib$(LIBNAME)-dbg$(LIBSUFFIX)
LINKLIB=game-dbg LINKLIB=game-dbg
CXXFLAGS=-pg -I./source -g -ggdb -gstabs -c $(SDL_CFLAGS) $(ADDL_CFLAGS) CXXFLAGS=-pg -I./source -g -ggdb -gstabs -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif endif
ifeq "$(CFG)" "Release" ifeq "$(CFG)" "Release"
OUTDIR=Release OUTDIR=Release
LIBTARGET=lib$(LIBNAME) LIBTARGET=lib$(LIBNAME)$(LIBSUFFIX)
LINKLIB=game LINKLIB=game
CXXFLAGS=-I./source -c $(SDL_CFLAGS) $(ADDL_CFLAGS) CXXFLAGS=-I./source -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif endif
LINKLIBS=-L../../$(CFG) -L$(OUTDIR) -l$(LINKLIB) $(SDL_LDFLAGS) -lSDL_image -lSDL_mixer LINKLIBS=-L../../$(CFG) -L$(OUTDIR) -l$(LINKLIB) $(SDL_LDFLAGS) -lSDL_image -lSDL_mixer
LIBOBJ=$(OUTDIR)/Common.o \ LIBOBJ=$(OBJDIR)/Common.o \
$(OUTDIR)/FontRenderer.o \ $(OBJDIR)/FontRenderer.o \
$(OUTDIR)/Renderable.o \ $(OBJDIR)/Renderable.o \
$(OUTDIR)/SpriteStrip.o \ $(OBJDIR)/SpriteStrip.o \
$(OUTDIR)/Animation.o \ $(OBJDIR)/Animation.o \
$(OUTDIR)/Actor.o \ $(OBJDIR)/Actor.o \
$(OUTDIR)/Display.o \ $(OBJDIR)/Display.o \
$(OUTDIR)/Display2D.o \ $(OBJDIR)/Display2D.o \
$(OUTDIR)/MenuDisplay.o \ $(OBJDIR)/MenuDisplay.o \
$(OUTDIR)/Game.o $(OBJDIR)/Game.o
DEMOS=bouncingball \
exploder \
explodingball \
frictionball \
gravity
CC = gcc CC = gcc
CXX = g++ CXX = g++
LD = $(CXX) LD = $(CXX)
INSTALL = $(shell which install) INSTALL = $(shell which install)
$(OUTDIR)/%.o : %.cpp $(OUTDIR)/%.o : $(OBJDIR)/%.cpp
$(CXX) $(CXXFLAGS) -o $@ $< $(CXX) $(CXXFLAGS) -o $@ $<
ifeq "$(OS)" "macosx" ifeq "$(OS)" "macosx"
all: sharedlib all: sharedlib
@@ -74,12 +85,13 @@ docs:
.PHONY: clean .PHONY: clean
clean: clean:
rm -f $(OUTDIR)/*.o rm -f $(OBJDIR)/*.o
rm -f $(OUTDIR)/$(LIBTARGET).* rm -f $(OUTDIR)/$(LIBTARGET).*
rm -rf docs/*
cd demo && for dir in $(DEMOS); do cd $$dir && make CFG=$(CFG) OS=$(OS) clean; if [ $$? -ne 0 ]; then exit 1 ; fi; cd .. ; done
.PHONY: demos .PHONY: demos
demos: demos:
cd demo && ./build-demos.sh $(CFG) cd demo && for dir in $(DEMOS); do cd $$dir && make CFG=$(CFG) OS=$(OS); if [ $$? -ne 0 ]; then exit 1 ; fi; cd .. ; done
.PHONY: rebuild .PHONY: rebuild
rebuild: rebuild:
@@ -90,8 +102,13 @@ rebuild:
.PHONY: install .PHONY: install
install: install:
$(INSTALL) $(OUTDIR)/$(LIBTARGET)* $(LIBDIR)/ $(INSTALL) $(OUTDIR)/$(LIBTARGET)* $(LIBDIR)/
mkdir -p $(HEADERDIR)/libgame mkdir -p $(HEADERDIR)/libsdlgame
$(INSTALL) *h $(HEADERDIR)/libgame/ $(INSTALL) $(OBJDIR)/*h $(HEADERDIR)/libsdlgame/
.PHONY: uninstall
uninstall:
rm $(LIBDIR)/$(LIBTARGET)*
rm -rf $(HEADERDIR)/libsdlgame
.PHONY: deps .PHONY: deps
deps: deps:

View File

@@ -35,8 +35,8 @@ ifeq "$(CFG)" "Release"
else else
BINTARGET=$(TARGET) BINTARGET=$(TARGET)
endif endif
LINKLIB=game LINKLIB=sdlgame
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS) CXXFLAGS=-I../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif endif
ifeq "$(CFG)" "Debug" ifeq "$(CFG)" "Debug"
OUTDIR=Debug OUTDIR=Debug
@@ -45,8 +45,8 @@ ifeq "$(CFG)" "Debug"
else else
BINTARGET=$(TARGET)-dbg BINTARGET=$(TARGET)-dbg
endif endif
LINKLIB=game-dbg LINKLIB=sdlgame-dbg
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS) CXXFLAGS=-I../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif endif
LINKLIBS=-L../../$(CFG) -L$(LIBDIR) -l$(LINKLIB) $(SDL_LDFLAGS) -lSDL_image -lSDL_mixer -lSDL_gfx -lSDL_ttf LINKLIBS=-L../../$(CFG) -L$(LIBDIR) -l$(LINKLIB) $(SDL_LDFLAGS) -lSDL_image -lSDL_mixer -lSDL_gfx -lSDL_ttf

View File

@@ -1,25 +0,0 @@
#!/bin/bash
BUILTOK=""
BUILTFAIL=""
for dir in $(find . -maxdepth 1 -type d | grep -v "\.$" );
do
echo "Making in $dir "
cd $dir
make CFG=$1 $2
if [ $? -eq 0 ]; then
BUILTOK="$(echo $BUILTOK $dir)"
else
BUILTFAIL="$(echo $BUILTFAIL $dir)"
fi
cd ..
done
echo
echo
echo "OK : $BUILTOK"
echo
echo "FAIL : $BUILTFAIL"

View File

@@ -35,8 +35,8 @@ ifeq "$(CFG)" "Release"
else else
BINTARGET=$(TARGET) BINTARGET=$(TARGET)
endif endif
LINKLIB=game LINKLIB=sdlgame
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS) CXXFLAGS=-I../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif endif
ifeq "$(CFG)" "Debug" ifeq "$(CFG)" "Debug"
OUTDIR=Debug OUTDIR=Debug
@@ -45,8 +45,8 @@ ifeq "$(CFG)" "Debug"
else else
BINTARGET=$(TARGET)-dbg BINTARGET=$(TARGET)-dbg
endif endif
LINKLIB=game-dbg LINKLIB=sdlgame-dbg
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS) CXXFLAGS=-I../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif endif
LINKLIBS=-L../../$(CFG) -L$(LIBDIR) -l$(LINKLIB) $(SDL_LDFLAGS) -lSDL_image -lSDL_mixer -lSDL_gfx -lSDL_ttf LINKLIBS=-L../../$(CFG) -L$(LIBDIR) -l$(LINKLIB) $(SDL_LDFLAGS) -lSDL_image -lSDL_mixer -lSDL_gfx -lSDL_ttf

View File

@@ -35,8 +35,8 @@ ifeq "$(CFG)" "Release"
else else
BINTARGET=$(TARGET) BINTARGET=$(TARGET)
endif endif
LINKLIB=game LINKLIB=sdlgame
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS) CXXFLAGS=-I../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif endif
ifeq "$(CFG)" "Debug" ifeq "$(CFG)" "Debug"
OUTDIR=Debug OUTDIR=Debug
@@ -45,8 +45,8 @@ ifeq "$(CFG)" "Debug"
else else
BINTARGET=$(TARGET)-dbg BINTARGET=$(TARGET)-dbg
endif endif
LINKLIB=game-dbg LINKLIB=sdlgame-dbg
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS) CXXFLAGS=-I../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif endif
LINKLIBS=-L../../$(CFG) -L$(LIBDIR) -l$(LINKLIB) $(SDL_LDFLAGS) -lSDL_image -lSDL_mixer -lSDL_gfx -lSDL_ttf LINKLIBS=-L../../$(CFG) -L$(LIBDIR) -l$(LINKLIB) $(SDL_LDFLAGS) -lSDL_image -lSDL_mixer -lSDL_gfx -lSDL_ttf

View File

@@ -35,8 +35,8 @@ ifeq "$(CFG)" "Release"
else else
BINTARGET=$(TARGET) BINTARGET=$(TARGET)
endif endif
LINKLIB=game LINKLIB=sdlgame
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS) CXXFLAGS=-I../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif endif
ifeq "$(CFG)" "Debug" ifeq "$(CFG)" "Debug"
OUTDIR=Debug OUTDIR=Debug
@@ -45,8 +45,8 @@ ifeq "$(CFG)" "Debug"
else else
BINTARGET=$(TARGET)-dbg BINTARGET=$(TARGET)-dbg
endif endif
LINKLIB=game-dbg LINKLIB=sdlgame-dbg
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS) CXXFLAGS=-I../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif endif
LINKLIBS=-L../../$(CFG) -L$(LIBDIR) -l$(LINKLIB) $(SDL_LDFLAGS) -lSDL_image -lSDL_mixer -lSDL_gfx -lSDL_ttf LINKLIBS=-L../../$(CFG) -L$(LIBDIR) -l$(LINKLIB) $(SDL_LDFLAGS) -lSDL_image -lSDL_mixer -lSDL_gfx -lSDL_ttf

View File

@@ -35,8 +35,8 @@ ifeq "$(CFG)" "Release"
else else
BINTARGET=$(TARGET) BINTARGET=$(TARGET)
endif endif
LINKLIB=game LINKLIB=sdlgame
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS) CXXFLAGS=-I../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif endif
ifeq "$(CFG)" "Debug" ifeq "$(CFG)" "Debug"
OUTDIR=Debug OUTDIR=Debug
@@ -45,8 +45,8 @@ ifeq "$(CFG)" "Debug"
else else
BINTARGET=$(TARGET)-dbg BINTARGET=$(TARGET)-dbg
endif endif
LINKLIB=game-dbg LINKLIB=sdlgame-dbg
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS) CXXFLAGS=-I../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif endif
LINKLIBS=-L../../$(CFG) -L$(LIBDIR) -l$(LINKLIB) $(SDL_LDFLAGS) -lSDL_image -lSDL_mixer -lSDL_gfx -lSDL_ttf LINKLIBS=-L../../$(CFG) -L$(LIBDIR) -l$(LINKLIB) $(SDL_LDFLAGS) -lSDL_image -lSDL_mixer -lSDL_gfx -lSDL_ttf

View File

@@ -1,4 +1,4 @@
#include "libgame.h" #include "libsdlgame.h"
#include <iostream> #include <iostream>
#include <SDL_ttf.h> #include <SDL_ttf.h>
#include <SDL_gfxPrimitives.h> #include <SDL_gfxPrimitives.h>

View File

@@ -29,7 +29,7 @@ protected:
* @class AnimatedRenderable * @class AnimatedRenderable
* @brief A subclass of Renderable for objects that are renderable and animated * @brief A subclass of Renderable for objects that are renderable and animated
* *
* This subclass defines the interface for libgame objects that are both * This subclass defines the interface for libsdlgame objects that are both
* Renderable, but that also perform some kind of internal logic to return * Renderable, but that also perform some kind of internal logic to return
* different surfaces each call. * different surfaces each call.
*/ */