Makefile.am 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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_explicit_sharedlibs=$(foreach lib,$(EXPLICIT_SHARED_LIBS_SO:lib%.so=%),lib$(lib).so.$(call get_soname,$(lib)))
  39. get_explicit_sharedlibs_two=$(foreach lib,$(EXPLICIT_SHARED_LIBS_SO:lib%.so=%),lib$(lib).so.$(call get_major,$(lib)))
  40. get_linker_add=$(if $($(call uc,$1)_LINKER_ADD),$($(call uc,$1)_LINKER_ADD))
  41. MAINTAINERCLEANFILES = Makefile.in
  42. AM_CFLAGS = -fPIC
  43. AM_LDFLAGS = -lpthread
  44. INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
  45. lib_LIBRARIES = libcpg.a libconfdb.a libevs.a libcfg.a libquorum.a \
  46. libvotequorum.a libpload.a libcoroipcc.a libsam.a
  47. SHARED_LIBS_SO = $(filter-out $(EXPLICIT_SHARED_LIBS_SO), $(lib_LIBRARIES:%.a=%.so))
  48. EXPLICIT_SHARED_LIBS_SO = libcoroipcc.so
  49. libcpg_a_SOURCES = cpg.c
  50. libcfg_a_SOURCES = cfg.c
  51. libevs_a_SOURCES = evs.c
  52. libpload_a_SOURCES = pload.c
  53. libquorum_a_SOURCES = quorum.c
  54. libvotequorum_a_SOURCES = votequorum.c
  55. libconfdb_a_SOURCES = confdb.c sa-confdb.c
  56. libconfdb_a_LIBADD = ../lcr/lcr_ifact.o
  57. CONFDB_LINKER_ADD = $(OS_DYFLAGS) $(OS_LDL)
  58. SAM_LINKER_ADD = -L. -lquorum
  59. libcoroipcc_a_SOURCES = coroipcc.c
  60. libsam_a_SOURCES = sam.c
  61. noinst_HEADERS = sa-confdb.h util.h \
  62. libcfg.versions libconfdb.versions \
  63. libcoroipcc.versions libcpg.versions \
  64. libevs.versions libpload.versions \
  65. libquorum.versions libvotequorum.versions \
  66. libsam.versions
  67. ../lcr/lcr_ifact.o:
  68. $(MAKE) -C ../lcr lcr_ifact.o
  69. if BUILD_DARWIN
  70. libcoroipcc.so.$(SONAME): coroipcc.o
  71. $(CC) $(LDFLAGS) $(DARWIN_OPTS) coroipcc.o -o $@ $(AM_LDFLAGS)
  72. ln -sf libcoroipcc.so.$(SONAME) libcoroipcc.so
  73. ln -sf libcoroipcc.so.$(SONAME) libcoroipcc.so.$(SOMAJOR)
  74. lib%.so: lib%.a libcoroipcc.so.$(SONAME)
  75. $(CC) $(DARWIN_OPTS) $(call get_linker_add,$*) -Wl,-whole-archive $^ -Wl,-no-whole-archive -o $@
  76. ln -sf lib$*.so.$(call get_soname,$*) lib$*.so
  77. ln -sf lib$*.so.$(call get_soname,$*) lib$*.so.$(call get_major,$*)
  78. else
  79. if BUILD_SOLARIS
  80. libcoroipcc.so.$(SONAME): coroipcc.o
  81. $(LD) $(LDFLAGS) $(SOLARIS_OPTS) -G coroipcc.o -o $@ $(AM_LDFLAGS) -lsocket -lnsl
  82. ln -sf libcoroipcc.so.$(SONAME) libcoroipcc.so
  83. ln -sf libcoroipcc.so.$(SONAME) libcoroipcc.so.$(SOMAJOR)
  84. lib%.so.$(SONAME): lib%.a libcoroipcc.so.$(SONAME)
  85. $(LD) $(SOLARIS_OPTS) $(call get_linker_add,$*) -G -whole-archive $^ -no-whole-archive -o $@
  86. ln -sf lib$*.so.$(call get_soname,$*) lib$*.so
  87. ln -sf lib$*.so.$(call get_soname,$*) lib$*.so.$(call get_major,$*)
  88. else
  89. libcoroipcc.so.$(SONAME): coroipcc.o
  90. $(CC) -shared -o $@ \
  91. -Wl,-soname=libcoroipcc.so.$(SOMAJOR) \
  92. -Wl,-version-script=$(srcdir)/libcoroipcc.versions \
  93. $^ $(LDFLAGS) $(AM_LDFLAGS)
  94. ln -sf libcoroipcc.so.$(SONAME) libcoroipcc.so
  95. ln -sf libcoroipcc.so.$(SONAME) libcoroipcc.so.$(SOMAJOR)
  96. lib%.so: lib%.a libcoroipcc.so.$(SONAME)
  97. if [ ! "$@" = "libcoroipcc.so" ] ; then \
  98. $(CC) -shared -o $@.$(call get_soname,$*) \
  99. -Wl,-soname=lib$*.so.$(call get_major,$*) \
  100. -Wl,-version-script=$(srcdir)/lib$*.versions \
  101. -Wl,-whole-archive $^ -Wl,-no-whole-archive $(LDFLAGS) $(AM_LDFLAGS) $(call get_linker_add,$*) ;\
  102. ln -sf lib$*.so.$(call get_soname,$*) lib$*.so ;\
  103. ln -sf lib$*.so.$(call get_soname,$*) lib$*.so.$(call get_major,$*) ;\
  104. fi
  105. endif
  106. endif
  107. all-local: $(get_explicit_sharedlibs) $(SHARED_LIBS_SO)
  108. @echo Built shared libs
  109. install-exec-local:
  110. $(INSTALL) -d $(DESTDIR)/$(libdir)
  111. $(INSTALL) -m 755 $(get_sharedlibs) $(get_explicit_sharedlibs) $(DESTDIR)/$(libdir)
  112. $(CP) -a $(SHARED_LIBS_SO) $(EXPLICIT_SHARED_LIBS_SO) $(get_sharedlibs_two) $(get_explicit_sharedlibs_two) $(DESTDIR)/$(libdir)
  113. uninstall-local:
  114. cd $(DESTDIR)/$(libdir)/ && \
  115. rm -f $(get_sharedlibs) $(SHARED_LIBS_SO) $(get_sharedlibs_two)
  116. clean-local:
  117. rm -f *.o *.a *.so* *.da *.bb *.bbg