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
endif
LIBNAME=game
LIBNAME=sdlgame
PROJECTHOME=$(shell pwd)
SDL_CFLAGS=$(shell sdl-config --cflags)
SDL_LDFLAGS=$(shell sdl-config --static-libs)
LIBDIR=/usr/lib
HEADERDIR=/usr/include
ADDL_CFLAGS=
OBJDIR=libsdlgame
EXESUFFIX=
LIBSUFFIX=
ifeq "$(OS)" "mingw32"
ADDL_CFLAGS=-mwindows
EXESUFFIX=".exe"
LIBSUFFIX=".a"
endif
ifeq "$(CFG)" "Debug"
OUTDIR=Debug
LIBTARGET=lib$(LIBNAME)-dbg
LIBTARGET=lib$(LIBNAME)-dbg$(LIBSUFFIX)
LINKLIB=game-dbg
CXXFLAGS=-pg -I./source -g -ggdb -gstabs -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
ifeq "$(CFG)" "Release"
OUTDIR=Release
LIBTARGET=lib$(LIBNAME)
LIBTARGET=lib$(LIBNAME)$(LIBSUFFIX)
LINKLIB=game
CXXFLAGS=-I./source -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
LINKLIBS=-L../../$(CFG) -L$(OUTDIR) -l$(LINKLIB) $(SDL_LDFLAGS) -lSDL_image -lSDL_mixer
LIBOBJ=$(OUTDIR)/Common.o \
$(OUTDIR)/FontRenderer.o \
$(OUTDIR)/Renderable.o \
$(OUTDIR)/SpriteStrip.o \
$(OUTDIR)/Animation.o \
$(OUTDIR)/Actor.o \
$(OUTDIR)/Display.o \
$(OUTDIR)/Display2D.o \
$(OUTDIR)/MenuDisplay.o \
$(OUTDIR)/Game.o
LIBOBJ=$(OBJDIR)/Common.o \
$(OBJDIR)/FontRenderer.o \
$(OBJDIR)/Renderable.o \
$(OBJDIR)/SpriteStrip.o \
$(OBJDIR)/Animation.o \
$(OBJDIR)/Actor.o \
$(OBJDIR)/Display.o \
$(OBJDIR)/Display2D.o \
$(OBJDIR)/MenuDisplay.o \
$(OBJDIR)/Game.o
DEMOS=bouncingball \
exploder \
explodingball \
frictionball \
gravity
CC = gcc
CXX = g++
LD = $(CXX)
INSTALL = $(shell which install)
$(OUTDIR)/%.o : %.cpp
$(OUTDIR)/%.o : $(OBJDIR)/%.cpp
$(CXX) $(CXXFLAGS) -o $@ $<
ifeq "$(OS)" "macosx"
all: sharedlib
@@ -74,12 +85,13 @@ docs:
.PHONY: clean
clean:
rm -f $(OUTDIR)/*.o
rm -f $(OBJDIR)/*.o
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
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
rebuild:
@@ -90,8 +102,13 @@ rebuild:
.PHONY: install
install:
$(INSTALL) $(OUTDIR)/$(LIBTARGET)* $(LIBDIR)/
mkdir -p $(HEADERDIR)/libgame
$(INSTALL) *h $(HEADERDIR)/libgame/
mkdir -p $(HEADERDIR)/libsdlgame
$(INSTALL) $(OBJDIR)/*h $(HEADERDIR)/libsdlgame/
.PHONY: uninstall
uninstall:
rm $(LIBDIR)/$(LIBTARGET)*
rm -rf $(HEADERDIR)/libsdlgame
.PHONY: deps
deps:

View File

@@ -35,8 +35,8 @@ ifeq "$(CFG)" "Release"
else
BINTARGET=$(TARGET)
endif
LINKLIB=game
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
LINKLIB=sdlgame
CXXFLAGS=-I../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
ifeq "$(CFG)" "Debug"
OUTDIR=Debug
@@ -45,8 +45,8 @@ ifeq "$(CFG)" "Debug"
else
BINTARGET=$(TARGET)-dbg
endif
LINKLIB=game-dbg
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
LINKLIB=sdlgame-dbg
CXXFLAGS=-I../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
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
BINTARGET=$(TARGET)
endif
LINKLIB=game
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
LINKLIB=sdlgame
CXXFLAGS=-I../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
ifeq "$(CFG)" "Debug"
OUTDIR=Debug
@@ -45,8 +45,8 @@ ifeq "$(CFG)" "Debug"
else
BINTARGET=$(TARGET)-dbg
endif
LINKLIB=game-dbg
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
LINKLIB=sdlgame-dbg
CXXFLAGS=-I../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
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
BINTARGET=$(TARGET)
endif
LINKLIB=game
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
LINKLIB=sdlgame
CXXFLAGS=-I../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
ifeq "$(CFG)" "Debug"
OUTDIR=Debug
@@ -45,8 +45,8 @@ ifeq "$(CFG)" "Debug"
else
BINTARGET=$(TARGET)-dbg
endif
LINKLIB=game-dbg
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
LINKLIB=sdlgame-dbg
CXXFLAGS=-I../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
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
BINTARGET=$(TARGET)
endif
LINKLIB=game
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
LINKLIB=sdlgame
CXXFLAGS=-I../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
ifeq "$(CFG)" "Debug"
OUTDIR=Debug
@@ -45,8 +45,8 @@ ifeq "$(CFG)" "Debug"
else
BINTARGET=$(TARGET)-dbg
endif
LINKLIB=game-dbg
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
LINKLIB=sdlgame-dbg
CXXFLAGS=-I../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
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
BINTARGET=$(TARGET)
endif
LINKLIB=game
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
LINKLIB=sdlgame
CXXFLAGS=-I../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
ifeq "$(CFG)" "Debug"
OUTDIR=Debug
@@ -45,8 +45,8 @@ ifeq "$(CFG)" "Debug"
else
BINTARGET=$(TARGET)-dbg
endif
LINKLIB=game-dbg
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
LINKLIB=sdlgame-dbg
CXXFLAGS=-I../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
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 <SDL_ttf.h>
#include <SDL_gfxPrimitives.h>

View File

@@ -29,7 +29,7 @@ protected:
* @class AnimatedRenderable
* @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
* different surfaces each call.
*/