Blame lib/Makefile.am

Packit c22fc9
# Makefile.am
Packit c22fc9
#
Packit c22fc9
# Keepalived OpenSource project.
Packit c22fc9
#
Packit c22fc9
# Copyright (C) 2001-2017 Alexandre Cassen, <acassen@gmail.com>
Packit c22fc9
Packit c22fc9
GIT_COMMIT_FILE		= git-commit.h
Packit c22fc9
Packit c22fc9
AM_CPPFLAGS		= $(KA_CPPFLAGS) $(DEBUG_CPPFLAGS)
Packit c22fc9
AM_CFLAGS		= $(KA_CFLAGS) $(DEBUG_CFLAGS)
Packit c22fc9
AM_LDFLAGS		= $(KA_LDFLAGS) $(DEBUG_LDFLAGS)
Packit c22fc9
# AM_LIBS		= $(KA_LIBS)
Packit c22fc9
# AM_LIBTOOLFLAGS	= $(KA_LIBTOOLFLAGS)
Packit c22fc9
BUILT_SOURCES		= $(GIT_COMMIT_FILE)
Packit c22fc9
Packit c22fc9
noinst_LIBRARIES	= liblib.a
Packit c22fc9
Packit c22fc9
liblib_a_SOURCES	= memory.c utils.c notify.c timer.c scheduler.c \
Packit c22fc9
	vector.c list.c html.c parser.c signals.c logger.c assert.c \
Packit c22fc9
	list_head.c rbtree.c process.c \
Packit c22fc9
	bitops.h timer.h scheduler.h vector.h parser.h \
Packit c22fc9
	signals.h notify.h logger.h list.h memory.h html.h utils.h \
Packit c22fc9
	keepalived_magic.h list_head.h rbtree.h process.h \
Packit c22fc9
	rbtree_augmented.h
Packit c22fc9
Packit c22fc9
liblib_a_LIBADD		=
Packit c22fc9
EXTRA_liblib_a_SOURCES	=
Packit c22fc9
Packit c22fc9
if WITH_VRRP
Packit c22fc9
  liblib_a_LIBADD	+= rttables.o
Packit c22fc9
  EXTRA_liblib_a_SOURCES += rttables.c rttables.h
Packit c22fc9
endif
Packit c22fc9
Packit c22fc9
if ! SOCK_NONBLOCK
Packit c22fc9
  liblib_a_LIBADD	+= old_socket.o
Packit c22fc9
  EXTRA_liblib_a_SOURCES += old_socket.c old_socket.h
Packit c22fc9
endif
Packit c22fc9
Packit c22fc9
EXTRA_DIST		= $(GIT_COMMIT_FILE)
Packit c22fc9
Packit c22fc9
MAINTAINERCLEANFILES	= @MAINTAINERCLEANFILES@
Packit c22fc9
Packit c22fc9
FORCE:
Packit c22fc9
Packit c22fc9
# The git commit file will contain the git version and date of last commit,
Packit c22fc9
# unless this is a tagged version, in which case the git commit is omitted.
Packit c22fc9
# If there have been any local modifications, '+' is appended to the git
Packit c22fc9
# version.
Packit c22fc9
# The one file that needs to be ignored is deletion of snap/snapcraft.yaml,
Packit c22fc9
# since in a snapcraft build that file is deleted
Packit c22fc9
# (see https://bugs.launchpad.net/snapcraft/+bug/1662388).
Packit c22fc9
$(GIT_COMMIT_FILE): FORCE
Packit c22fc9
	@if [ ! -f $(srcdir)/$@ -a ! -f $@ ]; then \
Packit c22fc9
		echo '#define GIT_DATE	"unknown"' >$@; \
Packit c22fc9
		echo "#define GIT_YEAR	\"`date +%Y`\"" >>$@; \
Packit c22fc9
	fi; \
Packit c22fc9
	if [ -x `type -p git` ]; then \
Packit c22fc9
		cd $(srcdir); \
Packit c22fc9
		git rev-parse --is-inside-work-tree >/dev/null 2>&1; \
Packit c22fc9
		if [ $$? -eq 0 ]; then \
Packit c22fc9
			GIT_REV=`git describe --tags`; \
Packit c22fc9
			GIT_TIMESTAMP=`git log -1 --format=%ct`; \
Packit c22fc9
			GIT_DATE=`date -d "1970-01-01 UTC $${GIT_TIMESTAMP} seconds" +"%m/%d,%Y"`; \
Packit c22fc9
			if test -n "$${GIT_DATE}"; then \
Packit c22fc9
				GIT_YEAR=`date -d "1970-01-01 UTC $${GIT_TIMESTAMP} seconds" +"%Y"`; \
Packit c22fc9
			else \
Packit c22fc9
				GIT_DATE=`git log -1 --date=iso | grep Date: | sed -e "s/^[^ ]* *\(....\)-\(..\)-\(..\).*/\2\/\3,\1/"`; \
Packit c22fc9
				GIT_YEAR=`echo $${GIT_DATE} | sed -e "s/.*,//"`; \
Packit c22fc9
			fi; \
Packit c22fc9
			if [ "`git status --porcelain | \
Packit c22fc9
			       grep -v '^??' | \
Packit c22fc9
			       grep -v "^ D snap/snapcraft.yaml" | \
Packit c22fc9
			       wc -l`" -ne 0 ]; then \
Packit c22fc9
				EXTRA="+"; \
Packit c22fc9
			else \
Packit c22fc9
				EXTRA=""; \
Packit c22fc9
			fi; \
Packit c22fc9
			echo $${GIT_REV} | grep -qE -- "-[1-9][0-9]*-g[0-9a-f]{7,}$$"; \
Packit c22fc9
			if [ $$? -eq 0 -o -n "$${EXTRA}" ]; then \
Packit c22fc9
				echo "#define GIT_COMMIT \"$${GIT_REV}$${EXTRA}\"" >$(abs_builddir)/$@.new; \
Packit c22fc9
			fi; \
Packit c22fc9
			echo "#define GIT_DATE \"$${GIT_DATE}\"" >>$(abs_builddir)/$@.new; \
Packit c22fc9
			echo "#define GIT_YEAR \"$${GIT_YEAR}\"" >>$(abs_builddir)/$@.new; \
Packit c22fc9
			diff -q $(abs_builddir)/$@ $(abs_builddir)/$@.new 2>/dev/null >/dev/null; \
Packit c22fc9
			if [ $$? -eq 0 ]; then \
Packit c22fc9
				rm $(abs_builddir)/$@.new; \
Packit c22fc9
			else \
Packit c22fc9
				mv $(abs_builddir)/$@.new $(abs_builddir)/$@; \
Packit c22fc9
			fi; \
Packit c22fc9
		fi; \
Packit c22fc9
		cd $(abs_builddir); \
Packit c22fc9
	fi