-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·116 lines (98 loc) · 3.66 KB
/
configure
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
114
115
116
#!/bin/sh
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# create the makevars for unix like systems (tested on debian and ubuntu)
#
# NOTES:
# The system variable USESPECIALPYTHONVERSION can be used to link to a special
# python version.
# export USESPECIALPYTHONVERSION="python3.4"
# it can be very usefull especially for testing but one has to ensure that
# the file PYVERSION-config is present at the provided location else it will
# fail.
# But when using python3 also python3-dev has to be installed
# (apt-get install python3-dev)
#
# gcc:
# there seems to be a new option which doesn't allows me to compile
# -fstack-protector-strong so I just remove it
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if ! [ -z "$USESPECIALPYTHONVERSION" ]; then
echo "use special version"
alias python3="$USESPECIALPYTHONVERSION"
fi
if ! [ -z "$(python3 -V 2>&1 | grep 'python')" ]; then
if ! [ -z "$(python -V 2>&1 | grep 'python')" ]; then
echo "Could not find python!"
exit 1
else
alias python3=python
fi
fi
PYVERSION=`python3 -c "import sys;import distutils.sysconfig as sc;sys.stdout.write(sc.get_config_var('VERSION'))"`
PYINCLUDE=`python3 -c "import sys;import distutils.sysconfig as sc;sys.stdout.write(sc.get_config_var('INCLUDEPY'))"`
PYBINPATH=`python3 -c "import sys;import os;sys.stdout.write(os.path.dirname(sys.executable))"`
# sys.version_info.major would be a alternative to hexversion
PY3FLAG=`python3 -c 'import sys; print("%i" % (sys.hexversion<0x03000000))'`
PYABOVE38FLAG=`python3 -c 'import sys; print("%i" % (sys.hexversion>0x03080000))'`
PICFLAGS=`"${R_HOME}/bin/R" CMD config CXX11PICFLAGS`
if [ $PYABOVE38FLAG -eq 1 ]; then
echo "detected python3.8 or newer"
PYEMBEDPKGCONF="-embed"
PYEMBEDPYCONF="--embed"
fi
#python-3.8-embed
## echo $PYVERSION
## echo $PYBINPATH
## echo $PY3FLAG
## echo $PICFLAGS
## echo ""
## TODO:
## Change the generation of PKG_LIBS so it works with conda.
## PYLIBS="PKG_LIBS="`python -c 'import sysconfig; print(" ".join(sysconfig.get_config_var("LDSHARED").split()[1:]))'`
if [ $PY3FLAG -eq 0 ]; then
echo "python version is > 3"
PYXY="PYTHONLIBXY=libpython"$PYVERSION"m.so"
else
echo "python version is < 3"
PYXY="PYTHONLIBXY=libpython"$PYVERSION".so"
fi
PKG_LIBS=`$PYBINPATH/python$PYVERSION-config --ldflags $PYEMBEDPYCONF`
##
## PKG_CFLAGS
##
if [ -z "$(pkg-config --version 2>&1 | grep 'pkg-config')" ]; then
if (pkg-config --exists python-$PYVERSION$PYEMBEDPKGCONF); then
echo "pkg-config"
PKG_CFLAGS=`pkg-config --cflags python-$PYVERSION$PYEMBEDPKGCONF`
else
#echo "python-config"
#PKG_CFLAGS=`$PYBINPATH/python$PYVERSION-config --cflags $PYEMBEDPYCONF`
PKG_CFLAGS="-I$PYINCLUDE"
fi
else
#echo "python-config"
#PKG_CFLAGS=`$PYBINPATH/python$PYVERSION-config --cflags $PYEMBEDPYCONF`
PKG_CFLAGS="-I$PYINCLUDE"
fi
PKG_CFLAGS=$(echo $PKG_CFLAGS | sed 's/ -Wstrict-prototypes//')
PKG_CFLAGS=$(echo $PKG_CFLAGS | sed 's/ -fstack-protector-strong//')
PKG_CFLAGS=$(echo $PKG_CFLAGS | sed 's/ -Wdate-time//')
PKG_CFLAGS=$(echo $PKG_CFLAGS | sed 's/ -Werror=format-security//')
PKG_CFLAGS=$(echo $PKG_CFLAGS | sed 's/ -Wformat//')
## added 27.07.2018
PKG_CFLAGS=$(echo $PKG_CFLAGS | sed 's/ -fstack-clash-protection//')
PKG_CFLAGS=$(echo $PKG_CFLAGS | sed 's/ -fcf-protection//')
if ! [ -z "$PICFLAGS" ]; then
PKG_CFLAGS=$(echo $PKG_CFLAGS | sed 's/ -fpic//')
fi
sed -e "s|@PKG_CFLAGS@|$PKG_CFLAGS|" -e "s|@PKG_LIBS@|$PKG_LIBS|" -e "s|@PYXY@|$PYXY|" src/Makevars.in > src/Makevars
echo ""
echo "-----------------------------------"
echo " Makevars:"
echo ""
cat src/Makevars
echo ""
echo "-----------------------------------"
echo ""
exit 0