mirror of
https://github.com/Orc/discount.git
synced 2026-09-25 04:10:00 +03:00
Make defining BRANCH depend on the branch; if I'm on the master branch I don't
care about the branch name at all, otherwise I do. So make a little utility
program that I can feed the output from `git describe --all` into and which
returns either nothing (master branch) or "({name})" (with the quotes) if I'm
on branch {name}
This commit is contained in:
+5
-3
@@ -19,7 +19,7 @@ OBJS=mkdio.o markdown.o dumptree.o generate.o \
|
||||
xml.o Csio.o xmlpage.o basename.o emmatch.o \
|
||||
github_flavoured.o setup.o tags.o html5.o flags.o \
|
||||
@AMALLOC@ @H1TITLE@
|
||||
TESTFRAMEWORK=echo cols
|
||||
TESTFRAMEWORK=echo cols branch
|
||||
|
||||
# modules that markdown, makepage, mkd2html, &tc use
|
||||
COMMON=pgm_options.o gethopt.o
|
||||
@@ -76,8 +76,8 @@ $(DESTDIR)$(LIBDIR):
|
||||
@MK_PKGCONFIG@$(DESTDIR)$(PKGDIR):
|
||||
@MK_PKGCONFIG@ @INSTALL_DIR@ $(DESTDIR)$(PKGDIR)
|
||||
|
||||
version.o: version.c VERSION
|
||||
$(CC) $(CFLAGS) -DBRANCH=\"`basename \`git describe --all\``\" -DVERSION=\"`cat VERSION`\" -c version.c
|
||||
version.o: version.c VERSION branch
|
||||
$(CC) $(CFLAGS) -DBRANCH=`./branch \`git describe --all\`` -DVERSION=\"`cat VERSION`\" -c version.c
|
||||
|
||||
VERSION:
|
||||
@true
|
||||
@@ -121,6 +121,8 @@ test: $(PGMS) $(TESTFRAMEWORK) verify
|
||||
@LD_LIBRARY_PATH@=`pwd` sh $$x || exit 1; \
|
||||
done
|
||||
|
||||
branch: tools/branch.c config.h
|
||||
$(CC) -o branch tools/branch.c
|
||||
cols: tools/cols.c config.h
|
||||
$(CC) -o cols tools/cols.c
|
||||
echo: tools/echo.c config.h
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
char *root;
|
||||
|
||||
if ( argc <= 1 )
|
||||
return 0;
|
||||
|
||||
if ( root = strrchr(argv[1], '/') )
|
||||
++root;
|
||||
else
|
||||
root = argv[1];
|
||||
|
||||
if ( strcmp(root, "master" ) != 0 )
|
||||
printf("\"(%s)\"", root);
|
||||
|
||||
return 0;
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#include "config.h"
|
||||
|
||||
char markdown_version[] = "(" BRANCH ") " VERSION
|
||||
char markdown_version[] = BRANCH VERSION
|
||||
#if @TABSTOP@ != 4
|
||||
" TAB=@TABSTOP@"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user