From d0a93670177f2b7691cc86d516e1576d05dc6547 Mon Sep 17 00:00:00 2001 From: Geremia Date: Sat, 27 Feb 2016 23:56:29 -0700 Subject: [PATCH 1/2] "make example" builds example.c if libgcrypt present using AM_PATH_LIBGCRYPT to check for libgcrypt removed AC_MSG_RESULT in configure.ac; added phony "example" target in Makefile.am if libcrypt not found --- Makefile.am | 11 +++++++++++ README | 3 ++- configure.ac | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 578acab..209262f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -50,3 +50,14 @@ dist_noinst_DATA = \ AUTHORS COPYING README \ example.c \ testinput.c + +if CAN_COMPILE_EXAMPLE +EXTRA_PROGRAMS = example +example_SOURCES = example.c +example_LDADD = libblkmaker-$(LIBBLKMAKER_API_VERSION).la libblkmaker_jansson-$(LIBBLKMAKER_API_VERSION).la $(LIBGCRYPT_LIBS) +example_CFLAGS = $(LIBGCRYPT_CFLAGS) +else +example: + @echo "libgcrypt is required to build the example, but was not found" +.PHONY: example +endif diff --git a/README b/README index 1f6f5bf..7c412f1 100644 --- a/README +++ b/README @@ -5,7 +5,8 @@ Example dependencies: Jansson 2.1 (to read JSON from stdin) libgcrypt (for SHA256) -For usage, check out example.c +For usage, check out example.c. Run "make example" to build it. + Note that you must assign blkmk_sha256_impl to a function pointer: bool mysha256(void *hash_out, const void *data, size_t datasz) hash_out must be able to overlap with data! diff --git a/configure.ac b/configure.ac index 67e3d9e..633105c 100644 --- a/configure.ac +++ b/configure.ac @@ -51,4 +51,18 @@ PKG_CHECK_MODULES([libbase58],[libbase58]) AC_CHECK_LIB([ws2_32], [strchr]) +#libgcrypt necessary to build example.c with "make example" +#check for libgcrypt: +m4_ifdef([AM_PATH_LIBGCRYPT], [ + AM_PATH_LIBGCRYPT([], + [ + [can_compile_example=yes] + ],[ + [compile_example=no] + ]) +],[ + m4_warn([syntax], [AM_PATH_LIBGCRYPT missing; CLI tool will not be available]) +]) +AM_CONDITIONAL([CAN_COMPILE_EXAMPLE], [test x$can_compile_example = xyes]) + AC_OUTPUT From 2d822c6bbc81c24aa2ace77fff2a71f435b26e4b Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 26 Jul 2016 03:20:08 +0000 Subject: [PATCH 2/2] Minor fixups for "make example" --- configure.ac | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 633105c..4671ca7 100644 --- a/configure.ac +++ b/configure.ac @@ -51,17 +51,17 @@ PKG_CHECK_MODULES([libbase58],[libbase58]) AC_CHECK_LIB([ws2_32], [strchr]) -#libgcrypt necessary to build example.c with "make example" -#check for libgcrypt: +dnl libgcrypt necessary to build example.c with "make example" +dnl check for libgcrypt: m4_ifdef([AM_PATH_LIBGCRYPT], [ AM_PATH_LIBGCRYPT([], [ - [can_compile_example=yes] + can_compile_example=yes ],[ - [compile_example=no] + can_compile_example=no ]) ],[ - m4_warn([syntax], [AM_PATH_LIBGCRYPT missing; CLI tool will not be available]) + m4_warn([syntax], [AM_PATH_LIBGCRYPT missing; example will not be available]) ]) AM_CONDITIONAL([CAN_COMPILE_EXAMPLE], [test x$can_compile_example = xyes])