From f83c866a1f00445737d4a63e7dd6cbd09ed4034c Mon Sep 17 00:00:00 2001 From: "psyc://loupsycedyglgamf.onion/~lynX" Date: Tue, 16 Feb 2016 07:07:27 +0000 Subject: [PATCH] configure: detect gnunet and newer libpsyc --- src/autoconf/Makefile | 3 ++ src/autoconf/configure.in | 61 +++++++++++++++++++++++++++++++------ src/autoconf/test-gnunet.c | 12 ++++++++ src/autoconf/test-libpsyc.c | 10 ++++++ src/configure | 2 +- 5 files changed, 78 insertions(+), 10 deletions(-) create mode 100644 src/autoconf/test-gnunet.c create mode 100644 src/autoconf/test-libpsyc.c diff --git a/src/autoconf/Makefile b/src/autoconf/Makefile index b0e70ee..499622e 100644 --- a/src/autoconf/Makefile +++ b/src/autoconf/Makefile @@ -1,3 +1,6 @@ +CPPFLAGS=-I/usr/depot/include +LDFLAGS=-L/usr/depot/lib -lpsyc -lgnunetutil -lgnunetcadet + ../configure-do: configure.in configure.head Makefile autoreconf rm -f $@ diff --git a/src/autoconf/configure.in b/src/autoconf/configure.in index 29eecc6..a5e55c4 100644 --- a/src/autoconf/configure.in +++ b/src/autoconf/configure.in @@ -117,6 +117,7 @@ AC_MY_ARG_ENABLE(use-system-crypt,yes,,) AC_MY_ARG_ENABLE(udp-send,yes,,) AC_MY_ARG_ENABLE(use-ipv6,no,,[Enables support for IPv6]) AC_MY_ARG_ENABLE(use-alists,no,,[Enables alist support]) +AC_MY_ARG_ENABLE(use-gnunet,no,,[Enables GNUnet support]) AC_MY_ARG_ENABLE(use-psyc,no,,[Enables libpsyc support]) AC_MY_ARG_ENABLE(use-mccp,no,,[Enables MCCP support]) AC_MY_ARG_ENABLE(use-mysql,no,,[Enables mySQL support]) @@ -1214,9 +1215,48 @@ else enable_use_pthreads=no fi +# --- GNUnet --- + +echo "--- GNUnet" + +lp_cv_has_gnunet_lib="no" +AC_CHECK_LIB(gnunetcadet,main, lp_cv_has_gnunet_lib="yes") + +if test $lp_cv_has_gnunet_lib = yes; then + LIBS="-lgnunetutil -lgnunetcadet" + AC_CACHE_CHECK(for GNUnet crypto,lp_cv_has_gnunet, + AC_TRY_RUN([ +#include +#include +#include +#include +#include + +int main(void) { + const struct GNUNET_HashCode *hash = GC_u2h (4404); + const char* expect = "VFQCGVPZJJ6PHN5DQ6NWH1BJY3Q3SNF0BVCT2B1S4Q915SMYHDRW1X2BFTEEWXG9ZC23PVH3Y1W6D4DRKRTHV2CFGHAW66W52QGM0B8"; + printf( "u2h(4404) = %s ... ", GNUNET_h2s( hash ) ); + if (strcmp(expect, GNUNET_h2s_full( hash ))) return -1; + return 0; +} + ], + lp_cv_has_gnunet=yes, + lp_cv_has_gnunet=no + )) + CFLAGS="$saveflags" + + if test $lp_cv_has_gnunet = yes; then + AC_DEFINE(HAS_GNUNET, 1, [Does the machine offer GNUnet?]) + PKGLIBS="$PKGLIBS $LIBS" + echo ">>> Congrats! GNUnet CADET is available." + else + echo "GNUnet CADET not available on this system yet." + fi +fi + # --- libpsyc --- -echo "*** libpsyc" +echo "--- libpsyc" lp_cv_has_psyc_lib="no" AC_CHECK_LIB(psyc,main, lp_cv_has_psyc_lib="yes") @@ -1224,13 +1264,16 @@ AC_CHECK_LIB(psyc,main, lp_cv_has_psyc_lib="yes") # dont know why this fails on bsd, had to patch machine.h manually... FIXME if test $lp_cv_has_psyc_lib = yes; then LIBS="-lpsyc" - AC_CACHE_CHECK(for libpsyc usability,lp_cv_has_psyc, + AC_CACHE_CHECK(for libpsyc functionality,lp_cv_has_psyc, AC_TRY_RUN([ +#include #include int main(void) { - (void) psyc_version(); - return 0; + size_t tlen = 0; + const char *t = psyc_template(PSYC_MC_REQUEST_CONTEXT_ENTER, &tlen); + printf("%s ... ", t); + return PSYC_VERSION ? 0 : -1; } ], lp_cv_has_psyc=yes, @@ -1240,8 +1283,8 @@ int main(void) { if test $lp_cv_has_psyc = yes; then AC_DEFINE(HAS_PSYC, 1, [Does the machine offer libpsyc?]) - PKGLIBS="$PKGLIBS -lpsyc" - echo "Congrats! libpsyc is available on this system." + PKGLIBS="$PKGLIBS $LIBS" + echo ">>> Congrats! libpsyc is available on this system." else echo "libpsyc not available on this system yet." fi @@ -1256,7 +1299,7 @@ if test $lp_cv_has_pcre_lib = yes; then # saveflags="$CFLAGS" # CFLAGS="$CFLAGS -lpcre" LIBS="-lpcre" - AC_CACHE_CHECK(for PCRE usability,lp_cv_has_pcre, + AC_CACHE_CHECK(for PCRE functionality,lp_cv_has_pcre, AC_TRY_RUN([ #include @@ -1288,7 +1331,7 @@ fi # --- iconv --- -echo "*** libiconv" +echo "--- libiconv" # iconv in glibc 2.2.5 is broken - but not every system even # uses glibc. changequote(,)dnl @@ -1441,7 +1484,7 @@ if test "x$lp_cv_has_iconv_nonconst_in" = "xyes"; then fi # --- libidn --- -echo "*** libidn" +echo "--- libidn" AC_CHECK_HEADER(idna.h, lp_cv_has_idn=yes,lp_cv_has_idn=no) AC_CHECK_HEADER(stringprep.h, lp_cv_has_idn=yes,lp_cv_has_idn=no) diff --git a/src/autoconf/test-gnunet.c b/src/autoconf/test-gnunet.c new file mode 100644 index 0000000..65e3669 --- /dev/null +++ b/src/autoconf/test-gnunet.c @@ -0,0 +1,12 @@ +#include +#include +#include +#include +#include + +int main(void) { + const struct GNUNET_HashCode *hash = GC_u2h (4404); + puts( GNUNET_h2s_full( hash ) ); + return 0; +} + diff --git a/src/autoconf/test-libpsyc.c b/src/autoconf/test-libpsyc.c new file mode 100644 index 0000000..9c5d678 --- /dev/null +++ b/src/autoconf/test-libpsyc.c @@ -0,0 +1,10 @@ +#include +#include + +int main(void) { + size_t tlen = 0; + const char *t = psyc_template(PSYC_MC_REQUEST_CONTEXT_ENTER, &tlen); + puts(t); + return PSYC_VERSION ? 0 : -1; +} + diff --git a/src/configure b/src/configure index 3241443..9be6c29 100755 --- a/src/configure +++ b/src/configure @@ -6,4 +6,4 @@ if test ! -f "configure-do" ; then fi # then run it with psyced defaults -settings/psyced +settings/psyced $*