Makefile.am 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #
  2. # Copyright (c) 2012 Red Hat, Inc.
  3. #
  4. # Authors: Angus Salkeld
  5. #
  6. # This software licensed under BSD license, the text of which follows:
  7. #
  8. # Redistribution and use in source and binary forms, with or without
  9. # modification, are permitted provided that the following conditions are met:
  10. #
  11. # - Redistributions of source code must retain the above copyright notice,
  12. # this list of conditions and the following disclaimer.
  13. # - Redistributions in binary form must reproduce the above copyright notice,
  14. # this list of conditions and the following disclaimer in the documentation
  15. # and/or other materials provided with the distribution.
  16. # - Neither the name of the MontaVista Software, Inc. nor the names of its
  17. # contributors may be used to endorse or promote products derived from this
  18. # software without specific prior written permission.
  19. #
  20. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21. # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23. # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  24. # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  25. # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  26. # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27. # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28. # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29. # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  30. # THE POSSIBILITY OF SUCH DAMAGE.
  31. # Functions
  32. uc=$(shell echo $1 | tr a-z A-Z)
  33. get_soname=$(if $($(call uc,$1)_SONAME),$($(call uc,$1)_SONAME),$(SONAME))
  34. get_major=$(firstword $(subst ., ,$(call get_soname,$1)))
  35. get_sharedlibs=$(foreach lib,$(SHARED_LIBS_SO:lib%.so=%),lib$(lib).so.$(call get_soname,$(lib)))
  36. get_sharedlibs_two=$(foreach lib,$(SHARED_LIBS_SO:lib%.so=%),lib$(lib).so.$(call get_major,$(lib)))
  37. get_linker_add=$(if $($(call uc,$1)_LINKER_ADD),$($(call uc,$1)_LINKER_ADD))
  38. MAINTAINERCLEANFILES = Makefile.in
  39. AM_CFLAGS = -fPIC
  40. INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
  41. lib_LIBRARIES = libcorosync_common.a
  42. SHARED_LIBS_SO = $(lib_LIBRARIES:%.a=%.so)
  43. libcorosync_common_a_SOURCES = error_conversion.c
  44. if BUILD_DARWIN
  45. lib%.so: lib%.a $(LIBQB_LIBS)
  46. $(CC) $(DARWIN_OPTS) $(call get_linker_add,$*) -Wl,-whole-archive $^ -Wl,-no-whole-archive -o $@
  47. ln -sf lib$*.so.$(call get_soname,$*) lib$*.so
  48. ln -sf lib$*.so.$(call get_soname,$*) lib$*.so.$(call get_major,$*)
  49. else
  50. if BUILD_SOLARIS
  51. lib%.so.$(SONAME): lib%.a
  52. $(LD) $(SOLARIS_OPTS) $(call get_linker_add,$*) -G -whole-archive $^ -no-whole-archive -o $@
  53. ln -sf lib$*.so.$(call get_soname,$*) lib$*.so
  54. ln -sf lib$*.so.$(call get_soname,$*) lib$*.so.$(call get_major,$*)
  55. else
  56. lib%.so: lib%.a
  57. $(CC) -shared -o $@.$(call get_soname,$*) \
  58. -Wl,-soname=lib$*.so.$(call get_major,$*) \
  59. -Wl,-whole-archive $^ -Wl,-no-whole-archive $(LDFLAGS) $(LIBQB_LIBS) $(AM_LDFLAGS) $(call get_linker_add,$*)
  60. ln -sf lib$*.so.$(call get_soname,$*) lib$*.so
  61. ln -sf lib$*.so.$(call get_soname,$*) lib$*.so.$(call get_major,$*)
  62. endif
  63. endif
  64. all-local: $(get_explicit_sharedlibs) $(SHARED_LIBS_SO)
  65. @echo Built shared libs
  66. install-exec-local:
  67. $(INSTALL) -d $(DESTDIR)/$(libdir)
  68. $(INSTALL) -m 755 $(get_sharedlibs) $(DESTDIR)/$(libdir)
  69. $(CP) -a $(SHARED_LIBS_SO) $(get_sharedlibs_two) $(DESTDIR)/$(libdir)
  70. uninstall-local:
  71. cd $(DESTDIR)/$(libdir)/ && \
  72. rm -f $(get_sharedlibs) $(SHARED_LIBS_SO) $(get_sharedlibs_two)
  73. clean-local:
  74. rm -f *.o *.a *.so* *.da *.bb *.bbg