diff --git a/Include/cpython/pyerrors.h b/Include/cpython/pyerrors.h index 6b63d304b0d929..c26577cddb9644 100644 --- a/Include/cpython/pyerrors.h +++ b/Include/cpython/pyerrors.h @@ -83,6 +83,14 @@ typedef struct { PyObject *name; } PyAttributeErrorObject; +#ifdef RISCOS +typedef struct { + PyException_HEAD + PyObject *errnum; + PyObject *errmsg; +} PyRISCOSErrorObject; +#endif + /* Compatibility typedefs */ typedef PyOSErrorObject PyEnvironmentErrorObject; #ifdef MS_WINDOWS diff --git a/Include/osdefs.h b/Include/osdefs.h index 2599e87a9d7c4b..81116cc2d2356c 100644 --- a/Include/osdefs.h +++ b/Include/osdefs.h @@ -24,6 +24,11 @@ extern "C" { # define DELIM L';' #endif +#ifdef RISCOS +# define DELIM L',' +# define SEP L'.' +#endif + /* Filename separator */ #ifndef SEP # define SEP L'/' diff --git a/Modules/_ssl.c b/Modules/_ssl.c index 417d5ca593158f..2008edb5a254a4 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -5872,10 +5872,18 @@ _ssl_get_default_verify_paths_impl(PyObject *module) if (!target) goto error; \ } +#ifdef RISCOS + // The defaults from the X509_... calls are somewhat useless. + ofile_env = Py_None; Py_INCREF(Py_None); + ofile = Py_None; Py_INCREF(Py_None); + odir_env = Py_None; Py_INCREF(Py_None); + odir = Py_None; Py_INCREF(Py_None); +#else CONVERT(X509_get_default_cert_file_env(), ofile_env); CONVERT(X509_get_default_cert_file(), ofile); CONVERT(X509_get_default_cert_dir_env(), odir_env); CONVERT(X509_get_default_cert_dir(), odir); +#endif #undef CONVERT return Py_BuildValue("NNNN", ofile_env, ofile, odir_env, odir); diff --git a/Modules/getbuildinfo.c b/Modules/getbuildinfo.c index b68f0f5cc56a44..1865e88739041c 100644 --- a/Modules/getbuildinfo.c +++ b/Modules/getbuildinfo.c @@ -50,10 +50,14 @@ Py_GetBuildInfo(void) initialized = 1; const char *revision = _Py_gitversion(); const char *sep = *revision ? ":" : ""; +#ifdef RISCOS + const char *gitid = "riscos-1"; +#else const char *gitid = _Py_gitidentifier(); if (!(*gitid)) { gitid = "main"; } +#endif PyOS_snprintf(buildinfo, sizeof(buildinfo), "%s%s%s, %.20s, %.9s", gitid, sep, revision, DATE, TIME); diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 1bfbf3f6a0b991..0257ab8e718582 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -2259,8 +2259,15 @@ pysleep(PyTime_t timeout) #elif defined(HAVE_NANOSLEEP) ret = nanosleep(&timeout_ts, NULL); err = errno; +#else +#ifdef RISCOS + unsigned int end = _swi(OS_ReadMonotonicTime, _RETURN(0)) + + (timeout_tv.tv_sec * 100 + timeout_tv.tv_usec / 10000); + while ((unsigned)_swi(OS_ReadMonotonicTime, _RETURN(0)) < end) ; + ret = 0; #else ret = select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &timeout_tv); +#endif err = errno; #endif Py_END_ALLOW_THREADS diff --git a/Objects/exceptions.c b/Objects/exceptions.c index b17cac83551670..f2961dd03902be 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -4193,6 +4193,73 @@ SimpleExtendsException(PyExc_Warning, ResourceWarning, "Base class for warnings about resource usage."); +#ifdef RISCOS +/* + * RISC OS error. + */ + +static int +RISCOSError_init(PyRISCOSErrorObject *self, PyObject *args, PyObject *kwds) +{ + Py_ssize_t lenargs = PyTuple_GET_SIZE(args); + + if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) + return -1; + + if (lenargs >= 1) { + Py_INCREF(PyTuple_GET_ITEM(args, 0)); + Py_XSETREF(self->errnum, PyTuple_GET_ITEM(args, 0)); + } + if (lenargs == 2) { + Py_INCREF(PyTuple_GET_ITEM(args, 1)); + Py_XSETREF(self->errmsg, PyTuple_GET_ITEM(args, 1)); + } + return 0; +} + +static int +RISCOSError_clear(PyRISCOSErrorObject *self) +{ + Py_CLEAR(self->errmsg); + Py_CLEAR(self->errnum); + return BaseException_clear((PyBaseExceptionObject *)self); +} + +static void +RISCOSError_dealloc(PyRISCOSErrorObject *self) +{ + _PyObject_GC_UNTRACK(self); + RISCOSError_clear(self); + Py_TYPE(self)->tp_free((PyObject *)self); +} + +static int +RISCOSError_traverse(PyRISCOSErrorObject *self, visitproc visit, void *arg) +{ + Py_VISIT(self->errmsg); + Py_VISIT(self->errnum); + return BaseException_traverse((PyBaseExceptionObject *)self, visit, arg); +} + +static PyObject * +RISCOSError_str(PyRISCOSErrorObject *self) +{ + return self->errmsg; +} + +static PyMemberDef RISCOSError_members[] = { + {"errmsg", _Py_T_OBJECT, offsetof(PyRISCOSErrorObject, errmsg), Py_READONLY, + PyDoc_STR("error message")}, + {"errnum", _Py_T_OBJECT, offsetof(PyRISCOSErrorObject, errnum), Py_READONLY, + PyDoc_STR("error number")}, + {NULL} /* Sentinel */ +}; + +ComplexExtendsException(PyExc_Exception, RISCOSError, RISCOSError, + 0, 0, RISCOSError_members, 0, + RISCOSError_str, "RISC OS error."); +#endif + #ifdef MS_WINDOWS #include @@ -4341,6 +4408,9 @@ static struct static_exception static_exceptions[] = { ITEM(UnicodeDecodeError), ITEM(UnicodeEncodeError), ITEM(UnicodeTranslateError), +#ifdef RISCOS + ITEM(RISCOSError), // base: Exception +#endif #undef ITEM }; diff --git a/Programs/_freeze_module.c b/Programs/_freeze_module.c index 06d1ee016dc2a8..c3b42f22e6f462 100644 --- a/Programs/_freeze_module.c +++ b/Programs/_freeze_module.c @@ -14,6 +14,13 @@ #include "pycore_fileutils.h" // _Py_stat_struct #include +#ifdef RISCOS +#include +int __riscosify_control = __RISCOSIFY_NO_PROCESS | + __RISCOSIFY_NO_SUFFIX | + __RISCOSIFY_NO_REVERSE_SUFFIX; +#endif + #include #include // malloc() #include @@ -79,12 +86,18 @@ read_text(const char *inpath) } struct _Py_stat_struct stat; +#ifdef RISCOS + fseek(infile, 0, SEEK_END); + size_t text_size = ftell(infile); + fseek(infile, 0, SEEK_SET); +#else if (_Py_fstat_noraise(fileno(infile), &stat)) { fprintf(stderr, "cannot fstat '%s'\n", inpath); fclose(infile); return NULL; } size_t text_size = (size_t)stat.st_size; +#endif char *text = (char *) malloc(text_size + 1); if (text == NULL) { diff --git a/Programs/python.c b/Programs/python.c index 84148f7767a7e3..9cee46b2623f19 100644 --- a/Programs/python.c +++ b/Programs/python.c @@ -2,6 +2,13 @@ #include "Python.h" +#ifdef RISCOS +#include +int __riscosify_control = __RISCOSIFY_NO_PROCESS | + __RISCOSIFY_NO_SUFFIX | + __RISCOSIFY_NO_REVERSE_SUFFIX; +#endif + #ifdef MS_WINDOWS int wmain(int argc, wchar_t **argv) diff --git a/Python/dynload_shlib.c b/Python/dynload_shlib.c index 583c9b752dfd90..eeae9f29a36f81 100644 --- a/Python/dynload_shlib.c +++ b/Python/dynload_shlib.c @@ -8,6 +8,10 @@ #include "pycore_interp.h" // _PyInterpreterState.dlopenflags #include "pycore_pystate.h" // _PyInterpreterState_GET() +#ifdef RISCOS +#include +#endif + #include #include @@ -37,7 +41,10 @@ */ const char *_PyImport_DynLoadFiletab[] = { -#ifdef __CYGWIN__ +#if defined(RISCOS) + "/so", + "/" SOABI "/so", +#elif defined(__CYGWIN__) ".dll", #else /* !__CYGWIN__ */ "." SOABI ".so", @@ -59,14 +66,18 @@ _PyImport_FindSharedFuncptr(const char *prefix, dl_funcptr p; void *handle; char funcname[258]; +#ifndef RISCOS char pathbuf[260]; +#endif int dlopenflags=0; +#ifndef RISCOS if (strchr(pathname, '/') == NULL) { /* Prefix bare filename with "./" */ PyOS_snprintf(pathbuf, sizeof(pathbuf), "./%-.255s", pathname); pathname = pathbuf; } +#endif PyOS_snprintf(funcname, sizeof(funcname), LEAD_UNDERSCORE "%.20s_%.200s", prefix, shortname); @@ -79,7 +90,13 @@ _PyImport_FindSharedFuncptr(const char *prefix, dlopenflags = _PyImport_GetDLOpenFlags(_PyInterpreterState_GET()); +#ifdef RISCOS + char* unixpath = __unixify(pathname, 0x0, 0, 0, -1); + handle = dlopen(unixpath, dlopenflags); + free(unixpath); +#else handle = dlopen(pathname, dlopenflags); +#endif if (handle == NULL) { PyObject *mod_name; diff --git a/Python/initconfig.c b/Python/initconfig.c index 2dce878770db4a..b008708911edbc 100644 --- a/Python/initconfig.c +++ b/Python/initconfig.c @@ -1795,6 +1795,14 @@ config_init_hash_seed(PyConfig *config) } +#ifdef RISCOS +#warning config_wstr_to_int hardcoded to return 0 +static int +config_wstr_to_int(const wchar_t *wstr, int *result) +{ + return 0; +} +#else static int config_wstr_to_int(const wchar_t *wstr, int *result) { @@ -1811,6 +1819,7 @@ config_wstr_to_int(const wchar_t *wstr, int *result) *result = (int)value; return 0; } +#endif static PyStatus config_read_gil(PyConfig *config, size_t len, wchar_t first_char) diff --git a/RISCOS/Makefile b/RISCOS/Makefile new file mode 100644 index 00000000000000..b4f36505e95681 --- /dev/null +++ b/RISCOS/Makefile @@ -0,0 +1,1576 @@ +# Top-level Makefile for Python on RISC OS +# + +# === Variables set by makesetup === + +MODBUILT_NAMES= posix errno pwd _sre _codecs _weakref _functools _operator _collections _abc itertools atexit _signal _stat time _thread _locale _io faulthandler _tracemalloc _symtable xxsubtype +MODDISABLED_NAMES= +MODOBJS=Modules/posixmodule.o Modules/errnomodule.o Modules/pwdmodule.o Modules/_sre.o Modules/_codecsmodule.o Modules/_weakref.o Modules/_functoolsmodule.o Modules/_operator.o Modules/_collectionsmodule.o Modules/_abc.o Modules/itertoolsmodule.o Modules/atexitmodule.o Modules/signalmodule.o Modules/_stat.o Modules/timemodule.o Modules/_threadmodule.o Modules/_localemodule.o Modules/_iomodule.o Modules/iobase.o Modules/fileio.o Modules/bytesio.o Modules/bufferedio.o Modules/textio.o Modules/stringio.o Modules/faulthandler.o Modules/_tracemalloc.o Modules/hashtable.o Modules/symtablemodule.o Modules/xxsubtype.o +MODLIBS= $(LOCALMODLIBS) $(BASEMODLIBS) + +# === Variables set by configure +VERSION= 3.14 +srcdir= . + +# Add -mfpu=vfp -mfloat-abi=softfp for VFP +CC= gcc +CXX= cxx +RM= X Wipe +RMFLAGS=~CFR~V + +#ifneq ($(GCCSDK_INSTALL_CROSSBIN),"") +# CC= arm-unknown-riscos-gcc +# CXX= arm-unknown-riscos-g++ +# RM= rm +# RMFLAGS=-rf +#endif + +MAINCC= $(CC) +LINKCC= $(PURIFY) $(MAINCC) +AR= ar +READELF= readelf +SOABI= cpython-38-arm-riscos +LDVERSION= $(VERSION)$(ABIFLAGS) +LIBPYTHON= +GITVERSION= git --git-dir $(srcdir)/.git rev-parse --short HEAD +GITTAG= git --git-dir $(srcdir)/.git describe --all --always --dirty +GITBRANCH= git --git-dir $(srcdir)/.git name-rev --name-only HEAD +PGO_PROF_GEN_FLAG=-fprofile-generate +PGO_PROF_USE_FLAG=-fprofile-use -fprofile-correction +LLVM_PROF_MERGER=true +LLVM_PROF_FILE= +LLVM_PROF_ERR=no +DTRACE= +DFLAGS= +DTRACE_HEADERS= +DTRACE_OBJS= +#VFP_FLAGS= -mfloat-abi=softfp -mfpu=vfp +# -mcpu=arm1176jzf-s +VFP_FLAGS= + +GNULD= yes + +# Shell used by make (some versions default to the login shell, which is bad) +SHELL= /bin/sh + +# Use this to make a link between python$(VERSION) and python in $(BINDIR) +LN= ln + +# Portable install script (configure doesn't always guess right) +INSTALL= /usr/bin/install -c +INSTALL_PROGRAM=${INSTALL} +INSTALL_SCRIPT= ${INSTALL} +INSTALL_DATA= ${INSTALL} -m 644 +# Shared libraries must be installed with executable mode on some systems; +# rather than figuring out exactly which, we always give them executable mode. +INSTALL_SHARED= ${INSTALL} -m 755 + +MKDIR_P= /usr/bin/mkdir -p + +MAKESETUP= $(srcdir)/Modules/makesetup + +# Compiler options +OPT= -O3 -DNDEBUG -DRISCOS -fwrapv -Wall -fno-builtin -std=c99 +BASECFLAGS= -Wno-unused-result -Wsign-compare -THROWBACK +BASECPPFLAGS= +CONFIGURE_CFLAGS= +EXTRA_CFLAGS= $(VFP_FLAGS) +# CFLAGS_NODIST is used for building the interpreter and stdlib C extensions. +# Use it when a compiler flag should _not_ be part of the distutils CFLAGS +# once Python is installed (Issue #21121). +CONFIGURE_CFLAGS_NODIST=-Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration +# LDFLAGS_NODIST is used in the same manner as CFLAGS_NODIST. +# Use it when a linker flag should _not_ be part of the distutils LDFLAGS +# once Python is installed (bpo-35257) +CONFIGURE_LDFLAGS_NODIST= +CONFIGURE_CPPFLAGS= +CONFIGURE_LDFLAGS= +# Avoid assigning CFLAGS, LDFLAGS, etc. so users can use them on the +# command line to append to these values without stomping the pre-set +# values. +PY_CFLAGS= $(BASECFLAGS) $(OPT) $(CONFIGURE_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) +PY_CFLAGS_NODIST=$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_NODIST) -IInclude/internal +# Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to +# be able to build extension modules using the directories specified in the +# environment variables +PY_CPPFLAGS= $(BASECPPFLAGS) -IInclude -IRISCOS $(CONFIGURE_CPPFLAGS) $(CPPFLAGS) +PY_LDFLAGS= $(CONFIGURE_LDFLAGS) $(LDFLAGS) $(VFP_FLAGS) +PY_LDFLAGS_NODIST=$(CONFIGURE_LDFLAGS_NODIST) $(LDFLAGS_NODIST) +NO_AS_NEEDED= -Wl,--no-as-needed +SGI_ABI= @SGI_ABI@ +CCSHARED= -fPIC +# LINKFORSHARED are the flags passed to the $(CC) command that links +# the python executable -- this is only needed for a few systems +LINKFORSHARED= -Xlinker -export-dynamic +ARFLAGS= rcs +# Extra C flags added for building the interpreter object files. +CFLAGSFORSHARED= +# C flags used for building the interpreter object files +PY_STDMODULE_CFLAGS= $(PY_CFLAGS) $(PY_CFLAGS_NODIST) $(PY_CPPFLAGS) $(CFLAGSFORSHARED) +PY_BUILTIN_MODULE_CFLAGS= $(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN +PY_CORE_CFLAGS= $(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE +# Linker flags used for building the interpreter object files +PY_CORE_LDFLAGS=$(PY_LDFLAGS) $(PY_LDFLAGS_NODIST) +# Strict or non-strict aliasing flags used to compile dtoa.c, see above +CFLAGS_ALIASING= + + +# Machine-dependent subdirectories +MACHDEP= RISCOS + +# Install prefix for architecture-independent files +prefix= /usr/local + +# Install prefix for architecture-dependent files +exec_prefix= ${prefix} + +# Install prefix for data files +datarootdir= ${prefix}/share + +# Expanded directories +BINDIR= ${exec_prefix}/bin +LIBDIR= ${exec_prefix}/lib +MANDIR= ${datarootdir}/man +INCLUDEDIR= ${prefix}/include +CONFINCLUDEDIR= $(exec_prefix)/include +SCRIPTDIR= $(prefix)/lib +ABIFLAGS= + +# Detailed destination directories +BINLIBDEST= $(LIBDIR)/python$(VERSION) +LIBDEST= $(SCRIPTDIR)/python$(VERSION) +INCLUDEPY= $(INCLUDEDIR)/python$(LDVERSION) +CONFINCLUDEPY= $(CONFINCLUDEDIR)/python$(LDVERSION) + +# Symbols used for using shared libraries +SHLIB_SUFFIX= /so +EXT_SUFFIX= /so +LDSHARED= $(CC) -shared $(PY_LDFLAGS) +BLDSHARED= $(CC) -shared $(PY_CORE_LDFLAGS) +LDCXXSHARED= $(CXX) -shared +DESTSHARED= $(BINLIBDEST)/lib-dynload + +# Executable suffix (.exe on Windows and Mac OS X) +EXE= +BUILDEXE= +#ifneq ($(GCCSDK_INSTALL_CROSSBIN),"") +# EXE=,e1f +# BUILDEXE=,e1f +#endif + +# Option to install to strip binaries +STRIPFLAG=-s + +# Environment to run shared python without installed libraries +RUNSHARED= + +# ensurepip options +ENSUREPIP= upgrade + +# OpenSSL options for setup.py so sysconfig can pick up AC_SUBST() vars. +OPENSSL_INCLUDES=-ILibSSL: +OPENSSL_LIBS=-lssl -lcrypto +OPENSSL_LDFLAGS= + +# Modes for directories, executables and data files created by the +# install process. Default to user-only-writable for all file types. +DIRMODE= 755 +EXEMODE= 755 +FILEMODE= 644 + +# configure script arguments +CONFIG_ARGS= + + +# Subdirectories with code +SRCDIRS= Parser Objects Python Modules Modules/_io Programs + +# Other subdirectories +SUBDIRSTOO= Include Lib Misc + +# Files and directories to be distributed +CONFIGFILES= configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in +DISTFILES= README.rst ChangeLog $(CONFIGFILES) +DISTDIRS= $(SUBDIRS) $(SUBDIRSTOO) Ext-dummy +DIST= $(DISTFILES) $(DISTDIRS) + + +#LIBRARY= libpython$(VERSION)$(ABIFLAGS).a +#LDLIBRARY= libpython$(VERSION)$(ABIFLAGS).a +LIBRARY= libpython38 +LDLIBRARY= $(LIBRARY) +BLDLIBRARY= $(LDLIBRARY) +PY3LIBRARY= +DLLLIBRARY= +LDLIBRARYDIR= +INSTSONAME= $(LDLIBRARY) + + +#LIBS= -lcrypt -lpthread -ldl -lutil -lm +LIBS= -ldl +LIBM= -lm +LIBC= +SYSLIBS= $(LIBM) $(LIBC) +SHLIBS= $(LIBS) + +DLINCLDIR= . +DYNLOADFILE= dynload_shlib.o +MACHDEP_OBJS= +LIBOBJDIR= Python/ +LIBOBJS= + +PYTHON= python38 +BUILDPYTHON= python3$(EXE) + +PYTHON_FOR_REGEN=python3.8 +UPDATE_FILE=python3.8 $(srcdir)/Tools/scripts/update_file.py +PYTHON_FOR_BUILD=./$(BUILDPYTHON) -E +_PYTHON_HOST_PLATFORM=_riscos +HOST_GNU_TYPE=arm-unknown-riscos + +# Tcl and Tk config info from --with-tcltk-includes and -libs options +TCLTK_INCLUDES= +TCLTK_LIBS= + +# The task to run while instrumented when building the profile-opt target. +# To speed up profile generation, we don't run the full unit test suite +# by default. The default is "-m test --pgo". To run more tests, use +# PROFILE_TASK="-m test --pgo-extended" +PROFILE_TASK= -m test --pgo + +# report files for gcov / lcov coverage report +COVERAGE_INFO= $(abs_builddir)/coverage.info +COVERAGE_REPORT=$(abs_builddir)/lcov-report +COVERAGE_REPORT_OPTIONS=--no-branch-coverage --title "CPython lcov report" + + +# === Definitions added by makesetup === + +LOCALMODLIBS= +BASEMODLIBS= +PYTHONPATH=$(COREPYTHONPATH) +COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(TESTPATH) +TESTPATH= +SITEPATH= +DESTPATH= +MACHDESTLIB=$(BINLIBDEST) +DESTLIB=$(LIBDEST) + + + +########################################################################## +# Modules +MODULE_OBJS= \ + RISCOS/config.o \ + RISCOS/getpath.o \ + RISCOS/swimodule.o \ + Modules/main.o \ + Modules/gcmodule.o + +IO_H= Modules/_io/_iomodule.h + +IO_OBJS= \ + Modules/_io/_iomodule.o \ + Modules/_io/iobase.o \ + Modules/_io/fileio.o \ + Modules/_io/bufferedio.o \ + Modules/_io/textio.o \ + Modules/_io/bytesio.o \ + Modules/_io/stringio.o + +########################################################################## + +LIBFFI_INCLUDEDIR= + +########################################################################## +# Parser +POBJS= \ + Parser/acceler.o \ + Parser/grammar1.o \ + Parser/listnode.o \ + Parser/node.o \ + Parser/parser.o \ + Parser/token.o \ + +PARSER_OBJS= $(POBJS) \ + Parser/myreadline.o \ + Parser/parsetok.o \ + Parser/tokenizer.o + +PARSER_HEADERS= \ + $(srcdir)/Include/grammar.h \ + $(srcdir)/Include/parsetok.h \ + $(srcdir)/Parser/parser.h \ + $(srcdir)/Parser/tokenizer.h + +########################################################################## +# Python +PYTHON_OBJS= \ + Python/_warnings.o \ + Python/Python-ast.o \ + Python/asdl.o \ + Python/ast.o \ + Python/ast_opt.o \ + Python/ast_unparse.o \ + Python/bltinmodule.o \ + Python/ceval.o \ + Python/codecs.o \ + Python/compile.o \ + Python/context.o \ + Python/dynamic_annotations.o \ + Python/errors.o \ + Python/frozenmain.o \ + Python/future.o \ + Python/getargs.o \ + Python/getcompiler.o \ + Python/getcopyright.o \ + Python/getplatform.o \ + Python/getversion.o \ + Python/graminit.o \ + Python/hamt.o \ + Python/import.o \ + Python/importdl.o \ + Python/initconfig.o \ + Python/marshal.o \ + Python/modsupport.o \ + Python/mysnprintf.o \ + Python/mystrtoul.o \ + Python/pathconfig.o \ + Python/peephole.o \ + Python/preconfig.o \ + Python/pyarena.o \ + Python/pyctype.o \ + Python/pyfpe.o \ + Python/pyhash.o \ + Python/pylifecycle.o \ + Python/pymath.o \ + Python/pystate.o \ + Python/pythonrun.o \ + Python/pytime.o \ + Python/bootstrap_hash.o \ + Python/structmember.o \ + Python/symtable.o \ + Python/sysmodule.o \ + Python/thread.o \ + Python/traceback.o \ + Python/getopt.o \ + Python/pystrcmp.o \ + Python/pystrtod.o \ + Python/pystrhex.o \ + Python/dtoa.o \ + Python/formatter_unicode.o \ + Python/fileutils.o \ + Python/$(DYNLOADFILE) \ + $(LIBOBJS) \ + $(MACHDEP_OBJS) \ + $(DTRACE_OBJS) + + +########################################################################## +# Objects +OBJECT_OBJS= \ + Objects/abstract.o \ + Objects/accu.o \ + Objects/boolobject.o \ + Objects/bytes_methods.o \ + Objects/bytearrayobject.o \ + Objects/bytesobject.o \ + Objects/call.o \ + Objects/capsule.o \ + Objects/cellobject.o \ + Objects/classobject.o \ + Objects/codeobject.o \ + Objects/complexobject.o \ + Objects/descrobject.o \ + Objects/enumobject.o \ + Objects/exceptions.o \ + Objects/genobject.o \ + Objects/fileobject.o \ + Objects/floatobject.o \ + Objects/frameobject.o \ + Objects/funcobject.o \ + Objects/interpreteridobject.o \ + Objects/iterobject.o \ + Objects/listobject.o \ + Objects/longobject.o \ + Objects/dictobject.o \ + Objects/odictobject.o \ + Objects/memoryobject.o \ + Objects/methodobject.o \ + Objects/moduleobject.o \ + Objects/namespaceobject.o \ + Objects/object.o \ + Objects/obmalloc.o \ + Objects/picklebufobject.o \ + Objects/rangeobject.o \ + Objects/setobject.o \ + Objects/sliceobject.o \ + Objects/structseq.o \ + Objects/tupleobject.o \ + Objects/typeobject.o \ + Objects/unicodeobject.o \ + Objects/unicodectype.o \ + Objects/weakrefobject.o + +########################################################################## +# objects that get linked into the Python library +LIBRARY_OBJS_OMIT_FROZEN= \ + Modules/getbuildinfo.o \ + $(PARSER_OBJS) \ + $(OBJECT_OBJS) \ + $(PYTHON_OBJS) \ + $(MODULE_OBJS) \ + $(MODOBJS) + +LIBRARY_OBJS= \ + $(LIBRARY_OBJS_OMIT_FROZEN) \ + Python/frozen.o + +########################################################################## +# DTrace + +# On some systems, object files that reference DTrace probes need to be modified +# in-place by dtrace(1). +DTRACE_DEPS = \ + Python/ceval.o Python/import.o Python/sysmodule.o Modules/gcmodule.o + +######################################################################### +# Rules + +# Default target +all: build_all +#build_all: check-clean-src $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks +build_all: $(BUILDPYTHON) +# Programs/_testembed +# sharedmods \ +# python-config + +# Check that the source is clean when building out of source. +check-clean-src: + @if test -n "$(VPATH)" -a -f "$(srcdir)/Programs/python.o"; then \ + echo "Error: The source directory ($(srcdir)) is not clean" ; \ + echo "Building Python out of the source tree (in $(abs_builddir)) requires a clean source tree ($(abs_srcdir))" ; \ + echo "Try to run: make -C \"$(srcdir)\" clean" ; \ + exit 1; \ + fi + +# Run "Argument Clinic" over all source files +.PHONY=clinic +clinic: check-clean-src $(srcdir)/Modules/_blake2/blake2s_impl.c + $(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py --make --srcdir $(srcdir) + +# Build the interpreter +$(BUILDPYTHON): Programs/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY) + $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) + +platform: $(BUILDPYTHON) pybuilddir + $(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform + +# Create build directory and generate the sysconfig build-time data there. +# pybuilddir.txt contains the name of the build dir and is used for +# sys.path fixup -- see Modules/getpath.c. +# Since this step runs before shared modules are built, try to avoid bootstrap +# problems by creating a dummy pybuilddir.txt just to allow interpreter +# initialization to succeed. It will be overwritten by generate-posix-vars +# or removed in case of failure. +pybuilddir: $(BUILDPYTHON) + @echo "none" > ./pybuilddir.txt + $(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars ;\ + if test $$? -ne 0 ; then \ + echo "generate-posix-vars failed" ; \ + rm pybuilddir ; \ + exit 1 ; \ + fi + +# This is shared by the math and cmath modules +Modules/_math.o: Modules/_math.c Modules/_math.h + $(CC) -c $(CCSHARED) $(PY_CORE_CFLAGS) -o $@ $< + +# blake2s is auto-generated from blake2b +$(srcdir)/Modules/_blake2/blake2s_impl.c: $(srcdir)/Modules/_blake2/blake2b_impl.c $(srcdir)/Modules/_blake2/blake2b2s.py + $(PYTHON_FOR_REGEN) $(srcdir)/Modules/_blake2/blake2b2s.py + $(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py -f $@ + +# RISC OS SWI module +RISCOS/swimodule.o: RISCOS/swimodule.c + $(CC) -c $(PY_CORE_CFLAGS) -o $@ $< + +# RISC OS getpath +RISCOS/getpath.o: RISCOS/getpath.c + $(CC) -c $(PY_CORE_CFLAGS) -DVERSION=\"$(VERSION)\" -DPYTHONPATH=\"\" -DPREFIX=\"\\" -DEXEC_PREFIX=\"\\" -DVPATH=\"\" -o $@ $< +# -DP`REFIX='"$(prefix)"' \ +# -DEXEC_PREFIX='"$(exec_prefix)"' \ +# -DVPATH='"$(VPATH)"' \ + +# Build the shared modules +sharedmods: $(BUILDPYTHON) pybuilddir Modules/_math.o + Set CC '$(CC)' + Set LDSHARED '$(BLDSHARED)' + Set OPT '$(OPT)' + Set _TCLTK_INCLUDES '$(TCLTK_INCLUDES)' + Set _TCLTK_LIBS '$(TCLTK_LIBS)' + $(PYTHON_FOR_BUILD) setup/py build +# $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' $(PYTHON_FOR_BUILD) $(srcdir)/setup $$quiet build + +# Build static library +$(LIBRARY): $(LIBRARY_OBJS) + $(RM) $@ $(RMFLAGS) + $(AR) $(ARFLAGS) $@ $(LIBRARY_OBJS) + +#libpython$(LDVERSION).so: $(LIBRARY_OBJS) $(DTRACE_OBJS) +# if test $(INSTSONAME) != $(LDLIBRARY); then \ +# $(BLDSHARED) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM); \ +# $(LN) -f $(INSTSONAME) $@; \ +# else \ +# $(BLDSHARED) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM); \ +# fi +# +#libpython3.so: libpython$(LDVERSION).so +# $(BLDSHARED) $(NO_AS_NEEDED) -o $@ -Wl,-h$@ $^ +# +#libpython$(LDVERSION).dylib: $(LIBRARY_OBJS) +# $(CC) -dynamiclib -Wl,-single_module $(PY_CORE_LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$#(LDVERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(DTRACE_OBJS) $(SHLIBS) $(LIBC) $(LIBM); \ + + +libpython$(VERSION).sl: $(LIBRARY_OBJS) + $(LDSHARED) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) + +Programs/_testembed: Programs/_testembed.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY) + $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/_testembed.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) + +############################################################################ +# Importlib + +Programs/_freeze_importlib.o: Programs/_freeze_importlib.c + +Programs/_freeze_importlib$(EXE): Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN) + $(LINKCC) $(PY_CORE_LDFLAGS) -o $@ Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN) $(LIBS) $(MODLIBS) $(SYSLIBS) + +.PHONY: regen-importlib +regen-importlib: Programs/_freeze_importlib + # Regenerate Python/importlib_external.h + # from Lib/importlib/_bootstrap_external.py using _freeze_importlib + ./Programs/_freeze_importlib importlib._bootstrap_external \ + $(srcdir)/Lib/importlib/_bootstrap_external.py \ + $(srcdir)/Python/importlib_external.h.new + $(UPDATE_FILE) $(srcdir)/Python/importlib_external.h $(srcdir)/Python/importlib_external.h.new + # Regenerate Python/importlib.h from Lib/importlib/_bootstrap.py + # using _freeze_importlib + ./Programs/_freeze_importlib importlib._bootstrap \ + $(srcdir)/Lib/importlib/_bootstrap.py \ + $(srcdir)/Python/importlib.h.new + $(UPDATE_FILE) $(srcdir)/Python/importlib.h $(srcdir)/Python/importlib.h.new + # Regenerate Python/importlib_zipimport.h from Lib/zipimport.py + # using _freeze_importlib + ./Programs/_freeze_importlib zipimport \ + $(srcdir)/Lib/zipimport.py \ + $(srcdir)/Python/importlib_zipimport.h.new + $(UPDATE_FILE) $(srcdir)/Python/importlib_zipimport.h $(srcdir)/Python/importlib_zipimport.h.new + + +############################################################################ +# Regenerate all generated files + +regen-all: regen-opcode regen-opcode-targets regen-typeslots regen-grammar \ + regen-token regen-keyword regen-symbol regen-ast regen-importlib clinic + +############################################################################ +# Special rules for object files + +Modules/getbuildinfo.o: $(PARSER_OBJS) \ + $(OBJECT_OBJS) \ + $(PYTHON_OBJS) \ + $(MODULE_OBJS) \ + $(MODOBJS) \ + $(DTRACE_OBJS) \ + $(srcdir)/Modules/getbuildinfo.c +# $(CC) -c $(PY_CORE_CFLAGS) \ +# -DGITVERSION="\"`LC_ALL=C $(GITVERSION)`\"" \ +# -DGITTAG="\"`LC_ALL=C $(GITTAG)`\"" \ +# -DGITBRANCH="\"`LC_ALL=C $(GITBRANCH)`\"" \ + $(CC) -c $(PY_CORE_CFLAGS) \ + -o $@ $(srcdir)/Modules/getbuildinfo.c + +Modules/getpath.o: $(srcdir)/Modules/getpath.c + $(CC) -c $(PY_CORE_CFLAGS) \ + -DPYTHONPATH='"$(PYTHONPATH)"' \ + -DPREFIX='"$(prefix)"' \ + -DEXEC_PREFIX='"$(exec_prefix)"' \ + -DVERSION='"$(VERSION)"' \ + -DVPATH='"$(VPATH)"' \ + -o $@ $(srcdir)/Modules/getpath.c + +Programs/python.o: $(srcdir)/Programs/python.c + $(MAINCC) -c $(PY_CORE_CFLAGS) -o $@ $(srcdir)/Programs/python.c + +Programs/_testembed.o: $(srcdir)/Programs/_testembed.c + $(MAINCC) -c $(PY_CORE_CFLAGS) -o $@ $(srcdir)/Programs/_testembed.c + +Modules/_sre.o: $(srcdir)/Modules/_sre.c $(srcdir)/Modules/sre.h $(srcdir)/Modules/sre_constants.h $(srcdir)/Modules/sre_lib.h + +Modules/posixmodule.o: $(srcdir)/Modules/posixmodule.c $(srcdir)/Modules/posixmodule.h + +Modules/grpmodule.o: $(srcdir)/Modules/grpmodule.c $(srcdir)/Modules/posixmodule.h + +Modules/pwdmodule.o: $(srcdir)/Modules/pwdmodule.c $(srcdir)/Modules/posixmodule.h + +Modules/signalmodule.o: $(srcdir)/Modules/signalmodule.c $(srcdir)/Modules/posixmodule.h + +Python/dynload_shlib.o: $(srcdir)/Python/dynload_shlib.c + $(CC) -c $(PY_CORE_CFLAGS) -DSOABI=\"$(SOABI)\" -o $@ $(srcdir)/Python/dynload_shlib.c + +Python/sysmodule.o: $(srcdir)/Python/sysmodule.c $(srcdir)/Include/pydtrace.h + $(CC) -c $(PY_CORE_CFLAGS) -DABIFLAGS="\"$(ABIFLAGS)\"" -o $@ $(srcdir)/Python/sysmodule.c + +$(IO_OBJS): $(IO_H) + +.PHONY: regen-grammar +regen-grammar: regen-token + # Regenerate Include/graminit.h and Python/graminit.c + # from Grammar/Grammar using pgen + @$(MKDIR_P) Include + PYTHONPATH=$(srcdir) $(PYTHON_FOR_REGEN) -m Parser.pgen $(srcdir)/Grammar/Grammar \ + $(srcdir)/Grammar/Tokens \ + $(srcdir)/Include/graminit.h.new \ + $(srcdir)/Python/graminit.c.new + $(UPDATE_FILE) $(srcdir)/Include/graminit.h $(srcdir)/Include/graminit.h.new + $(UPDATE_FILE) $(srcdir)/Python/graminit.c $(srcdir)/Python/graminit.c.new + +.PHONY=regen-ast +regen-ast: + # Regenerate Include/Python-ast.h using Parser/asdl_c.py -h + $(MKDIR_P) $(srcdir)/Include + $(PYTHON_FOR_REGEN) $(srcdir)/Parser/asdl_c.py \ + -h $(srcdir)/Include/Python-ast.h.new \ + $(srcdir)/Parser/Python.asdl + $(UPDATE_FILE) $(srcdir)/Include/Python-ast.h $(srcdir)/Include/Python-ast.h.new + # Regenerate Python/Python-ast.c using Parser/asdl_c.py -c + $(MKDIR_P) $(srcdir)/Python + $(PYTHON_FOR_REGEN) $(srcdir)/Parser/asdl_c.py \ + -c $(srcdir)/Python/Python-ast.c.new \ + $(srcdir)/Parser/Python.asdl + $(UPDATE_FILE) $(srcdir)/Python/Python-ast.c $(srcdir)/Python/Python-ast.c.new + +.PHONY: regen-opcode +regen-opcode: + # Regenerate Include/opcode.h from Lib/opcode.py + # using Tools/scripts/generate_opcode_h.py + $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_opcode_h.py \ + $(srcdir)/Lib/opcode.py \ + $(srcdir)/Include/opcode.h.new + $(UPDATE_FILE) $(srcdir)/Include/opcode.h $(srcdir)/Include/opcode.h.new + +.PHONY: regen-token +regen-token: + # Regenerate Doc/library/token-list.inc from Grammar/Tokens + # using Tools/scripts/generate_token.py + $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py rst \ + $(srcdir)/Grammar/Tokens \ + $(srcdir)/Doc/library/token-list.inc + # Regenerate Include/token.h from Grammar/Tokens + # using Tools/scripts/generate_token.py + $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py h \ + $(srcdir)/Grammar/Tokens \ + $(srcdir)/Include/token.h + # Regenerate Parser/token.c from Grammar/Tokens + # using Tools/scripts/generate_token.py + $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py c \ + $(srcdir)/Grammar/Tokens \ + $(srcdir)/Parser/token.c + # Regenerate Lib/token.py from Grammar/Tokens + # using Tools/scripts/generate_token.py + $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py py \ + $(srcdir)/Grammar/Tokens \ + $(srcdir)/Lib/token.py + +.PHONY: regen-keyword +regen-keyword: + # Regenerate Lib/keyword.py from Grammar/Grammar and Grammar/Tokens + # using Parser/pgen + PYTHONPATH=$(srcdir) $(PYTHON_FOR_REGEN) -m Parser.pgen.keywordgen $(srcdir)/Grammar/Grammar \ + $(srcdir)/Grammar/Tokens \ + $(srcdir)/Lib/keyword.py.new + $(UPDATE_FILE) $(srcdir)/Lib/keyword.py $(srcdir)/Lib/keyword.py.new + +.PHONY: regen-symbol +regen-symbol: $(srcdir)/Include/graminit.h + # Regenerate Lib/symbol.py from Include/graminit.h + # using Tools/scripts/generate_symbol_py.py + $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_symbol_py.py \ + $(srcdir)/Include/graminit.h \ + $(srcdir)/Lib/symbol.py + +Python/compile.o Python/symtable.o Python/ast_unparse.o Python/ast.o Python/future.o Parser/parsetok.o: $(srcdir)/Include/graminit.h $(srcdir)/Include/Python-ast.h + +Python/getplatform.o: $(srcdir)/Python/getplatform.c + $(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c + +Python/importdl.o: $(srcdir)/Python/importdl.c + $(CC) -c $(PY_CORE_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c + +Objects/unicodectype.o: $(srcdir)/Objects/unicodectype.c \ + $(srcdir)/Objects/unicodetype_db.h + +BYTESTR_DEPS = \ + $(srcdir)/Objects/stringlib/count.h \ + $(srcdir)/Objects/stringlib/ctype.h \ + $(srcdir)/Objects/stringlib/fastsearch.h \ + $(srcdir)/Objects/stringlib/find.h \ + $(srcdir)/Objects/stringlib/join.h \ + $(srcdir)/Objects/stringlib/partition.h \ + $(srcdir)/Objects/stringlib/split.h \ + $(srcdir)/Objects/stringlib/stringdefs.h \ + $(srcdir)/Objects/stringlib/transmogrify.h + +UNICODE_DEPS = \ + $(srcdir)/Objects/stringlib/asciilib.h \ + $(srcdir)/Objects/stringlib/codecs.h \ + $(srcdir)/Objects/stringlib/count.h \ + $(srcdir)/Objects/stringlib/fastsearch.h \ + $(srcdir)/Objects/stringlib/find.h \ + $(srcdir)/Objects/stringlib/find_max_char.h \ + $(srcdir)/Objects/stringlib/localeutil.h \ + $(srcdir)/Objects/stringlib/partition.h \ + $(srcdir)/Objects/stringlib/replace.h \ + $(srcdir)/Objects/stringlib/split.h \ + $(srcdir)/Objects/stringlib/ucs1lib.h \ + $(srcdir)/Objects/stringlib/ucs2lib.h \ + $(srcdir)/Objects/stringlib/ucs4lib.h \ + $(srcdir)/Objects/stringlib/undef.h \ + $(srcdir)/Objects/stringlib/unicode_format.h \ + $(srcdir)/Objects/stringlib/unicodedefs.h + +Objects/bytes_methods.o: $(srcdir)/Objects/bytes_methods.c $(BYTESTR_DEPS) +Objects/bytesobject.o: $(srcdir)/Objects/bytesobject.c $(BYTESTR_DEPS) +Objects/bytearrayobject.o: $(srcdir)/Objects/bytearrayobject.c $(BYTESTR_DEPS) + +Objects/unicodeobject.o: $(srcdir)/Objects/unicodeobject.c $(UNICODE_DEPS) + +Objects/odictobject.o: $(srcdir)/Objects/dict-common.h +Objects/dictobject.o: $(srcdir)/Objects/stringlib/eq.h $(srcdir)/Objects/dict-common.h +Objects/setobject.o: $(srcdir)/Objects/stringlib/eq.h + +.PHONY: regen-opcode-targets +regen-opcode-targets: + # Regenerate Python/opcode_targets.h from Lib/opcode.py + # using Python/makeopcodetargets.py + $(PYTHON_FOR_REGEN) $(srcdir)/Python/makeopcodetargets.py \ + $(srcdir)/Python/opcode_targets.h.new + $(UPDATE_FILE) $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/opcode_targets.h.new + +Python/ceval.o: $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/ceval_gil.h \ + $(srcdir)/Python/condvar.h + +Python/frozen.o: $(srcdir)/Python/importlib.h $(srcdir)/Python/importlib_external.h \ + $(srcdir)/Python/importlib_zipimport.h + +# Generate DTrace probe macros, then rename them (PYTHON_ -> PyDTrace_) to +# follow our naming conventions. dtrace(1) uses the output filename to generate +# an include guard, so we can't use a pipeline to transform its output. +Include/pydtrace_probes.h: $(srcdir)/Include/pydtrace.d + $(MKDIR_P) Include + $(DTRACE) $(DFLAGS) -o $@ -h -s $< + : sed in-place edit with POSIX-only tools + sed 's/PYTHON_/PyDTrace_/' $@ > $@.tmp + mv $@.tmp $@ + +Python/ceval.o: $(srcdir)/Include/pydtrace.h +Python/import.o: $(srcdir)/Include/pydtrace.h +Modules/gcmodule.o: $(srcdir)/Include/pydtrace.h + +Python/pydtrace.o: $(srcdir)/Include/pydtrace.d $(DTRACE_DEPS) + $(DTRACE) $(DFLAGS) -o $@ -G -s $< $(DTRACE_DEPS) + +Objects/typeobject.o: Objects/typeslots.inc + +.PHONY: regen-typeslots +regen-typeslots: + # Regenerate Objects/typeslots.inc from Include/typeslotsh + # using Objects/typeslots.py + $(PYTHON_FOR_REGEN) $(srcdir)/Objects/typeslots.py \ + < $(srcdir)/Include/typeslots.h \ + $(srcdir)/Objects/typeslots.inc.new + $(UPDATE_FILE) $(srcdir)/Objects/typeslots.inc $(srcdir)/Objects/typeslots.inc.new + +############################################################################ +# Header files + +PYTHON_HEADERS= \ + $(srcdir)/Include/Python.h \ + $(srcdir)/Include/abstract.h \ + $(srcdir)/Include/asdl.h \ + $(srcdir)/Include/ast.h \ + $(srcdir)/Include/bitset.h \ + $(srcdir)/Include/bltinmodule.h \ + $(srcdir)/Include/boolobject.h \ + $(srcdir)/Include/bytearrayobject.h \ + $(srcdir)/Include/bytes_methods.h \ + $(srcdir)/Include/bytesobject.h \ + $(srcdir)/Include/cellobject.h \ + $(srcdir)/Include/ceval.h \ + $(srcdir)/Include/classobject.h \ + $(srcdir)/Include/code.h \ + $(srcdir)/Include/codecs.h \ + $(srcdir)/Include/compile.h \ + $(srcdir)/Include/complexobject.h \ + $(srcdir)/Include/context.h \ + $(srcdir)/Include/descrobject.h \ + $(srcdir)/Include/dictobject.h \ + $(srcdir)/Include/dtoa.h \ + $(srcdir)/Include/dynamic_annotations.h \ + $(srcdir)/Include/enumobject.h \ + $(srcdir)/Include/errcode.h \ + $(srcdir)/Include/eval.h \ + $(srcdir)/Include/fileobject.h \ + $(srcdir)/Include/fileutils.h \ + $(srcdir)/Include/floatobject.h \ + $(srcdir)/Include/frameobject.h \ + $(srcdir)/Include/funcobject.h \ + $(srcdir)/Include/genobject.h \ + $(srcdir)/Include/import.h \ + $(srcdir)/Include/interpreteridobject.h \ + $(srcdir)/Include/intrcheck.h \ + $(srcdir)/Include/iterobject.h \ + $(srcdir)/Include/listobject.h \ + $(srcdir)/Include/longintrepr.h \ + $(srcdir)/Include/longobject.h \ + $(srcdir)/Include/marshal.h \ + $(srcdir)/Include/memoryobject.h \ + $(srcdir)/Include/methodobject.h \ + $(srcdir)/Include/modsupport.h \ + $(srcdir)/Include/moduleobject.h \ + $(srcdir)/Include/namespaceobject.h \ + $(srcdir)/Include/node.h \ + $(srcdir)/Include/object.h \ + $(srcdir)/Include/objimpl.h \ + $(srcdir)/Include/odictobject.h \ + $(srcdir)/Include/opcode.h \ + $(srcdir)/Include/osdefs.h \ + $(srcdir)/Include/osmodule.h \ + $(srcdir)/Include/patchlevel.h \ + $(srcdir)/Include/picklebufobject.h \ + $(srcdir)/Include/pyarena.h \ + $(srcdir)/Include/pycapsule.h \ + $(srcdir)/Include/pyctype.h \ + $(srcdir)/Include/pydebug.h \ + $(srcdir)/Include/pydtrace.h \ + $(srcdir)/Include/pyerrors.h \ + $(srcdir)/Include/pyfpe.h \ + $(srcdir)/Include/pyhash.h \ + $(srcdir)/Include/pylifecycle.h \ + $(srcdir)/Include/pymacconfig.h \ + $(srcdir)/Include/pymacro.h \ + $(srcdir)/Include/pymath.h \ + $(srcdir)/Include/pymem.h \ + $(srcdir)/Include/pyport.h \ + $(srcdir)/Include/pystate.h \ + $(srcdir)/Include/pystrcmp.h \ + $(srcdir)/Include/pystrhex.h \ + $(srcdir)/Include/pystrtod.h \ + $(srcdir)/Include/pythonrun.h \ + $(srcdir)/Include/pythread.h \ + $(srcdir)/Include/pytime.h \ + $(srcdir)/Include/rangeobject.h \ + $(srcdir)/Include/setobject.h \ + $(srcdir)/Include/sliceobject.h \ + $(srcdir)/Include/structmember.h \ + $(srcdir)/Include/structseq.h \ + $(srcdir)/Include/symtable.h \ + $(srcdir)/Include/sysmodule.h \ + $(srcdir)/Include/token.h \ + $(srcdir)/Include/traceback.h \ + $(srcdir)/Include/tracemalloc.h \ + $(srcdir)/Include/tupleobject.h \ + $(srcdir)/Include/ucnhash.h \ + $(srcdir)/Include/unicodeobject.h \ + $(srcdir)/Include/warnings.h \ + $(srcdir)/Include/weakrefobject.h \ + \ + $(srcdir)/RISCOS/pyconfig.h \ + $(PARSER_HEADERS) \ + $(srcdir)/Include/Python-ast.h \ + \ + $(srcdir)/Include/cpython/abstract.h \ + $(srcdir)/Include/cpython/dictobject.h \ + $(srcdir)/Include/cpython/fileobject.h \ + $(srcdir)/Include/cpython/initconfig.h \ + $(srcdir)/Include/cpython/interpreteridobject.h \ + $(srcdir)/Include/cpython/object.h \ + $(srcdir)/Include/cpython/objimpl.h \ + $(srcdir)/Include/cpython/pyerrors.h \ + $(srcdir)/Include/cpython/pylifecycle.h \ + $(srcdir)/Include/cpython/pymem.h \ + $(srcdir)/Include/cpython/pystate.h \ + $(srcdir)/Include/cpython/sysmodule.h \ + $(srcdir)/Include/cpython/traceback.h \ + $(srcdir)/Include/cpython/tupleobject.h \ + $(srcdir)/Include/cpython/unicodeobject.h \ + \ + $(srcdir)/Include/internal/pycore_accu.h \ + $(srcdir)/Include/internal/pycore_atomic.h \ + $(srcdir)/Include/internal/pycore_ceval.h \ + $(srcdir)/Include/internal/pycore_code.h \ + $(srcdir)/Include/internal/pycore_condvar.h \ + $(srcdir)/Include/internal/pycore_context.h \ + $(srcdir)/Include/internal/pycore_fileutils.h \ + $(srcdir)/Include/internal/pycore_getopt.h \ + $(srcdir)/Include/internal/pycore_gil.h \ + $(srcdir)/Include/internal/pycore_hamt.h \ + $(srcdir)/Include/internal/pycore_initconfig.h \ + $(srcdir)/Include/internal/pycore_object.h \ + $(srcdir)/Include/internal/pycore_pathconfig.h \ + $(srcdir)/Include/internal/pycore_pyerrors.h \ + $(srcdir)/Include/internal/pycore_pyhash.h \ + $(srcdir)/Include/internal/pycore_pylifecycle.h \ + $(srcdir)/Include/internal/pycore_pymem.h \ + $(srcdir)/Include/internal/pycore_pystate.h \ + $(srcdir)/Include/internal/pycore_traceback.h \ + $(srcdir)/Include/internal/pycore_tupleobject.h \ + $(srcdir)/Include/internal/pycore_warnings.h \ + $(DTRACE_HEADERS) + +$(LIBRARY_OBJS) $(MODOBJS) Programs/python.o: $(PYTHON_HEADERS) + + +###################################################################### + +TESTOPTS= $(EXTRATESTOPTS) +TESTPYTHON= $(RUNSHARED) ./$(BUILDPYTHON) $(TESTPYTHONOPTS) +TESTRUNNER= $(TESTPYTHON) Tools.scripts.run_tests/py +TESTTIMEOUT= 1200 + +.PHONY: test testall buildbottest pythoninfo + +# Remove "test_python_*" directories of previous failed test jobs. +# Pass TESTOPTS options because it can contain --tempdir option. +cleantest: build_all + $(TESTRUNNER) $(TESTOPTS) --cleanup + +# Run a basic set of regression tests. +# This excludes some tests that are particularly resource-intensive. +test: all platform + $(TESTRUNNER) $(TESTOPTS) + +# Run the full test suite twice - once without .pyc files, and once with. +# In the past, we've had problems where bugs in the marshalling or +# elsewhere caused bytecode read from .pyc files to behave differently +# than bytecode generated directly from a .py source file. Sometimes +# the bytecode read from a .pyc file had the bug, sometimes the directly +# generated bytecode. This is sometimes a very shy bug needing a lot of +# sample data. +testall: all platform + -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f + $(TESTPYTHON) -E Lib.compileall/py + -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f + -$(TESTRUNNER) -u all $(TESTOPTS) + $(TESTRUNNER) -u all $(TESTOPTS) + +pythoninfo: build_all + $(RUNSHARED) ./$(BUILDPYTHON) -m test.pythoninfo + +QUICKTESTOPTS= $(TESTOPTS) -x test_subprocess test_io test_lib2to3 \ + test_multibytecodec test_urllib2_localnet test_itertools \ + test_multiprocessing_fork test_multiprocessing_spawn \ + test_multiprocessing_forkserver \ + test_mailbox test_socket test_poll \ + test_select test_zipfile test_concurrent_futures +quicktest: all platform + $(TESTRUNNER) $(QUICKTESTOPTS) + +# SSL tests +.PHONY: multisslcompile multissltest +multisslcompile: build_all + $(RUNSHARED) ./$(BUILDPYTHON) Tools/ssl/multissltests.py --steps=modules + +multissltest: build_all + $(RUNSHARED) ./$(BUILDPYTHON) Tools/ssl/multissltests.py + +# +# Install the library +XMLLIBSUBDIRS= xml xml/dom xml/etree xml/parsers xml/sax +LIBSUBDIRS= tkinter tkinter/test tkinter/test/test_tkinter \ + tkinter/test/test_ttk site-packages test \ + test/audiodata \ + test/capath test/data \ + test/cjkencodings test/decimaltestdata \ + test/xmltestdata test/xmltestdata/c14n-20 \ + test/dtracedata \ + test/eintrdata \ + test/imghdrdata \ + test/libregrtest \ + test/subprocessdata test/sndhdrdata test/support \ + test/tracedmodules test/encoded_modules \ + test/test_import \ + test/test_import/data \ + test/test_import/data/circular_imports \ + test/test_import/data/circular_imports/subpkg \ + test/test_import/data/package \ + test/test_import/data/package2 \ + importlib \ + importlib/metadata \ + test/test_importlib \ + test/test_importlib/builtin \ + test/test_importlib/data \ + test/test_importlib/data01 \ + test/test_importlib/data01/subdirectory \ + test/test_importlib/data02 \ + test/test_importlib/data02/one \ + test/test_importlib/data02/two \ + test/test_importlib/data03 \ + test/test_importlib/data03/namespace \ + test/test_importlib/data03/namespace/portion1 \ + test/test_importlib/data03/namespace/portion2 \ + test/test_importlib/extension \ + test/test_importlib/frozen \ + test/test_importlib/import_ \ + test/test_importlib/namespace_pkgs \ + test/test_importlib/namespace_pkgs/both_portions \ + test/test_importlib/namespace_pkgs/both_portions/foo \ + test/test_importlib/namespace_pkgs/module_and_namespace_package \ + test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test \ + test/test_importlib/namespace_pkgs/not_a_namespace_pkg \ + test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo \ + test/test_importlib/namespace_pkgs/portion1 \ + test/test_importlib/namespace_pkgs/portion1/foo \ + test/test_importlib/namespace_pkgs/portion2 \ + test/test_importlib/namespace_pkgs/portion2/foo \ + test/test_importlib/namespace_pkgs/project1 \ + test/test_importlib/namespace_pkgs/project1/parent \ + test/test_importlib/namespace_pkgs/project1/parent/child \ + test/test_importlib/namespace_pkgs/project2 \ + test/test_importlib/namespace_pkgs/project2/parent \ + test/test_importlib/namespace_pkgs/project2/parent/child \ + test/test_importlib/namespace_pkgs/project3 \ + test/test_importlib/namespace_pkgs/project3/parent \ + test/test_importlib/namespace_pkgs/project3/parent/child \ + test/test_importlib/source \ + test/test_importlib/zipdata01 \ + test/test_importlib/zipdata02 \ + test/ziptestdata \ + asyncio \ + test/test_asyncio \ + collections concurrent concurrent/futures encodings \ + email email/mime test/test_email test/test_email/data \ + ensurepip ensurepip/_bundled \ + html json test/test_json http dbm xmlrpc \ + sqlite3 sqlite3/test \ + logging csv wsgiref urllib \ + lib2to3 lib2to3/fixes lib2to3/pgen2 lib2to3/tests \ + lib2to3/tests/data lib2to3/tests/data/fixers \ + lib2to3/tests/data/fixers/myfixes \ + ctypes ctypes/test ctypes/macholib \ + idlelib idlelib/Icons idlelib/idle_test \ + distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \ + test/test_tools test/test_warnings test/test_warnings/data \ + turtledemo \ + multiprocessing multiprocessing/dummy \ + unittest unittest/test unittest/test/testmock \ + venv venv/scripts venv/scripts/common venv/scripts/posix \ + curses pydoc_data +libinstall: build_all $(srcdir)/Modules/xxmodule.c + @for i in $(SCRIPTDIR) $(LIBDEST); \ + do \ + if test ! -d $(DESTDIR)$$i; then \ + echo "Creating directory $$i"; \ + $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \ + else true; \ + fi; \ + done + @for d in $(LIBSUBDIRS); \ + do \ + a=$(srcdir)/Lib/$$d; \ + if test ! -d $$a; then continue; else true; fi; \ + b=$(LIBDEST)/$$d; \ + if test ! -d $(DESTDIR)$$b; then \ + echo "Creating directory $$b"; \ + $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$b; \ + else true; \ + fi; \ + done + @for i in $(srcdir)/Lib/*.py; \ + do \ + if test -x $$i; then \ + $(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \ + echo $(INSTALL_SCRIPT) $$i $(LIBDEST); \ + else \ + $(INSTALL_DATA) $$i $(DESTDIR)$(LIBDEST); \ + echo $(INSTALL_DATA) $$i $(LIBDEST); \ + fi; \ + done + @for d in $(LIBSUBDIRS); \ + do \ + a=$(srcdir)/Lib/$$d; \ + if test ! -d $$a; then continue; else true; fi; \ + if test `ls $$a | wc -l` -lt 1; then continue; fi; \ + b=$(LIBDEST)/$$d; \ + for i in $$a/*; \ + do \ + case $$i in \ + *CVS) ;; \ + *.py[co]) ;; \ + *.orig) ;; \ + *~) ;; \ + *) \ + if test -d $$i; then continue; fi; \ + if test -x $$i; then \ + echo $(INSTALL_SCRIPT) $$i $$b; \ + $(INSTALL_SCRIPT) $$i $(DESTDIR)$$b; \ + else \ + echo $(INSTALL_DATA) $$i $$b; \ + $(INSTALL_DATA) $$i $(DESTDIR)$$b; \ + fi;; \ + esac; \ + done; \ + done + $(INSTALL_DATA) `cat pybuilddir.txt`/_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH).py \ + $(DESTDIR)$(LIBDEST); \ + $(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt + if test -d $(DESTDIR)$(LIBDEST)/distutils/tests; then \ + $(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \ + $(DESTDIR)$(LIBDEST)/distutils/tests ; \ + fi + -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ + $(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \ + -j0 -d $(LIBDEST) -f \ + -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ + $(DESTDIR)$(LIBDEST) + -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ + $(PYTHON_FOR_BUILD) -Wi -O $(DESTDIR)$(LIBDEST)/compileall.py \ + -j0 -d $(LIBDEST) -f \ + -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ + $(DESTDIR)$(LIBDEST) + -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ + $(PYTHON_FOR_BUILD) -Wi -OO $(DESTDIR)$(LIBDEST)/compileall.py \ + -j0 -d $(LIBDEST) -f \ + -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ + $(DESTDIR)$(LIBDEST) + -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ + $(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \ + -j0 -d $(LIBDEST)/site-packages -f \ + -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages + -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ + $(PYTHON_FOR_BUILD) -Wi -O $(DESTDIR)$(LIBDEST)/compileall.py \ + -j0 -d $(LIBDEST)/site-packages -f \ + -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages + -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ + $(PYTHON_FOR_BUILD) -Wi -OO $(DESTDIR)$(LIBDEST)/compileall.py \ + -j0 -d $(LIBDEST)/site-packages -f \ + -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages + -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ + $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt + -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ + $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt + +# bpo-21536: Misc/python-config.sh is generated in the build directory +# from $(srcdir)Misc/python-config.sh.in. +python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh + @ # Substitution happens here, as the completely-expanded BINDIR + @ # is not available in configure + sed -e "s,@EXENAME@,$(BINDIR)/python$(LDVERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config.py + @ # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR} + LC_ALL=C sed -e 's,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g' < Misc/python-config.sh >python-config + @ # On Darwin, always use the python version of the script, the shell + @ # version doesn't use the compiler customizations that are provided + @ # in python (_osx_support.py). + @if test `uname -s` = Darwin; then \ + cp python-config.py python-config; \ + fi + + +# Install the include files +INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY) +inclinstall: + @for i in $(INCLDIRSTOMAKE); \ + do \ + if test ! -d $(DESTDIR)$$i; then \ + echo "Creating directory $$i"; \ + $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \ + else true; \ + fi; \ + done + @if test ! -d $(DESTDIR)$(INCLUDEPY)/cpython; then \ + echo "Creating directory $(DESTDIR)$(INCLUDEPY)/cpython"; \ + $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(INCLUDEPY)/cpython; \ + else true; \ + fi + @if test ! -d $(DESTDIR)$(INCLUDEPY)/internal; then \ + echo "Creating directory $(DESTDIR)$(INCLUDEPY)/internal"; \ + $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(INCLUDEPY)/internal; \ + else true; \ + fi + @for i in $(srcdir)/Include/*.h; \ + do \ + echo $(INSTALL_DATA) $$i $(INCLUDEPY); \ + $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY); \ + done + @for i in $(srcdir)/Include/cpython/*.h; \ + do \ + echo $(INSTALL_DATA) $$i $(INCLUDEPY)/cpython; \ + $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY)/cpython; \ + done + @for i in $(srcdir)/Include/internal/*.h; \ + do \ + echo $(INSTALL_DATA) $$i $(INCLUDEPY)/internal; \ + $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY)/internal; \ + done + $(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h + +# Install the library and miscellaneous stuff needed for extending/embedding +# This goes into $(exec_prefix) +LIBPL= $(prefix)/lib/python3.8/config-$(VERSION)$(ABIFLAGS)-arm-riscos + +# pkgconfig directory +LIBPC= $(LIBDIR)/pkgconfig + +libainstall: all python-config + @for i in $(LIBDIR) $(LIBPL) $(LIBPC); \ + do \ + if test ! -d $(DESTDIR)$$i; then \ + echo "Creating directory $$i"; \ + $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \ + else true; \ + fi; \ + done + @if test -d $(LIBRARY); then :; else \ + if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \ + if test "$(SHLIB_SUFFIX)" = .dll; then \ + $(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \ + else \ + $(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \ + fi; \ + else \ + echo Skip install of $(LIBRARY) - use make frameworkinstall; \ + fi; \ + fi + $(INSTALL_DATA) Modules/config.c $(DESTDIR)$(LIBPL)/config.c + $(INSTALL_DATA) Programs/python.o $(DESTDIR)$(LIBPL)/python.o + $(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(DESTDIR)$(LIBPL)/config.c.in + $(INSTALL_DATA) Makefile $(DESTDIR)$(LIBPL)/Makefile + $(INSTALL_DATA) $(srcdir)/Modules/Setup $(DESTDIR)$(LIBPL)/Setup + $(INSTALL_DATA) Modules/Setup.local $(DESTDIR)$(LIBPL)/Setup.local + $(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION).pc + $(INSTALL_DATA) Misc/python-embed.pc $(DESTDIR)$(LIBPC)/python-$(VERSION)-embed.pc + $(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup + $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh + $(INSTALL_SCRIPT) python-config.py $(DESTDIR)$(LIBPL)/python-config.py + $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(LDVERSION)-config + @if [ -s Modules/python.exp -a \ + "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \ + echo; echo "Installing support files for building shared extension modules on AIX:"; \ + $(INSTALL_DATA) Modules/python.exp \ + $(DESTDIR)$(LIBPL)/python.exp; \ + echo; echo "$(LIBPL)/python.exp"; \ + $(INSTALL_SCRIPT) $(srcdir)/Modules/makexp_aix \ + $(DESTDIR)$(LIBPL)/makexp_aix; \ + echo "$(LIBPL)/makexp_aix"; \ + $(INSTALL_SCRIPT) Modules/ld_so_aix \ + $(DESTDIR)$(LIBPL)/ld_so_aix; \ + echo "$(LIBPL)/ld_so_aix"; \ + echo; echo "See Misc/AIX-NOTES for details."; \ + else true; \ + fi + +# Install the dynamically loadable modules +# This goes into $(exec_prefix) +sharedinstall: sharedmods + $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \ + --prefix=$(prefix) \ + --install-scripts=$(BINDIR) \ + --install-platlib=$(DESTSHARED) \ + --root=$(DESTDIR)/ + -rm $(DESTDIR)$(DESTSHARED)/_sysconfigdata_$(ABIFLAGS)_$(MACHDEP).py + -rm -r $(DESTDIR)$(DESTSHARED)/__pycache__ + +# Here are a couple of targets for MacOSX again, to install a full +# framework-based Python. frameworkinstall installs everything, the +# subtargets install specific parts. Much of the actual work is offloaded to +# the Makefile in Mac +# +# +# This target is here for backward compatibility, previous versions of Python +# hadn't integrated framework installation in the normal install process. +frameworkinstall: install + +# On install, we re-make the framework +# structure in the install location, /Library/Frameworks/ or the argument to +# --enable-framework. If --enable-framework has been specified then we have +# automatically set prefix to the location deep down in the framework, so we +# only have to cater for the structural bits of the framework. + +frameworkinstallframework: frameworkinstallstructure install frameworkinstallmaclib + +frameworkinstallstructure: $(LDLIBRARY) + @if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \ + echo Not configured with --enable-framework; \ + exit 1; \ + else true; \ + fi + @for i in $(prefix)/Resources/English.lproj $(prefix)/lib; do\ + if test ! -d $(DESTDIR)$$i; then \ + echo "Creating directory $(DESTDIR)$$i"; \ + $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \ + else true; \ + fi; \ + done + $(LN) -fsn include/python$(LDVERSION) $(DESTDIR)$(prefix)/Headers + sed 's/%VERSION%/'"`$(RUNSHARED) ./$(BUILDPYTHON) -c 'import platform; print(platform.python_version())'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(prefix)/Resources/Info.plist + $(LN) -fsn $(VERSION) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/Current + $(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/$(PYTHONFRAMEWORK) + $(LN) -fsn Versions/Current/Headers $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers + $(LN) -fsn Versions/Current/Resources $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Resources + $(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/$(LDLIBRARY) + +# This installs Mac/Lib into the framework +# Install a number of symlinks to keep software that expects a normal unix +# install (which includes python-config) happy. +frameworkinstallmaclib: + $(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBPL)/libpython$(LDVERSION).a" + $(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBPL)/libpython$(LDVERSION).dylib" + $(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBPL)/libpython$(VERSION).a" + $(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBPL)/libpython$(VERSION).dylib" + $(LN) -fs "../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/libpython$(LDVERSION).dylib" + $(LN) -fs "../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/libpython$(VERSION).dylib" + +# This installs the IDE, the Launcher and other apps into /Applications +frameworkinstallapps: + cd Mac && $(MAKE) installapps DESTDIR="$(DESTDIR)" + +# Build the bootstrap executable that will spawn the interpreter inside +# an app bundle within the framework. This allows the interpreter to +# run OS X GUI APIs. +frameworkpythonw: + cd Mac && $(MAKE) pythonw + +# This installs the python* and other bin symlinks in $prefix/bin or in +# a bin directory relative to the framework root +frameworkinstallunixtools: + cd Mac && $(MAKE) installunixtools DESTDIR="$(DESTDIR)" + +frameworkaltinstallunixtools: + cd Mac && $(MAKE) altinstallunixtools DESTDIR="$(DESTDIR)" + +# This installs the Tools into the applications directory. +# It is not part of a normal frameworkinstall +frameworkinstallextras: + cd Mac && $(MAKE) installextras DESTDIR="$(DESTDIR)" + +# Run the configure script. +config.status: $(srcdir)/configure + $(SHELL) $(srcdir)/configure $(CONFIG_ARGS) + +.PRECIOUS: config.status $(BUILDPYTHON) Makefile Makefile.pre + +# Some make's put the object file in the current directory +.c.o: + $(CC) -c $(PY_CORE_CFLAGS) -o $@ $< + +# bpo-30104: dtoa.c uses union to cast double to unsigned long[2]. clang 4.0 +# with -O2 or higher and strict aliasing miscompiles the ratio() function +# causing rounding issues. Compile dtoa.c using -fno-strict-aliasing on clang. +# https://bugs.llvm.org//show_bug.cgi?id=31928 +Python/dtoa.o: Python/dtoa.c + $(CC) -c $(PY_CORE_CFLAGS) $(CFLAGS_ALIASING) -o $@ $< + +# Run reindent on the library +reindent: + ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/reindent.py -r $(srcdir)/Lib + +# Rerun configure with the same options as it was run last time, +# provided the config.status script exists +recheck: + $(SHELL) config.status --recheck + $(SHELL) config.status + +# Create a tags file for vi +tags:: + ctags -w $(srcdir)/Include/*.h $(srcdir)/Include/cpython/*.h $(srcdir)/Include/internal/*.h + for i in $(SRCDIRS); do ctags -f tags -w -a $(srcdir)/$$i/*.[ch]; done + ctags -f tags -w -a $(srcdir)/Modules/_ctypes/*.[ch] + LC_ALL=C sort -o tags tags + +# Create a tags file for GNU Emacs +TAGS:: + cd $(srcdir); \ + etags Include/*.h Include/cpython/*.h Include/internal/*.h; \ + for i in $(SRCDIRS); do etags -a $$i/*.[ch]; done + +# Sanitation targets -- clean leaves libraries, executables and tags +# files, which clobber removes as well +pycremoval: + -find $(srcdir) -depth -name '__pycache__' -exec rm -rf {} ';' + -find $(srcdir) -name '*.py[co]' -exec rm -f {} ';' + +rmtestturds: + -rm -f *BAD *GOOD *SKIPPED + -rm -rf OUT + -rm -f *.TXT + -rm -f *.txt + -rm -f gb-18030-2000.xml + +docclean: + -rm -rf Doc/build + -rm -rf Doc/tools/sphinx Doc/tools/pygments Doc/tools/docutils + +clean: pycremoval + find . -name '*.[oa]' -exec rm -f {} ';' + find . -name '*.s[ol]' -exec rm -f {} ';' + find . -name '*.so.[0-9]*.[0-9]*' -exec rm -f {} ';' + find build -name 'fficonfig.h' -exec rm -f {} ';' || true + find build -name '*.py' -exec rm -f {} ';' || true + find build -name '*.py[co]' -exec rm -f {} ';' || true + -rm -f pybuilddir.txt + -rm -f Lib/lib2to3/*Grammar*.pickle + -rm -f Programs/_testembed Programs/_freeze_importlib + -find build -type f -a ! -name '*.gc??' -exec rm -f {} ';' + -rm -f Include/pydtrace_probes.h + -rm -f profile-gen-stamp + +profile-removal: + find . -name '*.gc??' -exec rm -f {} ';' + find . -name '*.profclang?' -exec rm -f {} ';' + find . -name '*.dyn' -exec rm -f {} ';' + rm -f $(COVERAGE_INFO) + rm -rf $(COVERAGE_REPORT) + rm -f profile-run-stamp + +clobber: clean profile-removal + -rm -f $(BUILDPYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \ + tags TAGS \ + config.cache config.log pyconfig.h Modules/config.c + -rm -rf build platform + -rm -rf $(PYTHONFRAMEWORKDIR) + -rm -f python-config.py python-config + -rm -f profile-gen-stamp profile-clean-stamp + +# Make things extra clean, before making a distribution: +# remove all generated files, even Makefile[.pre] +# Keep configure and Python-ast.[ch], it's possible they can't be generated +distclean: clobber + for file in $(srcdir)/Lib/test/data/* ; do \ + if test "$$file" != "$(srcdir)/Lib/test/data/README"; then rm "$$file"; fi; \ + done + -rm -f core Makefile Makefile.pre config.status Modules/Setup.local \ + Modules/ld_so_aix Modules/python.exp Misc/python.pc \ + Misc/python-embed.pc Misc/python-config.sh + -rm -f python*-gdb.py + # Issue #28258: set LC_ALL to avoid issues with Estonian locale. + # Expansion is performed here by shell (spawned by make) itself before + # arguments are passed to find. So LC_ALL=C must be set as a separate + # command. + LC_ALL=C; find $(srcdir)/[a-zA-Z]* '(' -name '*.fdc' -o -name '*~' \ + -o -name '[@,#]*' -o -name '*.old' \ + -o -name '*.orig' -o -name '*.rej' \ + -o -name '*.bak' ')' \ + -exec rm -f {} ';' + +# Check that all symbols exported by libpython start with "Py" or "_Py" +smelly: all + $(RUNSHARED) ./$(BUILDPYTHON) Tools/scripts/smelly.py + +# Find files with funny names +funny: + find $(SUBDIRS) $(SUBDIRSTOO) \ + -type d \ + -o -name '*.[chs]' \ + -o -name '*.py' \ + -o -name '*.pyw' \ + -o -name '*.dat' \ + -o -name '*.el' \ + -o -name '*.fd' \ + -o -name '*.in' \ + -o -name '*.gif' \ + -o -name '*.txt' \ + -o -name '*.xml' \ + -o -name '*.xbm' \ + -o -name '*.xpm' \ + -o -name '*.uue' \ + -o -name '*.decTest' \ + -o -name '*.tmCommand' \ + -o -name '*.tmSnippet' \ + -o -name 'Setup' \ + -o -name 'Setup.*' \ + -o -name README \ + -o -name NEWS \ + -o -name HISTORY \ + -o -name Makefile \ + -o -name ChangeLog \ + -o -name .hgignore \ + -o -name MANIFEST \ + -o -print + +# Perform some verification checks on any modified files. +patchcheck: all + $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.py + +# Dependencies + +Python/thread.o: $(srcdir)/Python/thread_nt.h $(srcdir)/Python/thread_pthread.h $(srcdir)/Python/condvar.h + +# Declare targets that aren't real files +.PHONY: all build_all sharedmods check-clean-src oldsharedmods test quicktest +.PHONY: install altinstall oldsharedinstall bininstall altbininstall +.PHONY: maninstall libinstall inclinstall libainstall sharedinstall +.PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure +.PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools +.PHONY: frameworkaltinstallunixtools recheck clean clobber distclean +.PHONY: smelly funny patchcheck touch altmaninstall commoninstall +.PHONY: gdbhooks + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY +# Local Variables: +# mode: makefile +# End: + +# Rules appended by makesetup + +Modules/posixmodule.o: $(srcdir)/Modules/posixmodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -c $(srcdir)/Modules/posixmodule.c -o Modules/posixmodule.o +Modules/posix$(EXT_SUFFIX): Modules/posixmodule.o; $(BLDSHARED) Modules/posixmodule.o -o Modules/posix$(EXT_SUFFIX) +Modules/errnomodule.o: $(srcdir)/Modules/errnomodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/errnomodule.c -o Modules/errnomodule.o +Modules/errno$(EXT_SUFFIX): Modules/errnomodule.o; $(BLDSHARED) Modules/errnomodule.o -o Modules/errno$(EXT_SUFFIX) +Modules/pwdmodule.o: $(srcdir)/Modules/pwdmodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/pwdmodule.c -o Modules/pwdmodule.o +Modules/pwd$(EXT_SUFFIX): Modules/pwdmodule.o; $(BLDSHARED) Modules/pwdmodule.o -o Modules/pwd$(EXT_SUFFIX) +Modules/_sre.o: $(srcdir)/Modules/_sre.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/_sre.c -o Modules/_sre.o +Modules/_sre$(EXT_SUFFIX): Modules/_sre.o; $(BLDSHARED) Modules/_sre.o -o Modules/_sre$(EXT_SUFFIX) +Modules/_codecsmodule.o: $(srcdir)/Modules/_codecsmodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/_codecsmodule.c -o Modules/_codecsmodule.o +Modules/_codecs$(EXT_SUFFIX): Modules/_codecsmodule.o; $(BLDSHARED) Modules/_codecsmodule.o -o Modules/_codecs$(EXT_SUFFIX) +Modules/_weakref.o: $(srcdir)/Modules/_weakref.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/_weakref.c -o Modules/_weakref.o +Modules/_weakref$(EXT_SUFFIX): Modules/_weakref.o; $(BLDSHARED) Modules/_weakref.o -o Modules/_weakref$(EXT_SUFFIX) +Modules/_functoolsmodule.o: $(srcdir)/Modules/_functoolsmodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -c $(srcdir)/Modules/_functoolsmodule.c -o Modules/_functoolsmodule.o +Modules/_functools$(EXT_SUFFIX): Modules/_functoolsmodule.o; $(BLDSHARED) Modules/_functoolsmodule.o -o Modules/_functools$(EXT_SUFFIX) +Modules/_operator.o: $(srcdir)/Modules/_operator.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/_operator.c -o Modules/_operator.o +Modules/_operator$(EXT_SUFFIX): Modules/_operator.o; $(BLDSHARED) Modules/_operator.o -o Modules/_operator$(EXT_SUFFIX) +Modules/_collectionsmodule.o: $(srcdir)/Modules/_collectionsmodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/_collectionsmodule.c -o Modules/_collectionsmodule.o +Modules/_collections$(EXT_SUFFIX): Modules/_collectionsmodule.o; $(BLDSHARED) Modules/_collectionsmodule.o -o Modules/_collections$(EXT_SUFFIX) +Modules/_abc.o: $(srcdir)/Modules/_abc.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/_abc.c -o Modules/_abc.o +Modules/_abc$(EXT_SUFFIX): Modules/_abc.o; $(BLDSHARED) Modules/_abc.o -o Modules/_abc$(EXT_SUFFIX) +Modules/itertoolsmodule.o: $(srcdir)/Modules/itertoolsmodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/itertoolsmodule.c -o Modules/itertoolsmodule.o +Modules/itertools$(EXT_SUFFIX): Modules/itertoolsmodule.o; $(BLDSHARED) Modules/itertoolsmodule.o -o Modules/itertools$(EXT_SUFFIX) +Modules/atexitmodule.o: $(srcdir)/Modules/atexitmodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/atexitmodule.c -o Modules/atexitmodule.o +Modules/atexit$(EXT_SUFFIX): Modules/atexitmodule.o; $(BLDSHARED) Modules/atexitmodule.o -o Modules/atexit$(EXT_SUFFIX) +Modules/signalmodule.o: $(srcdir)/Modules/signalmodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -c $(srcdir)/Modules/signalmodule.c -o Modules/signalmodule.o +Modules/_signal$(EXT_SUFFIX): Modules/signalmodule.o; $(BLDSHARED) Modules/signalmodule.o -o Modules/_signal$(EXT_SUFFIX) +Modules/_stat.o: $(srcdir)/Modules/_stat.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/_stat.c -o Modules/_stat.o +Modules/_stat$(EXT_SUFFIX): Modules/_stat.o; $(BLDSHARED) Modules/_stat.o -o Modules/_stat$(EXT_SUFFIX) +Modules/timemodule.o: $(srcdir)/Modules/timemodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -c $(srcdir)/Modules/timemodule.c -o Modules/timemodule.o +Modules/time$(EXT_SUFFIX): Modules/timemodule.o; $(BLDSHARED) Modules/timemodule.o -o Modules/time$(EXT_SUFFIX) +Modules/_threadmodule.o: $(srcdir)/Modules/_threadmodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -c $(srcdir)/Modules/_threadmodule.c -o Modules/_threadmodule.o +Modules/_thread$(EXT_SUFFIX): Modules/_threadmodule.o; $(BLDSHARED) Modules/_threadmodule.o -o Modules/_thread$(EXT_SUFFIX) +Modules/_localemodule.o: $(srcdir)/Modules/_localemodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -c $(srcdir)/Modules/_localemodule.c -o Modules/_localemodule.o +Modules/_locale$(EXT_SUFFIX): Modules/_localemodule.o; $(BLDSHARED) Modules/_localemodule.o -o Modules/_locale$(EXT_SUFFIX) +Modules/_iomodule.o: $(srcdir)/Modules/_io/_iomodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -I$(srcdir)/Modules/_io -c $(srcdir)/Modules/_io/_iomodule.c -o Modules/_iomodule.o +Modules/iobase.o: $(srcdir)/Modules/_io/iobase.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -I$(srcdir)/Modules/_io -c $(srcdir)/Modules/_io/iobase.c -o Modules/iobase.o +Modules/fileio.o: $(srcdir)/Modules/_io/fileio.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -I$(srcdir)/Modules/_io -c $(srcdir)/Modules/_io/fileio.c -o Modules/fileio.o +Modules/bytesio.o: $(srcdir)/Modules/_io/bytesio.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -I$(srcdir)/Modules/_io -c $(srcdir)/Modules/_io/bytesio.c -o Modules/bytesio.o +Modules/bufferedio.o: $(srcdir)/Modules/_io/bufferedio.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -I$(srcdir)/Modules/_io -c $(srcdir)/Modules/_io/bufferedio.c -o Modules/bufferedio.o +Modules/textio.o: $(srcdir)/Modules/_io/textio.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -I$(srcdir)/Modules/_io -c $(srcdir)/Modules/_io/textio.c -o Modules/textio.o +Modules/stringio.o: $(srcdir)/Modules/_io/stringio.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -I$(srcdir)/Modules/_io -c $(srcdir)/Modules/_io/stringio.c -o Modules/stringio.o +Modules/_io$(EXT_SUFFIX): Modules/_iomodule.o Modules/iobase.o Modules/fileio.o Modules/bytesio.o Modules/bufferedio.o Modules/textio.o Modules/stringio.o; $(BLDSHARED) Modules/_iomodule.o Modules/iobase.o Modules/fileio.o Modules/bytesio.o Modules/bufferedio.o Modules/textio.o Modules/stringio.o -o Modules/_io$(EXT_SUFFIX) +Modules/faulthandler.o: $(srcdir)/Modules/faulthandler.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/faulthandler.c -o Modules/faulthandler.o +Modules/faulthandler$(EXT_SUFFIX): Modules/faulthandler.o; $(BLDSHARED) Modules/faulthandler.o -o Modules/faulthandler$(EXT_SUFFIX) +Modules/_tracemalloc.o: $(srcdir)/Modules/_tracemalloc.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/_tracemalloc.c -o Modules/_tracemalloc.o +Modules/hashtable.o: $(srcdir)/Modules/hashtable.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/hashtable.c -o Modules/hashtable.o +Modules/_tracemalloc$(EXT_SUFFIX): Modules/_tracemalloc.o Modules/hashtable.o; $(BLDSHARED) Modules/_tracemalloc.o Modules/hashtable.o -o Modules/_tracemalloc$(EXT_SUFFIX) +Modules/symtablemodule.o: $(srcdir)/Modules/symtablemodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/symtablemodule.c -o Modules/symtablemodule.o +Modules/_symtable$(EXT_SUFFIX): Modules/symtablemodule.o; $(BLDSHARED) Modules/symtablemodule.o -o Modules/_symtable$(EXT_SUFFIX) +Modules/xxsubtype.o: $(srcdir)/Modules/xxsubtype.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/xxsubtype.c -o Modules/xxsubtype.o +Modules/xxsubtype$(EXT_SUFFIX): Modules/xxsubtype.o; $(BLDSHARED) Modules/xxsubtype.o -o Modules/xxsubtype$(EXT_SUFFIX) diff --git a/RISCOS/ReleaseNotes b/RISCOS/ReleaseNotes new file mode 100644 index 00000000000000..7bc32ce9473ec1 --- /dev/null +++ b/RISCOS/ReleaseNotes @@ -0,0 +1,131 @@ +Python 3.14.3 for RISC OS (skeleton port) +------------------------ +Port by Chris Johns, development supported by RISC OS Developments Ltd. + +Welcome to Python on RISC OS, bringing the power and flexibility of the Python language to RISC OS. + +This document does not go into any detail about the python programming language itself, but details the RISC OS specific items. There are lots of documents and tutorials online and in books about Python itself. + +It can be obtained with the !PackMan package manager. + +Mailing List +------------ +There is a riscos-python mailing list https://www.freelists.org/riscos-python for discussions about the python on RISC OS. + +Feedback and bugs +----------------- +Please send any feedback or bug reports to chris@lessthan3.org.uk + +Filetypes +--------- +One of the major differences between RISC OS and other operating systems is the use of filetypes rather than extensions to identify the content of a file, and the use of the . as a directory separator. + +So on Linux a Python file may be named spam.py (file spam with extension of .py), on RISC OS 'spam.py' would mean the file called py in directory spam, which is almost certainly not what you want! + +So the 'RISC OS way' is to have a file called spam with the filetype of Python. To assist with running code from other platforms, you can also call the file spam/py (with any type). As long as !Python has been 'seen', double-clicking on a Python file will run it in a TaskWindow. + +Types are also used for the cached bytecode (.pyc) and extensions (.so). + + +The subprocess module on RISC OS +-------------------------------- +Limited subprocess support is provided using the TaskRunner module to execute subprocesses using the RISC OS TaskWindow system. + +RISC OS additions +----------------- +os.get_filetype(object) returns the file type of a given object. +os.set_filetype(object,type) will set it. + +swi.swi(arg1,arg2,arg3) allows Python code to call RISC OS SWIs. + arg1 is the SWI number or name, + arg2 is a format string for arg3, + arg3 is the rest of the arguments. +eg: swi.swi("OS_Write0","s","Hello RISC OS World") + +stat will also return st_loadaddr (Load Address), st_execaddr (Exex Address), st_filetype (Filetype), and st_objtype (Object type) + +Known Bugs +---------- +Much of the standard library is still largely untested. + +History +------- +3.8.0a1 +Initial RISC OS Alpha Release. + +3.8.0a2 +Added support for Python$Path. +Fixed get/set filetype calls to handle non-ASCII characters. +Added SSL and SQLite3 modules. + +3.8.0a3 +Fixed bug that was preventing sockets being created. +Use OS_ReadLine32 to get input in interactive mode. +os.getenv reads the RISC OS environment. +Added support to get data as bytes from the swi module. +Fixed SSL to get the CA certificates from . +Added lzma and bz2 modules. +Added ctypes module. +Various build fixes. +Renamed to !Python3 and uses allocated types. + +3.8.0a4 +Use Python3$Path (not Python$Path). +Fixed issue where Python3$Path is unset. +Fixed !Boot/!Run files to use Python3$Dir +Changed env vars to PythonX.Y$Prefix and PythonX.Y$ExecPrefix +Fixed imports from script directory. +Added 'u' (unsigned integer) to swi interface. + +3.8.0a5 Fixed bug in socket.accept +*!* Changed unsigned int swi to 'I' ('u' now deprecated) +Work-around for partial-second waits in timermodule. +Where available, use 'TimerMod' for higher resolution monotonic time. +swi.block[] now uses UNsigned integers. +Added swi.block to/from signed/unsigned. +Added RISCOSError exception, and derived SwiError from it. +Added cannonicalise function to risospath (FSControl 37) +Fixed Lib2to3 to not assume '.ext' in filenmes. +Added os.read_catalogue_into / os.write_catalogue_info +Added RISC OS support to zipfile. +Fixed RISC OS time handling in xmlrpc client. + +3.8.0rc6 +UrlLib: Added RISC OS url2pathname/pathname2url +Subprocess; Use TaskRunner module on RISC OS +Initial PIP support. + +3.8.5-riscos-0 +Updated to 3.8.5. +Created a RiscPkg to help install Python and it's dependancies. + +3.8.5-1 +Changed version string to 3.8.5+ as some things were getting confused by it. +os.path.join will now try to handle adding a file.ext to a path - eg. os.path.join('foo','bar','hello.txt') will return 'foo.bar.hello/txt' to catch things that just assume filenames are of the file.ext format. +Use new !PythonSite for site packages. + +3.8.5-2 +Overhaul of riscospath module. +New !PythonUser for user packages. +Run action for python files no longer runs in a TaskWindow. + +3.8.5-3 +!Python3 work to (hopefully) ease port of 3.9 + +3.8.5-4 +Update subprocess to close Taskrunner tasks when finished, and to better handle +more use cases. +Fixed environment setting in os.environ. +Treat '..' as '^' in paths. +Updated importer to use cache fr typed files. +os.stat now includes RISC OS attributes - st_loadaddr, st_execaddr, st_filetype and st_objtype +Overhaul of the initial path setup code - not works more like the Unix one. Environment variables PYTHONPATH and PYTHONHOME are used. PythonX.Y$* not longer used. Will search from executable directory or use .PythonXY.Lib(.Lib-Dynload). + +3.8.5-5 +Bug fixes. + +3.8.8-1 +Update to Python 3.8.8 + +3.14.3-1 +Port skeleton to Python 3.14.3 - API updates required for full functionality. diff --git a/RISCOS/RiscPkg-314/Control b/RISCOS/RiscPkg-314/Control new file mode 100644 index 00000000000000..0cd30e77b6e67f --- /dev/null +++ b/RISCOS/RiscPkg-314/Control @@ -0,0 +1,12 @@ +Package: Python-314 +Version: 3.14.3-1 +Section: Development +Priority: Optional +Maintainer: Chris Johns +Standards-Version: 0.4.0 +Environment: any +Licence: Free +Description: The Python Programming Language (Version 3.14) + Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed. +Depends: Python-Core (>= 0.0.2-1), SharedLibs (>= 4.0-Rel5-1), SharedUnixLibrary (>= 1.16-1), SharedLibs-C2 (>= 4.7.4-Rel5-1), CryptRandom (>= 0.13-1), LibFFI6 (>= 3.2.1-2) +Recommends: TaskRunner (>= 0.15-1), LibSSL (>= 1.0.2k-3), LibSQLite3 (>= 3.13.0-1), ZLib1g (>= 1.2.11.dfsg-3), LibBZ2-1.0 (>= 1.0.6-4), LibLZMA5 (>= 5.2.4-1), LibExpat1 (>= 2.2.6-3), Python-314-pip (>= 20.0.2-4) \ No newline at end of file diff --git a/RISCOS/RiscPkg-314/Copyright b/RISCOS/RiscPkg-314/Copyright new file mode 100644 index 00000000000000..e7ed41a5617946 --- /dev/null +++ b/RISCOS/RiscPkg-314/Copyright @@ -0,0 +1,18 @@ +PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 +-------------------------------------------- + +1. This LICENSE AGREEMENT is between the Python Software Foundation("PSF"), and the Individual or Organization ("Licensee") accessing and otherwise using this software ("Python") in source or binary form and its associated documentation. + +2. Subject to the terms and conditions of this License Agreement, PSF hereby grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce analyze, test, perform and/or display publicly, prepare derivative works distribute, and otherwise use Python alone or in any derivative version provided, however, that PSF's License Agreement and PSF's notice of copyright, i.e., "Copyright (c) 2001-2026 Python Software Foundation; All Rights Reserved" are retained in Python alone or in any derivative version prepared by Licensee. + +3. In the event Licensee prepares a derivative work that is based on or incorporates Python or any part thereof, and wants to make the derivative work available to others as provided herein, then Licensee hereby agrees to include in any such work a brief summary of the changes made to Python. + +4. PSF is making Python available to Licensee on an "AS IS" basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT INFRINGE ANY THIRD PARTY RIGHTS. + +5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +6. This License Agreement will automatically terminate upon a material breach of its terms and conditions. + +7. Nothing in this License Agreement shall be deemed to create any relationship of agency, partnership, or joint venture between PSF and Licensee. This License Agreement does not grant permission to use PSF trademarks or trade name in a trademark sense to endorse or promote products or services of Licensee, or any third party. + +8. By copying, installing or otherwise using Python, Licensee agrees to be bound by the terms and conditions of this License Agreement. \ No newline at end of file diff --git a/RISCOS/RiscPkg-Core/Control b/RISCOS/RiscPkg-Core/Control new file mode 100644 index 00000000000000..1f5939ea2545af --- /dev/null +++ b/RISCOS/RiscPkg-Core/Control @@ -0,0 +1,11 @@ +Package: Python-Core +Version: 0.0.2-1 +Section: Development +Priority: Optional +Maintainer: Chris Johns +Standards-Version: 0.4.0 +Environment: any +Licence: Free +Description: Python Core Package + This package provides core the Python resources. +Components: Apps.Development.!Python3 (Movable LookAt), Resources.!PythonSite (Movable LookAt), ToBeLoaded.!PythonUser (Movable LookAt) diff --git a/RISCOS/RiscPkg-Core/Copyright b/RISCOS/RiscPkg-Core/Copyright new file mode 100644 index 00000000000000..ece98a217bfd06 --- /dev/null +++ b/RISCOS/RiscPkg-Core/Copyright @@ -0,0 +1,18 @@ +PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 +-------------------------------------------- + +1. This LICENSE AGREEMENT is between the Python Software Foundation("PSF"), and the Individual or Organization ("Licensee") accessing and otherwise using this software ("Python") in source or binary form and its associated documentation. + +2. Subject to the terms and conditions of this License Agreement, PSF hereby grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce analyze, test, perform and/or display publicly, prepare derivative works distribute, and otherwise use Python alone or in any derivative version provided, however, that PSF's License Agreement and PSF's notice of copyright, i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Python Software Foundation; All Rights Reserved" are retained in Python alone or in any derivative version prepared by Licensee. + +3. In the event Licensee prepares a derivative work that is based on or incorporates Python or any part thereof, and wants to make the derivative work available to others as provided herein, then Licensee hereby agrees to include in any such work a brief summary of the changes made to Python. + +4. PSF is making Python available to Licensee on an "AS IS" basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT INFRINGE ANY THIRD PARTY RIGHTS. + +5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +6. This License Agreement will automatically terminate upon a material breach of its terms and conditions. + +7. Nothing in this License Agreement shall be deemed to create any relationship of agency, partnership, or joint venture between PSF and Licensee. This License Agreement does not grant permission to use PSF trademarks or trade name in a trademark sense to endorse or promote products or services of Licensee, or any third party. + +8. By copying, installing or otherwise using Python, Licensee agrees to be bound by the terms and conditions of this License Agreement. \ No newline at end of file diff --git a/RISCOS/RiscPkg-Site/Control b/RISCOS/RiscPkg-Site/Control new file mode 100644 index 00000000000000..3c6a21a40ae30d --- /dev/null +++ b/RISCOS/RiscPkg-Site/Control @@ -0,0 +1,10 @@ +Package: PythonSite +Version: 0.0.2-1 +Section: Development +Priority: Optional +Maintainer: Chris Johns +Standards-Version: 0.4.0 +Environment: any +Licence: Free +Description: Container for python site packages +Components: Resources.!PythonSite (Movable LookAt) diff --git a/RISCOS/RiscPkg-Site/Copyright b/RISCOS/RiscPkg-Site/Copyright new file mode 100644 index 00000000000000..278a2d6c97eb66 --- /dev/null +++ b/RISCOS/RiscPkg-Site/Copyright @@ -0,0 +1,19 @@ +Copyright (c) 2020 Chris Johns + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/RISCOS/RiscPkg-User/Control b/RISCOS/RiscPkg-User/Control new file mode 100644 index 00000000000000..dbf2a1ff46ff76 --- /dev/null +++ b/RISCOS/RiscPkg-User/Control @@ -0,0 +1,10 @@ +Package: PythonUser +Version: 0.0.2-1 +Section: Development +Priority: Optional +Maintainer: Chris Johns +Standards-Version: 0.4.0 +Environment: any +Licence: Free +Description: Container for python user packages +Components: ToBeLoaded.!PythonUser (Movable LookAt) diff --git a/RISCOS/RiscPkg-User/Copyright b/RISCOS/RiscPkg-User/Copyright new file mode 100644 index 00000000000000..278a2d6c97eb66 --- /dev/null +++ b/RISCOS/RiscPkg-User/Copyright @@ -0,0 +1,19 @@ +Copyright (c) 2020 Chris Johns + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/RISCOS/_Python3/Scripts/2to3-314,feb b/RISCOS/_Python3/Scripts/2to3-314,feb new file mode 100644 index 00000000000000..8eaa6954f8b4f9 --- /dev/null +++ b/RISCOS/_Python3/Scripts/2to3-314,feb @@ -0,0 +1,6 @@ +python314 -xx Python3:Scripts.2to3-314 %*0 +Obey +import sys +from lib2to3.main import main + +sys.exit(main("lib2to3.fixes")) diff --git a/RISCOS/_Python3/Scripts/pydoc314,feb b/RISCOS/_Python3/Scripts/pydoc314,feb new file mode 100644 index 00000000000000..2682498c490cc4 --- /dev/null +++ b/RISCOS/_Python3/Scripts/pydoc314,feb @@ -0,0 +1,6 @@ +python314 -xx Python3:Scripts.pydoc314 %*0 +Obey + +import pydoc +if __name__ == '__main__': + pydoc.cli() diff --git a/RISCOS/_Python3/_Boot,feb b/RISCOS/_Python3/_Boot,feb new file mode 100644 index 00000000000000..0d03a2a230168e --- /dev/null +++ b/RISCOS/_Python3/_Boot,feb @@ -0,0 +1,19 @@ +| !Boot file for RISC OS Python 3. + +If "" <> "" Then Set Python3$Seen "True" +If "" = "" Then Set Python3$Dir +If "" = "" Then Set Python3$Path . +If "" = "" Then IconSprites .!Sprites +If "" = "" Then Run .!Setup +If "" = "" Then Run .!PathAdd -py3 + +Unset Python3$BootRun + +If "" = "" Then Set File$Type_a73 Python3 +If "" = "" Then Set File$Type_a74 PytnCode +If "" = "" Then Set File$Type_a75 PytnExtn + +Set Python3$RunTypeSet "True" +X If "" = "" Then Unset Python3$RunTypeSet +If "" = "" Then Set Alias$@RunType_a73 python3 %%*0 +Unset Python3$RunTypeSet diff --git a/RISCOS/_Python3/_PathAdd,ffb b/RISCOS/_Python3/_PathAdd,ffb new file mode 100644 index 00000000000000..41e166e5809177 Binary files /dev/null and b/RISCOS/_Python3/_PathAdd,ffb differ diff --git a/RISCOS/_Python3/_Run,feb b/RISCOS/_Python3/_Run,feb new file mode 100644 index 00000000000000..a2a6deb1769c92 --- /dev/null +++ b/RISCOS/_Python3/_Run,feb @@ -0,0 +1,15 @@ +| !Run file for RISC OS Python 3 + +Set Python3$Dir +Set Python3$Path . +IconSprites .!Sprites +Run .!Setup +Run .!PathAdd -py3 + +Set File$Type_a73 Python3 +Set File$Type_a74 PytnCode +Set File$Type_a75 PytnExtn + +Set Alias$@RunType_a73 python3 %%*0 + +TaskWindow "python3 %*0" -name "Python3" -ctrl -quit -wimpslot 8M diff --git a/RISCOS/_Python3/_Setup,ffb b/RISCOS/_Python3/_Setup,ffb new file mode 100644 index 00000000000000..afd85cff7290bd Binary files /dev/null and b/RISCOS/_Python3/_Setup,ffb differ diff --git a/RISCOS/_Python3/_Sprites22,ff9 b/RISCOS/_Python3/_Sprites22,ff9 new file mode 100644 index 00000000000000..96e689d11844a3 Binary files /dev/null and b/RISCOS/_Python3/_Sprites22,ff9 differ diff --git a/RISCOS/_PythonSite/PathAdd,ffb b/RISCOS/_PythonSite/PathAdd,ffb new file mode 100644 index 00000000000000..ab360cf5e9dd71 Binary files /dev/null and b/RISCOS/_PythonSite/PathAdd,ffb differ diff --git a/RISCOS/_PythonSite/_Boot,feb b/RISCOS/_PythonSite/_Boot,feb new file mode 100644 index 00000000000000..d81b649ba3168b --- /dev/null +++ b/RISCOS/_PythonSite/_Boot,feb @@ -0,0 +1,9 @@ +| !Boot file for RISC OS Python Site. + +If "" <> "" Then Set PythonSite$Seen "True" +If "" = "" Then Set PythonSite$Dir +If "" = "" Then Set PythonSite$Path . +If "" = "" Then IconSprites .!Sprites +If "" = "" Then Run .PathAdd -site + +Unset PythonSite$Seen diff --git a/RISCOS/_PythonSite/_Run,feb b/RISCOS/_PythonSite/_Run,feb new file mode 100644 index 00000000000000..c16c05d4098625 --- /dev/null +++ b/RISCOS/_PythonSite/_Run,feb @@ -0,0 +1,4 @@ +| !Run file for RISC OS Python Site. + +Unset PythonSite$Dir +Run .!Boot diff --git a/RISCOS/_PythonSite/_Sprites22,ff9 b/RISCOS/_PythonSite/_Sprites22,ff9 new file mode 100644 index 00000000000000..150adb244e667f Binary files /dev/null and b/RISCOS/_PythonSite/_Sprites22,ff9 differ diff --git a/RISCOS/_PythonUser/_Boot,feb b/RISCOS/_PythonUser/_Boot,feb new file mode 100644 index 00000000000000..a3cb992b7deed8 --- /dev/null +++ b/RISCOS/_PythonUser/_Boot,feb @@ -0,0 +1,8 @@ +| !Boot file for RISC OS Python User. + +If "" <> "" Then Set PythonUser$Seen "True" +If "" = "" Then Set PythonUser$Dir +If "" = "" Then IconSprites .!Sprites +If "" = "" Then Run .!PathAdd -user + +Unset PythonUser$Seen diff --git a/RISCOS/_PythonUser/_PathAdd,ffb b/RISCOS/_PythonUser/_PathAdd,ffb new file mode 100644 index 00000000000000..ab360cf5e9dd71 Binary files /dev/null and b/RISCOS/_PythonUser/_PathAdd,ffb differ diff --git a/RISCOS/_PythonUser/_Run,feb b/RISCOS/_PythonUser/_Run,feb new file mode 100644 index 00000000000000..d238ec520b8bc7 --- /dev/null +++ b/RISCOS/_PythonUser/_Run,feb @@ -0,0 +1,4 @@ +| !Run file for RISC OS Python User. + +Unset PythonUser$Dir +Run .!Boot diff --git a/RISCOS/_PythonUser/_Sprites22,ff9 b/RISCOS/_PythonUser/_Sprites22,ff9 new file mode 100644 index 00000000000000..cdbf3ce6eb2db9 Binary files /dev/null and b/RISCOS/_PythonUser/_Sprites22,ff9 differ diff --git a/RISCOS/config.c b/RISCOS/config.c new file mode 100644 index 00000000000000..7de79a57dfe60f --- /dev/null +++ b/RISCOS/config.c @@ -0,0 +1,116 @@ +/* config.c for RISC OS */ +/* -*- C -*- *********************************************** +Copyright (c) 2000, BeOpen.com. +Copyright (c) 1995-2000, Corporation for National Research Initiatives. +Copyright (c) 1990-1995, Stichting Mathematisch Centrum. +All rights reserved. + +See the file "Misc/COPYRIGHT" for information on usage and +redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. +******************************************************************/ + +/* Module configuration */ + +/* This file contains the table of built-in modules. + See create_builtin() in import.c. */ + +#include "Python.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +extern PyObject* PyInit_riscos(void); +extern PyObject* PyInit_errno(void); +extern PyObject* PyInit_pwd(void); +extern PyObject* PyInit__sre(void); +extern PyObject* PyInit__codecs(void); +extern PyObject* PyInit__weakref(void); +extern PyObject* PyInit__functools(void); +extern PyObject* PyInit__operator(void); +extern PyObject* PyInit__collections(void); +extern PyObject* PyInit__abc(void); +extern PyObject* PyInit_itertools(void); +extern PyObject* PyInit_atexit(void); +extern PyObject* PyInit__signal(void); +extern PyObject* PyInit__stat(void); +extern PyObject* PyInit_time(void); +extern PyObject* PyInit__thread(void); +extern PyObject* PyInit__locale(void); +extern PyObject* PyInit__io(void); +extern PyObject* PyInit_faulthandler(void); +extern PyObject* PyInit__tracemalloc(void); +extern PyObject* PyInit__symtable(void); +extern PyObject* PyInit_xxsubtype(void); + +/* -- ADDMODULE MARKER 1 -- */ + +extern PyObject* PyMarshal_Init(void); +extern PyObject* PyInit__imp(void); +extern PyObject* PyInit_gc(void); +extern PyObject* PyInit__ast(void); +extern PyObject* _PyWarnings_Init(void); +extern PyObject* PyInit__string(void); +extern PyObject* PyInit_swi(void); + +struct _inittab _PyImport_Inittab[] = { + + {"riscos", PyInit_riscos}, + {"errno", PyInit_errno}, + {"pwd", PyInit_pwd}, + {"_sre", PyInit__sre}, + {"_codecs", PyInit__codecs}, + {"_weakref", PyInit__weakref}, + {"_functools", PyInit__functools}, + {"_operator", PyInit__operator}, + {"_collections", PyInit__collections}, + {"_abc", PyInit__abc}, + {"itertools", PyInit_itertools}, + {"atexit", PyInit_atexit}, + {"_signal", PyInit__signal}, + {"_stat", PyInit__stat}, + {"time", PyInit_time}, + {"_thread", PyInit__thread}, + {"_locale", PyInit__locale}, + {"_io", PyInit__io}, + {"faulthandler", PyInit_faulthandler}, + {"_tracemalloc", PyInit__tracemalloc}, + {"_symtable", PyInit__symtable}, + {"xxsubtype", PyInit_xxsubtype}, + +/* -- ADDMODULE MARKER 2 -- */ + + /* This module lives in marshal.c */ + {"marshal", PyMarshal_Init}, + + /* This lives in import.c */ + {"_imp", PyInit__imp}, + + /* This lives in Python/Python-ast.c */ + {"_ast", PyInit__ast}, + + /* These entries are here for sys.builtin_module_names */ + {"builtins", NULL}, + {"sys", NULL}, + + /* This lives in gcmodule.c */ + {"gc", PyInit_gc}, + + /* This lives in _warnings.c */ + {"_warnings", _PyWarnings_Init}, + + /* This lives in Objects/unicodeobject.c */ + {"_string", PyInit__string}, + + /* This lives in RISCOS/swimodule.c */ + {"swi", PyInit_swi}, + + /* Sentinel */ + {0, 0} +}; + + +#ifdef __cplusplus +} +#endif diff --git a/RISCOS/getpath.c b/RISCOS/getpath.c new file mode 100644 index 00000000000000..7e240ed110d779 --- /dev/null +++ b/RISCOS/getpath.c @@ -0,0 +1,1106 @@ +/* Return the initial module search path - RISC OS Version. */ + +#include "Python.h" +#include "pycore_initconfig.h" +#include "osdefs.h" +#include "pycore_fileutils.h" +#include "pycore_pathconfig.h" +#include "pycore_pystate.h" + +#include "swis.h" + +#include +#include + +/* Search in some common locations for the associated Python libraries. + * This is a variant of the posix system. + * + * Two directories must be found, the platform independent directory + * (prefix), containing the common .py and .pyc files, and the platform + * dependent directory (exec_prefix), containing the shared library + * modules. Note that prefix and exec_prefix can be the same directory, + * but for some installations, they are different. + * + * Py_GetPath() carries out separate searches for prefix and exec_prefix. + * Each search tries a number of different locations until a ``landmark'' + * file or directory is found. If no prefix or exec_prefix is found, a + * warning message is issued and the preprocessor defined PREFIX and + * EXEC_PREFIX are used (even though they will not work); python carries on + * as best as is possible, but most imports will fail. + * + * Before any searches are done, the location of the executable is + * determined. On RISC OS argv[0] is always the full pathname so + * argv0_path is set to the directory containing the executable + * (i.e. the last component is stripped). + * + * With argv0_path in hand, we perform a number of steps. The same steps + * are performed for prefix and for exec_prefix, but with a different + * landmark. + * + * Step 1. Are we running python out of the build directory? This is + * checked by looking for a different kind of landmark relative to + * argv0_path. For prefix, the landmark's path is derived from the VPATH + * preprocessor variable (taking into account that its value is almost, but + * not quite, what we need). For exec_prefix, the landmark is + * pybuilddir/txt. If the landmark is found, we're done. + * + * For the remaining steps, the prefix landmark will always be + * lib.pythonXY.os(/py) and the exec_prefix will always be + * lib.pythonXY.lib-dynload, where XY is the version number without dots. + * Note that this means that no more build directory checking is performed; + * if the first step did not find the landmarks, the assumption is that python + * is running from an installed setup. + * + * Step 2. See if the $PYTHONHOME environment variable points to the + * installed location of the Python libraries. If $PYTHONHOME is set, then + * it points to prefix and exec_prefix. $PYTHONHOME can be a single + * directory, which is used for both, or the prefix and exec_prefix + * directories separated by a comma. + * + * Step 3. Try to find prefix and exec_prefix relative to argv0_path, + * backtracking up the path until it is exhausted. This is the most common + * step to succeed. Note that if prefix and exec_prefix are different, + * exec_prefix is more likely to be found; however if exec_prefix is a + * subdirectory of prefix, both will be found. + * + * Step 3. Search the directories pointed to by the preprocessor variables + * PREFIX and EXEC_PREFIX. These are supplied by the Makefile but can be + * passed in as options to the configure script. They are both set to + * . The variables will be canonicalised, so the current run-time + * values of those variables will be used. + * + * That's it! + * + * Well, almost. Once we have determined prefix and exec_prefix, the + * preprocessor variable PYTHONPATH is used to construct a path. Each + * relative path on PYTHONPATH is prefixed with prefix. Then the directory + * containing the shared library modules is appended. The environment + * variable $PYTHONPATH is inserted in front of it all. Finally, the + * prefix and exec_prefix globals are tweaked so they reflect the values + * expected by other code, by stripping the "lib/python$VERSION/..." stuff + * off. If either points to the build directory, the globals are reset to + * the corresponding preprocessor variables (so sys.prefix will reflect the + * installation location, even though sys.path points into the build + * directory). This seems to make more sense given that currently the only + * known use of sys.prefix and sys.exec_prefix is for the ILU installation + * process to find the installed Python tree. + * + * An embedding application can use Py_SetPath() to override all of + * these authomatic path computations. + * + * NOTE: Windows MSVC builds use PC/getpathp.c instead. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(PREFIX) || !defined(EXEC_PREFIX) || !defined(VERSION) || !defined(VPATH) +#error "PREFIX, EXEC_PREFIX, VERSION, and VPATH must be constant defined" +#endif + +#ifndef LANDMARK +#define LANDMARK "os" +#endif + +#define DECODE_LOCALE_ERR(NAME, LEN) \ + ((LEN) == (size_t)-2) \ + ? _PyStatus_ERR("cannot decode " NAME) \ + : _PyStatus_NO_MEMORY() + +#define PATHLEN_ERR() _PyStatus_ERR("path configuration: path too long") + +typedef struct { + char *python_home; /* PYTHONHOME */ + char *pythonpath; /* PYTHONPATH macro */ + char *prefix; /* PREFIX macro (canonicalised) */ + char *exec_prefix; /* EXEC_PREFIX macro (canonicalised) */ + + char *lib_python; /* "pythonXY.lib" */ + + int prefix_found; /* found platform independent libraries? */ + int exec_prefix_found; /* found the platform dependent libraries? */ + + int warnings; + char *pythonpath_env; +} PyCalculatePath; + +static const char delimiter[2] = {DELIM, '\0'}; +static const char separator[2] = {SEP, '\0'}; + +static void +reduce(char *dir) +{ + size_t i = strlen(dir); + while (i > 0 && dir[i] != SEP) { + --i; + } + dir[i] = '\0'; +} + +/* canonicalise (FS_Control 37) and return a PyMem_Malloc-ed string */ +static char * +Py_canonicialise(const char *path) +{ + int size = 0; + if (_swix(OS_FSControl, _INR(0,5) | _OUT(5), + 37, path, 0, 0, 0, 0, &size )) + { + return _PyMem_RawStrdup(path); + } + size = 1-size; + char *res = PyMem_Malloc(size); + if (_swix(OS_FSControl, _INR(0,5) | _OUT(5), + 37, path, res, 0, 0, size, &size )) + { + PyMem_Free(res); + return _PyMem_RawStrdup(path); + } + return res; +} + +/* get RISC OS object type (file, directory or image) */ +static int +get_obj_type(const char *pathname) +{ + int obj_type = 0; + if (_swix(OS_File, _INR(0,1) | _OUT(0), + 17, pathname, + &obj_type)) + { + return -1; + } + return obj_type; +} + +/* get RISC OS filetype */ +static int +get_filetype(const char *filename) +{ + int filetype; + if (!_swix(OS_File, _INR(0,1) | _OUT(6), + 23, filename, + &filetype)) + { + return filetype; + } + return -1; +} + +/* Is file, not directory */ +static int +isfile(const char *filename) +{ + return get_obj_type(filename) == 1; // File +} + +/* Is directory */ +static int +isdir(char *filename) +{ + int obj_type = get_obj_type(filename); + return (obj_type == 2 || obj_type == 3); // Directory or image +} + +/* Is 'module' in 'directory'? Check types and for /pyc too. */ +static int +ismodule(const char *directory, const char *module) +{ + char buffer[256]; + strcpy(buffer, directory); + strcat(buffer, "."); + strcat(buffer, module); + + // Is it a typed file? + int filetype = get_filetype(buffer); + if (filetype == 0xa73 || filetype == 0xa74) + return 1; // It's a python one + + // add /py and try that? + strcat(buffer, "/py"); + if (isfile(buffer)) + return 1; + + // try the /pyc? + strcat(buffer, "c"); + if (isfile(buffer)) + return 1; + + return 0; +} + +/* Add a path component, by appending stuff to buffer. + buflen: 'buffer' length in characters including trailing NUL. */ +static PyStatus +joinpath(char *buffer, const char *stuff, size_t buflen) +{ + size_t n, k; + if (stuff[0] != SEP) { + n = strlen(buffer); + if (n >= buflen) { + return PATHLEN_ERR(); + } + + if (n > 0 && buffer[n-1] != SEP) { + buffer[n++] = SEP; + } + } + else { + n = 0; + } + + k = strlen(stuff); + if (n + k >= buflen) { + return PATHLEN_ERR(); + } + strncpy(buffer+n, stuff, k); + buffer[n+k] = '\0'; + + return _PyStatus_OK(); +} + +static inline int +safe_strcpy(char *dst, const char *src, size_t n) +{ + size_t srclen = strlen(src); + if (n <= srclen) { + dst[0] = L'\0'; + return -1; + } + memcpy(dst, src, (srclen + 1) * sizeof(char)); + return 0; +} + +/* search_for_prefix requires that argv0_path be no more than MAXPATHLEN + bytes long. +*/ +static PyStatus +search_for_prefix(PyCalculatePath *calculate, _PyPathConfig *pathconfig, + const char *argv0_path, + char *prefix, size_t prefix_len, int *found) +{ + char path[MAXPATHLEN+1]; + memset(path, 0, sizeof(path)); + size_t path_len = Py_ARRAY_LENGTH(path); + + PyStatus status; + + /* If PYTHONHOME is set, we believe it unconditionally */ + if (pathconfig->home) { + printf("got PYTHONHOME\n"); + /* Path: / */ + if (safe_strcpy(prefix, Py_EncodeLocale(pathconfig->home, NULL), prefix_len) < 0) { + return PATHLEN_ERR(); + } + char *delim = strchr(prefix, DELIM); + if (delim) { + *delim = L'\0'; + } + status = joinpath(prefix, calculate->lib_python, prefix_len); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + *found = 1; + return _PyStatus_OK(); + } + + /* Check to see if argv[0] is in the build directory */ + if (safe_strcpy(path, argv0_path, path_len) < 0) { + return PATHLEN_ERR(); + } + + status = joinpath(path, "Modules.Setup/local", path_len); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + + if (isfile(path)) { + /* Check VPATH to see if argv0_path is in the build directory. + VPATH can be empty. */ + if (VPATH != NULL) { + /* Path: / / Lib / LANDMARK */ + if (safe_strcpy(prefix, argv0_path, prefix_len) < 0) { + return PATHLEN_ERR(); + } + + if (strlen(VPATH) > 0) + { + status = joinpath(prefix, VPATH, prefix_len); + PyMem_RawFree(VPATH); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + } + + status = joinpath(prefix, "lib", prefix_len); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + + if (ismodule(prefix, LANDMARK)) { + *found = -1; + return _PyStatus_OK(); + } + } + } + + /* Search from argv0_path, until root is found */ + if (safe_strcpy(prefix, argv0_path, prefix_len) < 0) { + return PATHLEN_ERR(); + } + + do { + /* Path: / / LANDMARK */ + size_t n = strlen(prefix); + status = joinpath(prefix, calculate->lib_python, prefix_len); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + + if (ismodule(prefix, LANDMARK)) { + *found = 1; + //reduce(prefix); + return _PyStatus_OK(); + } + prefix[n] = '\0'; + + size_t ln = strlen(prefix); + + if (ln > 1) + { + char lc = prefix[ln-1]; + if (lc == '$' || lc == '&' || lc == '%') + prefix[0] = 0; + } + if (prefix[0]) + reduce(prefix); + } while (prefix[0]); + + /* Look at configure's PREFIX. + Path: / / LANDMARK */ + if (safe_strcpy(prefix, calculate->prefix, prefix_len) < 0) { + return PATHLEN_ERR(); + } + status = joinpath(prefix, calculate->lib_python, prefix_len); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + + if (ismodule(prefix, LANDMARK)) { + *found = 1; + return _PyStatus_OK(); + } + + /* Fail */ + *found = 0; + return _PyStatus_OK(); +} + + +static PyStatus +calculate_prefix(PyCalculatePath *calculate, _PyPathConfig *pathconfig, + const char *argv0_path, + char *prefix, size_t prefix_len) +{ + PyStatus status; + + status = search_for_prefix(calculate, pathconfig, argv0_path, + prefix, prefix_len, + &calculate->prefix_found); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + + if (!calculate->prefix_found) { + if (calculate->warnings) { + fprintf(stderr, + "Could not find platform independent libraries \n"); + } + if (safe_strcpy(prefix, calculate->prefix, prefix_len) < 0) { + return PATHLEN_ERR(); + } + status = joinpath(prefix, calculate->lib_python, prefix_len); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + } + return _PyStatus_OK(); +} + + +static PyStatus +calculate_set_prefix(PyCalculatePath *calculate, _PyPathConfig *pathconfig, + char *prefix) +{ + /* Reduce prefix and exec_prefix to their essence, + * e.g. /usr/local/lib/python1.5 is reduced to /usr/local. + * If we're loading relative to the build directory, + * return the compiled-in defaults instead. + */ + size_t len = 0; + if (calculate->prefix_found > 0) { + reduce(prefix); + reduce(prefix); + /* The prefix is the root directory, but reduce() chopped + * off the "/". */ + //if (!prefix[0]) { + // strcpy(prefix, separator); + //} + pathconfig->prefix = Py_DecodeLocale(prefix, &len); + if (!pathconfig->prefix) { + return DECODE_LOCALE_ERR("Calculated Prefix", len); + } + } + else + { + pathconfig->prefix = Py_DecodeLocale(calculate->prefix, &len); + if (!pathconfig->prefix) { + return DECODE_LOCALE_ERR("Calculated Prefix", len); + } + } + return _PyStatus_OK(); +} + + +static PyStatus +calculate_pybuilddir(const char *argv0_path, + char *exec_prefix, size_t exec_prefix_len, + int *found) +{ + PyStatus status; + + char filename[MAXPATHLEN+1]; + memset(filename, 0, sizeof(filename)); + size_t filename_len = Py_ARRAY_LENGTH(filename); + + /* Check to see if argv[0] is in the build directory. "pybuilddir.txt" + is written by setup.py and contains the relative path to the location + of shared library modules. + + Filename: / "pybuilddir.txt" */ + if (safe_strcpy(filename, argv0_path, filename_len) < 0) { + return PATHLEN_ERR(); + } + + status = joinpath(filename, "pybuilddir/txt", filename_len); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + + if (!isfile(filename)) { + return _PyStatus_OK(); + } + + FILE *fp = fopen(filename, "rb"); + if (fp == NULL) { + errno = 0; + return _PyStatus_OK(); + } + + char pybuilddir[MAXPATHLEN + 1]; + size_t n = fread(pybuilddir, 1, Py_ARRAY_LENGTH(pybuilddir) - 1, fp); + pybuilddir[n] = '\0'; + fclose(fp); + + /* Path: / */ + if (safe_strcpy(exec_prefix, argv0_path, exec_prefix_len) < 0) { + return PATHLEN_ERR(); + } + status = joinpath(exec_prefix, pybuilddir, exec_prefix_len); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + + *found = -1; + return _PyStatus_OK(); +} + + +/* search_for_exec_prefix requires that argv0_path be no more than + MAXPATHLEN bytes long. +*/ +static PyStatus +search_for_exec_prefix(PyCalculatePath *calculate, _PyPathConfig *pathconfig, + const char *argv0_path, + char *exec_prefix, size_t exec_prefix_len, + int *found) +{ + PyStatus status; + + /* If PYTHONHOME is set, we believe it unconditionally */ + if (calculate->python_home) { + /* Path: / / "lib-dynload" */ + char *delim = strchr(calculate->python_home, DELIM); + if (delim) { + if (safe_strcpy(exec_prefix, delim+1, exec_prefix_len) < 0) { + return PATHLEN_ERR(); + } + } + else { + if (safe_strcpy(exec_prefix, calculate->python_home, exec_prefix_len) < 0) { + return PATHLEN_ERR(); + } + } + status = joinpath(exec_prefix, calculate->lib_python, exec_prefix_len); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + status = joinpath(exec_prefix, "lib-dynload", exec_prefix_len); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + *found = 1; + return _PyStatus_OK(); + } + + /* Check for pybuilddir.txt */ + assert(*found == 0); + status = calculate_pybuilddir(argv0_path, exec_prefix, exec_prefix_len, + found); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + if (*found) { + return _PyStatus_OK(); + } + + /* Search from argv0_path, until root is found */ + if (safe_strcpy(exec_prefix, argv0_path, exec_prefix_len) < 0) { + return PATHLEN_ERR(); + } + + do { + /* Path: / / "lib-dynload" */ + size_t n = strlen(exec_prefix); + status = joinpath(exec_prefix, calculate->lib_python, exec_prefix_len); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + status = joinpath(exec_prefix, "lib-dynload", exec_prefix_len); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + if (isdir(exec_prefix)) { + *found = 1; + return _PyStatus_OK(); + } + exec_prefix[n] = L'\0'; + reduce(exec_prefix); + } while (exec_prefix[0]); + + /* Look at configure's EXEC_PREFIX. + + Path: / / "lib-dynload" */ + if (safe_strcpy(exec_prefix, calculate->exec_prefix, exec_prefix_len) < 0) { + return PATHLEN_ERR(); + } + status = joinpath(exec_prefix, calculate->lib_python, exec_prefix_len); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + status = joinpath(exec_prefix, "lib-dynload", exec_prefix_len); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + if (isdir(exec_prefix)) { + *found = 1; + return _PyStatus_OK(); + } + + /* Fail */ + *found = 0; + return _PyStatus_OK(); +} + + +static PyStatus +calculate_exec_prefix(PyCalculatePath *calculate, _PyPathConfig *pathconfig, + const char *argv0_path, + char *exec_prefix, size_t exec_prefix_len) +{ + PyStatus status; + + status = search_for_exec_prefix(calculate, pathconfig, argv0_path, + exec_prefix, exec_prefix_len, + &calculate->exec_prefix_found); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + + if (!calculate->exec_prefix_found) { + if (calculate->warnings) { + fprintf(stderr, + "Could not find platform dependent libraries \n"); + } + if (safe_strcpy(exec_prefix, calculate->exec_prefix, exec_prefix_len) < 0) { + return PATHLEN_ERR(); + } + status = joinpath(exec_prefix, "lib/lib-dynload", exec_prefix_len); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + } + /* If we found EXEC_PREFIX do *not* reduce it! (Yet.) */ + return _PyStatus_OK(); +} + + +static PyStatus +calculate_set_exec_prefix(PyCalculatePath *calculate, + _PyPathConfig *pathconfig, + char *exec_prefix) +{ + size_t len = 0; + if (calculate->exec_prefix_found > 0) { + reduce(exec_prefix); + reduce(exec_prefix); + reduce(exec_prefix); + //if (!exec_prefix[0]) { + // strcpy(exec_prefix, separator); + //} + + pathconfig->exec_prefix = Py_DecodeLocale(exec_prefix, &len); + if (!pathconfig->exec_prefix) { + return DECODE_LOCALE_ERR("Calculated Exec Prefix", len); + } + } + else { + pathconfig->exec_prefix = Py_DecodeLocale(calculate->exec_prefix, &len); + if (!pathconfig->exec_prefix) { + return DECODE_LOCALE_ERR("Calculated Exec Prefix", len); + } + } + + if (pathconfig->exec_prefix == NULL) { + return _PyStatus_NO_MEMORY(); + } + + return _PyStatus_OK(); +} + + +static PyStatus +calculate_argv0_path(PyCalculatePath *calculate, const wchar_t *program_full_path, + char *argv0_path, size_t argv0_path_len) +{ + char *_program_full_path = Py_EncodeLocale(program_full_path, NULL); + if (safe_strcpy(argv0_path, _program_full_path, argv0_path_len) < 0) { + PyMem_Free(_program_full_path); + return PATHLEN_ERR(); + } + PyMem_Free(_program_full_path); + reduce(argv0_path); + /* At this point, argv0_path is guaranteed to be less than + MAXPATHLEN bytes long. */ + return _PyStatus_OK(); +} + + +/* Search for an "pyvenv.cfg" environment configuration file, first in the + executable's directory and then in the parent directory. + If found, open it for use when searching for prefixes. +*/ +static PyStatus +calculate_read_pyenv(PyCalculatePath *calculate, + char *argv0_path, size_t argv0_path_len) +{ + PyStatus status; +#ifdef RISCOS + const char *env_cfg = "pyvenv/cfg"; +#else + const char *env_cfg = "pyvenv.cfg"; +#endif + FILE *env_file; + + char filename[MAXPATHLEN+1]; + const size_t filename_len = Py_ARRAY_LENGTH(filename); + memset(filename, 0, sizeof(filename)); + + /* Filename: / "pyvenv.cfg" */ + if (safe_strcpy(filename, argv0_path, filename_len) < 0) { + return PATHLEN_ERR(); + } + + status = joinpath(filename, env_cfg, filename_len); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + env_file = fopen(filename, "r"); + if (env_file == NULL) { + errno = 0; + + /* Filename: / "pyvenv.cfg" */ + reduce(filename); + reduce(filename); + status = joinpath(filename, env_cfg, filename_len); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + + env_file = fopen(filename, "r"); + if (env_file == NULL) { + errno = 0; + return _PyStatus_OK(); + } + } + + + /* Look for a 'home' variable and set argv0_path to it, if found */ + /* + char home[MAXPATHLEN+1]; + memset(home, 0, sizeof(home)); + + if (_Py_FindEnvConfigValue(env_file, "home", + home, Py_ARRAY_LENGTH(home))) { + if (safe_strcpy(argv0_path, home, argv0_path_len) < 0) { + fclose(env_file); + return PATHLEN_ERR(); + } + } + */ + fclose(env_file); + return _PyStatus_OK(); +} + + +static PyStatus +calculate_zip_path(PyCalculatePath *calculate, const char *prefix, + char *zip_path, size_t zip_path_len) +{ + PyStatus status; + + if (calculate->prefix_found > 0) { + /* Use the reduced prefix returned by Py_GetPrefix() */ + if (safe_strcpy(zip_path, prefix, zip_path_len) < 0) { + return PATHLEN_ERR(); + } + reduce(zip_path); + reduce(zip_path); + } + else { + if (safe_strcpy(zip_path, calculate->prefix, zip_path_len) < 0) { + return PATHLEN_ERR(); + } + } + status = joinpath(zip_path, "lib.python00/zip", zip_path_len); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + + /* Replace "00" with version */ + size_t bufsz = strlen(zip_path); + zip_path[bufsz - 6] = VERSION[0]; + zip_path[bufsz - 5] = VERSION[2]; + return _PyStatus_OK(); +} + + +static PyStatus +calculate_module_search_path(PyCalculatePath *calculate, + _PyPathConfig *pathconfig, + const char *prefix, + const char *exec_prefix, + const char *zip_path) +{ + /* Calculate size of return buffer */ + size_t bufsz = 0; + if (calculate->pythonpath_env != NULL) { + bufsz += strlen(calculate->pythonpath_env) + 1; + } + + char *defpath = calculate->pythonpath; + size_t prefixsz = strlen(prefix) + 1; + while (1) { + char *delim = strchr(defpath, DELIM); + + if (defpath[0] != SEP) { + /* Paths are relative to prefix */ + bufsz += prefixsz; + } + + if (delim) { + bufsz += delim - defpath + 1; + } + else { + bufsz += strlen(defpath) + 1; + break; + } + defpath = delim + 1; + } + + if (zip_path) + bufsz += strlen(zip_path) + 1; + bufsz += strlen(exec_prefix) + 1; + + /* Allocate the buffer */ + char *buf = PyMem_RawMalloc(bufsz * sizeof(char)); + if (buf == NULL) { + return _PyStatus_NO_MEMORY(); + } + buf[0] = '\0'; + + /* Run-time value of $PYTHONPATH goes first */ + if (calculate->pythonpath_env) { + strcpy(buf, calculate->pythonpath_env); + strcat(buf, delimiter); + } + + /* Next is the default zip path */ + if (zip_path) + { + strcat(buf, zip_path); + strcat(buf, delimiter); + } + + /* Next goes merge of compile-time $PYTHONPATH with + * dynamically located prefix. + */ + defpath = calculate->pythonpath; + while (1) { + char *delim = strchr(defpath, DELIM); + + if (defpath[0] != SEP) { + strcat(buf, prefix); + if (prefixsz >= 2 && prefix[prefixsz - 2] != SEP && + defpath[0] != (delim ? DELIM : L'\0')) + { + /* not empty */ + strcat(buf, separator); + } + } + + if (delim) { + size_t len = delim - defpath + 1; + size_t end = strlen(buf) + len; + strncat(buf, defpath, len); + buf[end] = '\0'; + } + else { + strcat(buf, defpath); + break; + } + defpath = delim + 1; + } + strcat(buf, delimiter); + + /* Finally, on goes the directory for dynamic-load modules */ + strcat(buf, exec_prefix); + + size_t len; + pathconfig->module_search_path = Py_DecodeLocale(buf, &len); + if (!pathconfig->module_search_path) { + return DECODE_LOCALE_ERR("Calculated Prefix", len); + } + + return _PyStatus_OK(); +} + + +static PyStatus +calculate_init(PyCalculatePath *calculate, const PyConfig *config) +{ + size_t len; + + if (config->home) + { + calculate->python_home = Py_EncodeLocale(config->home, &len); +// if (!calculate->module_search_path) { +// return DECODE_LOCALE_ERR("Calculated Prefix", len); +// } + } + else + calculate->python_home = 0; + + calculate->pythonpath = _PyMem_RawStrdup(PYTHONPATH); + if (!calculate->pythonpath) { + return _PyStatus_NO_MEMORY(); + } + calculate->prefix = Py_canonicialise(PREFIX); + if (!calculate->prefix) { + return _PyStatus_NO_MEMORY(); + } + calculate->exec_prefix = Py_canonicialise(EXEC_PREFIX); + if (!calculate->exec_prefix) { + return _PyStatus_NO_MEMORY(); + } + calculate->lib_python = PyMem_Malloc(16); + if (!calculate->lib_python) { + return _PyStatus_NO_MEMORY(); + } + sprintf(calculate->lib_python, "python%c%c.lib", VERSION[0], VERSION[2]); + + calculate->warnings = config->pathconfig_warnings; + + if (config->pythonpath_env) + { + calculate->pythonpath_env = Py_EncodeLocale(config->pythonpath_env, &len); + } + else + calculate->pythonpath_env = 0; + + return _PyStatus_OK(); +} + + +static void +calculate_free(PyCalculatePath *calculate) +{ + PyMem_RawFree(calculate->python_home); + PyMem_RawFree(calculate->pythonpath); + PyMem_RawFree(calculate->prefix); + PyMem_RawFree(calculate->exec_prefix); + PyMem_RawFree(calculate->lib_python); +} + + +static PyStatus +calculate_path(PyCalculatePath *calculate, _PyPathConfig *pathconfig) +{ + PyStatus status; + + // the program name is the full path + pathconfig->program_full_path = _PyMem_RawWcsdup(pathconfig->program_name); + + char argv0_path[MAXPATHLEN+1]; + memset(argv0_path, 0, sizeof(argv0_path)); + + status = calculate_argv0_path(calculate, pathconfig->program_full_path, + argv0_path, Py_ARRAY_LENGTH(argv0_path)); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + + /* If a pyvenv.cfg configure file is found, + argv0_path is overriden with its 'home' variable. */ + status = calculate_read_pyenv(calculate, + argv0_path, Py_ARRAY_LENGTH(argv0_path)); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + + char prefix[MAXPATHLEN+1]; + memset(prefix, 0, sizeof(prefix)); + status = calculate_prefix(calculate, pathconfig, + argv0_path, + prefix, Py_ARRAY_LENGTH(prefix)); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + + char zip_path[MAXPATHLEN+1]; /* "....lib.pythonXY/zip" */ + memset(zip_path, 0, sizeof(zip_path)); + + status = calculate_zip_path(calculate, prefix, + zip_path, Py_ARRAY_LENGTH(zip_path)); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + + char exec_prefix[MAXPATHLEN+1]; + memset(exec_prefix, 0, sizeof(exec_prefix)); + status = calculate_exec_prefix(calculate, pathconfig, argv0_path, + exec_prefix, Py_ARRAY_LENGTH(exec_prefix)); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + + if ((!calculate->prefix_found || !calculate->exec_prefix_found) && + calculate->warnings) + { + fprintf(stderr, + "Consider setting $PYTHONHOME to [,]\n"); + } + + if (pathconfig->module_search_path == NULL) { + char *zip_pathp = 0; + if (isfile(zip_path)) + zip_pathp = zip_path; + else + { + zip_path[strlen(zip_path)-4] = 0; + int filetype = get_filetype(zip_path); + if (filetype == 0xa91) + zip_pathp = zip_path; + } + status = calculate_module_search_path(calculate, pathconfig, + prefix, exec_prefix, zip_pathp); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + } + + if (pathconfig->prefix == NULL) { + status = calculate_set_prefix(calculate, pathconfig, prefix); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + } + + if (pathconfig->exec_prefix == NULL) { + status = calculate_set_exec_prefix(calculate, pathconfig, exec_prefix); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + } + + return _PyStatus_OK(); +} + + +/* Calculate the Python path configuration. + + Inputs: + + - PATH environment variable + - Macros: PYTHONPATH, PREFIX, EXEC_PREFIX, VERSION (ex: "3.9"). + PREFIX and EXEC_PREFIX are generated by the configure script. + PYTHONPATH macro is the default search path. + - pybuilddir.txt file + - pyvenv.cfg configuration file + - PyConfig fields ('config' function argument): + + - pathconfig_warnings + - pythonpath_env (PYTHONPATH environment variable) + + - _PyPathConfig fields ('pathconfig' function argument): + + - program_name: see config_init_program_name() + - home: Py_SetPythonHome() or PYTHONHOME environment variable + + - current working directory: see copy_absolute() + + Outputs, 'pathconfig' fields: + + - program_full_path + - module_search_path + - prefix + - exec_prefix + + If a field is already set (non NULL), it is left unchanged. */ +PyStatus +_PyPathConfig_Calculate(_PyPathConfig *pathconfig, const PyConfig *config) +{ + PyStatus status; + PyCalculatePath calculate; + memset(&calculate, 0, sizeof(calculate)); + + status = calculate_init(&calculate, config); + if (_PyStatus_EXCEPTION(status)) { + goto done; + } + + status = calculate_path(&calculate, pathconfig); + if (_PyStatus_EXCEPTION(status)) { + goto done; + } + + status = _PyStatus_OK(); + +done: + calculate_free(&calculate); + return status; +} + +#ifdef __cplusplus +} +#endif diff --git a/RISCOS/pyconfig.h b/RISCOS/pyconfig.h new file mode 100644 index 00000000000000..06a538a2150ace --- /dev/null +++ b/RISCOS/pyconfig.h @@ -0,0 +1,1665 @@ +/* pyconfig.h for RISC OS */ + + +#ifndef Py_PYCONFIG_H +#define Py_PYCONFIG_H + + +/* Define if building universal (internal helper macro) */ +#undef AC_APPLE_UNIVERSAL_BUILD + +/* Define for AIX if your compiler is a genuine IBM xlC/xlC_r and you want + support for AIX C++ shared extension modules. */ +#undef AIX_GENUINE_CPLUSPLUS + +/* Alternative SOABI used in debug build to load C extensions built in release + mode */ +#undef ALT_SOABI + +/* The Android API level. */ +#undef ANDROID_API_LEVEL + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM + mixed-endian order (byte order 45670123) */ +#define DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 1 + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most + significant byte first */ +#undef DOUBLE_IS_BIG_ENDIAN_IEEE754 + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +#undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 + +/* Define if --enable-ipv6 is specified */ +#undef ENABLE_IPV6 + +/* Define to 1 if your system stores words within floats with the most + significant word first */ +#undef FLOAT_WORDS_BIGENDIAN + +/* Define if flock needs to be linked with bsd library. */ +#undef FLOCK_NEEDS_LIBBSD + +/* Define if getpgrp() must be called as getpgrp(0). */ +#undef GETPGRP_HAVE_ARG + +/* Define if gettimeofday() does not have second (timezone) argument This is + the case on Motorola V4 (R40V4.2) */ +#undef GETTIMEOFDAY_NO_TZ + +/* Define to 1 if you have the `accept4' function. */ +#define HAVE_ACCEPT4 1 + +/* Define to 1 if you have the `acosh' function. */ +#define HAVE_ACOSH 1 + +/* struct addrinfo (netdb.h) */ +#define HAVE_ADDRINFO 1 + +/* Define to 1 if you have the `alarm' function. */ +#define HAVE_ALARM 1 + +/* Define if aligned memory access is required */ +#undef HAVE_ALIGNED_REQUIRED + +/* Define to 1 if you have the header file. */ +#define HAVE_ALLOCA_H 1 + +/* Define this if your time.h defines altzone. */ +#undef HAVE_ALTZONE + +/* Define to 1 if you have the `asinh' function. */ +#define HAVE_ASINH 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_ASM_TYPES_H + +/* Define to 1 if you have the `atanh' function. */ +#define HAVE_ATANH 1 + +/* Define to 1 if you have the `bind_textdomain_codeset' function. */ +#undef HAVE_BIND_TEXTDOMAIN_CODESET + +/* Define to 1 if you have the header file. */ +#undef HAVE_BLUETOOTH_BLUETOOTH_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_BLUETOOTH_H + +/* Define if mbstowcs(NULL, "text", 0) does not return the number of wide + chars that would be converted. */ +#define HAVE_BROKEN_MBSTOWCS 1 + +/* Define if nice() returns success/failure instead of the new priority. */ +#undef HAVE_BROKEN_NICE + +/* Define if the system reports an invalid PIPE_BUF value. */ +#undef HAVE_BROKEN_PIPE_BUF + +/* Define if poll() sets errno on invalid file descriptors. */ +#undef HAVE_BROKEN_POLL + +/* Define if the Posix semaphores do not work on your system */ +#undef HAVE_BROKEN_POSIX_SEMAPHORES + +/* Define if pthread_sigmask() does not work on your system. */ +#undef HAVE_BROKEN_PTHREAD_SIGMASK + +/* define to 1 if your sem_getvalue is broken. */ +#undef HAVE_BROKEN_SEM_GETVALUE + +/* Define if `unsetenv` does not return an int. */ +#undef HAVE_BROKEN_UNSETENV + +/* Has builtin atomics */ +#undef HAVE_BUILTIN_ATOMIC + +/* Define to 1 if you have the 'chflags' function. */ +#undef HAVE_CHFLAGS + +/* Define to 1 if you have the `chown' function. */ +#undef HAVE_CHOWN + +/* Define if you have the 'chroot' function. */ +#undef HAVE_CHROOT + +/* Define to 1 if you have the `clock' function. */ +#define HAVE_CLOCK 1 + +/* Define to 1 if you have the `clock_getres' function. */ +#define HAVE_CLOCK_GETRES 1 + +/* Define to 1 if you have the `clock_gettime' function. */ +#define HAVE_CLOCK_GETTIME 1 + +/* Define to 1 if you have the `clock_settime' function. */ +#define HAVE_CLOCK_SETTIME 1 + +/* Define if the C compiler supports computed gotos. */ +#define HAVE_COMPUTED_GOTOS 1 + +/* Define to 1 if you have the `confstr' function. */ +#undef HAVE_CONFSTR + +/* Define to 1 if you have the header file. */ +#undef HAVE_CONIO_H + +/* Define to 1 if you have the `copysign' function. */ +#undef HAVE_COPYSIGN + +/* Define to 1 if you have the `copy_file_range' function. */ +#undef HAVE_COPY_FILE_RANGE + +/* Define to 1 if you have the header file. */ +#define HAVE_CRYPT_H 1 + +/* Define if you have the crypt_r() function. */ +#define HAVE_CRYPT_R 1 + +/* Define to 1 if you have the `ctermid' function. */ +#undef HAVE_CTERMID + +/* Define if you have the 'ctermid_r' function. */ +#undef HAVE_CTERMID_R + +/* Define if you have the 'filter' function. */ +#undef HAVE_CURSES_FILTER + +/* Define to 1 if you have the header file. */ +#undef HAVE_CURSES_H + +/* Define if you have the 'has_key' function. */ +#undef HAVE_CURSES_HAS_KEY + +/* Define if you have the 'immedok' function. */ +#undef HAVE_CURSES_IMMEDOK + +/* Define if you have the 'is_pad' function or macro. */ +#undef HAVE_CURSES_IS_PAD + +/* Define if you have the 'is_term_resized' function. */ +#undef HAVE_CURSES_IS_TERM_RESIZED + +/* Define if you have the 'resizeterm' function. */ +#undef HAVE_CURSES_RESIZETERM + +/* Define if you have the 'resize_term' function. */ +#undef HAVE_CURSES_RESIZE_TERM + +/* Define if you have the 'syncok' function. */ +#undef HAVE_CURSES_SYNCOK + +/* Define if you have the 'typeahead' function. */ +#undef HAVE_CURSES_TYPEAHEAD + +/* Define if you have the 'use_env' function. */ +#undef HAVE_CURSES_USE_ENV + +/* Define if you have the 'wchgat' function. */ +#undef HAVE_CURSES_WCHGAT + +/* Define to 1 if you have the declaration of `isfinite', and to 0 if you + don't. */ +#define HAVE_DECL_ISFINITE 1 + +/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. + */ +#define HAVE_DECL_ISINF 1 + +/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. + */ +#define HAVE_DECL_ISNAN 1 + +/* Define to 1 if you have the declaration of `RTLD_DEEPBIND', and to 0 if you + don't. */ +#define HAVE_DECL_RTLD_DEEPBIND 0 + +/* Define to 1 if you have the declaration of `RTLD_GLOBAL', and to 0 if you + don't. */ +#define HAVE_DECL_RTLD_GLOBAL 1 + +/* Define to 1 if you have the declaration of `RTLD_LAZY', and to 0 if you + don't. */ +#define HAVE_DECL_RTLD_LAZY 1 + +/* Define to 1 if you have the declaration of `RTLD_LOCAL', and to 0 if you + don't. */ +#define HAVE_DECL_RTLD_LOCAL 1 + +/* Define to 1 if you have the declaration of `RTLD_MEMBER', and to 0 if you + don't. */ +#define HAVE_DECL_RTLD_MEMBER 0 + +/* Define to 1 if you have the declaration of `RTLD_NODELETE', and to 0 if you + don't. */ +#define HAVE_DECL_RTLD_NODELETE 0 + +/* Define to 1 if you have the declaration of `RTLD_NOLOAD', and to 0 if you + don't. */ +#define HAVE_DECL_RTLD_NOLOAD 0 + +/* Define to 1 if you have the declaration of `RTLD_NOW', and to 0 if you + don't. */ +#define HAVE_DECL_RTLD_NOW 1 + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +#define HAVE_DECL_TZNAME 1 + +/* Define to 1 if you have the device macros. */ +#undef HAVE_DEVICE_MACROS + +/* Define to 1 if you have the /dev/ptc device file. */ +#undef HAVE_DEV_PTC + +/* Define to 1 if you have the /dev/ptmx device file. */ +#undef HAVE_DEV_PTMX + +/* Define to 1 if you have the header file. */ +#undef HAVE_DIRECT_H + +/* Define to 1 if the dirent structure has a d_type field */ +#define HAVE_DIRENT_D_TYPE 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the 'dirfd' function or macro. */ +#define HAVE_DIRFD 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the `dup2' function. */ +#define HAVE_DUP2 1 + +/* Define to 1 if you have the `dup3' function. */ +#undef HAVE_DUP3 + +/* Defined when any dynamic module loading is enabled. */ +#define HAVE_DYNAMIC_LOADING 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ENDIAN_H 1 + +/* Define if you have the 'epoll' functions. */ +#undef HAVE_EPOLL + +/* Define if you have the 'epoll_create1' function. */ +#undef HAVE_EPOLL_CREATE1 + +/* Define to 1 if you have the `erf' function. */ +#define HAVE_ERF 1 + +/* Define to 1 if you have the `erfc' function. */ +#define HAVE_ERFC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `execv' function. */ +#define HAVE_EXECV 1 + +/* Define to 1 if you have the `explicit_bzero' function. */ +#undef HAVE_EXPLICIT_BZERO + +/* Define to 1 if you have the `explicit_memset' function. */ +#undef HAVE_EXPLICIT_MEMSET + +/* Define to 1 if you have the `expm1' function. */ +#define HAVE_EXPM1 1 + +/* Define to 1 if you have the `faccessat' function. */ +#undef HAVE_FACCESSAT + +/* Define if you have the 'fchdir' function. */ +#define HAVE_FCHDIR 1 + +/* Define to 1 if you have the `fchmod' function. */ +#undef HAVE_FCHMOD + +/* Define to 1 if you have the `fchmodat' function. */ +#undef HAVE_FCHMODAT + +/* Define to 1 if you have the `fchown' function. */ +#undef HAVE_FCHOWN + +/* Define to 1 if you have the `fchownat' function. */ +#undef HAVE_FCHOWNAT + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the 'fdatasync' function. */ +#undef HAVE_FDATASYNC + +/* Define to 1 if you have the `fdopendir' function. */ +#undef HAVE_FDOPENDIR + +/* Define to 1 if you have the `fdwalk' function. */ +#undef HAVE_FDWALK + +/* Define to 1 if you have the `fexecve' function. */ +#undef HAVE_FEXECVE + +/* Define to 1 if you have the `finite' function. */ +#define HAVE_FINITE 1 + +/* Define to 1 if you have the `flock' function. */ +#undef HAVE_FLOCK + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `forkpty' function. */ +#undef HAVE_FORKPTY + +/* Define to 1 if you have the `fpathconf' function. */ +#undef HAVE_FPATHCONF + +/* Define to 1 if you have the `fseek64' function. */ +#undef HAVE_FSEEK64 + +/* Define to 1 if you have the `fseeko' function. */ +#undef HAVE_FSEEKO + +/* Define to 1 if you have the `fstatat' function. */ +#undef HAVE_FSTATAT + +/* Define to 1 if you have the `fstatvfs' function. */ +#undef HAVE_FSTATVFS + +/* Define if you have the 'fsync' function. */ +#undef HAVE_FSYNC + +/* Define to 1 if you have the `ftell64' function. */ +#undef HAVE_FTELL64 + +/* Define to 1 if you have the `ftello' function. */ +#define HAVE_FTELLO 1 + +/* Define to 1 if you have the `ftime' function. */ +#define HAVE_FTIME 1 + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `futimens' function. */ +#undef HAVE_FUTIMENS + +/* Define to 1 if you have the `futimes' function. */ +#undef HAVE_FUTIMES + +/* Define to 1 if you have the `futimesat' function. */ +#undef HAVE_FUTIMESAT + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `gamma' function. */ +#define HAVE_GAMMA 1 + +/* Define if we can use gcc inline assembler to get and set mc68881 fpcr */ +#undef HAVE_GCC_ASM_FOR_MC68881 + +/* Define if we can use x64 gcc inline assembler */ +#undef HAVE_GCC_ASM_FOR_X64 + +/* Define if we can use gcc inline assembler to get and set x87 control word + */ +#undef HAVE_GCC_ASM_FOR_X87 + +/* Define if your compiler provides __uint128_t */ +#undef HAVE_GCC_UINT128_T + +/* Define if you have the getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ +#undef HAVE_GETC_UNLOCKED + +/* Define to 1 if you have the `getentropy' function. */ +#undef HAVE_GETENTROPY + +/* Define to 1 if you have the `getgrgid_r' function. */ +#undef HAVE_GETGRGID_R + +/* Define to 1 if you have the `getgrnam_r' function. */ +#undef HAVE_GETGRNAM_R + +/* Define to 1 if you have the `getgrouplist' function. */ +#undef HAVE_GETGROUPLIST + +/* Define to 1 if you have the `getgroups' function. */ +#undef HAVE_GETGROUPS + +/* Define to 1 if you have the `gethostbyname' function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define this if you have some version of gethostbyname_r() */ +#define HAVE_GETHOSTBYNAME_R 1 + +/* Define this if you have the 3-arg version of gethostbyname_r(). */ +#undef HAVE_GETHOSTBYNAME_R_3_ARG + +/* Define this if you have the 5-arg version of gethostbyname_r(). */ +#undef HAVE_GETHOSTBYNAME_R_5_ARG + +/* Define this if you have the 6-arg version of gethostbyname_r(). */ +#define HAVE_GETHOSTBYNAME_R_6_ARG 1 + +/* Define to 1 if you have the `getitimer' function. */ +#define HAVE_GETITIMER 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#undef HAVE_GETLOADAVG + +/* Define to 1 if you have the `getlogin' function. */ +#define HAVE_GETLOGIN 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define if you have the 'getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getpeername' function. */ +#define HAVE_GETPEERNAME 1 + +/* Define to 1 if you have the `getpgid' function. */ +#undef HAVE_GETPGID + +/* Define to 1 if you have the `getpgrp' function. */ +#undef HAVE_GETPGRP + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpriority' function. */ +#define HAVE_GETPRIORITY 1 + +/* Define to 1 if you have the `getpwent' function. */ +#undef HAVE_GETPWENT + +/* Define to 1 if you have the `getpwnam_r' function. */ +#undef HAVE_GETPWNAM_R + +/* Define to 1 if you have the `getpwuid_r' function. */ +#undef HAVE_GETPWUID_R + +/* Define to 1 if the getrandom() function is available */ +#undef HAVE_GETRANDOM + +/* Define to 1 if the Linux getrandom() syscall is available */ +#undef HAVE_GETRANDOM_SYSCALL + +/* Define to 1 if you have the `getresgid' function. */ +#undef HAVE_GETRESGID + +/* Define to 1 if you have the `getresuid' function. */ +#undef HAVE_GETRESUID + +/* Define to 1 if you have the `getsid' function. */ +#undef HAVE_GETSID + +/* Define to 1 if you have the `getspent' function. */ +#undef HAVE_GETSPENT + +/* Define to 1 if you have the `getspnam' function. */ +#undef HAVE_GETSPNAM + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `getwd' function. */ +#define HAVE_GETWD 1 + +/* Define if glibc has incorrect _FORTIFY_SOURCE wrappers for memmove and + bcopy. */ +#undef HAVE_GLIBC_MEMMOVE_BUG + +/* Define to 1 if you have the header file. */ +#undef HAVE_GRP_H + +/* Define if you have the 'hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* Define this if you have le64toh() */ +#undef HAVE_HTOLE64 + +/* Define to 1 if you have the `hypot' function. */ +#define HAVE_HYPOT 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_IEEEFP_H + +/* Define to 1 if you have the `if_nameindex' function. */ +#undef HAVE_IF_NAMEINDEX + +/* Define if you have the 'inet_aton' function. */ +#define HAVE_INET_ATON 1 + +/* Define if you have the 'inet_pton' function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the `initgroups' function. */ +#undef HAVE_INITGROUPS + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_IO_H + +/* Define if gcc has the ipa-pure-const bug. */ +#undef HAVE_IPA_PURE_CONST_BUG + +/* Define to 1 if you have the `kill' function. */ +#define HAVE_KILL 1 + +/* Define to 1 if you have the `killpg' function. */ +#define HAVE_KILLPG 1 + +/* Define if you have the 'kqueue' functions. */ +#undef HAVE_KQUEUE + +/* Define to 1 if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Defined to enable large file support when an off_t is bigger than a long + and long long is at least as big as an off_t. You may need to add some + flags for configuration and compilation to enable this mode. (For Solaris + and Linux, the necessary defines are already defined.) */ +#undef HAVE_LARGEFILE_SUPPORT + +/* Define to 1 if you have the 'lchflags' function. */ +#undef HAVE_LCHFLAGS + +/* Define to 1 if you have the `lchmod' function. */ +#undef HAVE_LCHMOD + +/* Define to 1 if you have the `lchown' function. */ +#undef HAVE_LCHOWN + +/* Define to 1 if you have the `lgamma' function. */ +#define HAVE_LGAMMA 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#define HAVE_LIBDL 1 + +/* Define to 1 if you have the `dld' library (-ldld). */ +#undef HAVE_LIBDLD + +/* Define to 1 if you have the `ieee' library (-lieee). */ +#undef HAVE_LIBIEEE + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBINTL_H + +/* Define if you have the readline library (-lreadline). */ +#undef HAVE_LIBREADLINE + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +#undef HAVE_LIBRESOLV + +/* Define to 1 if you have the `sendfile' library (-lsendfile). */ +#undef HAVE_LIBSENDFILE + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBUTIL_H + +/* Define if you have the 'link' function. */ +#undef HAVE_LINK + +/* Define to 1 if you have the `linkat' function. */ +#undef HAVE_LINKAT + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_CAN_BCM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_CAN_H + +/* Define if compiling using Linux 3.6 or later. */ +#undef HAVE_LINUX_CAN_RAW_FD_FRAMES + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_CAN_RAW_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_MEMFD_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_NETLINK_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_QRTR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_RANDOM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_TIPC_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_VM_SOCKETS_H + +/* Define to 1 if you have the `lockf' function. */ +#undef HAVE_LOCKF + +/* Define to 1 if you have the `log1p' function. */ +#define HAVE_LOG1P 1 + +/* Define to 1 if you have the `log2' function. */ +#define HAVE_LOG2 1 + +/* Define to 1 if the system has the type `long double'. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define to 1 if you have the `lstat' function. */ +#define HAVE_LSTAT 1 + +/* Define to 1 if you have the `lutimes' function. */ +#undef HAVE_LUTIMES + +/* Define to 1 if you have the `madvise' function. */ +#define HAVE_MADVISE 1 + +/* Define this if you have the makedev macro. */ +#undef HAVE_MAKEDEV + +/* Define to 1 if you have the `mbrtowc' function. */ +#define HAVE_MBRTOWC 1 + +/* Define if you have the 'memfd_create' function. */ +#undef HAVE_MEMFD_CREATE + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memrchr' function. */ +#define HAVE_MEMRCHR 1 + +/* Define to 1 if you have the `mkdirat' function. */ +#undef HAVE_MKDIRAT + +/* Define to 1 if you have the `mkfifo' function. */ +#define HAVE_MKFIFO 1 + +/* Define to 1 if you have the `mkfifoat' function. */ +#undef HAVE_MKFIFOAT + +/* Define to 1 if you have the `mknod' function. */ +#undef HAVE_MKNOD + +/* Define to 1 if you have the `mknodat' function. */ +#undef HAVE_MKNODAT + +/* Define to 1 if you have the `mktime' function. */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the `mmap' function. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `mremap' function. */ +#define HAVE_MREMAP 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_NCURSES_H + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +#undef HAVE_NDIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETPACKET_PACKET_H + +/* Define to 1 if you have the header file. */ +#define HAVE_NET_IF_H 1 + +/* Define to 1 if you have the `nice' function. */ +#define HAVE_NICE 1 + +/* Define to 1 if you have the `openat' function. */ +#undef HAVE_OPENAT + +/* Define to 1 if you have the `openpty' function. */ +#undef HAVE_OPENPTY + +/* Define to 1 if you have the `pathconf' function. */ +#undef HAVE_PATHCONF + +/* Define to 1 if you have the `pause' function. */ +#undef HAVE_PAUSE + +/* Define to 1 if you have the `pipe2' function. */ +#undef HAVE_PIPE2 + +/* Define to 1 if you have the `plock' function. */ +#undef HAVE_PLOCK + +/* Define to 1 if you have the `poll' function. */ +#undef HAVE_POLL + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the `posix_fadvise' function. */ +#undef HAVE_POSIX_FADVISE + +/* Define to 1 if you have the `posix_fallocate' function. */ +#undef HAVE_POSIX_FALLOCATE + +/* Define to 1 if you have the `posix_spawn' function. */ +#undef HAVE_POSIX_SPAWN + +/* Define to 1 if you have the `posix_spawnp' function. */ +#undef HAVE_POSIX_SPAWNP + +/* Define to 1 if you have the `pread' function. */ +#undef HAVE_PREAD + +/* Define to 1 if you have the `preadv' function. */ +#undef HAVE_PREADV + +/* Define to 1 if you have the `preadv2' function. */ +#undef HAVE_PREADV2 + +/* Define if you have the 'prlimit' functions. */ +#undef HAVE_PRLIMIT + +/* Define if you have the '_dyld_shared_cache_contains_path' function. */ +#undef HAVE_DYLD_SHARED_CACHE_CONTAINS_PATH + +/* Define to 1 if you have the header file. */ +#undef HAVE_PROCESS_H + +/* Define if your compiler supports function prototype */ +#define HAVE_PROTOTYPES 1 + +/* Define to 1 if you have the `pthread_condattr_setclock' function. */ +#undef HAVE_PTHREAD_CONDATTR_SETCLOCK + +/* Defined for Solaris 2.6 bug in pthread header. */ +#undef HAVE_PTHREAD_DESTRUCTOR + +/* Define to 1 if you have the `pthread_getcpuclockid' function. */ +#undef HAVE_PTHREAD_GETCPUCLOCKID + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_init' function. */ +#undef HAVE_PTHREAD_INIT + +/* Define to 1 if you have the `pthread_kill' function. */ +#define HAVE_PTHREAD_KILL 1 + +/* Define to 1 if you have the `pthread_sigmask' function. */ +#define HAVE_PTHREAD_SIGMASK 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_PTY_H + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define to 1 if you have the `pwrite' function. */ +#undef HAVE_PWRITE + +/* Define to 1 if you have the `pwritev' function. */ +#undef HAVE_PWRITEV + +/* Define to 1 if you have the `pwritev2' function. */ +#undef HAVE_PWRITEV2 + +/* Define to 1 if you have the `readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the `readlinkat' function. */ +#undef HAVE_READLINKAT + +/* Define to 1 if you have the `readv' function. */ +#define HAVE_READV 1 + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define to 1 if you have the `renameat' function. */ +#undef HAVE_RENAMEAT + +/* Define if readline supports append_history */ +#undef HAVE_RL_APPEND_HISTORY + +/* Define if you can turn off readline's signal handling. */ +#undef HAVE_RL_CATCH_SIGNAL + +/* Define if you have readline 2.2 */ +#undef HAVE_RL_COMPLETION_APPEND_CHARACTER + +/* Define if you have readline 4.0 */ +#undef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK + +/* Define if you have readline 4.2 */ +#undef HAVE_RL_COMPLETION_MATCHES + +/* Define if you have rl_completion_suppress_append */ +#undef HAVE_RL_COMPLETION_SUPPRESS_APPEND + +/* Define if you have readline 4.0 */ +#undef HAVE_RL_PRE_INPUT_HOOK + +/* Define if you have readline 4.0 */ +#undef HAVE_RL_RESIZE_TERMINAL + +/* Define to 1 if you have the `round' function. */ +#define HAVE_ROUND 1 + +/* Define to 1 if you have the `rtpSpawn' function. */ +#undef HAVE_RTPSPAWN + +/* Define to 1 if you have the `sched_get_priority_max' function. */ +#undef HAVE_SCHED_GET_PRIORITY_MAX + +/* Define to 1 if you have the header file. */ +#define HAVE_SCHED_H 1 + +/* Define to 1 if you have the `sched_rr_get_interval' function. */ +#undef HAVE_SCHED_RR_GET_INTERVAL + +/* Define to 1 if you have the `sched_setaffinity' function. */ +#undef HAVE_SCHED_SETAFFINITY + +/* Define to 1 if you have the `sched_setparam' function. */ +#undef HAVE_SCHED_SETPARAM + +/* Define to 1 if you have the `sched_setscheduler' function. */ +#undef HAVE_SCHED_SETSCHEDULER + +/* Define to 1 if you have the `sem_getvalue' function. */ +#define HAVE_SEM_GETVALUE 1 + +/* Define to 1 if you have the `sem_open' function. */ +#define HAVE_SEM_OPEN 1 + +/* Define to 1 if you have the `sem_timedwait' function. */ +#undef HAVE_SEM_TIMEDWAIT + +/* Define to 1 if you have the `sem_unlink' function. */ +#define HAVE_SEM_UNLINK 1 + +/* Define to 1 if you have the `sendfile' function. */ +#undef HAVE_SENDFILE + +/* Define to 1 if you have the `setegid' function. */ +#undef HAVE_SETEGID + +/* Define to 1 if you have the `seteuid' function. */ +#undef HAVE_SETEUID + +/* Define to 1 if you have the `setgid' function. */ +#undef HAVE_SETGID + +/* Define if you have the 'setgroups' function. */ +#undef HAVE_SETGROUPS + +/* Define to 1 if you have the `sethostname' function. */ +#define HAVE_SETHOSTNAME 1 + +/* Define to 1 if you have the `setitimer' function. */ +#define HAVE_SETITIMER 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setpgid' function. */ +#undef HAVE_SETPGID + +/* Define to 1 if you have the `setpgrp' function. */ +#undef HAVE_SETPGRP + +/* Define to 1 if you have the `setpriority' function. */ +#define HAVE_SETPRIORITY 1 + +/* Define to 1 if you have the `setregid' function. */ +#undef HAVE_SETREGID + +/* Define to 1 if you have the `setresgid' function. */ +#undef HAVE_SETRESGID + +/* Define to 1 if you have the `setresuid' function. */ +#undef HAVE_SETRESUID + +/* Define to 1 if you have the `setreuid' function. */ +#undef HAVE_SETREUID + +/* Define to 1 if you have the `setsid' function. */ +#undef HAVE_SETSID + +/* Define to 1 if you have the `setuid' function. */ +#undef HAVE_SETUID + +/* Define to 1 if you have the `setvbuf' function. */ +#define HAVE_SETVBUF 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SHADOW_H + +/* Define to 1 if you have the `shm_open' function. */ +#undef HAVE_SHM_OPEN + +/* Define to 1 if you have the `shm_unlink' function. */ +#undef HAVE_SHM_UNLINK + +/* Define to 1 if you have the `sigaction' function. */ +#undef HAVE_SIGACTION + +/* Define to 1 if you have the `sigaltstack' function. */ +#undef HAVE_SIGALTSTACK + +/* Define to 1 if you have the `sigfillset' function. */ +#undef HAVE_SIGFILLSET + +/* Define to 1 if `si_band' is a member of `siginfo_t'. */ +#define HAVE_SIGINFO_T_SI_BAND 1 + +/* Define to 1 if you have the `siginterrupt' function. */ +#define HAVE_SIGINTERRUPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `sigpending' function. */ +#define HAVE_SIGPENDING 1 + +/* Define to 1 if you have the `sigrelse' function. */ +#undef HAVE_SIGRELSE + +/* Define to 1 if you have the `sigtimedwait' function. */ +#undef HAVE_SIGTIMEDWAIT + +/* Define to 1 if you have the `sigwait' function. */ +#define HAVE_SIGWAIT 1 + +/* Define to 1 if you have the `sigwaitinfo' function. */ +#undef HAVE_SIGWAITINFO + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* struct sockaddr_alg (linux/if_alg.h) */ +#undef HAVE_SOCKADDR_ALG + +/* Define if sockaddr has sa_len member */ +#undef HAVE_SOCKADDR_SA_LEN + +/* struct sockaddr_storage (sys/socket.h) */ +#define HAVE_SOCKADDR_STORAGE 1 + +/* Define if you have the 'socketpair' function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SPAWN_H + +/* Define if your compiler provides ssize_t */ +#define HAVE_SSIZE_T 1 + +/* Define to 1 if you have the `statvfs' function. */ +#undef HAVE_STATVFS + +/* Define if you have struct stat.st_mtim.tv_nsec */ +#undef HAVE_STAT_TV_NSEC + +/* Define if you have struct stat.st_mtimensec */ +#undef HAVE_STAT_TV_NSEC2 + +/* Define if your compiler supports variable length function prototypes (e.g. + void fprintf(FILE *, char *, ...);) *and* */ +#define HAVE_STDARG_PROTOTYPES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Has stdatomic.h with atomic_int */ +#undef HAVE_STD_ATOMIC + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcpy' function. */ +#undef HAVE_STRLCPY + +/* Define to 1 if you have the header file. */ +#undef HAVE_STROPTS_H + +/* Define to 1 if you have the `strsignal' function. */ +#define HAVE_STRSIGNAL 1 + +/* Define to 1 if `pw_gecos' is a member of `struct passwd'. */ +#undef HAVE_STRUCT_PASSWD_PW_GECOS + +/* Define to 1 if `pw_passwd' is a member of `struct passwd'. */ +#undef HAVE_STRUCT_PASSWD_PW_PASSWD + +/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ +#undef HAVE_STRUCT_STAT_ST_BIRTHTIME + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#undef HAVE_STRUCT_STAT_ST_BLKSIZE + +/* Define to 1 if `st_blocks' is a member of `struct stat'. */ +#undef HAVE_STRUCT_STAT_ST_BLOCKS + +/* Define to 1 if `st_flags' is a member of `struct stat'. */ +#undef HAVE_STRUCT_STAT_ST_FLAGS + +/* Define to 1 if `st_gen' is a member of `struct stat'. */ +#undef HAVE_STRUCT_STAT_ST_GEN + +/* Define to 1 if `st_rdev' is a member of `struct stat'. */ +#undef HAVE_STRUCT_STAT_ST_RDEV + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define if you have the 'symlink' function. */ +#undef HAVE_SYMLINK + +/* Define to 1 if you have the `symlinkat' function. */ +#undef HAVE_SYMLINKAT + +/* Define to 1 if you have the `sync' function. */ +#undef HAVE_SYNC + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_AUDIOIO_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_BSDTTY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_DEVPOLL_H + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_DIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_ENDIAN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_EPOLL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_EVENT_H + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_KERN_CONTROL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_LOADAVG_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_LOCK_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_MEMFD_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_MKDEV_H + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_MMAN_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_MODEM_H + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_NDIR_H + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_POLL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_RANDOM_H + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SENDFILE_H + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STATVFS_H + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SYSCALL_H + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSMACROS_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SYS_DOMAIN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TERMIO_H + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_XATTR_H + +/* Define to 1 if you have the `tcgetpgrp' function. */ +#define HAVE_TCGETPGRP 1 + +/* Define to 1 if you have the `tcsetpgrp' function. */ +#define HAVE_TCSETPGRP 1 + +/* Define to 1 if you have the `tempnam' function. */ +#define HAVE_TEMPNAM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_TERM_H + +/* Define to 1 if you have the `tgamma' function. */ +#define HAVE_TGAMMA 1 + +/* Define to 1 if you have the `timegm' function. */ +#define HAVE_TIMEGM 1 + +/* Define to 1 if you have the `times' function. */ +#undef HAVE_TIMES + +/* Define to 1 if you have the `tmpfile' function. */ +#define HAVE_TMPFILE 1 + +/* Define to 1 if you have the `tmpnam' function. */ +#define HAVE_TMPNAM 1 + +/* Define to 1 if you have the `tmpnam_r' function. */ +#define HAVE_TMPNAM_R 1 + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#undef HAVE_TM_ZONE + +/* Define to 1 if you have the `truncate' function. */ +#define HAVE_TRUNCATE 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +#undef HAVE_TZNAME + +/* Define this if you have tcl and TCL_UTF_MAX==6 */ +#undef HAVE_UCS4_TCL + +/* Define to 1 if you have the `uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unlinkat' function. */ +#undef HAVE_UNLINKAT + +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define if you have a useable wchar_t type defined in wchar.h; useable means + wchar_t must be an unsigned type with at least 16 bits. (see + Include/unicodeobject.h). */ +#define HAVE_USABLE_WCHAR_T 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_UTIL_H + +/* Define to 1 if you have the `utimensat' function. */ +#undef HAVE_UTIMENSAT + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define if uuid_create() exists. */ +#undef HAVE_UUID_CREATE + +/* Define if uuid_enc_be() exists. */ +#undef HAVE_UUID_ENC_BE + +/* Define if uuid_generate_time_safe() exists. */ +#undef HAVE_UUID_GENERATE_TIME_SAFE + +/* Define to 1 if you have the header file. */ +#undef HAVE_UUID_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UUID_UUID_H + +/* Define to 1 if you have the `wait3' function. */ +#define HAVE_WAIT3 1 + +/* Define to 1 if you have the `wait4' function. */ +#define HAVE_WAIT4 1 + +/* Define to 1 if you have the `waitid' function. */ +#undef HAVE_WAITID + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define if the compiler provides a wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcscoll' function. */ +#undef HAVE_WCSCOLL + +/* Define to 1 if you have the `wcsftime' function. */ +#undef HAVE_WCSFTIME + +/* Define to 1 if you have the `wcsxfrm' function. */ +#undef HAVE_WCSXFRM + +/* Define to 1 if you have the `wmemcmp' function. */ +#define HAVE_WMEMCMP 1 + +/* Define if tzset() actually switches the local timezone in a meaningful way. + */ +#define HAVE_WORKING_TZSET 1 + +/* Define to 1 if you have the `writev' function. */ +#define HAVE_WRITEV 1 + +/* Define if libssl has X509_VERIFY_PARAM_set1_host and related function */ +#define HAVE_X509_VERIFY_PARAM_SET1_HOST 1 + +/* Define if the zlib library has inflateCopy */ +#define HAVE_ZLIB_COPY 1 + +/* Define to 1 if you have the `_getpty' function. */ +#undef HAVE__GETPTY + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +#undef MAJOR_IN_MKDEV + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +#undef MAJOR_IN_SYSMACROS + +/* Define if mvwdelch in curses.h is an expression. */ +#undef MVWDELCH_IS_EXPRESSION + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define if POSIX semaphores aren't enabled on your system */ +#undef POSIX_SEMAPHORES_NOT_ENABLED + +/* Define if pthread_key_t is compatible with int. */ +#undef PTHREAD_KEY_T_IS_COMPATIBLE_WITH_INT + +/* Defined if PTHREAD_SCOPE_SYSTEM supported. */ +#undef PTHREAD_SYSTEM_SCHED_SUPPORTED + +/* Define as the preferred size in bits of long digits */ +#undef PYLONG_BITS_IN_DIGIT + +/* Define if you want to coerce the C locale to a UTF-8 based locale */ +#undef PY_COERCE_C_LOCALE + +/* Define to printf format modifier for Py_ssize_t */ +#define PY_FORMAT_SIZE_T "z" + +/* Default cipher suites list for ssl module. 1: Python's preferred selection, + 2: leave OpenSSL defaults untouched, 0: custom string */ +#undef PY_SSL_DEFAULT_CIPHERS + +/* Cipher suite string for PY_SSL_DEFAULT_CIPHERS=0 */ +#undef PY_SSL_DEFAULT_CIPHER_STRING + +/* Define if you want to build an interpreter with many run-time checks. */ +#undef Py_DEBUG + +/* Defined if Python is built as a shared library. */ +#undef Py_ENABLE_SHARED + +/* Define hash algorithm for str, bytes and memoryview. SipHash24: 1, FNV: 2, + externally defined: 0 */ +#undef Py_HASH_ALGORITHM + +/* Define if you want to enable tracing references for debugging purpose */ +#undef Py_TRACE_REFS + +/* assume C89 semantics that RETSIGTYPE is always void */ +#undef RETSIGTYPE + +/* Define if setpgrp() must be called as setpgrp(0, 0). */ +#undef SETPGRP_HAVE_ARG + +/* Define to 1 if you must link with -lrt for shm_open(). */ +#undef SHM_NEEDS_LIBRT + +/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ +#undef SIGNED_RIGHT_SHIFT_ZERO_FILLS + +/* The size of `double', as computed by sizeof. */ +#define SIZEOF_DOUBLE 8 + +/* The size of `float', as computed by sizeof. */ +#define SIZEOF_FLOAT 4 + +/* The size of `fpos_t', as computed by sizeof. */ +#define SIZEOF_FPOS_T 4 + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of `long double', as computed by sizeof. */ +#define SIZEOF_LONG_DOUBLE 8 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 4 + +/* The size of `pid_t', as computed by sizeof. */ +#define SIZEOF_PID_T 4 + +/* The size of `pthread_key_t', as computed by sizeof. */ +#define SIZEOF_PTHREAD_KEY_T 4 + +/* The size of `pthread_t', as computed by sizeof. */ +#define SIZEOF_PTHREAD_T 4 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 4 + +/* The size of `time_t', as computed by sizeof. */ +#define SIZEOF_TIME_T 4 + +/* The size of `uintptr_t', as computed by sizeof. */ +#define SIZEOF_UINTPTR_T 4 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 4 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* The size of `_Bool', as computed by sizeof. */ +#define SIZEOF__BOOL 1 + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +#define SYS_SELECT_WITH_SYS_TIME 1 + +/* Library needed by timemodule.c: librt may be needed for clock_gettime() */ +#undef TIMEMODULE_LIB + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +#define TM_IN_SYS_TIME 1 + +/* Define if you want to use computed gotos in ceval.c. */ +#undef USE_COMPUTED_GOTOS + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# undef _ALL_SOURCE +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# undef _GNU_SOURCE +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# undef _POSIX_PTHREAD_SEMANTICS +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# undef _TANDEM_SOURCE +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# undef __EXTENSIONS__ +#endif + + +/* Define if WINDOW in curses.h offers a field _flags. */ +#undef WINDOW_HAS_FLAGS + +/* Define if you want documentation strings in extension modules */ +#undef WITH_DOC_STRINGS + +/* Define if you want to compile in DTrace support */ +#undef WITH_DTRACE + +/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic + linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). + Dyld is necessary to support frameworks. */ +#define WITH_DYLD 1 + +/* Define to 1 if libintl is needed for locale functions. */ +#undef WITH_LIBINTL + +/* Define if you want to produce an OpenStep/Rhapsody framework (shared + library plus accessory files). */ +#undef WITH_NEXT_FRAMEWORK + +/* Define if you want to compile in Python-specific mallocs */ +#undef WITH_PYMALLOC + +/* Define if you want pymalloc to be disabled when running under valgrind */ +#undef WITH_VALGRIND + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +# undef WORDS_BIGENDIAN +# endif +#endif + +/* Define if arithmetic is subject to x87-style double rounding issue */ +#undef X87_DOUBLE_ROUNDING + +/* Define on OpenBSD to activate all library features */ +#define _BSD_SOURCE + +/* Define on Darwin to activate all library features */ +#undef _DARWIN_C_SOURCE + +/* This must be set to 64 on some systems to enable large file support. */ +#undef _FILE_OFFSET_BITS + +/* Define on Linux to activate all library features */ +#define _GNU_SOURCE + +/* Define to include mbstate_t for mbrtowc */ +#undef _INCLUDE__STDC_A1_SOURCE + +/* This must be defined on some systems to enable large file support. */ +#undef _LARGEFILE_SOURCE + +/* This must be defined on AIX systems to enable large file support. */ +#undef _LARGE_FILES + +/* Define to 1 if on MINIX. */ +#undef _MINIX + +/* Define on NetBSD to activate all library features */ +#undef _NETBSD_SOURCE + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +#undef _POSIX_1_SOURCE + +/* Define to activate features from IEEE Stds 1003.1-2008 */ +#define _POSIX_C_SOURCE 200809L + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +#define _POSIX_SOURCE + +/* Define if you have POSIX threads, and your system does not define that. */ +#undef _POSIX_THREADS + +/* framework name */ +#define _PYTHONFRAMEWORK "" + +/* Define to force use of thread-safe errno, h_errno, and other functions */ +#undef _REENTRANT + +/* Define to the level of X/Open that your system supports */ +#define _XOPEN_SOURCE 700 + +/* Define to activate Unix95-and-earlier features */ +#undef _XOPEN_SOURCE_EXTENDED + +/* Define on FreeBSD to activate all library features */ +#define __BSD_VISIBLE 1 + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +# undef __CHAR_UNSIGNED__ +#endif + +/* Define to 'long' if doesn't define. */ +#undef clock_t + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `int' if doesn't define. */ +#undef gid_t + +/* Define to `int' if does not define. */ +#undef mode_t + +/* Define to `long int' if does not define. */ +#undef off_t + +/* Define to `int' if does not define. */ +#undef pid_t + +/* Define to empty if the keyword does not work. */ +#undef signed + +/* Define to `unsigned int' if does not define. */ +#undef size_t + +/* Define to `int' if does not define. */ +#undef socklen_t + +/* Define to `int' if doesn't define. */ +#undef uid_t + + +/* Define the macros needed if on a UnixWare 7.x system. */ +#if defined(__USLC__) && defined(__SCO_VERSION__) +#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#endif + +#define DONT_HAVE_FSTAT 1 +#define DONT_HAVE_STAT 1 + +#define PLATFORM "riscos" + +#endif /*Py_PYCONFIG_H*/ + diff --git a/RISCOS/swimodule.c b/RISCOS/swimodule.c new file mode 100644 index 00000000000000..baaac6d1e8d53d --- /dev/null +++ b/RISCOS/swimodule.c @@ -0,0 +1,706 @@ +/* swi + + RISC OS swi functions + + 1.00 Chris Stretch + + + 1.01 12 May 1999 Laurence Tratt + + * Changed swi.error to be a class based exception rather than string based + * Added swi.ArgError which is generated for errors when the user passes invalid arguments to + functions etc + * Added "errnum" attribute to swi.error, so one can now check to see what the error number was + + 1.02 03 March 2002 Dietmar Schwertberger + * Added string, integer, integers, tuple and tuples + + 1.10 21 September 2019 Chris Johns + * Updated to Python 3 + + 1.11 06 February 2020 Chris Johns + * Added 'I' / 'u' for unsigned integer. + + 1.12 16 March 2020 Chris Johns. + * Added 'y' for bytes. + + 2.00 10 April 2020 Chris Johns. + * Major version bump as block[] now uses unsigned rather than signed. + * Added block.signed / .unsigned to set values. + * Added block.tosigned / .tounsigned to get values. + * Added block.toutf8 + * Changed SwiError to use PyExc_RISCOSError +*/ + +//#include "oslib/os.h" +#include +#include + +#include "Python.h" + +#define PyBlock_Check(op) ((op)->ob_type == &PyBlockType) + +static PyObject *SwiError; /* Exception swi.error */ +static PyObject *ArgError; /* Exception swi.ArgError */ +static _kernel_oserror *e; + +static PyObject *swi_oserror(void) +{ + //printf("swi_oserror %s\n", e->errmess); + PyObject *exc_args = PyTuple_New(2); + PyTuple_SetItem(exc_args, 0, PyUnicode_FromString(e->errmess)); + PyTuple_SetItem(exc_args, 1, PyLong_FromLong (e->errnum )); + PyErr_SetObject(SwiError, exc_args); + +// PyErr_SetString(SwiError,e->errmess); + //printf("%x\n", PyErr_Occurred()); + //PyObject *errnum = PyLong_FromLong(e->errnum); + //printf("%x\n", errnum); + //int rv = PyObject_SetAttrString(PyErr_Occurred(), "errnum", errnum); + //printf("%d\n", rv); + return 0; +} + +static PyObject *swi_error(char *s) +{ PyErr_SetString(ArgError,s); + return 0; +} + +typedef struct +{ PyObject_HEAD + void *block; + int length; /*length in bytes*/ + int heap; +} PyBlockObject; + +static PyTypeObject PyBlockType; + +/* block commands */ + +static PyObject *PyBlock_New(PyObject *self,PyObject *args) +{ int size; + PyBlockObject *b; + PyObject *init=0; + if(!PyArg_ParseTuple(args,"i|O",&size,&init)) return NULL; + if(size<1) size=1; + b=PyObject_NEW(PyBlockObject,&PyBlockType); + if(!b) return NULL; + b->block=malloc(4*size); + if(!b->block) + { Py_DECREF(b); + return PyErr_NoMemory(); + } + b->length=4*size; + b->heap=1; + if(init) + { if(PyUnicode_Check(init)) + { int n=PyUnicode_GET_LENGTH(init); + if (n>4*size) n=4*size; + memcpy(b->block,PyUnicode_AsUTF8(init),n); + memset((char*)b->block+n,0,4*size-n); + } + else + { int n,k; + long *p=(long*)b->block; + if(!PyList_Check(init)) goto fail; + n=PyList_Size(init); + if (n>size) n=size; + for(k=0;kblock=(void*)ptr; + b->length=4*size; + b->heap=0; + return (PyObject *)b; +} + +static PyObject *PyBlock_ToString(PyBlockObject *self,PyObject *arg) +{ int s=0,e=self->length; + if(!PyArg_ParseTuple(arg,"|ii",&s,&e)) return NULL; + if(s<0||e>self->length||s>e) + { PyErr_SetString(PyExc_IndexError,"block index out of range"); + return NULL; + } + return PyUnicode_DecodeLatin1((char*)self->block+s,e-s,NULL); +} + +static PyObject *PyBlock_NullString(PyBlockObject *self,PyObject *arg) +{ int s=0,e=self->length,i; + char *p=(char*)self->block; + if(!PyArg_ParseTuple(arg,"|ii",&s,&e)) return NULL; + if(s<0||e>self->length||s>e) + { PyErr_SetString(PyExc_IndexError,"block index out of range"); + return NULL; + } + for(i=s;iblock+s,i-s,NULL); +} + +static PyObject *PyBlock_CtrlString(PyBlockObject *self,PyObject *arg) +{ int s=0,e=self->length,i; + char *p=(char*)self->block; + if(!PyArg_ParseTuple(arg,"|ii",&s,&e)) return NULL; + if(s<0||e>self->length||s>e) + { PyErr_SetString(PyExc_IndexError,"block index out of range"); + return NULL; + } + for(i=s;iblock+s,i-s,NULL); +} + +static PyObject *PyBlock_ToUTF8(PyBlockObject *self,PyObject *arg) +{ int s=0,e=self->length,i; + char *p=(char*)self->block; + if(!PyArg_ParseTuple(arg,"|ii",&s,&e)) return NULL; + if(s<0||e>self->length||s>e) + { PyErr_SetString(PyExc_IndexError,"block index out of range"); + return NULL; + } + for(i=s;iblock+s,e-s,NULL); +} + +static PyObject *PyBlock_PadString(PyBlockObject *self,PyObject *arg) +{ int s=0,e=self->length,n,m; + char *str; + char c; + char *p=(char*)self->block; + if(!PyArg_ParseTuple(arg,"s#c|ii",&str,&n,&c,&s,&e)) return NULL; + if(s<0||e>self->length||s>e) + { PyErr_SetString(PyExc_IndexError,"block index out of range"); + return NULL; + } + m=e-s; + if(n>m) n=m; + memcpy(p+s,str,n);memset(p+s+n,c,m-n); + Py_INCREF(Py_None);return Py_None; +} + +static PyObject *PyBlock_BitSet(PyBlockObject *self,PyObject *arg) +{ int i,x,y; + int *p=(int*)self->block; + if(!PyArg_ParseTuple(arg,"III",&i,&x,&y)) return NULL; + if(i<0||i>=self->length/4) + { PyErr_SetString(PyExc_IndexError,"block index out of range"); + return NULL; + } + p[i]=(p[i]&y)^x; + Py_INCREF(Py_None);return Py_None; +} + +static PyObject *PyBlock_Resize(PyBlockObject *self,PyObject *arg) +{ int n; + if(!PyArg_ParseTuple(arg,"i",&n)) return NULL; + if(n<1) n=1; + if(self->heap) + { void *v=realloc(self->block,4*n); + if (!v) return PyErr_NoMemory(); + self->block=v; + } + self->length=4*n; + Py_INCREF(Py_None);return Py_None; +} + +static PyObject *PyBlock_ToFile(PyBlockObject *self,PyObject *arg) +{ int s=0,e=self->length/4; + PyObject *f; + FILE *fp; + if(!PyArg_ParseTuple(arg,"O|ii",&f,&s,&e)) return NULL; + int fd = PyObject_AsFileDescriptor(f); + printf("fd=%d\n",fd); + fp=0; + //fp=PyFile_AsFile(f); + if (!fp) + { PyErr_SetString(PyExc_TypeError, "arg must be open file"); + return NULL; + } + fwrite((int*)(self->block)+s,4,e-s,fp); + Py_INCREF(Py_None);return Py_None; +} + +static PyObject *PyBlock_ToBytes(PyBlockObject *self,PyObject *arg) +{ int s=0,e=self->length; + if(!PyArg_ParseTuple(arg,"|ii",&s,&e)) return NULL; + if(s<0||e>self->length||s>e) + { PyErr_SetString(PyExc_IndexError,"block index out of range"); + return NULL; + } + return PyBytes_FromStringAndSize((char*)self->block+s,e-s); +} + +static PyObject *PyBlock_ToSigned(PyBlockObject *self,PyObject *arg) +{ int i=0; + if(!PyArg_ParseTuple(arg,"i",&i)) return NULL; + if(i<0||i>self->length) + { PyErr_SetString(PyExc_IndexError,"block index out of range"); + return NULL; + } + return PyLong_FromLong(((long*)(self->block))[i]); +} + +static PyObject *PyBlock_Signed(PyBlockObject *self,PyObject *arg) +{ int i=0, v=0; + if(!PyArg_ParseTuple(arg,"ii",&i,&v)) return NULL; + if(i<0||i>self->length) + { PyErr_SetString(PyExc_IndexError,"block index out of range"); + return NULL; + } + ((int*)self->block)[i] = v; + Py_INCREF(Py_None);return Py_None; +} + +static PyObject *PyBlock_ToUnsigned(PyBlockObject *self,PyObject *arg) +{ int i=0; + if(!PyArg_ParseTuple(arg,"i",&i)) return NULL; + if(i<0||i>self->length) + { PyErr_SetString(PyExc_IndexError,"block index out of range"); + return NULL; + } + return PyLong_FromUnsignedLong(((long*)(self->block))[i]); +} + +static PyObject *PyBlock_Unsigned(PyBlockObject *self,PyObject *arg) +{ int i=0; unsigned v=0; + if(!PyArg_ParseTuple(arg,"iI",&i,&v)) return NULL; + if(i<0||i>self->length) + { PyErr_SetString(PyExc_IndexError,"block index out of range"); + return NULL; + } + ((int*)self->block)[i] = v; + Py_INCREF(Py_None);return Py_None; +} + +static struct PyMethodDef PyBlock_Methods[]= +{ { "tostring", (PyCFunction)PyBlock_ToString, METH_VARARGS, NULL}, + { "padstring", (PyCFunction)PyBlock_PadString, METH_VARARGS, NULL}, + { "nullstring", (PyCFunction)PyBlock_NullString, METH_VARARGS, NULL}, + { "ctrlstring", (PyCFunction)PyBlock_CtrlString, METH_VARARGS, NULL}, + { "toutf8", (PyCFunction)PyBlock_ToUTF8, METH_VARARGS, NULL}, + { "bitset", (PyCFunction)PyBlock_BitSet, METH_VARARGS, NULL}, + { "resize", (PyCFunction)PyBlock_Resize, METH_VARARGS, NULL}, + { "tofile", (PyCFunction)PyBlock_ToFile, METH_VARARGS, NULL}, + { "tobytes", (PyCFunction)PyBlock_ToBytes, METH_VARARGS, NULL}, + { "signed", (PyCFunction)PyBlock_Signed, METH_VARARGS, NULL}, + { "unsigned", (PyCFunction)PyBlock_Unsigned, METH_VARARGS, NULL}, + { "tosigned", (PyCFunction)PyBlock_ToSigned, METH_VARARGS, NULL}, + { "tounsigned", (PyCFunction)PyBlock_ToUnsigned, METH_VARARGS, NULL}, + { NULL,NULL, 0, 0 } /* sentinel */ +}; + +static int block_len(PyBlockObject *b) +{ return b->length/4; +} + +static PyObject *block_concat(PyBlockObject *b,PyBlockObject *c) +{ PyErr_SetString(PyExc_IndexError,"block concatenation not implemented"); + return NULL; +} + +static PyObject *block_repeat(PyBlockObject *b,Py_ssize_t i) +{ PyErr_SetString(PyExc_IndexError,"block repetition not implemented"); + return NULL; +} + +static PyObject *block_item(PyBlockObject *b,Py_ssize_t i) +{ if(i<0||4*i>=b->length) + { PyErr_SetString(PyExc_IndexError,"block index out of range"); + return NULL; + } + return PyLong_FromUnsignedLong(((long*)(b->block))[i]); +} + +static PyObject *block_slice(PyBlockObject *b,Py_ssize_t i,Py_ssize_t j) +{ Py_ssize_t n,k; + long *p=b->block; + PyObject *result; + if(j>b->length/4) j=b->length/4; + if(i<0||i>j) + { PyErr_SetString(PyExc_IndexError,"block index out of range"); + return NULL; + } + n=j-i; + result=PyList_New(n); + for(k=0;k=b->length/4) + { PyErr_SetString(PyExc_IndexError,"block index out of range"); + return -1; + } + if(!PyLong_Check(v)) + { PyErr_SetString(PyExc_TypeError,"block item must be integer"); + return -1; + } + ((long*)(b->block))[i]=PyLong_AsUnsignedLong(v); + return 0; +} + +static int block_ass_slice(PyBlockObject *b,Py_ssize_t i,Py_ssize_t j,PyObject *v) +{ Py_ssize_t n,k; + long *p=b->block; + if(j>b->length/4) j=b->length/4; + if(i<0||i>j) + { PyErr_SetString(PyExc_IndexError,"block index out of range"); + return -1; + } + if(!PyList_Check(v)) goto fail; + n=PyList_Size(v); + if(n>j-i) n=j-i; + for(k=0;klength); + if (!strcmp(name, "start")) return PyLong_FromLong((long)s->block); + if (!strcmp(name,"end")) return PyLong_FromLong(((long)(s->block)+s->length)); + if (!strcmp(name, "__members__")) + { PyObject *list = PyList_New(3); + if (list) + { PyList_SetItem(list, 0, PyUnicode_FromString("length")); + PyList_SetItem(list, 1, PyUnicode_FromString("start")); + PyList_SetItem(list, 2, PyUnicode_FromString("end")); + if (PyErr_Occurred()) { Py_DECREF(list);list = NULL;} + } + return list; + } + + return PyObject_GenericGetAttr(/*PyBlock_Methods,*/ (PyObject*) s, PyUnicode_FromString(name)); + //return Py_FindMethod(PyBlock_Methods, (PyObject*) s,name); +} + +static void PyBlock_Dealloc(PyBlockObject *b) +{ + if(b->heap) { + if (b->heap) + ; + else + PyMem_DEL(b->block); + } + PyMem_DEL(b); +} + +static PyTypeObject PyBlockType = +{ PyVarObject_HEAD_INIT(&PyType_Type, 0) + .tp_name = "swi.block", + .tp_basicsize = sizeof(PyBlockObject), + .tp_dealloc = (destructor)PyBlock_Dealloc, + .tp_getattr = (getattrfunc)PyBlock_GetAttr, + .tp_as_sequence = &block_as_sequence, + .tp_getattro = 0, + .tp_methods = PyBlock_Methods, +}; + +/* swi commands */ + +static PyObject *swi_swi(PyObject *self,PyObject *args) +{ PyObject *name,*format,*result=0,*v=0; + int swino,carry,rno=0,j,n; + char *swiname,*fmt,*outfmt; + _kernel_swi_regs r; + PyBlockObject *ao; + if(args==NULL||!PyTuple_Check(args)||(n=PyTuple_Size(args))<2) + { PyErr_BadArgument(); return NULL;} + name=PyTuple_GetItem(args,0); + if(!PyArg_Parse(name,"i",&swino)) + { PyErr_Clear(); + if(!PyArg_Parse(name,"s",&swiname)) return NULL; + r.r[1] = (int)swiname; + e=_kernel_swi(OS_SWINumberFromString,&r,&r); + if(e) return swi_oserror(); + swino = r.r[0]; + } + format=PyTuple_GetItem(args,1); + if(!PyArg_Parse(format,"s",&fmt)) return NULL; + j=2; + for(;;fmt++) + { switch(*fmt) + { case '.': rno++;continue; + case ';':case 0: goto swicall; + case '0':case '1':case '2':case '3':case '4': + case '5':case '6':case '7':case '8':case '9': + r.r[rno++]=*fmt-'0';continue; + case '-':r.r[rno++]=-1;continue; + } + if(j>=n) return swi_error("Too few arguments"); + v=PyTuple_GetItem(args,j++); + switch(*fmt) + { case 'i':if(!PyArg_Parse(v,"i",&r.r[rno])) return NULL; + break; + case 'I': + case 'u':if(!PyArg_Parse(v,"I",(unsigned)&r.r[rno])) return NULL; + break; + case 's':if(!PyArg_Parse(v,"s",(char**)(&r.r[rno]))) return NULL; + break; + case 'y':if(!PyArg_Parse(v,"y",(char**)(&r.r[rno]))) return NULL; + break; + case 'b':if(!PyArg_Parse(v,"O",(PyObject**)&ao)) return NULL; + if(!PyBlock_Check(v)) return swi_error("Not a block"); + r.r[rno]=(int)(ao->block); + break; + case 'e':if(!PyArg_Parse(v,"O",(PyObject**)&ao)) return NULL; + if(!PyBlock_Check(v)) return swi_error("Not a block"); + r.r[rno]=(int)(ao->block)+ao->length; + break; + default:return swi_error("Odd format character"); + } + rno++; + } + swicall:e=_kernel_swi_c(swino,&r,&r,&carry); + if(e) return swi_oserror(); + if(*fmt==0) { Py_INCREF(Py_None);return Py_None;} + n=0; + for(outfmt=++fmt;*outfmt;outfmt++) switch(*outfmt) + { case 'i':case 'u':case 'I':case 's':case 'y':case '*':n++;break; + case '.':break; + default:return swi_error("Odd format character"); + } + if(n==0) { Py_INCREF(Py_None);return Py_None;} + if(n!=1) + { result=PyTuple_New(n); + if(!result) return NULL; + } + rno=0;j=0; + for(;*fmt;fmt++) + { switch(*fmt) + { case 'i':v=PyLong_FromLong((long)r.r[rno++]); break; + case 'u': + case 'I':v=PyLong_FromUnsignedLong((unsigned long)r.r[rno++]); break; + case 's':v=PyUnicode_FromString((char*)(r.r[rno++])); break; + case 'y': + case 'S':v=PyBytes_FromString((char*)(r.r[rno++])); break; + case '.':rno++; continue; + case '*':v=PyLong_FromLong((long)carry); break; + } + if(!v) goto fail; + if(n==1) return v; + PyTuple_SetItem(result,j,v); + j++; + } + return result; + fail:Py_DECREF(result);return 0; +} + +static PyObject *swi_string(PyObject *self, PyObject *arg) +{ char *s; + int l=-1; + if(!PyArg_ParseTuple(arg,"i|i",(unsigned int *)&s, &l)) return NULL; + if (l==-1) + l = strlen(s); + return PyUnicode_DecodeLatin1((char*)s, l, NULL); +} + +static char swi_string__doc__[] = +"string(address[, length]) -> string\n\ +Read a null terminated string from the given address."; + + +static PyObject *swi_integer(PyObject *self, PyObject *arg) +{ int *i; + + if(!PyArg_ParseTuple(arg,"i",(unsigned int *)&i)) + return NULL; + return PyLong_FromLong(*i); +} + +static char swi_integer__doc__[] = +"integer(address) -> string\n\ +Read an integer from the given address."; + + +static PyObject *swi_integers(PyObject *self, PyObject *arg) +{ int *i; + int c=-1; + PyObject *result, *result1; + + if(!PyArg_ParseTuple(arg,"i|i",(unsigned int *)&i, &c)) return NULL; + result=PyList_New(0); + if (result) { + while ( c>0 || (c==-1 && *i) ) { + result1 = PyLong_FromLong((long)*i); + if (!result1) { + Py_DECREF(result); + return NULL; + } + if (PyList_Append(result, result1)!=0) { + Py_DECREF(result); + Py_DECREF(result1); + return NULL; + }; + i++; + if (c!=-1) + c--; + } + } + return result; +} + +static char swi_integers__doc__[] = +"integers(address[, count]) -> string\n\ +Either read a null terminated list of integers or\n\ +a list of given length from the given address."; + + +static PyObject *swi_tuples(PyObject *self, PyObject *arg) +{ + unsigned char *i; /* points to current */ + int c=-1, l=4, j, zero; /* count, length, index */ + PyObject *result, *result1, *result11; + + if(!PyArg_ParseTuple(arg,"i|ii",(unsigned int *)&i, &l, &c)) return NULL; + result=PyList_New(0); + if (result) { + while (c) { + result1 = PyTuple_New(l); + if (!result1) { + Py_DECREF(result); + return NULL; + } + zero = (c==-1); /* check for zeros? */ + for(j=0;j string\n\ +Either read a null terminated list of byte tuples or\n\ +a list of given length from the given address."; + + +static PyObject *swi_tuple(PyObject *self, PyObject *arg) +{ + unsigned char *i; /* points to current */ + int c=1, j; + PyObject *result, *result1; + + if(!PyArg_ParseTuple(arg,"i|i",(unsigned int *)&i, &c)) return NULL; + result = PyTuple_New(c); + if (!result) + return NULL; + for(j=0;j tuple\n\ +Read count bytes from given address."; + + +static PyMethodDef SwiMethods[]= +{ { "swi", swi_swi, METH_VARARGS}, + { "block", PyBlock_New, METH_VARARGS}, + { "register", PyRegister, METH_VARARGS}, + { "string", swi_string, METH_VARARGS, swi_string__doc__}, + { "integer", swi_integer, METH_VARARGS, swi_integer__doc__}, + { "integers", swi_integers, METH_VARARGS, swi_integers__doc__}, + { "tuples", swi_tuples, METH_VARARGS, swi_tuples__doc__}, + { "tuple", swi_tuple, METH_VARARGS, swi_tuple__doc__}, + { "bytes", swi_bytes, METH_VARARGS}, + { NULL,NULL,0,NULL} /* Sentinel */ +}; + +static struct PyModuleDef SwiModuleDef = { + PyModuleDef_HEAD_INIT, /*m_base*/ + "swi", /*m_name*/ + NULL, /*m_doc*/ + (Py_ssize_t)0, /*m_size*/ + SwiMethods, /*m_methods*/ + NULL, /*m_slots*/ + NULL, /*m_traverse*/ + NULL, /*m_clear*/ + NULL /*m_free*/ +}; + +PyObject* PyInit_swi() +{ + PyObject *m = PyModule_Create(&SwiModuleDef); + + SwiError = PyErr_NewException("swi.error", PyExc_RISCOSError, NULL); + Py_INCREF(SwiError); + PyModule_AddObject(m, "error", SwiError); + + ArgError=PyErr_NewException("swi.ArgError", NULL, NULL); + Py_INCREF(ArgError); + PyModule_AddObject(m, "ArgError", ArgError); + + return m; +}