From 04d29d0b890e07b7dcf53468710d0d96cb94353d Mon Sep 17 00:00:00 2001 From: gombasg Date: Mon, 26 Oct 2009 11:23:05 +0000 Subject: [PATCH] Modernize the DC-API autoconf macros Fix static linking for the client side Allow the caller to specify the actions when the client/master is found or not found git-svn-id: svn+ssh://cvs.lpds.sztaki.hu/var/lib/svn/szdg/dcapi/trunk@2278 a7169a2c-3604-0410-bc95-c702d8d87f7a --- dcapi/Makefile.am | 2 +- dcapi/cf/dcapi.m4 | 56 --------- dcapi/configure.ac | 1 - dcapi/dcapi.m4 | 109 ++++++++++++++++++ dcapi/examples/message-example/configure.ac | 8 +- dcapi/examples/message-example/dcapi.m4 | 53 --------- dcapi/examples/serialize-example/configure.ac | 8 +- dcapi/examples/serialize-example/dcapi.m4 | 53 --------- .../uppercase-with-callback/configure.ac | 8 +- .../examples/uppercase-with-callback/dcapi.m4 | 53 --------- 10 files changed, 119 insertions(+), 232 deletions(-) delete mode 100644 dcapi/cf/dcapi.m4 create mode 100644 dcapi/dcapi.m4 delete mode 100644 dcapi/examples/message-example/dcapi.m4 delete mode 100644 dcapi/examples/serialize-example/dcapi.m4 delete mode 100644 dcapi/examples/uppercase-with-callback/dcapi.m4 diff --git a/dcapi/Makefile.am b/dcapi/Makefile.am index 298cfedd87..7769f7c038 100644 --- a/dcapi/Makefile.am +++ b/dcapi/Makefile.am @@ -22,4 +22,4 @@ SUBDIRS += java endif aclocaldir = $(datadir)/aclocal -dist_aclocal_DATA = cf/dcapi.m4 +dist_aclocal_DATA = dcapi.m4 diff --git a/dcapi/cf/dcapi.m4 b/dcapi/cf/dcapi.m4 deleted file mode 100644 index 12eb4c7413..0000000000 --- a/dcapi/cf/dcapi.m4 +++ /dev/null @@ -1,56 +0,0 @@ -dnl -dnl SZDG_DCAPI -dnl -dnl Check for the Distributed Computing Platform development files -dnl - -AC_DEFUN([_SZDG_DCAPI_COMMON], [ - AC_ARG_WITH([dcapi_flavor], AS_HELP_STRING([--with-dcapi-flavor], - [DCAPI flavor to use @<:@boinc@:>@]),, - [with_dcapi_flavor=boinc]) - PKG_PROG_PKG_CONFIG([0.17]) -]) - -AC_DEFUN([SZDG_DCAPI_CLIENT], [ - AC_REQUIRE([_SZDG_DCAPI_COMMON]) - - PKG_CHECK_MODULES([DCAPI_CLIENT], [dcapi-${with_dcapi_flavor}-client],, - [AC_MSG_ERROR([DC-API client implementation not found])]) - dnl We want to link the client libs statically - dnl XXX We should check if -Wl actually works - DCAPI_CLIENT_LIBS="-Wl,-Bstatic $DCAPI_CLIENT_LIBS -Wl,-Bdynamic" - - save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $DCAPI_CLIENT_CFLAGS" - save_LIBS="$LIBS" - LIBS="$LIBS $DCAPI_CLIENT_LIBS" - AC_CHECK_HEADERS([dc_client.h], [], - [AC_MSG_ERROR([DC-API client headers are missing or unusable])]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[(void)DC_initClient()]])], - [true], - [AC_MSG_ERROR([DC-API client libraries are missing or unusable])]) - CPPFLAGS="$save_CPPFLAGS" - LIBS="$save_LIBS" -]) - -AC_DEFUN([SZDG_DCAPI_MASTER], [ - AC_REQUIRE([_SZDG_DCAPI_COMMON]) - - PKG_CHECK_MODULES([DCAPI_MASTER], [dcapi-${with_dcapi_flavor}-master],, - [AC_MSG_ERROR([DC-API master implementation not found])]) - - dnl Minimal check to see if the headers are usable - save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $DCAPI_MASTER_CFLAGS" - save_LIBS="$LIBS" - LIBS="$LIBS $DCAPI_MASTER_LIBS" - AC_CHECK_HEADERS([dc.h], [], - [AC_MSG_ERROR([DC-API master headers are missing or unusable])]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[(void)DC_initMaster((char *)0)]])], - [true], - [AC_MSG_ERROR([DC-API master libraries are missing or unusable])]) - CPPFLAGS="$save_CPPFLAGS" - LIBS="$save_LIBS" -]) diff --git a/dcapi/configure.ac b/dcapi/configure.ac index 8b943370e4..166ea7c553 100644 --- a/dcapi/configure.ac +++ b/dcapi/configure.ac @@ -7,7 +7,6 @@ AM_INIT_AUTOMAKE([foreign]) AC_PROG_CC AC_PROG_CXX -dnl AC_DISABLE_SHARED AC_PROG_LIBTOOL LIBTOOL="$LIBTOOL --silent" diff --git a/dcapi/dcapi.m4 b/dcapi/dcapi.m4 new file mode 100644 index 0000000000..535c263055 --- /dev/null +++ b/dcapi/dcapi.m4 @@ -0,0 +1,109 @@ +dnl +dnl SZDG_DCAPI +dnl +dnl Check for the Distributed Computing Platform development files +dnl + +AC_DEFUN([_SZDG_DCAPI_COMMON], [ + AC_ARG_WITH([dcapi_flavor], AS_HELP_STRING([--with-dcapi-flavor], + [DCAPI flavor to use @<:@boinc@:>@]),, + [with_dcapi_flavor=boinc]) + PKG_PROG_PKG_CONFIG([0.17]) +]) + +dnl +dnl Check for DC-API client libraries. +dnl +dnl Usage: SZDG_DCAPI_CLIENT([ACTION-IF-FOIND], [ACTION-IF-NOT-FOUND]) +dnl +AC_DEFUN([SZDG_DCAPI_CLIENT], [ + AC_REQUIRE([_SZDG_DCAPI_COMMON]) + + DCAPI_CLIENT_LIBS= + DCAPI_CLIENT_CFLAGS= + + AC_MSG_CHECKING([for DCAPI_CLIENT]) + PKG_CHECK_EXISTS([dcapi-${with_dcapi_flavor}-client], + [dcapi_client=yes], + [dcapi_client=no]) + AC_MSG_RESULT([$dcapi_client]) + if test "$dcapi_client" != no; then + DCAPI_CLIENT_LIBS=`pkg-config --libs --static dcapi-${with_dcapi_flavor}-client` + DCAPI_CLIENT_CPPFLAGS=`pkg-config --cflags dcapi-${with_dcapi_flavor}-client` + + DCAPI_CLIENT_LIBS="-Wl,-Bstatic $DCAPI_CLIENT_LIBS -Wl,-Bdynamic" + + save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $DCAPI_CLIENT_CFLAGS" + save_LIBS="$LIBS" + LIBS="$LIBS $DCAPI_CLIENT_LIBS" + AC_LANG_PUSH([C]) + AC_CHECK_HEADERS([dc_client.h], [], [dcapi_client=no]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[(void)DC_initClient()]])], + [true], + [dcapi_client=no]) + AC_LANG_POP([C]) + CPPFLAGS="$save_CPPFLAGS" + LIBS="$save_LIBS" + fi + + AC_SUBST([DCAPI_CLIENT_LIBS]) + AC_SUBST([DCAPI_CLIENT_CFLAGS]) + + dnl Backward compatibility: produce an error if the above tests fail + dnl and both $1 and $2 are empty + m4_ifblank([$1], [m4_ifblank([$2], + if test "$dcapi_client" != yes; then + AC_MSG_ERROR([DC-API client libraries were not found]) + fi)]) + + if test "$dcapi_client" = yes; then + m4_ifblank([$1], [:], [$1]) + m4_ifnblank([$2],[else + $2]) + fi +]) + +dnl +dnl Check for DC-API master libraries. +dnl +dnl Usage: SZDG_DCAPI_MASTER([ACTION-IF-FOIND], [ACTION-IF-NOT-FOUND]) +dnl +AC_DEFUN([SZDG_DCAPI_MASTER], [ + AC_REQUIRE([_SZDG_DCAPI_COMMON]) + + PKG_CHECK_MODULES([DCAPI_MASTER], + [dcapi-${with_dcapi_flavor}-master], + [dcapi_master=yes], + [dcapi_master=no]) + + if test "$dcapi_master" != no; then + save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $DCAPI_MASTER_CFLAGS" + save_LIBS="$LIBS" + LIBS="$LIBS $DCAPI_MASTER_LIBS" + AC_LANG_PUSH([C]) + AC_CHECK_HEADERS([dc.h], [], [dcapi_master=no]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[(void)DC_initMaster((char *)0)]])], + [true], + [dcapi_master=no]) + AC_LANG_POP([C]) + CPPFLAGS="$save_CPPFLAGS" + LIBS="$save_LIBS" + fi + + dnl Backward compatibility: produce an error if the above tests fail + dnl and both $1 and $2 are empty + m4_ifblank([$1], [m4_ifblank([$2], + if test "$dcapi_master" != yes; then + AC_MSG_ERROR([DC-API master libraries were not found]) + fi)]) + + if test "$dcapi_master" = yes; then + m4_ifblank([$1], [:], [$1]) + m4_ifnblank([$2],[else + $2]) + fi +]) diff --git a/dcapi/examples/message-example/configure.ac b/dcapi/examples/message-example/configure.ac index 9885506846..666c0efc50 100644 --- a/dcapi/examples/message-example/configure.ac +++ b/dcapi/examples/message-example/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([Message Passing Example Application], [5.01], [desktopgrid@lpds.sztaki.hu], [message-example]) +AC_INIT([Message Passing Example Application], [6.00], [desktopgrid@lpds.sztaki.hu], [message-example]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_SRCDIR([client.c]) @@ -24,13 +24,11 @@ AM_CONDITIONAL([BUILD_CLIENT], [test "$enable_client" = yes]) AM_CONDITIONAL([BUILD_MASTER], [test "$enable_master" = yes]) if test "$enable_client" = yes; then - SZDG_DCAPI_CLIENT - AC_MSG_NOTICE([will build client]) + SZDG_DCAPI_CLIENT([], [AC_MSG_ERROR([DC-API client libraries were not found])]) fi if test "$enable_master" = yes; then - SZDG_DCAPI_MASTER - AC_MSG_NOTICE([will build master]) + SZDG_DCAPI_MASTER([], [AC_MSG_ERROR([DC-API master libraries were not found])]) fi AC_CONFIG_FILES([Makefile]) diff --git a/dcapi/examples/message-example/dcapi.m4 b/dcapi/examples/message-example/dcapi.m4 deleted file mode 100644 index 1d7a4bf4e1..0000000000 --- a/dcapi/examples/message-example/dcapi.m4 +++ /dev/null @@ -1,53 +0,0 @@ -dnl -dnl SZDG_DCAPI -dnl -dnl Check for the Distributed Computing Platform development files -dnl - -AC_DEFUN([_SZDG_DCAPI_COMMON], [ - AC_ARG_WITH([dcapi_flavor], AS_HELP_STRING([--with-dcapi-flavor], - [DCAPI flavor to use @<:@boinc@:>@]),, - [with_dcapi_flavor=boinc]) - PKG_PROG_PKG_CONFIG([0.17]) -]) - -AC_DEFUN([SZDG_DCAPI_CLIENT], [ - AC_REQUIRE([_SZDG_DCAPI_COMMON]) - - PKG_CHECK_MODULES([DCAPI_CLIENT], [dcapi-${with_dcapi_flavor}-client],, - [AC_MSG_ERROR([DC-API client implementation not found])]) - - save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $DCAPI_CLIENT_CFLAGS" - save_LIBS="$LIBS" - LIBS="$LIBS $DCAPI_CLIENT_LIBS" - AC_CHECK_HEADERS([dc_client.h], [], - [AC_MSG_ERROR([DC-API client headers are missing or unusable])]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[(void)DC_initClient()]])], - [true], - [AC_MSG_ERROR([DC-API client libraries are missing or unusable])]) - CPPFLAGS="$save_CPPFLAGS" - LIBS="$save_LIBS" -]) - -AC_DEFUN([SZDG_DCAPI_MASTER], [ - AC_REQUIRE([_SZDG_DCAPI_COMMON]) - - PKG_CHECK_MODULES([DCAPI_MASTER], [dcapi-${with_dcapi_flavor}-master],, - [AC_MSG_ERROR([DC-API master implementation not found])]) - - dnl Minimal check to see if the headers are usable - save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $DCAPI_MASTER_CFLAGS" - save_LIBS="$LIBS" - LIBS="$LIBS $DCAPI_MASTER_LIBS" - AC_CHECK_HEADERS([dc.h], [], - [AC_MSG_ERROR([DC-API master headers are missing or unusable])]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[(void)DC_initMaster((char *)0)]])], - [true], - [AC_MSG_ERROR([DC-API master libraries are missing or unusable])]) - CPPFLAGS="$save_CPPFLAGS" - LIBS="$save_LIBS" -]) diff --git a/dcapi/examples/serialize-example/configure.ac b/dcapi/examples/serialize-example/configure.ac index 5c6e4870ec..b48c6cf9b2 100644 --- a/dcapi/examples/serialize-example/configure.ac +++ b/dcapi/examples/serialize-example/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([Example Application for master checkpoint], [5.01], [desktopgrid@lpds.sztaki.hu], [serialize-example]) +AC_INIT([Example Application for master checkpoint], [6.00], [desktopgrid@lpds.sztaki.hu], [serialize-example]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_SRCDIR([client.c]) @@ -24,13 +24,11 @@ AM_CONDITIONAL([BUILD_CLIENT], [test "$enable_client" = yes]) AM_CONDITIONAL([BUILD_MASTER], [test "$enable_master" = yes]) if test "$enable_client" = yes; then - SZDG_DCAPI_CLIENT - AC_MSG_NOTICE([will build client]) + SZDG_DCAPI_CLIENT([], [AC_MSG_ERROR([DC-API client libraries were not found])]) fi if test "$enable_master" = yes; then - SZDG_DCAPI_MASTER - AC_MSG_NOTICE([will build master]) + SZDG_DCAPI_MASTER([], [AC_MSG_ERROR([DC-API master libraries were not found])]) fi AC_CONFIG_FILES([Makefile]) diff --git a/dcapi/examples/serialize-example/dcapi.m4 b/dcapi/examples/serialize-example/dcapi.m4 deleted file mode 100644 index 1d7a4bf4e1..0000000000 --- a/dcapi/examples/serialize-example/dcapi.m4 +++ /dev/null @@ -1,53 +0,0 @@ -dnl -dnl SZDG_DCAPI -dnl -dnl Check for the Distributed Computing Platform development files -dnl - -AC_DEFUN([_SZDG_DCAPI_COMMON], [ - AC_ARG_WITH([dcapi_flavor], AS_HELP_STRING([--with-dcapi-flavor], - [DCAPI flavor to use @<:@boinc@:>@]),, - [with_dcapi_flavor=boinc]) - PKG_PROG_PKG_CONFIG([0.17]) -]) - -AC_DEFUN([SZDG_DCAPI_CLIENT], [ - AC_REQUIRE([_SZDG_DCAPI_COMMON]) - - PKG_CHECK_MODULES([DCAPI_CLIENT], [dcapi-${with_dcapi_flavor}-client],, - [AC_MSG_ERROR([DC-API client implementation not found])]) - - save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $DCAPI_CLIENT_CFLAGS" - save_LIBS="$LIBS" - LIBS="$LIBS $DCAPI_CLIENT_LIBS" - AC_CHECK_HEADERS([dc_client.h], [], - [AC_MSG_ERROR([DC-API client headers are missing or unusable])]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[(void)DC_initClient()]])], - [true], - [AC_MSG_ERROR([DC-API client libraries are missing or unusable])]) - CPPFLAGS="$save_CPPFLAGS" - LIBS="$save_LIBS" -]) - -AC_DEFUN([SZDG_DCAPI_MASTER], [ - AC_REQUIRE([_SZDG_DCAPI_COMMON]) - - PKG_CHECK_MODULES([DCAPI_MASTER], [dcapi-${with_dcapi_flavor}-master],, - [AC_MSG_ERROR([DC-API master implementation not found])]) - - dnl Minimal check to see if the headers are usable - save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $DCAPI_MASTER_CFLAGS" - save_LIBS="$LIBS" - LIBS="$LIBS $DCAPI_MASTER_LIBS" - AC_CHECK_HEADERS([dc.h], [], - [AC_MSG_ERROR([DC-API master headers are missing or unusable])]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[(void)DC_initMaster((char *)0)]])], - [true], - [AC_MSG_ERROR([DC-API master libraries are missing or unusable])]) - CPPFLAGS="$save_CPPFLAGS" - LIBS="$save_LIBS" -]) diff --git a/dcapi/examples/uppercase-with-callback/configure.ac b/dcapi/examples/uppercase-with-callback/configure.ac index e86cf7598c..956aae849c 100644 --- a/dcapi/examples/uppercase-with-callback/configure.ac +++ b/dcapi/examples/uppercase-with-callback/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([Uppercase Example Application], [5.01], [desktopgrid@lpds.sztaki.hu], [uppercase-example]) +AC_INIT([Uppercase Example Application], [6.00], [desktopgrid@lpds.sztaki.hu], [uppercase-example]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_SRCDIR([client.c]) @@ -24,13 +24,11 @@ AM_CONDITIONAL([BUILD_CLIENT], [test "$enable_client" = yes]) AM_CONDITIONAL([BUILD_MASTER], [test "$enable_master" = yes]) if test "$enable_client" = yes; then - SZDG_DCAPI_CLIENT - AC_MSG_NOTICE([will build client]) + SZDG_DCAPI_CLIENT([], [AC_MSG_ERROR([DC-API client libraries were not found])]) fi if test "$enable_master" = yes; then - SZDG_DCAPI_MASTER - AC_MSG_NOTICE([will build master]) + SZDG_DCAPI_MASTER([], [AC_MSG_ERROR([DC-API master libraries were not found])]) fi AC_CONFIG_FILES([Makefile]) diff --git a/dcapi/examples/uppercase-with-callback/dcapi.m4 b/dcapi/examples/uppercase-with-callback/dcapi.m4 deleted file mode 100644 index 1d7a4bf4e1..0000000000 --- a/dcapi/examples/uppercase-with-callback/dcapi.m4 +++ /dev/null @@ -1,53 +0,0 @@ -dnl -dnl SZDG_DCAPI -dnl -dnl Check for the Distributed Computing Platform development files -dnl - -AC_DEFUN([_SZDG_DCAPI_COMMON], [ - AC_ARG_WITH([dcapi_flavor], AS_HELP_STRING([--with-dcapi-flavor], - [DCAPI flavor to use @<:@boinc@:>@]),, - [with_dcapi_flavor=boinc]) - PKG_PROG_PKG_CONFIG([0.17]) -]) - -AC_DEFUN([SZDG_DCAPI_CLIENT], [ - AC_REQUIRE([_SZDG_DCAPI_COMMON]) - - PKG_CHECK_MODULES([DCAPI_CLIENT], [dcapi-${with_dcapi_flavor}-client],, - [AC_MSG_ERROR([DC-API client implementation not found])]) - - save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $DCAPI_CLIENT_CFLAGS" - save_LIBS="$LIBS" - LIBS="$LIBS $DCAPI_CLIENT_LIBS" - AC_CHECK_HEADERS([dc_client.h], [], - [AC_MSG_ERROR([DC-API client headers are missing or unusable])]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[(void)DC_initClient()]])], - [true], - [AC_MSG_ERROR([DC-API client libraries are missing or unusable])]) - CPPFLAGS="$save_CPPFLAGS" - LIBS="$save_LIBS" -]) - -AC_DEFUN([SZDG_DCAPI_MASTER], [ - AC_REQUIRE([_SZDG_DCAPI_COMMON]) - - PKG_CHECK_MODULES([DCAPI_MASTER], [dcapi-${with_dcapi_flavor}-master],, - [AC_MSG_ERROR([DC-API master implementation not found])]) - - dnl Minimal check to see if the headers are usable - save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $DCAPI_MASTER_CFLAGS" - save_LIBS="$LIBS" - LIBS="$LIBS $DCAPI_MASTER_LIBS" - AC_CHECK_HEADERS([dc.h], [], - [AC_MSG_ERROR([DC-API master headers are missing or unusable])]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[(void)DC_initMaster((char *)0)]])], - [true], - [AC_MSG_ERROR([DC-API master libraries are missing or unusable])]) - CPPFLAGS="$save_CPPFLAGS" - LIBS="$save_LIBS" -])