From 7d76d41944d4f331a0063b1933e567a0638ab1f9 Mon Sep 17 00:00:00 2001 From: TLINDEN Date: Sun, 14 Dec 2014 14:39:10 +0100 Subject: [PATCH] added configure flag --with-python-binding --- autogen.sh | 6 ++++++ bindings/py/Makefile.am | 2 +- configure.ac | 19 +++++++++++++++++++ include/pcp.h | 1 + man/pcp1.1 | 2 +- tests/sample.c | 4 +++- 6 files changed, 31 insertions(+), 3 deletions(-) diff --git a/autogen.sh b/autogen.sh index 6135234..22bf868 100755 --- a/autogen.sh +++ b/autogen.sh @@ -59,6 +59,12 @@ Pretty Curved Privacy - File encryption using eliptic curve cryptography. # generate usage.h (cd src && ./usage.sh) + # generate pypcp types + bindings/py/gencffi.pl include/pcp/defines.h include/pcp/structs.h include/pcp/key.h \ + include/pcp/buffer.h include/pcp/context.h include/pcp/mac.h \ + include/pcp/ed.h include/pcp/crypto.h include/pcp/vault.h \ + include/pcp/pcpstream.h include/pcp/z85.h > bindings/py/pypcp/raw.py + exit fi diff --git a/bindings/py/Makefile.am b/bindings/py/Makefile.am index 6cae2fc..6739383 100644 --- a/bindings/py/Makefile.am +++ b/bindings/py/Makefile.am @@ -5,4 +5,4 @@ install: python setup.py install clean: - rm -rf build \ No newline at end of file + rm -rf build pypcp/*.pyc \ No newline at end of file diff --git a/configure.ac b/configure.ac index 09879bc..ae26128 100755 --- a/configure.ac +++ b/configure.ac @@ -294,8 +294,27 @@ fi CFLAGS="$CFLAGS -Werror -Wextra -O2" CXXFLAGS="$CFLAGS" +AC_ARG_WITH([python-binding], + [AS_HELP_STRING([--with-python-binding], + [Enable python binding])], + [python="yes"], + []) + + + AC_SUBST(PACKAGE_VERSION) # Specify output files AC_CONFIG_FILES([Makefile include/Makefile libpcp/Makefile src/Makefile man/Makefile tests/Makefile libpcp/libpcp1.pc bindings/cpp/Makefile]) + + +if test "x$python" = "xyes"; then + if python -c "import cffi" > /dev/null 2>&1; then + AC_CONFIG_FILES([bindings/py/Makefile]) + else + AC_MSG_ERROR([python or cffi is not installed]) + fi +fi + + AC_OUTPUT diff --git a/include/pcp.h b/include/pcp.h index b9881a9..45255d0 100644 --- a/include/pcp.h +++ b/include/pcp.h @@ -8,6 +8,7 @@ extern "C" { #include "pcp/config.h" #include "pcp/base85.h" #include "pcp/buffer.h" +#include "pcp/config.h" #include "pcp/context.h" #include "pcp/crypto.h" #include "pcp/defines.h" diff --git a/man/pcp1.1 b/man/pcp1.1 index d8442b2..7f87623 100644 --- a/man/pcp1.1 +++ b/man/pcp1.1 @@ -124,7 +124,7 @@ .\" ======================================================================== .\" .IX Title "PCP1 1" -.TH PCP1 1 "2014-09-29" "PCP 0.2.3" "USER CONTRIBUTED DOCUMENTATION" +.TH PCP1 1 "2014-12-14" "PCP 0.2.3" "USER CONTRIBUTED DOCUMENTATION" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l diff --git a/tests/sample.c b/tests/sample.c index db42b3d..179c5cf 100644 --- a/tests/sample.c +++ b/tests/sample.c @@ -7,7 +7,7 @@ int main() { Pcpstream *clear_in, *crypt_out, *clear_out; PCPCTX *ptx; char message[] = "hello world"; - + printf("hh: %ld\n", sizeof(UT_hash_handle)); /* we always need a context */ ptx = ptx_new(); @@ -15,6 +15,8 @@ int main() { alice = pcpkey_new(); bob = pcpkey_new(); + pcpkey_setowner(alice, "alicia", "alicia@local"); + /* get the public parts of them */ alicepub = pcpkey_pub_from_secret(alice); bobpub = pcpkey_pub_from_secret(bob);