0001-Add-minimal-support-for-enable-disable-shared-static.patch 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. From c349964887901848fb4cd5db53a5bcb6dae27aaa Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  3. Date: Sun, 23 Nov 2014 10:16:33 +0100
  4. Subject: [PATCH] Add minimal support for --{enable,disable}-{shared,static}
  5. mpdecimal uses autoconf, but not automake or libtool, so this commit
  6. adds some basic handling of --{enable,disable}-{shared,static}, so
  7. that building the shared library can be disabled in pure static
  8. library contexts.
  9. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  10. ---
  11. Makefile.in | 6 ++++++
  12. configure.ac | 13 +++++++++++++
  13. libmpdec/Makefile.in | 11 ++++++++++-
  14. 3 files changed, 29 insertions(+), 1 deletion(-)
  15. diff --git a/Makefile.in b/Makefile.in
  16. index 2c91891..0c44f36 100644
  17. --- a/Makefile.in
  18. +++ b/Makefile.in
  19. @@ -9,6 +9,8 @@ LIBSTATIC = @LIBSTATIC@
  20. LIBSONAME = @LIBSONAME@
  21. LIBSHARED = @LIBSHARED@
  22. INSTALL = @INSTALL@
  23. +BUILD_SHARED = @BUILD_SHARED@
  24. +BUILD_STATIC = @BUILD_STATIC@
  25. prefix = @prefix@
  26. exec_prefix = @exec_prefix@
  27. @@ -32,9 +34,13 @@ install: FORCE
  28. $(INSTALL) -d -m 755 $(DESTDIR)$(includedir)
  29. $(INSTALL) -m 644 libmpdec/mpdecimal.h $(DESTDIR)$(includedir)
  30. $(INSTALL) -d -m 755 $(DESTDIR)$(libdir)
  31. +ifeq ($(BUILD_STATIC),yes)
  32. $(INSTALL) -m 644 libmpdec/$(LIBSTATIC) $(DESTDIR)$(libdir)
  33. +endif
  34. +ifeq ($(BUILD_SHARED),yes)
  35. $(INSTALL) -m 755 libmpdec/$(LIBSHARED) $(DESTDIR)$(libdir)
  36. cd $(DESTDIR)$(libdir) && ln -sf $(LIBSHARED) $(LIBSONAME) && ln -sf $(LIBSHARED) $(LIBNAME)
  37. +endif
  38. $(INSTALL) -d -m 755 $(DESTDIR)$(docdir)
  39. cp -R doc/* $(DESTDIR)$(docdir)
  40. diff --git a/configure.ac b/configure.ac
  41. index 7ee8f86..2b3e505 100644
  42. --- a/configure.ac
  43. +++ b/configure.ac
  44. @@ -88,6 +88,19 @@ CFLAGS="$saved_cflags"
  45. AC_PROG_INSTALL
  46. AC_SUBST(INSTALL)
  47. +AC_ARG_ENABLE([shared],
  48. + [AS_HELP_STRING([--enable-shared], [build shared library])],
  49. + [BUILD_SHARED=$enableval],
  50. + [BUILD_SHARED=yes])
  51. +
  52. +AC_ARG_ENABLE([static],
  53. + [AS_HELP_STRING([--enable-static], [build static library])],
  54. + [BUILD_STATIC=$enableval],
  55. + [BUILD_STATIC=yes])
  56. +
  57. +AC_SUBST(BUILD_SHARED)
  58. +AC_SUBST(BUILD_STATIC)
  59. +
  60. # _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect:
  61. # http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html
  62. AC_MSG_CHECKING(for glibc _FORTIFY_SOURCE/memmove bug)
  63. diff --git a/libmpdec/Makefile.in b/libmpdec/Makefile.in
  64. index d9619a3..985c73c 100644
  65. --- a/libmpdec/Makefile.in
  66. +++ b/libmpdec/Makefile.in
  67. @@ -7,6 +7,8 @@
  68. LIBSTATIC = @LIBSTATIC@
  69. LIBSONAME = @LIBSONAME@
  70. LIBSHARED = @LIBSHARED@
  71. +BUILD_SHARED = @BUILD_SHARED@
  72. +BUILD_STATIC = @BUILD_STATIC@
  73. CC = @CC@
  74. LD = @LD@
  75. @@ -32,8 +34,15 @@ ifeq ($(MAKECMDGOALS), profile_use)
  76. MPD_LDFLAGS += $(MPD_PUSE)
  77. endif
  78. +ifeq ($(BUILD_SHARED),yes)
  79. +TARGETS += $(LIBSHARED)
  80. +endif
  81. +
  82. +ifeq ($(BUILD_STATIC),yes)
  83. +TARGETS += $(LIBSTATIC)
  84. +endif
  85. -default: $(LIBSTATIC) $(LIBSHARED)
  86. +default: $(TARGETS)
  87. OBJS := basearith.o context.o constants.o convolute.o crt.o mpdecimal.o \
  88. --
  89. 2.1.0