forked from juergh/pykdump
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildPython.sh
More file actions
executable file
·114 lines (92 loc) · 2.46 KB
/
Copy pathbuildPython.sh
File metadata and controls
executable file
·114 lines (92 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
# Build Python as needed for PyKdump. If called without any options in Python src
# directory, it builds everything there.
# If called with an additional argument, it build Python in that directory
# Get file from SF GIT via HTTP-browser, using the 'master' branch
# Usage: getgitfile path outfile
getgitfile() {
url="http://sourceforge.net/p/pykdump/code/ci/master/tree/$1?format=raw"
#url="http://pykdump.git.sourceforge.net/git/gitweb.cgi?p=pykdump/pykdump;a=blob_plain;f=$1;hb=refs/heads/master"
echo $url
if ! wget -q "$url" -O $2
then
echo "Cannot retrieve $1 using HTTP"
exit 2
fi
}
getslocal() {
# Get Python version
if test ! -f "$CONFIGURE"
then
echo "Cannot find 'configure' file"
exit 1
fi
PYVERS=`grep PACKAGE_VERSION= $CONFIGURE | sed -e "s/PACKAGE_VERSION=//;s/'//g" `
setuploc="Setup.local-${PYVERS}"
getgitfile Extension/$setuploc Modules/Setup.local
}
PYDIR=$PWD
buildarch () {
local bdir
bdir="$1"
echo "------Building for $bdir ------"
# Test whether this directory already exists
if [ ! -d $bdir ];then
mkdir -p $bdir
fi
# Check whether this directory exists
if [ ! -d $bdir ];then
echo "Cannot create directory $bdir"
exit 3
fi
cd $bdir
CONFIGURE="$PYDIR/configure"
$CONFIGURE CFLAGS=-fPIC --disable-shared
getslocal
make
# For some reason, we need this in older RHEL
touch Modules/Setup.local
make
#strip -d libpython${PYVERS}.a
cd $PYDIR
}
Usage() {
cat <<_ACEOF
'buildPython.sh' lets you build Python as needed by PyKdump.
After unpacking Python sources, go its top directory and call
this script like that:
Usage: $0 [-a] [-b builddir]
Configuration:
-a Builds both 32-bit and 64-bit versions
of Python in X86 and X86_64 subdirectories
-h, --help display this help and exit
-b Use a separate directory for your build.
_ACEOF
}
build_dir='.'
while getopts "b:ha" opt
do
case $opt in
b)
build_dir="$OPTARG"
;;
a)
a3264=1
;;
h)
Usage;exit 0
;;
esac
done
#echo "build_dir=$build_dir"
#echo "a3264=$a3264"
#getgitfile Extension/Setup.local-2.7 /tmp/Setup.local
#exit 0
if test "${a3264+set}" != set; then
buildarch "$build_dir"
else
# Build in X86 and X86_64 subdirectories
buildarch "`dirname $build_dir/a`/X86_64"
CC='gcc -m32' buildarch "`dirname $build_dir/a`/X86"
exit 0
fi