Skip to content

Commit

Permalink
Fix gen/version.c generation for non-git builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
darkk committed Jan 3, 2012
1 parent 08f9460 commit f9b207a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ SRCS := $(OBJS:.o=.c)
CONF := config.h
DEPS := .depend
OUT := redsocks
VERSION := 0.2

LIBS := -levent
CFLAGS += -g -O2
Expand All @@ -29,15 +30,18 @@ $(CONF):
;; \
esac

# Dependency on .git is useful to rebuild `version.c' after commit
# FIXME: non-git builds should be supported.
gen/version.c: *.c *.h gen/.build .git
# Dependency on .git is useful to rebuild `version.c' after commit, but it breaks non-git builds.
gen/version.c: *.c *.h gen/.build
rm -f $@.tmp
echo '/* this file is auto-generated during build */' > $@.tmp
echo '#include "../version.h"' > $@.tmp
echo 'const char* redsocks_version = "redsocks.git/"' >> $@.tmp
echo '"'`git describe --tags`'"' >> $@.tmp
[ `git status --porcelain | grep -v -c '^??'` != 0 ] && { echo '"-unclean"' >> $@.tmp; } || true
echo '#include "../version.h"' >> $@.tmp
echo 'const char* redsocks_version = ' >> $@.tmp
if [ -d .git ]; then \
echo '"redsocks.git/'`git describe --tags`'"'; \
[ `git status --porcelain | grep -v -c '^??'` != 0 ] && { echo '"-unclean"' ; } \
else \
echo '"redsocks/$(VERSION)"'; \
fi >> $@.tmp
echo ';' >> $@.tmp
mv -f $@.tmp $@

Expand Down

0 comments on commit f9b207a

Please sign in to comment.