python version for rtems 4.11.2
Sebastian Huber
sebastian.huber at embedded-brains.de
Thu Oct 25 12:47:37 UTC 2018
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.huber at embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rtems-python.patch
Type: text/x-patch
Size: 8001 bytes
Desc: not available
URL: <http://lists.rtems.org/pipermail/users/attachments/20181025/9abd380c/attachment-0002.bin>
-------------- next part --------------
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)
More information about the users
mailing list