1# Bootstrap configuration.
2
3# Copyright (C) 2006-2017 Free Software Foundation, Inc.
4# Copyright (C) 2017, 2020 Luca Saiu
5# Updated by Luca Saiu for use in Jitter.
6
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 3 of the License, or
10# (at your option) any later version.
11
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16
17# You should have received a copy of the GNU General Public License
18# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20
21# ChangeLog and .in file generation.
22# ################################################################
23
24# Make an empty ChangeLog if we have none, early on.  This way autoreconf will
25# not complain.
26bootstrap_post_import_hook ()
27{
28  if ! test -r ChangeLog; then
29    echo 'The real ChangeLog will be generated from git' \
30      > ChangeLog
31  fi
32
33  # Expand away M4sh macros into *.in files.
34  unm4sh_all
35
36  # Make an empty directory to contain config.h.in .
37  if ! test -d config-private; then
38    mkdir config-private \
39      || (echo 'could not make config-private/'; exit 1)
40  fi
41}
42
43
44# M4sh machinery.
45# ################################################################
46
47# For every portable-shell script to be generated take SCRIPT.in.m4sh and
48# generate SCRIPT.in from that, on the machine where bootstrap is run; then
49# aclocal will be able to generate SCRIPT from SCRIPT.in by replacing
50# @-substitutions, even on a user machine with weaker tools installed.
51unm4sh_all ()
52{
53  # Generate FILE.in from each FILE.in.m4sh .
54  unm4sh "bin/jitter-config.in.m4sh"
55  unm4sh "scripts/generate-fast-branches.in.m4sh"
56}
57
58# Given a .in.m4sh file, build a .in file with the same extension by expanding
59# M4sh macros into portable shell.  The result will still need to be processed
60# by aclocal, on the user machine, for @-substitution.
61unm4sh ()
62{
63  source="$1"
64  top_srcdir=$(dirname "$0")
65  destination_basename=$(basename "$source" .m4sh)
66  destination_relative_dirname=$(dirname "$source")
67  destination_dirname=$top_srcdir/$destination_relative_dirname
68  destination=$destination_dirname/$destination_basename
69
70  echo "Building $destination from $source expanding away M4sh macros..."
71  # At least here on the machine where we are running bootstrap we can assume
72  # autom4te to be there, as we depend on Autoconf anyway; on the user's machine
73  # the situation is different, and configure will check.
74  autom4te \
75    --language=M4sh --prepend-include="$top_srcdir/m4-utility" \
76    --output="$destination" "$source"
77
78  # Amend the generated file by adding a shebang line.  See the comment in
79  # amend-autom4te-output for an explanation.
80  "${top_srcdir}/amend-autom4te-output" "$destination"
81}
82
83
84# Typical bootstrap.conf settings, with few customizations.
85# ################################################################
86
87# I prefer copies to symlinks, as I may want to move copies of the working
88# directory across machines.
89copy="true"
90
91# Delete .version , used for git-version-gen , from the source directory.
92# Doing it here ensures that I don't forget it; I'm used to calling
93# ./bootstrap from the source directory rather than simply autoreconf ,
94# so this will work for me.
95rm -f .version
96
97# My non-default Gnulib directories:
98m4_base="build-aux"
99build_aux="build-aux"
100source_base="gnulib-local"
101tests_base="gnulib-local-tests"
102doc_base="gnulib-local-doc"
103
104# I like to call the Gnulib library just "gnulib"; the default, as of
105# 2017-02-26, seems to depend on the package name (*not* its tarname),
106# which gets messy with automake when such name contains spaces.  This
107# solution is cleaner.
108gnulib_tool_option_extras='--lib libgnulib'
109
110# # Enabling conditional dependencies in Gnulib should make executables
111# # (Jitter libraries do not depend on Gnulib) smaller on GNU and on
112# # other systems which are not horribly limited.
113# gnulib_tool_option_extras="${gnulib_tool_option_extras} --conditional-dependencies"
114# FIXME: the line above makes full sense, but for some reason it leads to a link
115# failure in JitterLisp on GNU, with rpl_gettimeofday (not needed on GNU) not
116# found.  I may investigate the issue later.
117gnulib_tool_option_extras="${gnulib_tool_option_extras}"
118
119# gnulib modules used by this package.
120gnulib_modules="
121array-list
122argp
123c-ctype
124git-version-gen
125gitlog-to-changelog
126mkdtemp
127xalloc
128xlist
129"
130# I had problems like this when cross-linking to mipsel-uclibc:
131# gnulib-local/libgnulib.a(vasnprintf.o):vasnprintf.c:(.text+0x17e8): more undefined references to `wctomb' follow
132# Before introducing Gnulib there was no such issue.
133# The problem does *not* exist when cross-compiling to sussman (mipsel, glibc).
134#
135# I've since solved the problem by regenerating my cross tools with crosstool-ng
136# , this time enabling wchar_t support, which was disabled before.  I'm still a
137# little skeptical that that was the "correct" solution.
138
139# Additional xgettext options to use.  Use "\\\newline" to break lines.
140XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
141 --from-code=UTF-8\\\
142 --flag=asprintf:2:c-format --flag=vasprintf:2:c-format\\\
143 --flag=asnprintf:3:c-format --flag=vasnprintf:3:c-format\\\
144 --flag=wrapf:1:c-format\\\
145'
146
147# If "AM_GNU_GETTEXT(external" or "AM_GNU_GETTEXT([external]"
148# appears in configure.ac, exclude some unnecessary files.
149# Without grep's -E option (not portable enough, pre-configure),
150# the following test is ugly.  Also, this depends on the existence
151# of configure.ac, not the obsolescent-named configure.in.  But if
152# you're using this infrastructure, you should care about such things.
153
154gettext_external=0
155grep '^[	 ]*AM_GNU_GETTEXT(external\>' configure.ac > /dev/null &&
156  gettext_external=1
157grep '^[	 ]*AM_GNU_GETTEXT(\[external\]' configure.ac > /dev/null &&
158  gettext_external=1
159
160if test $gettext_external = 1; then
161  # Gettext supplies these files, but we don't need them since
162  # we don't have an intl subdirectory.
163  excluded_files='
164      m4/glibc2.m4
165      m4/intdiv0.m4
166      m4/lcmessage.m4
167      m4/lock.m4
168      m4/printf-posix.m4
169      m4/size_max.m4
170      m4/uintmax_t.m4
171      m4/ulonglong.m4
172      m4/visibility.m4
173      m4/xsize.m4
174  '
175fi
176
177# Build prerequisites
178buildreq="\
179autoconf   2.59
180automake   1.14
181bison      3.0.0
182flex       2.5.37
183help2man   -
184git        1.5.5
185tar        -
186"
187