Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Let PyCrypto build on FreeBSD.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Pierre Flori committed Dec 25, 2013
1 parent 036984d commit 528d988
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 42 deletions.
7 changes: 6 additions & 1 deletion build/pkgs/pycrypto/SPKG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@ Python 2.2 license.

== Special Update/Build Instructions ==

* None
=== Patches ===

* freebsd.patch: let pycrypto build on FreeBSD.

== Changelog ==

=== pycrypto-2.1.0.p0 (Jean-Pierre Flori, 4 July 2013) ===
* #12399: Let pycrypto build on FreeBSD.

=== pycrypto-2.1.0 (Minh Van Nguyen, June 26th, 2010) ===

* Ticket #9338; upgrade to PyCrypto 2.1.0.
Expand Down
2 changes: 1 addition & 1 deletion build/pkgs/pycrypto/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0
2.1.0.p0
13 changes: 13 additions & 0 deletions build/pkgs/pycrypto/patches/freebsd.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- src/src/libtom/tomcrypt_pk.h-orig 2012-01-21
19:43:56.000000000 +0000
+++ src/src/libtom/tomcrypt_pk.h 2012-01-21
19:45:01.000000000 +0000
@@ -496,7 +496,7 @@
int der_printable_value_decode(int v);

/* UTF-8 */
-#if (defined(SIZE_MAX) || __STDC_VERSION__ >= 199901L || defined(WCHAR_MAX) || defined(_WCHAR_T) || defined(_WCHAR_T_DEFINED)) && !defined(LTC_NO_WCHAR)
+#if (defined(SIZE_MAX) || __STDC_VERSION__ >= 199901L || defined(WCHAR_MAX) || defined(_WCHAR_T) || defined(_WCHAR_T_DEFINED) || defined(_GCC_WCHAR_T)) && !defined(LTC_NO_WCHAR)
#include <wchar.h>
#else
typedef ulong32 wchar_t;
33 changes: 4 additions & 29 deletions build/pkgs/pycrypto/spkg-check
Original file line number Diff line number Diff line change
@@ -1,41 +1,16 @@
#!/usr/bin/env bash

if [ -z $SAGE_LOCAL ]; then
echo "SAGE_LOCAL undefined... exiting"
echo "Maybe run 'sage -sh'?"
if [ -z "$SAGE_LOCAL" ]; then
echo >&2 "SAGE_LOCAL undefined ... exiting"
echo >&2 "Maybe run 'sage --sh'?"
exit 1
fi

# Let the user set an environment variable CFLAG64 to indicate the flag
# for the C compiler to build 64-bit code. If not set, assume it is -m64
# as that is what is used by both GCC and SunStudio, but -m64 is not used
# by IBM's compiler on AIX or HP's compiler on HP-UX.

if [ -z $CFLAG64 ]; then
# -m64 is used by gcc and SunStudio
CFLAG64=-m64
fi

# Likewise to build C++ code.
if [ -z $CXXFLAG64 ]; then
# -m64 is used by gcc and SunStudio
CXXFLAG64=-m64
fi

if [ "x$SAGE64" = xyes ]; then
CFLAGS="$CFLAGS $CFLAG64" && export CFLAGS
CXXFLAGS="$CXXFLAGS $CXXFLAG64" && export CXXFLAGS
LDFLAGS="$LDFLAGS $CFLAG64" && export LDFLAGS
# Very rare is CPPFLAGS needed, but sometimes it is.
CPPFLAGS="$CPPFLAGS $CFLAG64" && export CPPFLAGS
fi

cd src

echo "PyCrypto will now be tested"
python setup.py test

if [ $? -ne 0 ]; then
echo "An error occurred while testing PyCrypto... exiting"
echo >&2 "Error: PyCrypto failed to pass its test suite."
exit 1
fi
39 changes: 28 additions & 11 deletions build/pkgs/pycrypto/spkg-install
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
#!/usr/bin/env bash

if [ "$SAGE_LOCAL" = "" ]; then
echo "SAGE_LOCAL undefined... exiting"
echo "Maybe run 'sage -sh'?"
if [ -z "$SAGE_LOCAL" ]; then
echo >&2 "SAGE_LOCAL undefined ... exiting"
echo >&2 "Maybe run 'sage --sh'?"
exit 1
fi

if [ "x$SAGE64" = xyes ]; then
echo "64-bit build"
CFLAGS="-O2 -g -m64 "; export CFLAGS
LDFLAGS="-m64 "; export LDFLAGS
cd src

# Apply patches. See SPKG.txt for information about what each patch
# does.
for patch in ../patches/*.patch; do
[ -r "$patch" ] || continue # Skip non-existing or non-readable patches
patch -p1 <"$patch"
if [ $? -ne 0 ]; then
echo >&2 "Error applying '$patch'"
exit 1
fi
done

if [ "$SAGE_DEBUG" = "yes" ]; then
echo "Building a debug version of PyCrypto."
export CFLAGS="-O0 -g $CFLAGS"
else
export CFLAGS="-O2 -g $CFLAGS"
fi

CFLAGS="-I$SAGE_LOCAL/include -L$SAGE_LOCAL/lib $CFLAGS"
export CFLAGS
if [ "$SAGE64" = "yes" ]; then
echo "Building a 64-bit version of PyCrypto."
export ABI=64
CFLAGS="-m64 $CFLAGS"
fi

cd src
CFLAGS="-I$SAGE_LOCAL/include -L$SAGE_LOCAL/lib $CFLAGS"

python setup.py install
if [ $? -ne 0 ]; then
echo "Error installing PyCrypto... exiting"
echo >&2 "Error: Failed to install PyCrypto."
exit 1
fi

0 comments on commit 528d988

Please sign in to comment.