[Python-checkins] CVS: python/dist/src Makefile.pre.in,1.77,1.78 README,1.142,1.143 configure,1.291,1.292 configure.in,1.301,1.302

Martin v. L?wis loewis@users.sourceforge.net
Fri, 29 Mar 2002 08:28:33 -0800


Update of /cvsroot/python/python/dist/src
In directory usw-pr-cvs1:/tmp/cvs-serv21694

Modified Files:
	Makefile.pre.in README configure configure.in 
Log Message:
Patch #527027: Allow building python as shared library.


Index: Makefile.pre.in
===================================================================
RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v
retrieving revision 1.77
retrieving revision 1.78
diff -C2 -d -r1.77 -r1.78
*** Makefile.pre.in	23 Mar 2002 00:20:15 -0000	1.77
--- Makefile.pre.in	29 Mar 2002 16:28:30 -0000	1.78
***************
*** 109,112 ****
--- 109,115 ----
  PYTHONFRAMEWORKINSTALLDIR= @PYTHONFRAMEWORKINSTALLDIR@
  
+ # Environment to run shared python without installed libraries
+ RUNSHARED=       @RUNSHARED@
+ 
  # Modes for directories, executables and data files created by the
  # install process.  Default to user-only-writable for all file types.
***************
*** 137,140 ****
--- 140,144 ----
  DLLLIBRARY=	@DLLLIBRARY@
  LDLIBRARYDIR=   @LDLIBRARYDIR@
+ INSTSONAME=	@INSTSONAME@
  
  
***************
*** 293,297 ****
  
  # Build the interpreter
! $(BUILDPYTHON):	Modules/$(MAINOBJ) $(LDLIBRARY)
  		$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \
  			Modules/$(MAINOBJ) \
--- 297,301 ----
  
  # Build the interpreter
! $(BUILDPYTHON):	Modules/$(MAINOBJ) $(LIBRARY) $(LDLIBRARY)
  		$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \
  			Modules/$(MAINOBJ) \
***************
*** 299,303 ****
  
  platform: $(BUILDPYTHON)
! 	./$(BUILDPYTHON) -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
  
  
--- 303,307 ----
  
  platform: $(BUILDPYTHON)
! 	$(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
  
  
***************
*** 305,310 ****
  sharedmods: $(BUILDPYTHON)
  	case $$MAKEFLAGS in \
! 	*-s*) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
! 	*) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
  	esac
  
--- 309,314 ----
  sharedmods: $(BUILDPYTHON)
  	case $$MAKEFLAGS in \
! 	*-s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
! 	*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
  	esac
  
***************
*** 334,349 ****
  	$(RANLIB) $@
  
! # This rule is only here for DG/UX and BeOS!!!
! libpython$(VERSION).so:	$(LIBRARY)
! 	case `uname -s | tr -d '/ ' | tr '[A-Z]' '[a-z]'` in \
! 	*dgux*) \
! 	    test -d dgux || mkdir dgux; \
! 	    (cd dgux;ar x ../$^;ld -G -o ../$@ * ); \
! 	    /bin/rm -rf ./dgux \
! 	    ;; \
! 	beos) \
! 	    $(AR) so $(LIBRARY) $@ \
! 	    ;; \
! 	esac
  
  # This rule is here for OPENSTEP/Rhapsody/MacOSX
--- 338,346 ----
  	$(RANLIB) $@
  
! libpython$(VERSION).so: $(LIBRARY_OBJS)
! 	$(LDSHARED) -o $@ $(LIBRARY_OBJS) $(LIBC) $(LIBM)
! 
! libpython$(VERSION).sl: $(LIBRARY_OBJS)
! 	$(LDSHARED) -o $@ $(LIBRARY_OBJS) $(LIBC) $(LIBM)
  
  # This rule is here for OPENSTEP/Rhapsody/MacOSX
***************
*** 421,428 ****
  
  Python/getplatform.o: $(srcdir)/Python/getplatform.c
! 		$(CC) -c $(CFLAGS) $(CPPFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
  
  Python/importdl.o: $(srcdir)/Python/importdl.c
! 		$(CC) -c $(CFLAGS) $(CPPFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
  
  Objects/unicodectype.o:	$(srcdir)/Objects/unicodectype.c \
--- 418,425 ----
  
  Python/getplatform.o: $(srcdir)/Python/getplatform.c
! 		$(CC) -c $(CFLAGS) $(CPPFLAGS) $(CFLAGSFORSHARED) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
  
  Python/importdl.o: $(srcdir)/Python/importdl.c
! 		$(CC) -c $(CFLAGS) $(CPPFLAGS) $(CFLAGSFORSHARED) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
  
  Objects/unicodectype.o:	$(srcdir)/Objects/unicodectype.c \
***************
*** 487,491 ****
  TESTOPTS=	-l
  TESTPROG=	$(srcdir)/Lib/test/regrtest.py
! TESTPYTHON=	./$(BUILDPYTHON) -E -tt
  test:		all platform
  		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
--- 484,488 ----
  TESTOPTS=	-l
  TESTPROG=	$(srcdir)/Lib/test/regrtest.py
! TESTPYTHON=	$(RUNSHARED) ./$(BUILDPYTHON) -E -tt
  test:		all platform
  		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
***************
*** 557,562 ****
  	done
  	$(INSTALL_PROGRAM) $(BUILDPYTHON) $(BINDIR)/python$(VERSION)$(EXE)
! 	if test -f libpython$(VERSION).so; then \
! 		$(INSTALL_DATA) libpython$(VERSION).so $(LIBDIR); \
  	else	true; \
  	fi
--- 554,559 ----
  	done
  	$(INSTALL_PROGRAM) $(BUILDPYTHON) $(BINDIR)/python$(VERSION)$(EXE)
! 	if test -f libpython$(VERSION)$(SO); then \
! 		$(INSTALL_SHARED) libpython$(VERSION)$(SO) $(LIBDIR)/$(INSTSONAME); \
  	else	true; \
  	fi
***************
*** 641,648 ****
  	done
  	$(INSTALL_DATA) $(srcdir)/LICENSE $(LIBDEST)/LICENSE.txt
! 	PYTHONPATH=$(LIBDEST) \
  		./$(BUILDPYTHON) -tt $(LIBDEST)/compileall.py -x badsyntax \
  	        $(LIBDEST)
! 	PYTHONPATH=$(LIBDEST) \
  		./$(BUILDPYTHON) -O $(LIBDEST)/compileall.py -x badsyntax $(LIBDEST)
  
--- 638,645 ----
  	done
  	$(INSTALL_DATA) $(srcdir)/LICENSE $(LIBDEST)/LICENSE.txt
! 	PYTHONPATH=$(LIBDEST)  $(RUNSHARED) \
  		./$(BUILDPYTHON) -tt $(LIBDEST)/compileall.py -x badsyntax \
  	        $(LIBDEST)
! 	PYTHONPATH=$(LIBDEST) $(RUNSHARED) \
  		./$(BUILDPYTHON) -O $(LIBDEST)/compileall.py -x badsyntax $(LIBDEST)
  
***************
*** 687,696 ****
  		fi; \
  	done
! 	@if test -d $(LDLIBRARY); then :; else \
  		if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
! 			$(INSTALL_DATA) $(LDLIBRARY) $(LIBPL)/$(LDLIBRARY) ; \
! 			$(RANLIB) $(LIBPL)/$(LDLIBRARY) ; \
  		else \
! 			echo Skip install of $(LDLIBRARY) - use make frameworkinstall; \
  		fi; \
  	fi
--- 684,693 ----
  		fi; \
  	done
! 	@if test -d $(LIBRARY); then :; else \
  		if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
! 			$(INSTALL_DATA) $(LIBRARY) $(LIBPL)/$(LIBRARY) ; \
! 			$(RANLIB) $(LIBPL)/$(LIBRARY) ; \
  		else \
! 			echo Skip install of $(LIBRARY) - use make frameworkinstall; \
  		fi; \
  	fi
***************
*** 734,738 ****
  # This goes into $(exec_prefix)
  sharedinstall:
! 	./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
  		--install-scripts=$(BINDIR) \
  		--install-platlib=$(DESTSHARED)
--- 731,736 ----
  # This goes into $(exec_prefix)
  sharedinstall:
! 	$(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
! 	   	--prefix=$(prefix) \
  		--install-scripts=$(BINDIR) \
  		--install-platlib=$(DESTSHARED)

Index: README
===================================================================
RCS file: /cvsroot/python/python/dist/src/README,v
retrieving revision 1.142
retrieving revision 1.143
diff -C2 -d -r1.142 -r1.143
*** README	21 Mar 2002 23:52:20 -0000	1.142
--- README	29 Mar 2002 16:28:30 -0000	1.143
***************
*** 559,562 ****
--- 559,571 ----
  
  
+ Building a shared libpython
+ ---------------------------
+ 
+ Starting with Python 2.3, the majority of the interpreter can be built
+ into a shared library, which can then be used by the interpreter 
+ executable, and by applications embedding Python. To enable this feature,
+ configure with --enable-shared.
+ 
+ 
  Configuring additional built-in modules
  ---------------------------------------

Index: configure
===================================================================
RCS file: /cvsroot/python/python/dist/src/configure,v
retrieving revision 1.291
retrieving revision 1.292
diff -C2 -d -r1.291 -r1.292
*** configure	27 Mar 2002 18:49:01 -0000	1.291
--- configure	29 Mar 2002 16:28:30 -0000	1.292
***************
*** 1,5 ****
  #! /bin/sh
  
! # From configure.in Revision: 1.300 
  
  # Guess values for system-dependent variables and create Makefiles.
--- 1,5 ----
  #! /bin/sh
  
! # From configure.in Revision: 1.301 
  
[...5234 lines suppressed...]
! echo "configure:7710: checking for build directories" >&5
  for dir in $SRCDIRS; do
      if test ! -d $dir; then
***************
*** 7794,7797 ****
--- 7850,7854 ----
  s%@mandir@%$mandir%g
  s%@VERSION@%$VERSION%g
+ s%@SOVERSION@%$SOVERSION%g
  s%@CONFIG_ARGS@%$CONFIG_ARGS%g
  s%@PYTHONFRAMEWORK@%$PYTHONFRAMEWORK%g
***************
*** 7812,7815 ****
--- 7869,7874 ----
  s%@BLDLIBRARY@%$BLDLIBRARY%g
  s%@LDLIBRARYDIR@%$LDLIBRARYDIR%g
+ s%@INSTSONAME@%$INSTSONAME%g
+ s%@RUNSHARED@%$RUNSHARED%g
  s%@LINKCC@%$LINKCC%g
  s%@RANLIB@%$RANLIB%g

Index: configure.in
===================================================================
RCS file: /cvsroot/python/python/dist/src/configure.in,v
retrieving revision 1.301
retrieving revision 1.302
diff -C2 -d -r1.301 -r1.302
*** configure.in	27 Mar 2002 18:49:02 -0000	1.301
--- configure.in	29 Mar 2002 16:28:31 -0000	1.302
***************
*** 9,12 ****
--- 9,15 ----
  VERSION=2.3
  
+ AC_SUBST(SOVERSION)
+ SOVERSION=1.0
+ 
  # Arguments passed to configure.
  AC_SUBST(CONFIG_ARGS)
***************
*** 258,269 ****
--- 261,280 ----
  # DLLLIBRARY is the shared (i.e., DLL) library.
  # 
+ # RUNSHARED is used to run shared python without installed libraries
+ #
+ # INSTSONAME is the name of the shared library that will be use to install
+ # on the system - some systems like version suffix, others don't
  AC_SUBST(LDLIBRARY)
  AC_SUBST(DLLLIBRARY)
  AC_SUBST(BLDLIBRARY)
  AC_SUBST(LDLIBRARYDIR)
+ AC_SUBST(INSTSONAME)
+ AC_SUBST(RUNSHARED)
  LDLIBRARY="$LIBRARY"
  BLDLIBRARY='$(LDLIBRARY)'
+ INSTSONMAE='$(LDLIBRARY)'
  DLLLIBRARY=''
  LDLIBRARYDIR=''
+ RUNSHARED=''
  
  # LINKCC is the command that links the python executable -- default is $(CC).
***************
*** 302,321 ****
  AC_MSG_RESULT($LINKCC)
  
! AC_MSG_CHECKING(LDLIBRARY)
  
! # DG/UX requires some fancy ld contortions to produce a .so from an .a
! case $MACHDEP in
! dguxR4)
!       LDLIBRARY='libpython$(VERSION).so'
!       OPT="$OPT -pic"
!       ;;
! beos*)
!       LDLIBRARY='libpython$(VERSION).so'
!       ;;
! cygwin*)
!       LDLIBRARY='libpython$(VERSION).dll.a'
!       DLLLIBRARY='libpython$(VERSION).dll'
!       ;;
! esac
  
  # MacOSX framework builds need more magic. LDLIBRARY is the dynamic
--- 313,328 ----
  AC_MSG_RESULT($LINKCC)
  
! AC_MSG_CHECKING(for --enable-shared)
! AC_ARG_ENABLE(shared,
! [  --enable-shared                 disable/enable building shared python library])
  
! if test -z "$enable_shared"
! then 
!   enable_shared="no"
! fi
! AC_MSG_RESULT($enable_shared)
! 
! 
! AC_MSG_CHECKING(LDLIBRARY)
  
  # MacOSX framework builds need more magic. LDLIBRARY is the dynamic
***************
*** 334,337 ****
--- 341,385 ----
  fi  
  
+ # Other platforms follow
+ if test $enable_shared = "yes"; then
+   case $ac_sys_system in
+     BeOS*)
+           LDLIBRARY='libpython$(VERSION).so'
+           ;;
+     CYGWIN*)
+           LDLIBRARY='libpython$(VERSION).dll.a'
+           DLLLIBRARY='libpython$(VERSION).dll'
+           ;;
+     SunOS*)
+ 	  LDLIBRARY='libpython$(VERSION).so'
+ 	  BLDLIBRARY='-Wl,-rpath,$(LIBDIR) -L. -lpython$(VERSION)'
+ 	  RUNSHARED=LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH
+           ;;
+     Linux*)
+ 	  LDLIBRARY='libpython$(VERSION).so'
+ 	  BLDLIBRARY='-L. -lpython$(VERSION)'
+ 	  RUNSHARED=LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH
+ 	  INSTSONAME="$LDLIBRARY".$SOVERSION
+ 	  ;;
+     hp*|HP*)
+ 	  LDLIBRARY='libpython$(VERSION).sl'
+ 	  BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
+ 	  RUNSHARED=SHLIB_PATH=`pwd`:$SHLIB_PATH
+ 	  ;;
+     OSF*)
+ 	  LDLIBRARY='libpython$(VERSION).so'
+          BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
+ 	  RUNSHARED=LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH
+ 	  ;;
+   esac
+   # DG/UX requires some fancy ld contortions to produce a .so from an .a
+   case $MACHDEP in
+   dguxR4)
+         LDLIBRARY='libpython$(VERSION).so'
+         OPT="$OPT -pic"
+         ;;
+   esac
+ fi
+ 
  AC_MSG_RESULT($LDLIBRARY)
  
***************
*** 862,866 ****
  	AIX*)	LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
  	hp*|HP*)
! 	    LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
  	BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
  	Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
--- 910,915 ----
  	AIX*)	LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
  	hp*|HP*)
! 	    LINKFORSHARED="-Wl,-E -Wl,+s";;
! #	    LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
  	BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
  	Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;