나는 당신이 혼자 configure.ac
에서 원하는 것 무엇을 할 수 있다고 생각하지 않습니다. 이 코드 :
$(shell svnversion -n .)
실제로는 make
이 실행될 때인 것처럼 보입니다. configure
번으로 전화하면 AC_OUTPUT
입니다. 그 때 AC_DEFINE
은 모두 config.h
에 기록됩니다. 어떤 전에make
, 그래서 그 당시 작성된 아무것도 make
환경에되지 않습니다. 당신은 configure
환경에서이 명령을 실행할 수 있습니다 대부분 같은 효과를
SVNVERSION_REV=`svnversion -n .`
AC_DEFINE_UNQUOTED([SVN_REV],
["$SVNVERSION_REV"],
[Define svn revision number])
합니다. 버전 번호는 (예 : 파일을 수정하고 configure
이후에 파일을 커밋하는 등) 계속되는 경향이 있습니다. 이 문제를 해결하려면 이 아닌 Makefile.am
에서 모든 버전을 구동해야합니다.
autotools에 버전 정보를 가져 오는 것은 약간 까다 롭습니다. 다음은 .spec 파일에 Subversion 버전을 삽입하는 데 사용되는 다소 수정 된 버전입니다. 하기 위해
configure.ac
# check for svnversion (not required, except for the maintainer)
AX_WITH_PROG([SVNVERSION], [svnversion])
Makefile.am
# copy svnstamp to svn-revision
# if svn-revision non-existent or svnstamp is newer
svn-revision : $(top_builddir)/svnstamp
if test ! -f [email protected] -o $< -nt [email protected]; then \
cp $< [email protected]; \
fi
# always do this check to avoid staleness
.PHONY : svnstamp_
# This is supposed to do nothing
# all the work to create this file is in svnstamp_
$(top_builddir)/svnstamp : svnstamp_
@/bin/true
# run the command only if the codebase is a svn working copy
# I've taken out the RPM related strings so you might be able
# to plug it into your code more easily
svnstamp_ :
if test -d $(top_srcdir)/.svn ; then \
SVN_VERSION_STAMP=`$(SVNVERSION) $(top_srcdir) -n`; \
NEW_STAMP=`echo -n "$$SVN_VERSION_STAMP"`; \
if test ! -f $(top_builddir)/svnstamp; then \
echo "$$NEW_STAMP" > $(top_builddir)/svnstamp; \
else \
OLD_STAMP=`cat $(top_builddir)/svnstamp`; \
if test "$$OLD_STAMP" != "$$NEW_STAMP" ; then \
echo "$$NEW_STAMP" > $(top_builddir)/svnstamp; \
fi \
fi \
else \
if test ! -f $(top_builddir)/svnstamp \
-o $(top_srcdir)/svn-revision \
-nt $(top_builddir)/svnstamp; then \
cp $(top_srcdir)/svn-revision $(top_builddir)/svnstamp; \
fi \
fi; \
NEW_STAMP=`cat $(top_builddir)/svnstamp`; \
if test "x$$NEW_STAMP" = "x"; then \
echo " Failed to make svnstamp"; \
exit 1; \
fi
:
먼저 나는 svnversion
AX_WITH_PROG를 사용하여 이진 (또는 같은)를 잡아 버전이 필요한 번역 단위에 대해이 작업을 수행하십시오.
... -DSVN_REV=\"`cat svn-revision`\" ...
가 어떻게 Makefile.am에서 버전 물건을 이동할 수 스탬프, 당신은 그들에게
svn-revision
의 의존성을하고 빌드 단계에서 다음과 같은 일을해야합니다? 나는 성공하지 않으려 고 노력했다. – mastupristi