Hello,
I used this
https://devel.rtems.org/wiki/Packages/Python
to create a Makefile for Python 3.6. See attached files. Its a hack. I
used RTEMS 5.
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 5e88e3f..b6c7fe5 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -440,8 +440,7 @@ DTRACE_DEPS = \
# Default target
all: @DEF_MAKE_ALL_RULE@
-build_all: check-clean-src $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks \
- Programs/_testembed python-config
+build_all: check-clean-src $(BUILDPYTHON)
# Check that the source is clean when building out of source.
check-clean-src:
@@ -1102,8 +1101,7 @@ altinstall: commoninstall
fi
commoninstall: check-clean-src @FRAMEWORKALTINSTALLFIRST@ \
- altbininstall libinstall inclinstall libainstall \
- sharedinstall oldsharedinstall altmaninstall \
+ libinstall inclinstall libainstall \
@FRAMEWORKALTINSTALLLAST@
# Install shared libraries enabled by Setup
diff --git a/Modules/Setup.dist b/Modules/Setup.dist
index 735bacb..fe029ff 100644
--- a/Modules/Setup.dist
+++ b/Modules/Setup.dist
@@ -169,17 +169,17 @@ _symtable symtablemodule.c
# Modules that should always be present (non UNIX dependent):
-#array arraymodule.c # array objects
-#cmath cmathmodule.c _math.c # -lm # complex math library functions
-#math mathmodule.c _math.c # -lm # math library functions, e.g. sin()
-#_struct _struct.c # binary structure packing/unpacking
-#_weakref _weakref.c # basic weak reference support
+array arraymodule.c # array objects
+cmath cmathmodule.c _math.c -lm # complex math library functions
+math mathmodule.c _math.c -lm # math library functions, e.g. sin()
+_struct _struct.c # binary structure packing/unpacking
+_weakref _weakref.c # basic weak reference support
#_testcapi _testcapimodule.c # Python C API test module
-#_random _randommodule.c # Random number generator
-#_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator
+_random _randommodule.c # Random number generator
+_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator
#_pickle _pickle.c # pickle accelerator
-#_datetime _datetimemodule.c # datetime accelerator
-#_bisect _bisectmodule.c # Bisection algorithms
+_datetime _datetimemodule.c # datetime accelerator
+_bisect _bisectmodule.c # Bisection algorithms
#_heapq _heapqmodule.c # Heap queue algorithm
#_asyncio _asynciomodule.c # Fast asyncio Future
@@ -190,10 +190,10 @@ _symtable symtablemodule.c
# (If you have a really backward UNIX, select and socket may not be
# supported...)
-#fcntl fcntlmodule.c # fcntl(2) and ioctl(2)
+fcntl fcntlmodule.c # fcntl(2) and ioctl(2)
#spwd spwdmodule.c # spwd(3)
#grp grpmodule.c # grp(3)
-#select selectmodule.c # select(2); not on ancient System V
+select selectmodule.c # select(2); not on ancient System V
# Memory-mapped files (also works on Win32).
#mmap mmapmodule.c
@@ -202,7 +202,7 @@ _symtable symtablemodule.c
#_csv _csv.c
# Socket module helper for socket(2)
-#_socket socketmodule.c
+_socket socketmodule.c
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
@@ -242,15 +242,15 @@ _symtable symtablemodule.c
# The _md5 module implements the RSA Data Security, Inc. MD5
# Message-Digest Algorithm, described in RFC 1321.
-#_md5 md5module.c
+_md5 md5module.c
# The _sha module implements the SHA checksum algorithms.
# (NIST's Secure Hash Algorithms.)
-#_sha1 sha1module.c
-#_sha256 sha256module.c
-#_sha512 sha512module.c
-#_sha3 _sha3/sha3module.c
+_sha1 sha1module.c
+_sha256 sha256module.c
+_sha512 sha512module.c
+_sha3 _sha3/sha3module.c
# _blake module
#_blake2 _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c
@@ -363,7 +363,7 @@ _symtable symtablemodule.c
# Andrew Kuchling's zlib module.
# This require zlib 1.1.3 (or later).
# See http://www.gzip.org/zlib/
-#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
+zlib zlibmodule.c -lz
# Interface to the Expat XML parser
#
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
index d5194ca..eb51f62 100644
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -458,7 +458,9 @@ faulthandler_enable(void)
sigemptyset(&action.sa_mask);
/* Do not prevent the signal from being received from within
its own signal handler */
+#ifndef __rtems__
action.sa_flags = SA_NODEFER;
+#endif /* __rtems__ */
#ifdef HAVE_SIGALTSTACK
if (stack.ss_sp != NULL) {
/* Call the signal handler on an alternate signal stack
@@ -738,12 +740,14 @@ faulthandler_register(int signum, int chain, _Py_sighandler_t *p_previous)
/* if the signal is received while the kernel is executing a system
call, try to restart the system call instead of interrupting it and
return EINTR. */
+#ifndef __rtems__
action.sa_flags = SA_RESTART;
if (chain) {
/* do not prevent the signal from being received from within its
own signal handler */
action.sa_flags = SA_NODEFER;
}
+#endif /* __rtems__ */
#ifdef HAVE_SIGALTSTACK
if (stack.ss_sp != NULL) {
/* Call the signal handler on an alternate signal stack
@@ -932,6 +936,7 @@ faulthandler_suppress_crash_report(void)
SetErrorMode(mode | SEM_NOGPFAULTERRORBOX);
#endif
+#ifndef __rtems__
#ifdef HAVE_SYS_RESOURCE_H
struct rlimit rl;
@@ -941,6 +946,7 @@ faulthandler_suppress_crash_report(void)
setrlimit(RLIMIT_CORE, &rl);
}
#endif
+#endif /* __rtems__ */
#ifdef _MSC_VER
/* Visual Studio: configure abort() to not display an error message nor
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index ee27fa4..44493a6 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -9189,7 +9189,7 @@ os_WSTOPSIG_impl(PyObject *module, int status)
#endif /* HAVE_SYS_WAIT_H */
-#if defined(HAVE_FSTATVFS) && defined(HAVE_SYS_STATVFS_H)
+#if (defined(HAVE_STATVFS) || defined(HAVE_FSTATVFS)) && defined(HAVE_SYS_STATVFS_H)
#ifdef _SCO_DS
/* SCO OpenServer 5.0 and later requires _SVID3 before it reveals the
needed definitions in sys/statvfs.h */
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index 0b9e8f1..69bf847 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -976,12 +976,14 @@ fill_siginfo(siginfo_t *si)
PyStructSequence_SET_ITEM(result, 0, PyLong_FromLong((long)(si->si_signo)));
PyStructSequence_SET_ITEM(result, 1, PyLong_FromLong((long)(si->si_code)));
+#ifndef __rtems__
PyStructSequence_SET_ITEM(result, 2, PyLong_FromLong((long)(si->si_errno)));
PyStructSequence_SET_ITEM(result, 3, PyLong_FromPid(si->si_pid));
PyStructSequence_SET_ITEM(result, 4, _PyLong_FromUid(si->si_uid));
PyStructSequence_SET_ITEM(result, 5,
PyLong_FromLong((long)(si->si_status)));
PyStructSequence_SET_ITEM(result, 6, PyLong_FromLong(si->si_band));
+#endif /* __rtems__ */
if (PyErr_Occurred()) {
Py_DECREF(result);
return NULL;
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index dba3d04..fad92eb 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -1195,7 +1195,7 @@ PyInit_timezone(PyObject *m) {
And I'm lazy and hate C so nyer.
*/
-#if defined(HAVE_TZNAME) && !defined(__GLIBC__) && !defined(__CYGWIN__)
+#if defined(HAVE_TZNAME) && !defined(__GLIBC__) && !defined(__CYGWIN__) && !defined(__rtems__)
PyObject *otz0, *otz1;
tzset();
PyModule_AddIntConstant(m, "timezone", timezone);
diff --git a/configure b/configure
index ea1baef..40b253f 100755
--- a/configure
+++ b/configure
@@ -3249,6 +3249,9 @@ then
*-*-cygwin*)
ac_sys_system=Cygwin
;;
+ *-*-rtems*)
+ ac_sys_system=RTEMS
+ ;;
*)
# for now, limit cross builds to known configurations
MACHDEP="unknown"
@@ -3291,7 +3294,7 @@ if test "$cross_compiling" = yes; then
_host_cpu=$host_cpu
esac
;;
- *-*-cygwin*)
+ *-*-cygwin* | *-*-rtems*)
_host_cpu=
;;
*)
RTEMS_API = 5
RTEMS_CPU = arm
RTEMS_BSP = realview_pbx_a9_qemu
PYTHON_VERSION = 3.6
PYTHON_MICRO_VERSION = 5
OBJCOPY_TARGET = elf32-littlearm
RTEMS_TARGET = $(RTEMS_CPU)-rtems$(RTEMS_API)
prefix = /build/rtems/$(RTEMS_API)
exec_prefix = $(prefix)/$(RTEMS_TARGET)
RTEMS_ROOT = $(prefix)
RTEMS_SHARE = $(RTEMS_ROOT)/share/rtems$(RTEMS_API)
PROJECT_ROOT = $(RTEMS_ROOT)/$(RTEMS_TARGET)/$(RTEMS_BSP)
PROJECT_INCLUDE = $(PROJECT_ROOT)/lib/include
PROJECT_LIB = $(PROJECT_ROOT)/lib
BUILDDIR = b-$(RTEMS_BSP)
PYTHON_BUILDDIR = b-python$(PYTHON_VERSION)
PYTHONDIR = Python-$(PYTHON_VERSION).$(PYTHON_MICRO_VERSION)
INSTALLDIR = $(PWD)/install
include $(RTEMS_ROOT)/make/custom/$(RTEMS_BSP).cfg
DEPFLAGS = -MT $@ -MD -MP -MF $(basename $@).d
WARNFLAGS = -Wall
OPTFLAGS = -O2 -g -ffunction-sections -fdata-sections
EXEEXT = .exe
DOWNEXT = .img
CPPFLAGS += -I$(INSTALLDIR)/include/python$(PYTHON_VERSION)m
CFLAGS = -B$(PROJECT_LIB) $(DEPFLAGS) $(WARNFLAGS) $(CPU_CFLAGS) $(OPTFLAGS)
CXXFLAGS = -B$(PROJECT_LIB) $(DEPFLAGS) $(WARNFLAGS) $(CPU_CFLAGS) $(OPTFLAGS)
ASFLAGS = -B$(PROJECT_LIB) $(CPU_CFLAGS)
LDFLAGS = -B$(PROJECT_LIB) -specs bsp_specs -qrtems $(CPU_CFLAGS)
-Wl,--gc-sections
CCLINK = $(CC) $(LDFLAGS) -Wl,-Map,$(basename $@).map
CXXLINK = $(CXX) $(LDFLAGS) -Wl,-Map,$(basename $@).map
$(BUILDDIR)/%.o: %.c | $(BUILDDIR)
$(INSTALLDIR)/lib/libpython$(PYTHON_VERSION)m.a
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(BUILDDIR)/%.o: %.S | $(BUILDDIR)
$(INSTALLDIR)/lib/libpython$(PYTHON_VERSION)m.a
$(CC) $(CPPFLAGS) -DASM $(CFLAGS) -c $< -o $@
$(BUILDDIR)/%.o: %.cc | $(BUILDDIR)
$(INSTALLDIR)/lib/libpython$(PYTHON_VERSION)m.a
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
$(BUILDDIR)/%.o: %.cpp | $(BUILDDIR)
$(INSTALLDIR)/lib/libpython$(PYTHON_VERSION)m.a
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
$(BUILDDIR)/%.o: %.s | $(BUILDDIR)
$(INSTALLDIR)/lib/libpython$(PYTHON_VERSION)m.a
$(AS) $(ASFLAGS) $< -o $@
export PATH := $(RTEMS_ROOT)/bin:$(PATH)
export AR = $(RTEMS_CPU)-rtems$(RTEMS_API)-ar
export AS = $(RTEMS_CPU)-rtems$(RTEMS_API)-as
export CC = $(RTEMS_CPU)-rtems$(RTEMS_API)-gcc --pipe
export CXX = $(RTEMS_CPU)-rtems$(RTEMS_API)-g++
export LD = $(RTEMS_CPU)-rtems$(RTEMS_API)-ld
export NM = $(RTEMS_CPU)-rtems$(RTEMS_API)-nm
export OBJCOPY = $(RTEMS_CPU)-rtems$(RTEMS_API)-objcopy
export RANLIB = $(RTEMS_CPU)-rtems$(RTEMS_API)-ranlib
export SIZE = $(RTEMS_CPU)-rtems$(RTEMS_API)-size
export STRIP = $(RTEMS_CPU)-rtems$(RTEMS_API)-strip
APP = $(BUILDDIR)/app
APP_C_FILES =
APP_C_FILES += init.c
APP_C_FILES += python.c
APP_CC_FILES =
APP_CC_FILES += a.cc
APP_CC_FILES += a-wrap.cc
APP_OBJS = $(APP_C_FILES:%.c=$(BUILDDIR)/%.o)
$(APP_CC_FILES:%.cc=$(BUILDDIR)/%.o) $(BUILDDIR)/rootfs.o
APP_DEPS = $(APP_C_FILES:%.c=$(BUILDDIR)/%.d)
$(APP_CC_FILES:%.cc=$(BUILDDIR)/%.d)
all: $(PYTHONDIR) $(BUILDDIR) $(PYTHON_BUILDDIR) $(APP)$(DOWNEXT)
$(BUILDDIR)/rootfs.o: rootfs.tar.xz
$(OBJCOPY) -I binary -O $(OBJCOPY_TARGET) -B $(RTEMS_CPU) $< $@
rootfs.tar.xz: rootfs.tar
xz --lzma2=dict=8192 < $< > $@
rootfs.tar: a.py
cp a.py $(INSTALLDIR)/lib/python$(PYTHON_VERSION)/a.py
pax -w -f rootfs.tar -s '%$(INSTALLDIR)%%' -d \
$(INSTALLDIR)/lib \
$(INSTALLDIR)/lib/python$(PYTHON_VERSION) \
$(INSTALLDIR)/lib/python$(PYTHON_VERSION)/*.py \
$(INSTALLDIR)/lib/python$(PYTHON_VERSION)/collections/*.py \
$(INSTALLDIR)/lib/python$(PYTHON_VERSION)/encodings/*.py \
$(INSTALLDIR)/lib/python$(PYTHON_VERSION)/importlib/*.py \
$(INSTALLDIR)/lib/python$(PYTHON_VERSION)/xml/*.py
$(BUILDDIR):
mkdir $(BUILDDIR)
$(PYTHONDIR): Python-$(PYTHON_VERSION).$(PYTHON_MICRO_VERSION).tar.xz
tar xf $<
cd $(PYTHONDIR) && patch -p1 < ../rtems-python.patch
$(PYTHON_BUILDDIR):
mkdir $(PYTHON_BUILDDIR)
$(PYTHON_BUILDDIR)/Makefile: $(PYTHONDIR)/configure
export CFLAGS="-B$(PROJECT_LIB) $(CPU_CFLAGS)" \
&& export LDFLAGS="$(LDFLAGS)" \
&& export CONFIG_SITE=../CONFIG_SITE \
&& export LIBS="-lbsd -lm -lz" \
&& cd $(PYTHON_BUILDDIR) \
&& ../$(PYTHONDIR)/configure --host=$(RTEMS_TARGET)
--build=x86_64 --prefix=/
$(PYTHON_BUILDDIR)/libpython$(PYTHON_VERSION)m.a: $(PYTHON_BUILDDIR)/Makefile
make -C $(PYTHON_BUILDDIR)
make -C $(PYTHON_BUILDDIR) pybuilddir.txt
$(INSTALLDIR)/lib/libpython$(PYTHON_VERSION)m.a:
$(PYTHON_BUILDDIR)/libpython$(PYTHON_VERSION)m.a
make -C $(PYTHON_BUILDDIR) -k install DESTDIR=$(INSTALLDIR) ; true
$(APP)$(EXEEXT): $(APP_OBJS) $(INSTALLDIR)/lib/libpython$(PYTHON_VERSION)m.a
$(CXXLINK) $^ -Wl,--start-group -lbsd -lz -lm -lrtemscpu
-Wl,--end-group -o $@
$(BUILDDIR)/app.bin: $(APP)$(EXEEXT)
$(OBJCOPY) -O binary $^ $@
$(BUILDDIR)/app.bin.gz: $(BUILDDIR)/app.bin
gzip -9 -f -c $^ > $@
$(BUILDDIR)/app$(DOWNEXT): $(BUILDDIR)/app.bin.gz
mkimage -A ppc -O linux -T kernel -a 0x4000 -e 0x4000 -n RTEMS -d $^ $@
1>/dev/null
a-wrap.cc: a.h
swig -python -c++ -Wall -Wextra -includeall -o a-wrap.cc a.i
clean:
rm -rf $(BUILDDIR) rootfs.tar
very-clean: clean
rm -rf $(PYTHON_BUILDDIR) $(INSTALLDIR) rootfs.tar
-include $(APP_DEPS)
_______________________________________________
users mailing list
users@rtems.org
http://lists.rtems.org/mailman/listinfo/users