libnfc-build-systems-make-example-build-optional.patch 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. From 40a4871b171293d98acb40cf54be9ee9b78a3244 Mon Sep 17 00:00:00 2001
  2. From: Samuel Martin <s.martin49@gmail.com>
  3. Date: Wed, 6 Jun 2012 00:49:25 +0200
  4. Subject: [PATCH 1/1] build systems: make example build optional
  5. This patch makes example build optional for both cmake and autotools build
  6. systems.
  7. In order to keep the former behavior, example build is enabled by default.
  8. Signed-off-by: Samuel Martin <s.martin49@gmail.com>
  9. diff --git a/CMakeLists.txt b/CMakeLists.txt
  10. index dd7904d..0e35229 100644
  11. --- a/CMakeLists.txt
  12. +++ b/CMakeLists.txt
  13. @@ -27,6 +27,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/incl
  14. SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")
  15. # Options
  16. +SET(BUILD_EXAMPLES ON CACHE BOOL "Build examples")
  17. SET(LIBNFC_DEBUG_OUTPUT OFF CACHE BOOL "Debug output of communication with the NFC chip")
  18. IF(LIBNFC_DEBUG_OUTPUT)
  19. ADD_DEFINITIONS(-DDEBUG -g3)
  20. @@ -84,7 +85,7 @@ IF(NOT WIN32)
  21. ENDIF(LIBNFC_DRIVER_ACR122)
  22. # CMake lists are separated by a semi colon, replace with colon
  23. STRING(REPLACE ";" "," PKG_CONFIG_REQUIRES "${PKG_REQ}")
  24. - CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libnfc.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libnfc.pc @ONLY)
  25. + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libnfc.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libnfc.pc @ONLY)
  26. INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libnfc.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
  27. ENDIF(NOT WIN32)
  28. @@ -101,7 +102,10 @@ ENDIF(LIBUSB_INCLUDE_DIRS)
  29. ADD_SUBDIRECTORY(libnfc)
  30. ADD_SUBDIRECTORY(include)
  31. ADD_SUBDIRECTORY(utils)
  32. -ADD_SUBDIRECTORY(examples)
  33. +
  34. +IF(BUILD_EXAMPLES)
  35. + ADD_SUBDIRECTORY(examples)
  36. +ENDIF(BUILD_EXAMPLES)
  37. # Binary Package
  38. IF(WIN32)
  39. diff --git a/Makefile.am b/Makefile.am
  40. index 3671cb6..59fd75a 100644
  41. --- a/Makefile.am
  42. +++ b/Makefile.am
  43. @@ -2,7 +2,13 @@ ACLOCAL_AMFLAGS = -I m4
  44. AM_CFLAGS = $(LIBNFC_CFLAGS)
  45. -SUBDIRS = libnfc utils examples include contrib cmake test
  46. +SUBDIRS = libnfc utils
  47. +
  48. +if EXAMPLE_ENABLED
  49. +SUBDIRS += examples
  50. +endif
  51. +
  52. +SUBDIRS += include contrib cmake test
  53. pkgconfigdir = $(libdir)/pkgconfig
  54. pkgconfig_DATA = libnfc.pc
  55. diff --git a/configure.ac b/configure.ac
  56. index 0a222a8..6988164 100644
  57. --- a/configure.ac
  58. +++ b/configure.ac
  59. @@ -111,6 +111,14 @@ then
  60. fi
  61. AM_CONDITIONAL(DOC_ENABLED, [test x"$enable_doc" = xyes])
  62. +# Example build (default: yes)
  63. +AC_ARG_ENABLE([example],AS_HELP_STRING([--enable-example],[Enable example build.]),[enable_example=$enableval],[enable_example="yes"])
  64. +
  65. +AC_MSG_CHECKING(for example build)
  66. +AC_MSG_RESULT($enable_example)
  67. +
  68. +AM_CONDITIONAL(EXAMPLE_ENABLED, [test x"$enable_example" = xyes])
  69. +
  70. # Dependencies
  71. PKG_CONFIG_REQUIRES=""
  72. @@ -129,7 +137,11 @@ if test x$ac_cv_with_cutter = xyes -a x$ac_cv_use_cutter = xno; then
  73. fi
  74. AM_CONDITIONAL([WITH_CUTTER], [test "$ac_cv_use_cutter" != "no"])
  75. +
  76. +if test x"$enable_example" = "xyes"
  77. +then
  78. AC_CHECK_READLINE
  79. +fi
  80. # Help us to write great code ;-)
  81. CFLAGS="$CFLAGS -Wall -pedantic -Wextra"
  82. --
  83. 1.7.10.3