Makefile: Fix git tag issues
authorMichel Pollet <buserror@gmail.com>
Tue, 30 Oct 2012 15:10:42 +0000 (15:10 +0000)
committerMichel Pollet <buserror@gmail.com>
Tue, 30 Oct 2012 15:10:42 +0000 (15:10 +0000)
+ Pick the correct tag for the version number
+ Do not fail if git is not there
+ Add the version to the config file

Signed-off-by: Michel Pollet <buserror@gmail.com>
simavr/Makefile

index 4ade137..000e146 100644 (file)
 #      You should have received a copy of the GNU General Public License
 #      along with simavr.  If not, see <http://www.gnu.org/licenses/>.
 
-SIMAVR_VERSION = ${shell git tag |tail -1|sed 's/[^0-9]*//'}
+SHELL                  := ${shell which bash}
+SIMAVR_VERSION := ${shell \
+       { git log -1 --tags --simplify-by-decoration --pretty="format:%d"|\
+               sed -e 's/[\(\) ]//g'; } || \
+       echo "unknown" }
 SIMAVR_REVISION        = 2
 
 target = run_avr
 
 CFLAGS += -Werror
-# tracing id useful especialy if you develop simavr core.
+# tracing is useful especialy if you develop simavr core.
 # it otherwise eat quite a bit of few cycles, even disabled
 #CFLAGS        += -DCONFIG_SIMAVR_TRACE=1
 
@@ -30,9 +34,9 @@ all:  obj config libsimavr ${target}
 
 include ../Makefile.common
 
-cores  = ${wildcard cores/*.c}
-sim            = ${wildcard sim/sim_*.c} ${wildcard sim/avr_*.c}
-sim_o  = ${patsubst sim/%.c, ${OBJ}/%.o, ${sim}}
+cores  := ${wildcard cores/*.c}
+sim            := ${wildcard sim/sim_*.c} ${wildcard sim/avr_*.c}
+sim_o  := ${patsubst sim/%.c, ${OBJ}/%.o, ${sim}}
 
 VPATH  = cores
 VPATH  += sim
@@ -108,7 +112,7 @@ endif
 # in simavr officialy, this section shall diseapear
 debian: 
        rm -rf /tmp/simavr-tmp && mkdir -p /tmp/simavr-tmp/usr && \
-       make install DESTDIR=/tmp/simavr-tmp/usr && \
+       make cleam; make install DESTDIR=/tmp/simavr-tmp/usr RELEASE=1 && \
        (cd /tmp/simavr-tmp && \
        fpm -s dir -t deb -C /tmp/simavr-tmp -n libsimavr -v $(SIMAVR_VERSION) \
                --iteration $(SIMAVR_REVISION) \
@@ -159,6 +163,7 @@ sim_core_config.h ${OBJ}/cores.deps: $(cores) Makefile
        done ; \
        ( printf "// Autogenerated do not edit\n"; \
          printf "#ifndef __SIM_CORE_CONFIG_H__\n#define __SIM_CORE_CONFIG_H__\n\n"; \
+         printf "#define CONFIG_SIMAVR_VERSION \"${SIMAVR_VERSION}\"\n"; \
          printf "$$conf\n"; \
          printf "#endif\n"; \
        ) >sim_core_config.h