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}
6 mpdecimal uses autoconf, but not automake or libtool, so this commit
7 adds some basic handling of --{enable,disable}-{shared,static}, so
8 that building the shared library can be disabled in pure static
11 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
13 Makefile.in | 6 ++++++
14 configure.ac | 13 +++++++++++++
15 libmpdec/Makefile.in | 11 ++++++++++-
16 3 files changed, 29 insertions(+), 1 deletion(-)
18 diff --git a/Makefile.in b/Makefile.in
19 index 2c91891..0c44f36 100644
22 @@ -9,6 +9,8 @@ LIBSTATIC = @LIBSTATIC@
23 LIBSONAME = @LIBSONAME@
24 LIBSHARED = @LIBSHARED@
26 +BUILD_SHARED = @BUILD_SHARED@
27 +BUILD_STATIC = @BUILD_STATIC@
30 exec_prefix = @exec_prefix@
31 @@ -32,9 +34,13 @@ install: FORCE
32 $(INSTALL) -d -m 755 $(DESTDIR)$(includedir)
33 $(INSTALL) -m 644 libmpdec/mpdecimal.h $(DESTDIR)$(includedir)
34 $(INSTALL) -d -m 755 $(DESTDIR)$(libdir)
35 +ifeq ($(BUILD_STATIC),yes)
36 $(INSTALL) -m 644 libmpdec/$(LIBSTATIC) $(DESTDIR)$(libdir)
38 +ifeq ($(BUILD_SHARED),yes)
39 $(INSTALL) -m 755 libmpdec/$(LIBSHARED) $(DESTDIR)$(libdir)
40 cd $(DESTDIR)$(libdir) && ln -sf $(LIBSHARED) $(LIBSONAME) && ln -sf $(LIBSHARED) libmpdec.so
42 $(INSTALL) -d -m 755 $(DESTDIR)$(docdir)
43 cp -R doc/* $(DESTDIR)$(docdir)
45 diff --git a/configure.ac b/configure.ac
46 index 7ee8f86..2b3e505 100644
49 @@ -88,6 +88,19 @@ CFLAGS="$saved_cflags"
53 +AC_ARG_ENABLE([shared],
54 + [AS_HELP_STRING([--enable-shared], [build shared library])],
55 + [BUILD_SHARED=$enableval],
58 +AC_ARG_ENABLE([static],
59 + [AS_HELP_STRING([--enable-static], [build static library])],
60 + [BUILD_STATIC=$enableval],
63 +AC_SUBST(BUILD_SHARED)
64 +AC_SUBST(BUILD_STATIC)
66 # _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect:
67 # http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html
68 AC_MSG_CHECKING(for glibc _FORTIFY_SOURCE/memmove bug)
69 diff --git a/libmpdec/Makefile.in b/libmpdec/Makefile.in
70 index d9619a3..985c73c 100644
71 --- a/libmpdec/Makefile.in
72 +++ b/libmpdec/Makefile.in
74 LIBSTATIC = @LIBSTATIC@
75 LIBSONAME = @LIBSONAME@
76 LIBSHARED = @LIBSHARED@
77 +BUILD_SHARED = @BUILD_SHARED@
78 +BUILD_STATIC = @BUILD_STATIC@
82 @@ -32,8 +34,15 @@ ifeq ($(MAKECMDGOALS), profile_use)
83 MPD_LDFLAGS += $(MPD_PUSE)
86 +ifeq ($(BUILD_SHARED),yes)
87 +TARGETS += $(LIBSHARED)
90 +ifeq ($(BUILD_STATIC),yes)
91 +TARGETS += $(LIBSTATIC)
94 -default: $(LIBSTATIC) $(LIBSHARED)
98 OBJS := basearith.o context.o constants.o convolute.o crt.o mpdecimal.o \