From 9c0a00dd4838780c8efb41924584a11aa0b44b1a Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Sun, 21 Aug 2011 15:14:49 -0400 Subject: [PATCH] Created version.h This is an auto-generated file that provides a way to get the current version. --- .gitignore | 1 + Makefile | 25 ++++++++++++++++++++----- scripts/make_version.sh | 26 ++++++++++++++++++++++++++ scripts/version.tmpl | 23 +++++++++++++++++++++++ 4 files changed, 70 insertions(+), 5 deletions(-) create mode 100755 scripts/make_version.sh create mode 100644 scripts/version.tmpl diff --git a/.gitignore b/.gitignore index a80f905c..de1fb624 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.o *.swp ocarina +include/version.h diff --git a/Makefile b/Makefile index 1b64ef4a..39dca45c 100644 --- a/Makefile +++ b/Makefile @@ -1,26 +1,41 @@ +MAJOR = 5 +MINOR = 0 +BUG = 0 +DEBUG = y + export CC = g++ -export CFLAGS = -Wall -Werror -g -O2 export INCLUDE = -I$(CURDIR)/include export GTK = `pkg-config --cflags --libs gtk+-2.0` export GST = `pkg-config --cflags --libs gstreamer-0.10` export LINK = $(GST) $(GTK) -export BUILD = $(CC) $(CFLAGS) $(INCLUDE) export SRCDIR = $(CURDIR) +export MAKEFLAGS = --no-print-directory + DIRS = libsaria gui CLEANDIRS = $(DIRS:%=clean-%) -.PHONY: all $(DIRS) clean $(CLEANDIRS) +ifeq ($(DEBUG), y) + export CFLAGS = -Wall -Werror -g +else + export CFLAGS = -O2 +endif -all: $(DIRS) +export BUILD = $(CC) $(CFLAGS) $(INCLUDE) +.PHONY: all $(DIRS) clean $(CLEANDIRS) version.h + +all: version.h $(DIRS) $(BUILD) $(shell find . | grep "\.o$$") -o ocarina $(LINK) +version.h: + sh scripts/make_version.sh $(SRCDIR) $(MAJOR) $(MINOR) $(BUG) $(DEBUG) + $(DIRS): $(MAKE) -f $(SRCDIR)/scripts/Makefile -C $@ clean: $(CLEANDIRS) - rm -f *.o a.out + rm -f *.o ocarina include/version.h $(CLEANDIRS): $(MAKE) -f $(SRCDIR)/scripts/Makefile -C $(@:clean-%=%) clean diff --git a/scripts/make_version.sh b/scripts/make_version.sh new file mode 100755 index 00000000..990b0fe3 --- /dev/null +++ b/scripts/make_version.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +SRCDIR=$1 +MAJOR=$2 +MINOR=$3 +BUG=$4 +EXTRA="" + +if [ "$5" == "y" ]; then + EXTRA="-debug" +fi + +FILE=$SRCDIR/include/version.h +rm -f $FILE +cp $SRCDIR/scripts/version.tmpl $FILE + +function replace +{ + sed "s/$1/$2/" $FILE > $FILE.new + mv $FILE.new $FILE +} + +replace AAAAA $MAJOR +replace BBBBB $MINOR +replace CCCCC $BUG +replace DDDDD $EXTRA diff --git a/scripts/version.tmpl b/scripts/version.tmpl new file mode 100644 index 00000000..80235d63 --- /dev/null +++ b/scripts/version.tmpl @@ -0,0 +1,23 @@ +#ifndef OCARINA_VERSION_H +#define OCARINA_VERSION_H + +#include +#include +using namespace std; + +unsigned int MAJOR = AAAAA; +unsigned int MINOR = BBBBB; +unsigned int BUG = CCCCC; +string EXTRA = "DDDDD"; + +string vers_str() +{ + stringstream stream; + stream << MAJOR << "." << MINOR; + if (BUG != 0) + stream << "." << BUG; + if (EXTRA != "") + stream << EXTRA; + return stream.str(); +} +#endif /* OCARINA_VERSION_H */