3 # This script generates the autotools configure.in and
4 # Makefile.am files from the information provided by
5 # SyncEvolution and backends in src/backends. The
6 # motivation for this non-standard approach was that
7 # it allows adding new backends without touching core
8 # files, which should have simplified the development of
9 # out-of-tree backends. Now git pretty much removes
10 # the need for such tricks, but it's still around.
12 # Another reason for gen-autotools.sh is that it generates
13 # the version in the configure script. This cannot be
14 # done inside the script because autoconf expects a
15 # literal string, not some kind of variable.
17 # To use the version specified in AC_INIT() unmodified,
18 # the following checks must pass:
19 # - SyncEvolution source is clean (git status reports
20 # no "modified" files or "untracked" files, or the source
21 # is not in git at all)
22 # - the source is tagged with the version of SyncEvolution
23 # (git describe --tags HEAD reports something which matches,
24 # for example syncevolution-1-0-beta-2a for 1.0beta2a)
25 # - same for libsynthesis, if the SYNTHESISSRC env variable
28 # If these tests fail, the version is extended:
29 # +<yyyymmdd>+SE+<status>+SYSYNC+<status>
31 # <status> = <hash>[+unclean]
32 # <hash> = shortened hash from describe (for example, 1040ffd)
33 # +unclean = source was dirty
37 version=`grep '^AC_INIT' configure-pre.in | sed -e 's/.*\[\(.*\)\])/\1/'`
42 if [ ! -d $dir/.git ]; then
49 if git status | grep -e "modified:" -e "Untracked files:" -q; then
52 describe=`git describe --tags`
53 hash=`git show-ref --abbrev --hash HEAD`
54 if echo $describe | grep -e '-[0-9]+-[0-9a-f]{8}$' -q; then
56 tag=`echo $describe | sed -e 's/-[0123456789]*-g.*//'`
62 # Hyphens between numbers in the tag are dots in the version
63 # and all other hyphens can be removed.
65 tmp=`echo $simpletag | sed -e 's/\([0123456789]\)-\([0123456789]\)/\1.\2/'`
66 if [ $tmp = $simpletag ]; then
72 simpletag=`echo $simpletag | sed -e 's/-//g'`
73 if [ "$dirty" ] || [ "$force" ]; then
74 # previous check failed, always print hash
77 echo $simpletag | grep -q "syncevolution${version}\$"; then
86 syncevo=`checksource .`
87 if [ "$SYNTHESISSRC" ]; then
88 sysync=`checksource $SYNTHESISSRC $syncevo`
90 # run check again, to get hash when only libsynthesis failed
91 syncevo=`checksource . $sysync`
92 if [ "$syncevo" ]; then
93 versionsuffix=+SE+$syncevo
95 if [ "$sysync" ]; then
96 versionsuffix=$versionsuffix+SYSYNC+$sysync
98 if [ "$versionsuffix" ]; then
99 versionsuffix=+`date +%Y%m%d`$versionsuffix
103 # generate configure.in from main configure-*.in pieces
104 # and all backend configure-sub.in pieces
106 sed -e "s/^\\(AC_INIT.*\\)\\[\\(.*\\)\\]/\\1[\\2$versionsuffix]/" configure-pre.in >>configure.in
110 for sub in src/backends/*/configure-sub.in; do
111 BACKENDS="$BACKENDS `dirname $sub | sed -e 's;^src/;;'`"
113 echo "# vvvvvvvvvvvvvv $sub vvvvvvvvvvvvvv" >>configure.in
114 cat $sub >>configure.in
115 echo "AC_CONFIG_FILES(`echo $sub | sed -e s/configure-sub.in/Makefile/`)" >>configure.in
116 echo "# ^^^^^^^^^^^^^^ $sub ^^^^^^^^^^^^^^" >>configure.in
119 cat configure-post.in >>configure.in
121 TEMPLATE_FILES=`cd src && find templates -type f \( -name README -o -name '*.png' -o -name '*.svg' -o -name '*.ini' \)`
122 TEMPLATE_FILES=`echo $TEMPLATE_FILES`
124 # create Makefile.am files
125 sed -e "s;@BACKEND_REGISTRIES@;`echo src/backends/*/*Register.cpp | sed -e s%src/%%g`;" \
126 -e "s;@BACKENDS@;$BACKENDS;" \
127 -e "s;@TEMPLATE_FILES@;$TEMPLATE_FILES;" \
128 src/Makefile-gen.am >src/Makefile.am
130 sed -e "s;@CONFIG_SUBS@;$SUBS;" \
131 Makefile-gen.am >Makefile.am
133 # create LINGUAS file: every .po is included
134 (cd po && ls -1 *.po | sort -u | sed -e 's/.po$//' > LINGUAS)