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 2016 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.7.11
35 PKG=runtime/python-27
36 SUMMARY="$PROG"
37 DESC="$SUMMARY"
38
39 BUILD_DEPENDS_IPS="developer/build/autoconf"
40 DEPENDS_IPS="system/library/gcc-5-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.7/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.7/config/Makefile $DESTDIR/usr/lib/python2.7/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.7/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.7/config/libpython2.7.a || logerr "--- cannot remove static lib"
110 # XXX KEBE SAYS Uncomment me eventually...
111 # (cd $DESTDIR/usr/bin && ln -s python2.7 python) || logerr "--- could not setup python softlink"
112 # XXX KEBE SAYS Python2.7 appears to honor $LIB/amd64 for 64-bit python...
113 # mv $DESTDIR/usr/lib/python2.7/config/Makefile $DESTDIR/usr/lib/python2.7/config/Makefile.64 || logerr "--- Makefile backup (64)"
114 # mv $DESTDIR/usr/lib/python2.7/config/Makefile.32 $DESTDIR/usr/lib/python2.7/config/Makefile || logerr "--- Makefile restore (32)"
115 }
116
117 install_license(){
118 logcmd cp $TMPDIR/$BUILDDIR/LICENSE $DESTDIR/license
119 }
120
121 init
122 download_source $PROG $PROG $VER
123 patch_source
124 preprep_build
125 prep_build
126 build
127 make_isa_stub
128 strip_install -x
129 install_license
130 make_package
131 clean_up