Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 3049e53

Browse files
committed
Use ecl-config to determine compiler/linker flags for ecl
1 parent 9d686f2 commit 3049e53

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

build/pkgs/sage_conf/src/sage_conf.py.in

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ MAXIMA = "@prefix@/bin/maxima"
66

77
ARB_LIBRARY = "@SAGE_ARB_LIBRARY@"
88

9+
# Path to the ecl-config script
10+
# TODO: At the moment this is hard-coded, needs to be set during the configure phase if we want to support system-installed ecl.
11+
ECL_CONFIG_PATH = "@prefix@/bin/ecl-config"
12+
913
SAGE_NAUTY_BINS_PREFIX = "@SAGE_NAUTY_BINS_PREFIX@"
1014

1115
# Colon-separated list of pkg-config modules to search for cblas functionality.

src/sage/env.py

+11
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import sysconfig
3838
from . import version
3939
from pathlib import Path
40+
import subprocess
4041

4142

4243
# All variables set by var() appear in this SAGE_ENV dict and also
@@ -203,6 +204,7 @@ def var(key, *fallbacks, **kwds):
203204
var('SAGE_NAUTY_BINS_PREFIX', '')
204205
var('ARB_LIBRARY', 'arb')
205206
var('CBLAS_PC_MODULES', 'cblas:openblas:blas')
207+
var('ECL_CONFIG_PATH')
206208

207209
# misc
208210
var('SAGE_BANNER', '')
@@ -458,4 +460,13 @@ def uname_specific(name, value, alternative):
458460
except ValueError:
459461
pass
460462

463+
# Determine ecl-specific compiler arguments using the ecl-config script
464+
ecl_cflags = subprocess.run([ECL_CONFIG_PATH, "--cflags"], check=True, capture_output=True, text=True).stdout.split()
465+
aliases["ECL_CFLAGS"] = list(filter(lambda s: not s.startswith('-I'), ecl_cflags))
466+
aliases["ECL_INCDIR"] = list(map(lambda s: s[2:], filter(lambda s: s.startswith('-I'), ecl_cflags)))
467+
ecl_libs = subprocess.run([ECL_CONFIG_PATH, "--libs"], check=True, capture_output=True, text=True).stdout.split()
468+
aliases["ECL_LIBDIR"] = list(map(lambda s: s[2:], filter(lambda s: s.startswith('-L'), ecl_libs)))
469+
aliases["ECL_LIBRARIES"] = list(map(lambda s: s[2:], filter(lambda s: s.startswith('-l'), ecl_libs)))
470+
aliases["ECL_LIBEXTRA"] = list(filter(lambda s: not s.startswith(('-l','-L')), ecl_libs))
471+
461472
return aliases

src/sage/libs/ecl.pxd

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# distutils: libraries = ecl gmp
1+
# distutils: extra_compile_args = ECL_CFLAGS
2+
# distutils: include_dirs = ECL_INCDIR
3+
# distutils: libraries = ECL_LIBRARIES
4+
# distutils: library_dirs = ECL_LIBDIR
5+
# distutils: extra_link_args = ECL_LIBEXTRA
6+
27
###############################################################################
38
# Sage: Open Source Mathematical Software
49
# Copyright (C) 2009 Nils Bruin <[email protected]>
@@ -153,4 +158,4 @@ cdef extern from "ecl/ecl.h":
153158

154159
# symbols
155160

156-
cl_object ecl_make_symbol(const char *name, const char *package)
161+
cl_object ecl_make_symbol(const char *name, const char *package)

0 commit comments

Comments
 (0)