Created version.h

This is an auto-generated file that provides a way to get the current
version.
This commit is contained in:
Bryan Schumaker 2011-08-21 15:14:49 -04:00
parent ae5b3a358e
commit 9c0a00dd48
4 changed files with 70 additions and 5 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
*.o
*.swp
ocarina
include/version.h

View File

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

26
scripts/make_version.sh Executable file
View File

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

23
scripts/version.tmpl Normal file
View File

@ -0,0 +1,23 @@
#ifndef OCARINA_VERSION_H
#define OCARINA_VERSION_H
#include <string>
#include <sstream>
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 */