Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 1e32fe436a
Fetching contributors…

Cannot retrieve contributors at this time

169 lines (143 sloc) 4.748 kb
ARCH=@ARCH@
CC=@CC@
CFLAGS=@CFLAGS@
LDFLAGS=@LDFLAGS@
SHELL=/bin/bash
SYSDIR=../../../../system/python
ifeq (@USE_PYTHON2_6@,1)
PYVERSION=python2.6
SO=python26-$(ARCH).so
else ifeq (@USE_PYTHON2_5@,1)
PYVERSION=python2.5
SO=python25-$(ARCH).so
else ifeq (@USE_PYTHON2_4@,1)
PYVERSION=python2.4
SO=python24-$(ARCH).so
else
SO=python24-$(ARCH).so
endif
SLIB=$(SYSDIR)/$(SO)
ZIP=$(SYSDIR)/python24.zip ##Should probably add arch here too
DIRS=../Python
WRAPPER=../../../cores/DllLoader/exports/wrapper.o
WRAPPERDEF=$(WRAPPER:.o=.def)
PYWRAP=wrapper_python.o
PYWRAPDEF=$(PYWRAP:.o=.def)
ifeq ($(ARCH), powerpc64-linux)
PYLIBDIR=lib.linux-ppc64-2.4
else
ifeq ($(ARCH), powerpc-linux)
PYLIBDIR=lib.linux-ppc-2.4
else
ifeq ($(ARCH), x86_64-linux)
PYLIBDIR=lib.linux-x86_64-2.4
else
ifeq ($(ARCH), arm)
PYLIBDIR=lib.linux-`uname -m`-2.4
else
PYLIBDIR=lib.linux-i686-2.4
endif
endif
endif
endif
PYDIRS=bsddb compiler curses distutils email encodings hotshot idlelib \
lib-old lib-tk logging site-packages xml
ifeq ($(findstring osx,$(ARCH)),osx)
PYLIBDIR=lib.macosx-10.4-@ARCHTYPE@-2.4
PYDIRS+=plat-darwin
PYDIRS+=plat-mac
else
PYDIRS+=plat-linux2
endif
PY=$(wildcard ../Python/Lib/*.py)
PY+=$(foreach DIR, $(PYDIRS), $(wildcard ../Python/Lib/$(DIR)/*.py))
PY+=$(foreach DIR, $(PYDIRS), $(wildcard ../Python/Lib/$(DIR)/*/*.py))
PY+=$(foreach DIR, $(PYDIRS), $(wildcard ../Python/Lib/$(DIR)/*/*/*.py))
PYC=$(addsuffix c, $(PY))
PYO=$(addsuffix o, $(PY))
.PHONY: compile
ifeq ($(findstring osx,$(ARCH)), osx)
all: $(SLIB)
ifneq (@USE_EXTERNAL_PYTHON@,1)
$(SLIB): $(PYWRAP) ../Python/libpython2.4.a $(PYO) ../../../../tools/Mach5/wrapper.rb
rm -rf $(SYSDIR)/Lib
rsync -a --exclude '.svn' -t ../Python/build/$(PYLIBDIR)/*.so $(SYSDIR)/Lib
rsync -a --exclude '.svn' -t ../Python/Lib/*.{py,pyo} $(SYSDIR)/Lib
for dirs in $(PYDIRS); do rsync -a --exclude 'test*' --exclude '.svn' ../Python/Lib/$$dirs $(SYSDIR)/Lib; done
(mkdir -p tmp && rm -rf tmp/*)
(cd ./tmp && ar x ../../Python/libpython2.4.a)
$(CC) $(LDFLAGS) -bundle -flat_namespace -undefined suppress -o $@ \
tmp/*.o \
wrapper_python.o
../../../../tools/Mach5/wrapper.rb $@ libpython;mv output.so $@
../../../../tools/Mach5/wrapper.rb $@;mv output.so $@
@rm -rf tmp
else
$(SLIB): $(PYWRAP)
$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup -o $@ \
-l$(PYVERSION) wrapper_python.o
endif
../Python/libpython2.4.a: compile
$(MAKE) -C ../Python
%pyo: %py
@echo Compiling $@
@../Python/python.exe -O ../Python/Lib/py_compile.py $<
$(PYWRAP): $(PYWRAP:.o=.c)
$(CC) $(CFLAGS) -o $@ -c $<
else
all: $(SLIB)
ifneq (@USE_EXTERNAL_PYTHON@,1)
$(MAKE) $(ZIP)
endif
ifneq (@USE_EXTERNAL_PYTHON@,1)
$(SLIB): $(WRAPPER) $(WRAPPERDEF) $(PYWRAP) $(PYWRAPDEF) ../Python/libpython2.4.a
$(CC) $(LDFLAGS) -shared -o $@ -Wl,--whole-archive ../Python/libpython2.4.a \
-Wl,--no-whole-archive `cat wrapper_python.def` wrapper_python.o \
`cat ../../../cores/DllLoader/exports/wrapper.def` \
../../../cores/DllLoader/exports/wrapper.o
else
$(SLIB): $(WRAPPER) $(WRAPPERDEF) $(PYWRAP) $(PYWRAPDEF)
$(CC) $(LDFLAGS) -shared -o $@ -Wl,--no-as-needed -l$(PYVERSION) \
`cat wrapper_python.def` wrapper_python.o \
`cat ../../../cores/DllLoader/exports/wrapper.def` \
../../../cores/DllLoader/exports/wrapper.o
endif
$(ZIP): $(PYC) $(PYO)
pushd ../Python/build/$(PYLIBDIR)/ && \
zip -0guq ../../$@ *.so; \
popd
pushd ../Python/Lib/ && \
zip -0gurq ../$@ *.py* $(PYDIRS) -x *.svn* *test*; \
popd
../Python/libpython2.4.a: compile
$(MAKE) -C ../Python
%pyc: %py
@echo Compiling $@
@LD_PRELOAD=../Python/libpython2.4.so.1.0 ../Python/python \
../Python/Lib/py_compile.py $<
%pyo: %py
@echo Compiling $@
@LD_PRELOAD=../Python/libpython2.4.so.1.0 ../Python/python -O \
../Python/Lib/py_compile.py $<
$(PYWRAP): $(PYWRAP:.o=.c)
$(CC) $(CFLAGS) -fPIC -o $@ -D_FILE_DEFINED -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c $<
$(PYWRAPDEF): $(PYWRAPDEF:.def=.c)
LD_OPTS=$$(for func in $$(grep PYTHON_WRAP wrapper_python.c | \
grep -v define | awk -F ')' '{print $$1}' | \
awk -F'(' '{print $$2}' | grep -v '^l*stat$$' | \
awk '{printf("%s ",$$0);}'); \
do echo -n "-Wl,-wrap,$$func "; done); \
echo -n $$LD_OPTS > $@
endif
clean:
for d in $(DIRS); do [ ! -f $$d/Makefile ] || make -C $$d clean; done
rm -f $(SLIB) $(ZIP) $(PYC) $(PYO) ../Python/libpython2.4.a $(PYWRAP) $(PYWRAPDEF)
ifeq ($(findstring osx,$(ARCH)), osx)
rm -rf $(SYSDIR)/Lib
endif
distclean:
for d in $(DIRS); do [ ! -f $$d/Makefile ] || make -C $$d distclean; done
rm -f $(SLIB) $(ZIP) $(PYC) $(PYO) ../Python/libpython2.4.a $(PYWRAP) $(PYWRAPDEF)
ifeq ($(findstring osx,$(ARCH)), osx)
rm -rf $(SYSDIR)/Lib
endif
Jump to Line
Something went wrong with that request. Please try again.