1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-19 06:31:31 +00:00

Print the SVN version number when -V or --version is used.

git-svn-id: svn://svn.cc65.org/cc65/trunk@4100 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2009-08-31 17:17:18 +00:00
parent b3f3b21f80
commit b829bda8cb
4 changed files with 110 additions and 8 deletions

View File

@ -64,8 +64,9 @@
#include "macrotab.h" #include "macrotab.h"
#include "output.h" #include "output.h"
#include "scanner.h" #include "scanner.h"
#include "standard.h"
#include "segments.h" #include "segments.h"
#include "standard.h"
#include "svnversion.h"
@ -670,8 +671,9 @@ static void OptVersion (const char* Opt attribute ((unused)),
/* Print the compiler version */ /* Print the compiler version */
{ {
fprintf (stderr, fprintf (stderr,
"cc65 V%u.%u.%u\n", "cc65 V%u.%u.%u\n"
VER_MAJOR, VER_MINOR, VER_PATCH); "SVN version: %s\n",
VER_MAJOR, VER_MINOR, VER_PATCH, SVNVersion);
} }

View File

@ -4,6 +4,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# The executable to build # The executable to build
@ -22,6 +23,17 @@ CC=gcc
EBIND=emxbind EBIND=emxbind
LDFLAGS=-lm LDFLAGS=-lm
# Determine the svn version number if possible
ifneq "$(shell which svnversion 2>/dev/null)" ""
ifneq "$(wildcard .svn)" ""
SVNVERSION=$(shell svnversion)
else
SVNVERSION=unknown
endif
else
SVNVERSION=unknown
endif
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Object files and libraries to link # Object files and libraries to link
@ -86,6 +98,7 @@ OBJS = anonname.o \
stdfunc.o \ stdfunc.o \
stdnames.o \ stdnames.o \
stmt.o \ stmt.o \
svnversion.o \
swstmt.o \ swstmt.o \
symentry.o \ symentry.o \
symtab.o \ symtab.o \
@ -104,7 +117,7 @@ LIBS = $(COMMON)/common.a
# Main target - must be first # Main target - must be first
.PHONY: all .PHONY: all
ifeq (.depend,$(wildcard .depend)) ifeq (.depend,$(wildcard .depend))
all: $(EXE) all: svnversion $(EXE)
include .depend include .depend
else else
all: depend all: depend
@ -112,14 +125,23 @@ all: depend
endif endif
$(EXE): $(OBJS) $(LIBS) $(EXE): $(OBJS) $(LIBS)
$(CC) $^ $(LDFLAGS) -o $@ $(CC) $(OBJS) $(LIBS) $(LDFLAGS) -o $@
@if [ $(OS2_SHELL) ] ; then $(EBIND) $(EXE) ; fi @if [ $(OS2_SHELL) ] ; then $(EBIND) $(EXE) ; fi
.PHONY: svnversion
svnversion:
@$(RM) svnversion.c
@echo "/* This file is auto-generated - do not modify! */" >> svnversion.c
@echo "" >> svnversion.c
@echo "const char SVNVersion[] = \"$(SVNVERSION)\";" >> svnversion.c
svnversion.c: svnversion
clean: clean:
$(RM) *~ core.* *.map $(RM) *~ core.* *.map
zap: clean zap: clean
$(RM) *.o $(EXE) .depend $(RM) $(OBJS) $(EXE) .depend svnversion.c
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Make the dependencies # Make the dependencies

View File

@ -27,6 +27,17 @@ CFLAGS = -d1 -onatx -zp4 -5 -zq -w2 -i=..\\common
# Target files # Target files
EXE = cc65.exe EXE = cc65.exe
# Determine the svn version number if possible
ifneq "$(shell which svnversion 2>/dev/null)" ""
ifneq "$(wildcard .svn)" ""
SVNVERSION=$(shell svnversion)
else
SVNVERSION=unknown
endif
else
SVNVERSION=unknown
endif
# Create NT programs by default # Create NT programs by default
ifndef TARGET ifndef TARGET
TARGET = NT TARGET = NT
@ -121,6 +132,7 @@ OBJS = anonname.obj \
stdfunc.obj \ stdfunc.obj \
stdnames.obj \ stdnames.obj \
stmt.obj \ stmt.obj \
svnversion.obj \
swstmt.obj \ swstmt.obj \
symentry.obj \ symentry.obj \
symtab.obj \ symtab.obj \
@ -136,7 +148,7 @@ LIBS = ../common/common.lib
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Main targets # Main targets
all: $(EXE) all: svnversion $(EXE)
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -152,11 +164,20 @@ $(EXE): $(OBJS) $(LIBS)
@$(LD) system $(SYSTEM) @$(LNKCFG) @$(LD) system $(SYSTEM) @$(LNKCFG)
@rm $(LNKCFG) @rm $(LNKCFG)
.PHONY: svnversion
svnversion:
@$(RM) svnversion.c
@echo "/* This file is auto-generated - do not modify! */" >> svnversion.c
@echo "" >> svnversion.c
@echo "const char SVNVersion[] = \"$(SVNVERSION)\";" >> svnversion.c
svnversion.c: svnversion
clean: clean:
@rm -f *~ core @rm -f *~ core
zap: clean zap: clean
@rm -f *.obj $(EXE) @rm -f $(OBJS) $(EXE) svnversion.c
strip: strip:
@-$(WSTRIP) $(EXE) @-$(WSTRIP) $(EXE)

57
src/cc65/svnversion.h Normal file
View File

@ -0,0 +1,57 @@
/*****************************************************************************/
/* */
/* svnversion.h */
/* */
/* Keep track of the svn version */
/* */
/* */
/* */
/* (C) 1998-2008 Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* warranty. In no event will the authors be held liable for any damages */
/* arising from the use of this software. */
/* */
/* Permission is granted to anyone to use this software for any purpose, */
/* including commercial applications, and to alter it and redistribute it */
/* freely, subject to the following restrictions: */
/* */
/* 1. The origin of this software must not be misrepresented; you must not */
/* claim that you wrote the original software. If you use this software */
/* in a product, an acknowledgment in the product documentation would be */
/* appreciated but is not required. */
/* 2. Altered source versions must be plainly marked as such, and must not */
/* be misrepresented as being the original software. */
/* 3. This notice may not be removed or altered from any source */
/* distribution. */
/* */
/*****************************************************************************/
#ifndef SVNVERSION_H
#define SVNVERSION_H
/*****************************************************************************/
/* Data */
/*****************************************************************************/
/* This variable contains the SVN version string */
extern const char SVNVersion[];
/* End of svnversion.h */
#endif