Makefile.am 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. SOMAJOR=4
  45. SOMINOR=0
  46. SOMICRO=0
  47. SONAME=${SOMAJOR}.${SOMINOR}.${SOMICRO}
  48. if BUILD_DARWIN
  49. lib%.so: lib%.a $(LIBQB_LIBS)
  50. $(CC) $(DARWIN_OPTS) $(call get_linker_add,$*) -Wl,-whole-archive $^ -Wl,-no-whole-archive -o $@
  51. ln -sf lib$*.so.$(call get_soname,$*) lib$*.so
  52. ln -sf lib$*.so.$(call get_soname,$*) lib$*.so.$(call get_major,$*)
  53. else
  54. if BUILD_SOLARIS
  55. lib%.so.$(SONAME): lib%.a
  56. $(LD) $(SOLARIS_OPTS) $(call get_linker_add,$*) -G -whole-archive $^ -no-whole-archive -o $@
  57. ln -sf lib$*.so.$(call get_soname,$*) lib$*.so
  58. ln -sf lib$*.so.$(call get_soname,$*) lib$*.so.$(call get_major,$*)
  59. else
  60. lib%.so: lib%.a
  61. $(CC) -shared -o $@.$(call get_soname,$*) \
  62. -Wl,-soname=lib$*.so.$(call get_major,$*) \
  63. -Wl,-whole-archive $^ -Wl,-no-whole-archive $(LDFLAGS) $(LIBQB_LIBS) $(AM_LDFLAGS) $(call get_linker_add,$*)
  64. ln -sf lib$*.so.$(call get_soname,$*) lib$*.so
  65. ln -sf lib$*.so.$(call get_soname,$*) lib$*.so.$(call get_major,$*)
  66. endif
  67. endif
  68. all-local: $(get_explicit_sharedlibs) $(SHARED_LIBS_SO)
  69. @echo Built shared libs
  70. install-exec-local:
  71. $(INSTALL) -d $(DESTDIR)/$(libdir)
  72. $(INSTALL) -m 755 $(get_sharedlibs) $(DESTDIR)/$(libdir)
  73. $(CP) -a $(SHARED_LIBS_SO) $(get_sharedlibs_two) $(DESTDIR)/$(libdir)
  74. uninstall-local:
  75. cd $(DESTDIR)/$(libdir)/ && \
  76. rm -f $(get_sharedlibs) $(SHARED_LIBS_SO) $(get_sharedlibs_two)
  77. clean-local:
  78. rm -f *.o *.a *.so* *.da *.bb *.bbg