1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

fixed build error when make run with -jN option

Race can occur when gitversion file isn't fully generated before
it is used.
This commit is contained in:
Dmitry Podgorny 2014-03-06 02:06:22 +02:00
parent a9e2028981
commit 0fbaa6f5ee
8 changed files with 41 additions and 41 deletions

3
.gitignore vendored
View File

@ -32,7 +32,8 @@ TODO
plugins/ plugins/
*_key.txt *_key.txt
*_fingerprints.txt *_fingerprints.txt
src/gitversion.c src/gitversion.h
src/gitversion.h.in
*_key.txt *_key.txt
*_fingerprints.txt *_fingerprints.txt
TAGS TAGS

View File

@ -1,17 +1,3 @@
if INCLUDE_GIT_VERSION
src/gitversion.c: .git/HEAD .git/index
rm -f src/gitversion.c src/gitversion.o
echo "#ifndef PROF_GIT_BRANCH" >> $@
echo "#define PROF_GIT_BRANCH \"$(shell git rev-parse --symbolic-full-name --abbrev-ref HEAD)\"" >> $@
echo "#endif" >> $@
echo "#ifndef PROF_GIT_REVISION" >> $@
echo "#define PROF_GIT_REVISION \"$(shell git log --pretty=format:'%h' -n 1)\"" >> $@
echo "#endif" >> $@
clean-local:
rm -f src/gitversion.c src/gitversion.o
endif
core_sources = \ core_sources = \
src/contact.c src/contact.h src/log.c src/common.c \ src/contact.c src/contact.h src/log.c src/common.c \
src/log.h src/profanity.c src/common.h \ src/log.h src/profanity.c src/common.h \
@ -42,7 +28,7 @@ core_sources = \
src/config/preferences.c src/config/preferences.h \ src/config/preferences.c src/config/preferences.h \
src/config/theme.c src/config/theme.h src/config/theme.c src/config/theme.h
test_sources = \ tests_sources = \
src/contact.c src/contact.h src/common.c \ src/contact.c src/contact.h src/common.c \
src/log.h src/profanity.c src/common.h \ src/log.h src/profanity.c src/common.h \
src/profanity.h src/chat_session.c \ src/profanity.h src/chat_session.c \
@ -93,8 +79,7 @@ test_sources = \
main_source = src/main.c main_source = src/main.c
git_sources = \ git_include = src/gitversion.h
src/gitversion.c
otr3_sources = \ otr3_sources = \
src/otr/otrlib.h src/otr/otrlibv3.c src/otr/otr.h src/otr/otr.c src/otr/otrlib.h src/otr/otrlibv3.c src/otr/otr.h src/otr/otr.c
@ -102,34 +87,48 @@ otr3_sources = \
otr4_sources = \ otr4_sources = \
src/otr/otrlib.h src/otr/otrlibv4.c src/otr/otr.h src/otr/otr.c src/otr/otrlib.h src/otr/otrlibv4.c src/otr/otr.h src/otr/otr.c
if INCLUDE_GIT_VERSION
with_git_sources = $(git_sources) $(core_sources)
tests_with_git_sources = $(git_sources) $(test_sources)
else
with_git_sources = $(core_sources)
tests_with_git_sources = $(test_sources)
endif
if BUILD_OTR if BUILD_OTR
if BUILD_OTR3 if BUILD_OTR3
with_otr_sources = $(with_git_sources) $(otr3_sources) core_sources += $(otr3_sources)
tests_with_otr_sources = $(tests_with_git_sources) $(otr3_sources) tests_sources += $(otr3_sources)
endif endif
if BUILD_OTR4 if BUILD_OTR4
with_otr_sources = $(with_git_sources) $(otr4_sources) core_sources += $(otr4_sources)
tests_with_otr_sources = $(tests_with_git_sources) $(otr4_sources) tests_sources += $(otr4_sources)
endif endif
else
with_otr_sources = $(with_git_sources)
tests_with_otr_sources = $(tests_with_git_sources)
endif endif
bin_PROGRAMS = profanity bin_PROGRAMS = profanity
profanity_SOURCES = $(with_otr_sources) $(main_source) profanity_SOURCES = $(core_sources) $(main_source)
if INCLUDE_GIT_VERSION
BUILT_SOURCES = $(git_include)
endif
TESTS = tests/testsuite TESTS = tests/testsuite
check_PROGRAMS = tests/testsuite check_PROGRAMS = tests/testsuite
tests_testsuite_SOURCES = $(tests_with_otr_sources) tests_testsuite_SOURCES = $(tests_sources)
tests_testsuite_LDADD = -lcmocka tests_testsuite_LDADD = -lcmocka
man_MANS = docs/profanity.1 man_MANS = docs/profanity.1
if INCLUDE_GIT_VERSION
$(git_include).in: .git/HEAD .git/index
rm -f $@
echo "#ifndef PROF_GIT_BRANCH" >> $@
echo "#define PROF_GIT_BRANCH \"$(shell git rev-parse --symbolic-full-name --abbrev-ref HEAD)\"" >> $@
echo "#endif" >> $@
echo "#ifndef PROF_GIT_REVISION" >> $@
echo "#define PROF_GIT_REVISION \"$(shell git log --pretty=format:'%h' -n 1)\"" >> $@
echo "#endif" >> $@
#
# Create $(git_include) atomically to catch possible race. The race can occur
# when $(git_include) is generated in parallel with building of src/profanity.c.
# So this hack allows to find and fix the problem earlier.
#
$(git_include): $(git_include).in
cp $< $@
clean-local:
rm -f $(git_include) $(git_include).in
endif

View File

@ -24,7 +24,7 @@
#include "config.h" #include "config.h"
#ifdef HAVE_GIT_VERSION #ifdef HAVE_GIT_VERSION
#include "gitversion.c" #include "gitversion.h"
#endif #endif
#include "profanity.h" #include "profanity.h"

View File

@ -22,7 +22,7 @@
#include "config.h" #include "config.h"
#ifdef HAVE_GIT_VERSION #ifdef HAVE_GIT_VERSION
#include "gitversion.c" #include "gitversion.h"
#endif #endif
#include <locale.h> #include <locale.h>

View File

@ -41,7 +41,7 @@
#include "xmpp/bookmark.h" #include "xmpp/bookmark.h"
#ifdef HAVE_GIT_VERSION #ifdef HAVE_GIT_VERSION
#include "gitversion.c" #include "gitversion.h"
#endif #endif
static void _cons_splash_logo(void); static void _cons_splash_logo(void);

View File

@ -23,7 +23,7 @@
#include "config.h" #include "config.h"
#ifdef HAVE_GIT_VERSION #ifdef HAVE_GIT_VERSION
#include "gitversion.c" #include "gitversion.h"
#endif #endif
#include <stdlib.h> #include <stdlib.h>

View File

@ -23,7 +23,7 @@
#include "config.h" #include "config.h"
#ifdef HAVE_GIT_VERSION #ifdef HAVE_GIT_VERSION
#include "gitversion.c" #include "gitversion.h"
#endif #endif
#include <stdlib.h> #include <stdlib.h>

View File

@ -23,7 +23,7 @@
#include "config.h" #include "config.h"
#ifdef HAVE_GIT_VERSION #ifdef HAVE_GIT_VERSION
#include "gitversion.c" #include "gitversion.h"
#endif #endif
#include <stdlib.h> #include <stdlib.h>