Makefile.am 4.1 KB

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