Skip to content

Commit 7b0bd9b

Browse files
committed
unix: install m4 and autoconf
A future commit will introduce patches to configure.ac, which means we need to run autoconf. As macOS doesn't provide a sufficient autoconf and we want to use the same version of autoconf everywhere, it makes sense to build autoconf from source for all targets. So this commit does that. Autoconf requires m4, so we need to build and install m4 as well.
1 parent 069a157 commit 7b0bd9b

File tree

7 files changed

+150
-1
lines changed

7 files changed

+150
-1
lines changed

cpython-unix/Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ endif
8888

8989
toolchain: $(TOOLCHAIN_TARGET)
9090

91+
AUTOCONF_DEPENDS = \
92+
$(PYTHON_DEP_DEPENDS) \
93+
$(HERE)/build-autoconf.sh \
94+
$(OUTDIR)/m4-$(M4_VERSION)-$(PACKAGE_SUFFIX).tar \
95+
$(NULL)
96+
97+
$(OUTDIR)/autoconf-$(AUTOCONF_VERSION)-$(PACKAGE_SUFFIX).tar: $(AUTOCONF_DEPENDS)
98+
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) autoconf
99+
91100
$(OUTDIR)/bdb-$(BDB_VERSION)-$(PACKAGE_SUFFIX).tar: $(PYTHON_DEP_DEPENDS) $(HERE)/build-bdb.sh
92101
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) bdb
93102

@@ -147,6 +156,9 @@ LIBXCB_DEPENDS = \
147156
$(OUTDIR)/libxcb-$(LIBXCB_VERSION)-$(PACKAGE_SUFFIX).tar: $(LIBXCB_DEPENDS)
148157
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_XCB) libxcb
149158

159+
$(OUTDIR)/m4-$(M4_VERSION)-$(PACKAGE_SUFFIX).tar: $(PYTHON_DEP_DEPENDS) $(HERE)/build-m4.sh
160+
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) m4
161+
150162
$(OUTDIR)/ncurses-$(NCURSES_VERSION)-$(PACKAGE_SUFFIX).tar: $(PYTHON_DEP_DEPENDS) $(HERE)/build-ncurses.sh
151163
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) ncurses
152164

@@ -229,11 +241,13 @@ PYTHON_DEPENDS := \
229241
$(PYTHON_SUPPORT_FILES) \
230242
$(OUTDIR)/versions/VERSION.pip \
231243
$(OUTDIR)/versions/VERSION.setuptools \
244+
$(if $(NEED_AUTOCONF),$(OUTDIR)/autoconf-$(AUTOCONF_VERSION)-$(PACKAGE_SUFFIX).tar) \
232245
$(if $(NEED_BDB),$(OUTDIR)/bdb-$(BDB_VERSION)-$(PACKAGE_SUFFIX).tar) \
233246
$(if $(NEED_BZIP2),$(OUTDIR)/bzip2-$(BZIP2_VERSION)-$(PACKAGE_SUFFIX).tar) \
234247
$(if $(NEED_GDBM),$(OUTDIR)/gdbm-$(GDBM_VERSION)-$(PACKAGE_SUFFIX).tar) \
235248
$(if $(NEED_LIBEDIT),$(OUTDIR)/libedit-$(LIBEDIT_VERSION)-$(PACKAGE_SUFFIX).tar) \
236249
$(if $(NEED_LIBFFI),$(OUTDIR)/libffi-$(LIBFFI_VERSION)-$(PACKAGE_SUFFIX).tar) \
250+
$(if $(NEED_m4),$(OUTDIR)/m4-$(M4_VERSION)-$(PACKAGE_SUFFIX).tar) \
237251
$(if $(NEED_NCURSES),$(OUTDIR)/ncurses-$(NCURSES_VERSION)-$(PACKAGE_SUFFIX).tar) \
238252
$(if $(NEED_OPENSSL),$(OUTDIR)/openssl-$(OPENSSL_VERSION)-$(PACKAGE_SUFFIX).tar) \
239253
$(if $(NEED_PATCHELF),$(OUTDIR)/patchelf-$(PATCHELF_VERSION)-$(PACKAGE_SUFFIX).tar) \

cpython-unix/build-autoconf.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
# This Source Code Form is subject to the terms of the Mozilla Public
3+
# License, v. 2.0. If a copy of the MPL was not distributed with this
4+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
6+
set -ex
7+
8+
ROOT=`pwd`
9+
10+
export PATH=${TOOLS_PATH}/${TOOLCHAIN}/bin:${TOOLS_PATH}/host/bin:$PATH
11+
12+
tar -xf autoconf-${AUTOCONF_VERSION}.tar.gz
13+
14+
pushd autoconf-${AUTOCONF_VERSION}
15+
16+
CC="${HOST_CC}" CXX="${HOST_CXX}" CFLAGS="${EXTRA_HOST_CFLAGS} -fPIC" CPPFLAGS="${EXTRA_HOST_CFLAGS} -fPIC" LDFLAGS="${EXTRA_HOST_LDFLAGS}" ./configure \
17+
--build=${BUILD_TRIPLE} \
18+
--prefix=/tools/host
19+
20+
make -j ${NUM_CPUS}
21+
make -j ${NUM_CPUS} install DESTDIR=${ROOT}/out

cpython-unix/build-cpython.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,26 @@ export PATH=${TOOLS_PATH}/${TOOLCHAIN}/bin:${TOOLS_PATH}/host/bin:${TOOLS_PATH}/
1414
# environment variable.
1515
export LLVM_PROFDATA=${TOOLS_PATH}/${TOOLCHAIN}/bin/llvm-profdata
1616

17+
# autoconf has some paths hardcoded into scripts. These paths just work in
18+
# the containerized build environment. But from macOS the paths are wrong.
19+
# Explicitly point to the proper path via environment variable overrides.
20+
export AUTOCONF=${TOOLS_PATH}/host/bin/autoconf
21+
export AUTOHEADER=${TOOLS_PATH}/host/bin/autoheader
22+
export AUTOM4TE=${TOOLS_PATH}/host/bin/autom4te
23+
export autom4te_perllibdir=${TOOLS_PATH}/host/share/autoconf
24+
export AC_MACRODIR=${TOOLS_PATH}/host/share/autoconf
25+
export M4=${TOOLS_PATH}/host/bin/m4
26+
27+
# The share/autoconf/autom4te.cfg file also hard-codes some paths. Rewrite
28+
# those to the real tools path.
29+
if [ "${PYBUILD_PLATFORM}" = "macos" ]; then
30+
sed_args="-i '' -e"
31+
else
32+
sed_args="-i"
33+
fi
34+
35+
sed ${sed_args} "s|/tools/host|${TOOLS_PATH}/host|g" ${TOOLS_PATH}/host/share/autoconf/autom4te.cfg
36+
1737
# We force linking of external static libraries by removing the shared
1838
# libraries. This is hacky. But we're building in a temporary container
1939
# and it gets the job done.

cpython-unix/build-m4.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
# This Source Code Form is subject to the terms of the Mozilla Public
3+
# License, v. 2.0. If a copy of the MPL was not distributed with this
4+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
6+
set -ex
7+
8+
ROOT=`pwd`
9+
10+
export PATH=${TOOLS_PATH}/${TOOLCHAIN}/bin:${TOOLS_PATH}/host/bin:$PATH
11+
12+
tar -xf m4-${M4_VERSION}.tar.xz
13+
14+
pushd m4-${M4_VERSION}
15+
16+
CC="${HOST_CC}" CXX="${HOST_CXX}" CFLAGS="${EXTRA_HOST_CFLAGS} -fPIC" CPPFLAGS="${EXTRA_HOST_CFLAGS} -fPIC" LDFLAGS="${EXTRA_HOST_LDFLAGS}" ./configure \
17+
--build=${BUILD_TRIPLE} \
18+
--prefix=/tools/host
19+
20+
make -j ${NUM_CPUS}
21+
make -j ${NUM_CPUS} install DESTDIR=${ROOT}/out

cpython-unix/build.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,20 @@ def main():
984984
elif action == "musl":
985985
build_musl(client, get_image(client, ROOT, BUILD, "gcc"), host_platform)
986986

987+
elif action == "autoconf":
988+
simple_build(
989+
settings,
990+
client,
991+
get_image(client, ROOT, BUILD, docker_image),
992+
action,
993+
host_platform=host_platform,
994+
target_triple=target_triple,
995+
optimizations=optimizations,
996+
dest_archive=dest_archive,
997+
tools_path="host",
998+
extra_archives=["m4"],
999+
)
1000+
9871001
elif action == "libedit":
9881002
build_libedit(
9891003
settings,
@@ -1014,6 +1028,7 @@ def main():
10141028
"kbproto",
10151029
"libffi",
10161030
"libpthread-stubs",
1031+
"m4",
10171032
"ncurses",
10181033
"openssl",
10191034
"patchelf",
@@ -1028,7 +1043,7 @@ def main():
10281043
"xz",
10291044
"zlib",
10301045
):
1031-
tools_path = "host" if action == "patchelf" else "deps"
1046+
tools_path = "host" if action in ("m4", "patchelf") else "deps"
10321047

10331048
simple_build(
10341049
settings,

0 commit comments

Comments
 (0)