Adding version generation script for Makefile.
This commit is contained in:
parent
39b8fb640f
commit
d779db6715
3 changed files with 35 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,5 +1,6 @@
|
|||
.*
|
||||
*.o
|
||||
VERSION_FILE
|
||||
dlight
|
||||
dlight-*
|
||||
config
|
||||
|
|
|
|||
17
Makefile
17
Makefile
|
|
@ -1,4 +1,10 @@
|
|||
|
||||
all::
|
||||
|
||||
VERSION_FILE : FORCE
|
||||
@$(SHELL) VERSION-GEN $@
|
||||
-include VERSION_FILE
|
||||
|
||||
CC = gcc
|
||||
LDFLAGS = -lxml2 -lcurl -lpcre
|
||||
CFLAGS = -g -Wall -I/usr/include/libxml2
|
||||
|
|
@ -9,7 +15,7 @@ ifeq ($(DEBUG), 1)
|
|||
CFLAGS +=-D__DEBUG__
|
||||
endif
|
||||
|
||||
all : $(PROGRAMS)
|
||||
all:: $(PROGRAMS)
|
||||
|
||||
install : $(PROGRAMS)
|
||||
cp $^ $(HOME)/bin/
|
||||
|
|
@ -24,5 +30,14 @@ dlight-filter-check: filter-check.o filter.o error.o version.o
|
|||
dlight-% : %.o
|
||||
$(CC) $(LDFLAGS) -o $@ $^
|
||||
|
||||
version.o : VERSION_FILE FORCE
|
||||
version.o : EXTRA_CFLAGS = -DDLIGHT_VERSION=\"$(VERSION)\"
|
||||
|
||||
%.o : %.c
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
|
||||
|
||||
clean :
|
||||
$(RM) *.o $(PROGRAMS)
|
||||
$(RM) VERSION_FILE
|
||||
|
||||
FORCE:
|
||||
|
|
|
|||
18
VERSION-GEN
Normal file
18
VERSION-GEN
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/sh
|
||||
|
||||
VERSION=$(git describe --always --tags --match "v[0-9]*" HEAD 2>/dev/null)
|
||||
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
VERSION="${VERSION}-dirty"
|
||||
fi
|
||||
|
||||
if [ -f "${1}" ]; then
|
||||
OLD=$(cat ${1} | sed 's/VERSION = //')
|
||||
else
|
||||
OLD=unset
|
||||
fi
|
||||
|
||||
if [ "${VERSION}" != "${OLD}" ]; then
|
||||
#echo >&2 "VERSION = ${VERSION}"
|
||||
echo "VERSION = ${VERSION}" > ${1}
|
||||
fi
|
||||
Reference in a new issue