1 #!/usr/bin/bash
   2 #
   3 # CDDL HEADER START
   4 #
   5 # The contents of this file are subject to the terms of the
   6 # Common Development and Distribution License, Version 1.0 only
   7 # (the "License").  You may not use this file except in compliance
   8 # with the License.
   9 #
  10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  11 # or http://www.opensolaris.org/os/licensing.
  12 # See the License for the specific language governing permissions
  13 # and limitations under the License.
  14 #
  15 # When distributing Covered Code, include this CDDL HEADER in each
  16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  17 # If applicable, add the following below this CDDL HEADER, with the
  18 # fields enclosed by brackets "[]" replaced with your own identifying
  19 # information: Portions Copyright [yyyy] [name of copyright owner]
  20 #
  21 # CDDL HEADER END
  22 #
  23 #
  24 # Copyright 2011-2012 OmniTI Computer Consulting, Inc.  All rights reserved.
  25 # Use is subject to license terms.
  26 #
  27 # Load support functions
  28 . ../../lib/functions.sh
  29 
  30 CC=gcc
  31 CXX=g++
  32 
  33 PROG=Python
  34 VER=2.6.8
  35 PKG=runtime/python-26
  36 SUMMARY="$PROG"
  37 DESC="$SUMMARY"
  38 
  39 BUILD_DEPENDS_IPS="developer/build/autoconf"
  40 DEPENDS_IPS="system/library/gcc-4-runtime library/zlib library/libffi@$FFIVERS
  41         library/readline database/sqlite-3 compress/bzip2 library/libxml2
  42         library/ncurses library/security/openssl"
  43 
  44 export CCSHARED="-fPIC"
  45 CFLAGS="$CFLAGS -std=c99"
  46 LDFLAGS32="-L/usr/gnu/lib -R/usr/gnu/lib"
  47 LDFLAGS64="-L/usr/gnu/lib/amd64 -R/usr/gnu/lib/amd64"
  48 CPPFLAGS="$CPPFLAGS -I/usr/include/ncurses -D_LARGEFILE64_SOURCE"
  49 CPPFLAGS32="-I/usr/lib/libffi-$FFIVERS/include"
  50 CPPFLAGS64="-I/usr/lib/amd64/libffi-$FFIVERS/include"
  51 CONFIGURE_OPTS="--enable-shared
  52         --with-system-ffi
  53         ac_cv_opt_olimit_ok=no
  54         ac_cv_olimit_ok=no"
  55 
  56 preprep_build() {
  57     pushd $TMPDIR/$BUILDDIR > /dev/null || logerr "Cannot change to build directory"
  58     /usr/bin/autoheader || logerr "autoheaer failed"
  59     /usr/bin/autoconf || logerr "autoreconf failed"
  60     popd > /dev/null
  61 }
  62 
  63 post_config() {
  64     pushd $TMPDIR/$BUILDDIR > /dev/null || logerr "Cannot change to build directory"
  65     perl -pi -e 's/(^\#define _POSIX_C_SOURCE.*)/\/* $$1 *\//' pyconfig.h
  66     perl -pi -e 's/^(\#define _XOPEN_SOURCE.*)/\/* $$1 *\//' pyconfig.h
  67     perl -pi -e 's/^(\#define _XOPEN_SOURCE_EXTENDED.*)/\/* $$1 *\//' pyconfig.h
  68     popd > /dev/null
  69 }
  70 
  71 configure64() {
  72     logmsg "--- configure (64-bit)"
  73     CFLAGS="$CFLAGS $CFLAGS64" \
  74     CXXFLAGS="$CXXFLAGS $CXXFLAGS64" \
  75     CPPFLAGS="$CPPFLAGS $CPPFLAGS64" \
  76     LDFLAGS="$LDFLAGS $LDFLAGS64" \
  77     CC="$CC -m64" CXX=$CXX \
  78     logcmd $CONFIGURE_CMD $CONFIGURE_OPTS_64 \
  79     $CONFIGURE_OPTS || \
  80         logerr "--- Configure failed"
  81 }
  82 
  83 make_prog32() {
  84     post_config
  85     [[ -n $NO_PARALLEL_MAKE ]] && MAKE_JOBS=""
  86     logmsg "--- make"
  87     logcmd $MAKE $MAKE_JOBS DFLAGS=-32 || \
  88         logerr "--- Make failed"
  89 }
  90 
  91 make_prog64() {
  92     post_config
  93     [[ -n $NO_PARALLEL_MAKE ]] && MAKE_JOBS=""
  94     logmsg "--- make"
  95     logcmd $MAKE $MAKE_JOBS DFLAGS=-64 DESTSHARED=/usr/lib/python2.6/lib-dynload || \
  96         logerr "--- Make failed"
  97 }
  98 
  99 make_install32() {
 100     make_install
 101     rm $DESTDIR/usr/bin/i386/python || logerr "--- cannot remove arch hardlink"
 102     mv $DESTDIR/usr/lib/python2.6/config/Makefile $DESTDIR/usr/lib/python2.6/config/Makefile.32 || logerr "--- Makefile backup (32)"
 103 }
 104 make_install64() {
 105     logmsg "--- make install"
 106     logcmd $MAKE DESTDIR=${DESTDIR} install DESTSHARED=/usr/lib/python2.6/lib-dynload || \
 107         logerr "--- Make install failed"
 108     rm $DESTDIR/usr/bin/amd64/python || logerr "--- cannot remove arch hardlink"
 109     rm $DESTDIR/usr/lib/python2.6/config/libpython2.6.a || logerr "--- cannot remove static lib"
 110     (cd $DESTDIR/usr/bin && ln -s python2.6 python) ||  logerr "--- could not setup python softlink"
 111     mv $DESTDIR/usr/lib/python2.6/config/Makefile $DESTDIR/usr/lib/python2.6/config/Makefile.64 || logerr "--- Makefile backup (64)"
 112     mv $DESTDIR/usr/lib/python2.6/config/Makefile.32 $DESTDIR/usr/lib/python2.6/config/Makefile || logerr "--- Makefile restore (32)"
 113 }
 114 
 115 install_license(){
 116     logcmd cp $TMPDIR/$BUILDDIR/LICENSE $DESTDIR/license
 117 }
 118 
 119 init
 120 download_source $PROG $PROG $VER
 121 patch_source
 122 preprep_build
 123 prep_build
 124 build
 125 make_isa_stub
 126 strip_install -x
 127 install_license
 128 make_package
 129 clean_up