~sircmpwn/harec

a66a324f2394fef9b0d5adcd658bf6cb1ababbc6 — Ember Sawady 1 year, 4 months ago efc9cc3
Add harec -v

Signed-off-by: Ember Sawady <ecs@d2evs.net>
3 files changed, 30 insertions(+), 3 deletions(-)

M config.sh
A scripts/version
M src/main.c
M config.sh => config.sh +3 -1
@@ 238,7 238,8 @@ CFLAGS=${CFLAGS} \\
	-DPREFIX='"\$(PREFIX)"' \\
	-DLIBDIR='"\$(LIBDIR)"' \\
	-DVARLIBDIR='"\$(VARLIBDIR)"' \\
	-DSYSCONFDIR='"\$(SYSCONFDIR)"'
	-DSYSCONFDIR='"\$(SYSCONFDIR)"' \\
	-DVERSION='"'"\$\$(./scripts/version)"'"'
LDFLAGS=${LDFLAGS}
HARECACHE=./mod



@@ 282,6 283,7 @@ EOF
	populate "$srcdir/doc"
	populate "$srcdir/include"
	populate "$srcdir/rt"
	populate "$srcdir/scripts"
	populate "$srcdir/src"
	populate "$srcdir/tests"
	populate "$srcdir/testmod"

A scripts/version => scripts/version +22 -0
@@ 0,0 1,22 @@
#!/bin/sh
# Distro packagers may set the LOCALVER variable to add their distribution to
# the version, e.g. 1.0-alpine.
VERSION=${VERSION:-dev}

ver=$(git describe 2>/dev/null)
if [ $? -ne 0 ]
then
	ver="dev+$(git log -1 --format='%h' 2>/dev/null)"
	if [ $? -ne 0 ]
	then
		# git presumed unavailable
		ver=$VERSION
	fi
fi

localver=${LOCALVER:-}
if [ ${#localver} != 0 ]
then
	ver="$ver-$localver"
fi
echo $ver

M src/main.c => src/main.c +5 -2
@@ 20,7 20,7 @@ static void
usage(const char *argv_0)
{
	xfprintf(stderr,
		"Usage: %s [-a arch] [-D ident[:type]=value] [-o output] [-T] [-t typedefs] [-N namespace] input.ha...\n",
		"Usage: %s [-v] [-a arch] [-D ident[:type]=value] [-o output] [-T] [-t typedefs] [-N namespace] input.ha...\n",
		argv_0);
}



@@ 65,7 65,7 @@ main(int argc, char *argv[])
	struct ast_global_decl *defines = NULL, **next_def = &defines;

	int c;
	while ((c = getopt(argc, argv, "a:D:ho:Tt:N:")) != -1) {
	while ((c = getopt(argc, argv, "a:D:ho:Tt:N:v")) != -1) {
		switch (c) {
		case 'a':
			target = optarg;


@@ 97,6 97,9 @@ main(int argc, char *argv[])
				lex_finish(&lexer);
			}
			break;
		case 'v':
			printf("harec %s\n", VERSION);
			return EXIT_SUCCESS;
		case 'h':
		default:
			usage(argv[0]);