Skip to content

Commit

Permalink
Make boost_py shell scripts work under both unix and cygwin.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradbell committed Dec 5, 2010
1 parent 241e0c9 commit 4787acd
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 27 deletions.
36 changes: 23 additions & 13 deletions boost_py/exception.sh
Expand Up @@ -2,6 +2,18 @@
set -e
# Modified version of http://www.boost.org/doc/libs/1_45_0/libs/python/doc/v2/
# exception_translator.html
# ----------------------------------------------------------------------
python_version=`ls /usr/include | grep python | sed -e 's/python//'`
system=`uname | sed -e s/\(......\).*/\1/`
if [ "$system" == "CYGWIN" ]
then
extra_compile="-Wl,--enable-auto-image-base"
library_extension=".dll"
else
extra_compile=""
library_extension=".so"
fi
# ----------------------------------------------------------------------
#
echo "cat << EOF > exception.cpp"
cat << EOF > exception.cpp
Expand Down Expand Up @@ -51,23 +63,21 @@ BOOST_PYTHON_MODULE(exception)
}
EOF
#
echo "gcc -I/usr/include/python2.6 -g -c exception.cpp"
gcc -I/usr/include/python2.6 -g -c exception.cpp
echo "gcc -I/usr/include/python$python_version -g -c exception.cpp"
gcc -I/usr/include/python$python_version -g -c exception.cpp
#
echo "g++ -shared \\"
echo " -Wl,--enable-auto-image-base \\"
echo "g++ -shared $extra_compile \\"
echo " -g \\"
echo " exception.o \\"
echo " -L/usr/lib -L/usr/lib/python2.6/config \\"
echo " -lboost_python-mt -lpython2.6 \\"
echo " -o exception.dll"
g++ -shared \
-Wl,--enable-auto-image-base \
echo " -L/usr/lib -L/usr/lib/python$python_version/config \\"
echo " -lboost_python-mt -lpython$python_version \\"
echo " -o exception$library_extension"
g++ -shared $extra_compile \
-g \
exception.o \
-L/usr/lib -L/usr/lib/python2.6/config \
-lboost_python-mt -lpython2.6 \
-o exception.dll
-L/usr/lib -L/usr/lib/python$python_version/config \
-lboost_python-mt -lpython$python_version \
-o exception$library_extension
#
echo "cat << EOF > exception.py"
cat << EOF > exception.py
Expand All @@ -83,7 +93,7 @@ if python exception.py
then
flag=0
echo "exception.sh: OK"
for ext in .cpp .o .dll .py
for ext in .cpp .o $library_extension .py
do
echo "rm exception$ext"
rm exception$ext
Expand Down
37 changes: 23 additions & 14 deletions boost_py/simple.sh
Expand Up @@ -2,7 +2,18 @@
set -e
# Modified version of
# http://wiki.python.org/moin/boost.python/SimpleExample
#
# ----------------------------------------------------------------------
python_version=`ls /usr/include | grep python | sed -e 's/python//'`
system=`uname | sed -e s/\(......\).*/\1/`
if [ "$system" == "CYGWIN" ]
then
extra_compile="-Wl,--enable-auto-image-base"
library_extension=".dll"
else
extra_compile=""
library_extension=".so"
fi
# ----------------------------------------------------------------------
echo "cat << EOF > simple.cpp"
cat << EOF > simple.cpp
# include <string>
Expand All @@ -20,23 +31,21 @@ BOOST_PYTHON_MODULE(simple)
}
EOF
#
echo "gcc -I/usr/include/python2.6 -g -c simple.cpp"
gcc -I/usr/include/python2.6 -g -c simple.cpp
echo "gcc -I/usr/include/python$python_version -g -c simple.cpp"
gcc -I/usr/include/python$python_version -g -c simple.cpp
#
echo "g++ -shared \\"
echo " -Wl,--enable-auto-image-base \\"
echo "g++ -shared $extra_compile \\"
echo " -g \\"
echo " simple.o \\"
echo " -L/usr/lib -L/usr/lib/python2.6/config \\"
echo " -lboost_python-mt -lpython2.6 \\"
echo " -o simple.dll"
g++ -shared \
-Wl,--enable-auto-image-base \
echo " -L/usr/lib -L/usr/lib/python$python_version/config \\"
echo " -lboost_python-mt -lpython$python_version \\"
echo " -o simple$library_extension"
g++ -shared $extra_compile \
-g \
simple.o \
-L/usr/lib -L/usr/lib/python2.6/config \
-lboost_python-mt -lpython2.6 \
-o simple.dll
-L/usr/lib -L/usr/lib/python$python_version/config \
-lboost_python-mt -lpython$python_version \
-o simple$library_extension
#
echo "cat << EOF > simple.py"
cat << EOF > simple.py
Expand All @@ -58,7 +67,7 @@ if python simple.py
then
flag=0
echo "simple.sh: OK"
for ext in .cpp .o .dll .py
for ext in .cpp .o $library_extension .py
do
echo "rm simple$ext"
rm simple$ext
Expand Down

0 comments on commit 4787acd

Please sign in to comment.