diff --git a/relenv/build/common.py b/relenv/build/common.py index 209d4cac..762edf7b 100644 --- a/relenv/build/common.py +++ b/relenv/build/common.py @@ -358,6 +358,65 @@ def build_sqlite(env, dirs, logfp): runcmd(["make", "install"], env=env, stderr=logfp, stdout=logfp) +def build_ncurses(env, dirs, logfp): + """ + Build ncurses. + + :param env: The environment dictionary + :type env: dict + :param dirs: The working directories + :type dirs: ``relenv.build.common.Dirs`` + :param logfp: A handle for the log file + :type logfp: file + """ + configure = pathlib.Path(dirs.source) / "configure" + if env["RELENV_BUILD_ARCH"] == "aarch64" or env["RELENV_HOST_ARCH"] == "aarch64": + os.chdir(dirs.tmpbuild) + runcmd([str(configure)], stderr=logfp, stdout=logfp) + runcmd(["make", "-C", "include"], stderr=logfp, stdout=logfp) + runcmd(["make", "-C", "progs", "tic"], stderr=logfp, stdout=logfp) + os.chdir(dirs.source) + + # Configure with a prefix of '/' so things will be installed to '/lib' + # instead of '/usr/local/lib'. The root of the install will be specified + # via the DESTDIR make argument. + runcmd( + [ + str(configure), + "--prefix=/", + "--with-shared", + "--enable-termcap", + "--with-termlib", + "--without-cxx-shared", + "--without-static", + "--without-cxx", + "--enable-widec", + "--without-normal", + "--disable-stripping", + f"--with-pkg-config={dirs.prefix}/lib/pkgconfig", + "--enable-pc-files", + f"--build={env['RELENV_BUILD']}", + f"--host={env['RELENV_HOST']}", + ], + env=env, + stderr=logfp, + stdout=logfp, + ) + runcmd(["make", "-j8"], env=env, stderr=logfp, stdout=logfp) + ticdir = str(pathlib.Path(dirs.tmpbuild) / "progs" / "tic") + runcmd( + [ + "make", + f"DESTDIR={dirs.prefix}", + f"TIC_PATH={ticdir}", + "install", + ], + env=env, + stderr=logfp, + stdout=logfp, + ) + + def tarball_version(href): if href.endswith("tar.gz"): try: @@ -666,7 +725,7 @@ class Dirs: """ def __init__(self, dirs, name, arch, version): - # XXX name is the specific to a step where as everything + # XXX name is specific to a step whereas everything # else here is generalized to the entire build self.name = name self.version = version diff --git a/relenv/build/darwin.py b/relenv/build/darwin.py index 11964697..2a5787f4 100644 --- a/relenv/build/darwin.py +++ b/relenv/build/darwin.py @@ -6,7 +6,15 @@ import io from ..common import arches, DARWIN, MACOS_DEVELOPMENT_TARGET -from .common import runcmd, finalize, build_openssl, build_sqlite, builds +from .common import ( + runcmd, + finalize, + build_openssl, + build_sqlite, + builds, + build_ncurses, + tarball_version, +) ARCHES = arches[DARWIN] @@ -22,17 +30,24 @@ def populate_env(env, dirs): """ env["CC"] = "clang" ldflags = [ - "-Wl,-rpath,{prefix}/lib", - "-L{prefix}/lib", + f"-Wl,-rpath,{dirs.prefix}/lib", + f"-L{dirs.prefix}/lib", ] env["LDFLAGS"] = " ".join(ldflags).format(prefix=dirs.prefix) env["MACOSX_DEPLOYMENT_TARGET"] = MACOS_DEVELOPMENT_TARGET cflags = [ - "-L{prefix}/lib", - "-I{prefix}/include", - "-I{prefix}/include/readline", + f"-L{dirs.prefix}/lib", + f"-I{dirs.prefix}/include", + f"-I{dirs.prefix}/include/readline", + f"-I{dirs.prefix}/include/ncursesw", ] env["CFLAGS"] = " ".join(cflags).format(prefix=dirs.prefix) + cppflags = [ + f"-I{dirs.prefix}/include", + f"-I{dirs.prefix}/include/readline", + f"-I{dirs.prefix}/include/ncursesw", + ] + env["CPPFLAGS"] = " ".join(cppflags) def build_python(env, dirs, logfp): @@ -104,6 +119,20 @@ def build_python(env, dirs, logfp): }, ) + +build.add( + name="ncurses", + build_func=build_ncurses, + download={ + "url": "https://ftp.gnu.org/pub/gnu/ncurses/ncurses-{version}.tar.gz", + # XXX: Need to work out tinfo linkage + "version": "6.5", + "checksum": "cde3024ac3f9ef21eaed6f001476ea8fffcaa381", + "checkfunc": tarball_version, + }, +) + + build.add( "python", build_func=build_python, @@ -111,6 +140,7 @@ def build_python(env, dirs, logfp): "openssl", "XZ", "SQLite", + "ncurses", ], download={ "url": "https://www.python.org/ftp/python/{version}/Python-{version}.tar.xz", diff --git a/relenv/build/linux.py b/relenv/build/linux.py index 42562d7d..d235a219 100644 --- a/relenv/build/linux.py +++ b/relenv/build/linux.py @@ -55,16 +55,16 @@ def populate_env(env, dirs): f"-I{dirs.toolchain}/{env['RELENV_HOST']}/sysroot/usr/include", ] env["CFLAGS"] = " ".join(cflags) - # CPPFLAGS are needed for Python's setup.py to find the 'nessicery bits' + # CPPFLAGS are needed for Python's setup.py to find the 'necessary bits' # for things like zlib and sqlite. - cpplags = [ + cppflags = [ f"-I{dirs.prefix}/include", f"-I{dirs.prefix}/include/readline", f"-I{dirs.prefix}/include/ncursesw", f"-I{dirs.toolchain}/{env['RELENV_HOST']}/sysroot/usr/include", ] - # env["CXXFLAGS"] = " ".join(cpplags) - env["CPPFLAGS"] = " ".join(cpplags) + # env["CXXFLAGS"] = " ".join(cppflags) + env["CPPFLAGS"] = " ".join(cppflags) env["PKG_CONFIG_PATH"] = f"{dirs.prefix}/lib/pkgconfig" @@ -166,65 +166,6 @@ def build_gdbm(env, dirs, logfp): runcmd(["make", "install"], env=env, stderr=logfp, stdout=logfp) -def build_ncurses(env, dirs, logfp): - """ - Build ncurses. - - :param env: The environment dictionary - :type env: dict - :param dirs: The working directories - :type dirs: ``relenv.build.common.Dirs`` - :param logfp: A handle for the log file - :type logfp: file - """ - configure = pathlib.Path(dirs.source) / "configure" - if env["RELENV_BUILD_ARCH"] == "aarch64" or env["RELENV_HOST_ARCH"] == "aarch64": - os.chdir(dirs.tmpbuild) - runcmd([str(configure)], stderr=logfp, stdout=logfp) - runcmd(["make", "-C", "include"], stderr=logfp, stdout=logfp) - runcmd(["make", "-C", "progs", "tic"], stderr=logfp, stdout=logfp) - os.chdir(dirs.source) - - # Configure with a prefix of '/' so things will be installed to '/lib' - # instead of '/usr/local/lib'. The root of the install will be specified - # via the DESTDIR make argument. - runcmd( - [ - str(configure), - "--prefix=/", - "--with-shared", - "--enable-termcap", - "--with-termlib", - "--without-cxx-shared", - "--without-static", - "--without-cxx", - "--enable-widec", - "--without-normal", - "--disable-stripping", - f"--with-pkg-config={dirs.prefix}/lib/pkgconfig", - "--enable-pc-files", - f"--build={env['RELENV_BUILD']}", - f"--host={env['RELENV_HOST']}", - ], - env=env, - stderr=logfp, - stdout=logfp, - ) - runcmd(["make", "-j8"], env=env, stderr=logfp, stdout=logfp) - ticdir = str(pathlib.Path(dirs.tmpbuild) / "progs" / "tic") - runcmd( - [ - "make", - f"DESTDIR={dirs.prefix}", - f"TIC_PATH={ticdir}", - "install", - ], - env=env, - stderr=logfp, - stdout=logfp, - ) - - def build_readline(env, dirs, logfp): """ Build readline library. @@ -535,10 +476,8 @@ def build_python(env, dirs, logfp): download={ "url": "https://ftp.gnu.org/pub/gnu/ncurses/ncurses-{version}.tar.gz", # XXX: Need to work out tinfo linkage - # "version": "6.5", - # "checksum": "cde3024ac3f9ef21eaed6f001476ea8fffcaa381", - "version": "6.4", - "checksum": "bb5eb3f34b3ecd5bac8d0b58164b847f135b3d62", + "version": "6.5", + "checksum": "cde3024ac3f9ef21eaed6f001476ea8fffcaa381", "checkfunc": tarball_version, }, )