Makefile.am 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. ## Copyright (C) 2012-2015 Free Software Foundation, Inc.
  2. ## Contributed by Richard Henderson <rth@redhat.com>.
  3. ##
  4. ## This file is part of the GNU Atomic Library (libatomic).
  5. ##
  6. ## Libatomic is free software; you can redistribute it and/or modify it
  7. ## under the terms of the GNU General Public License as published by
  8. ## the Free Software Foundation; either version 3 of the License, or
  9. ## (at your option) any later version.
  10. ##
  11. ## Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
  12. ## WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  13. ## FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. ## more details.
  15. ##
  16. ## Under Section 7 of GPL version 3, you are granted additional
  17. ## permissions described in the GCC Runtime Library Exception, version
  18. ## 3.1, as published by the Free Software Foundation.
  19. ##
  20. ## You should have received a copy of the GNU General Public License and
  21. ## a copy of the GCC Runtime Library Exception along with this program;
  22. ## see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  23. ## <http://www.gnu.org/licenses/>.
  24. ACLOCAL_AMFLAGS = -I .. -I ../config
  25. SUBDIRS = testsuite
  26. ## May be used by toolexeclibdir.
  27. gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
  28. config_path= @config_path@
  29. search_path = $(addprefix $(top_srcdir)/config/, $(config_path)) \
  30. $(top_srcdir) $(top_builddir)
  31. vpath % $(strip $(search_path))
  32. DEFAULT_INCLUDES = $(addprefix -I, $(search_path))
  33. AM_CFLAGS = $(XCFLAGS)
  34. AM_CCASFLAGS = $(XCFLAGS)
  35. AM_LDFLAGS = $(XLDFLAGS) $(SECTION_LDFLAGS) $(OPT_LDFLAGS)
  36. toolexeclib_LTLIBRARIES = libatomic.la
  37. noinst_LTLIBRARIES = libatomic_convenience.la
  38. if LIBAT_BUILD_VERSIONED_SHLIB
  39. if LIBAT_BUILD_VERSIONED_SHLIB_GNU
  40. libatomic_version_script = -Wl,--version-script,$(top_srcdir)/libatomic.map
  41. libatomic_version_dep = $(top_srcdir)/libatomic.map
  42. endif
  43. if LIBAT_BUILD_VERSIONED_SHLIB_SUN
  44. libatomic_version_script = -Wl,-M,libatomic.map-sun
  45. libatomic_version_dep = libatomic.map-sun
  46. libatomic.map-sun : $(top_srcdir)/libatomic.map \
  47. $(top_srcdir)/../contrib/make_sunver.pl \
  48. $(libatomic_la_OBJECTS) $(libatomic_la_LIBADD)
  49. perl $(top_srcdir)/../contrib/make_sunver.pl \
  50. $(top_srcdir)/libatomic.map \
  51. $(libatomic_la_OBJECTS:%.lo=.libs/%.o) \
  52. `echo $(libatomic_la_LIBADD) | \
  53. sed 's,\([^/ ]*\)\.l\([ao]\),.libs/\1.\2,g'` \
  54. > $@ || (rm -f $@ ; exit 1)
  55. endif
  56. else
  57. libatomic_version_script =
  58. libatomic_version_dep =
  59. endif
  60. libatomic_version_info = -version-info $(libtool_VERSION)
  61. libatomic_la_LDFLAGS = $(libatomic_version_info) $(libatomic_version_script) $(lt_host_flags)
  62. libatomic_la_SOURCES = gload.c gstore.c gcas.c gexch.c glfree.c lock.c init.c \
  63. fenv.c
  64. SIZEOBJS = load store cas exch fadd fsub fand fior fxor fnand tas
  65. SIZES = @SIZES@
  66. EXTRA_libatomic_la_SOURCES = $(addsuffix _n.c,$(SIZEOBJS))
  67. libatomic_la_DEPENDENCIES = $(libatomic_la_LIBADD) $(libatomic_version_dep)
  68. ## And now our custom target patterns that allow us not to have tons of
  69. ## extra source files hanging about. Unfortunately, the complex relation
  70. ## between source and object filenames doesn't allow us to add an explicit
  71. ## dependency here. Fortunately that doesn't matter since auto-generated
  72. ## dependencies do the job just as well:
  73. -include $(wildcard $(DEPDIR)/*.Ppo)
  74. ## Naming pattern: base_n_i_.lo
  75. ##
  76. ## N size of data
  77. ## I IFUNC alternative, index beginning at 1.
  78. ##
  79. ## The trailing _ in the output object file name is required to differentiate
  80. ## these objects from those which should be compiled normally. We can only
  81. ## have one stem in the implicit rule.
  82. empty =
  83. space = $(empty) $(empty)
  84. PAT_SPLIT = $(subst _,$(space),$(*F))
  85. PAT_BASE = $(word 1,$(PAT_SPLIT))
  86. PAT_N = $(word 2,$(PAT_SPLIT))
  87. PAT_S = $(word 3,$(PAT_SPLIT))
  88. IFUNC_DEF = -DIFUNC_ALT=$(PAT_S)
  89. IFUNC_OPT = $(word $(PAT_S),$(IFUNC_OPTIONS))
  90. M_DEPS = -MT $@ -MD -MP -MF $(DEPDIR)/$(@F).Ppo
  91. M_SIZE = -DN=$(PAT_N)
  92. M_IFUNC = $(if $(PAT_S),$(IFUNC_DEF) $(IFUNC_OPT))
  93. M_FILE = $(PAT_BASE)_n.c
  94. # The lack of explicit dependency on the source file means that VPATH cannot
  95. # work properly. Instead, perform this operation by hand. First, collect a
  96. # list of all .c files in the search path.
  97. all_c_files := $(foreach dir,$(search_path),$(wildcard $(dir)/*.c))
  98. # Then sort through them to find the one we want, and select the first.
  99. M_SRC = $(firstword $(filter %/$(M_FILE), $(all_c_files)))
  100. %_.lo: Makefile
  101. $(LTCOMPILE) $(M_DEPS) $(M_SIZE) $(M_IFUNC) -c -o $@ $(M_SRC)
  102. ## Include all of the sizes in the "normal" set of compilation flags.
  103. libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix _$(s)_.lo,$(SIZEOBJS)))
  104. ## On a target-specific basis, include alternates to be selected by IFUNC.
  105. if HAVE_IFUNC
  106. if ARCH_ARM_LINUX
  107. IFUNC_OPTIONS = -march=armv7-a -DHAVE_KERNEL64
  108. libatomic_la_LIBADD += $(foreach s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS)))
  109. libatomic_la_LIBADD += $(addsuffix _8_2_.lo,$(SIZEOBJS))
  110. endif
  111. if ARCH_I386
  112. IFUNC_OPTIONS = -march=i586
  113. libatomic_la_LIBADD += $(addsuffix _8_1_.lo,$(SIZEOBJS))
  114. endif
  115. if ARCH_X86_64
  116. IFUNC_OPTIONS = -mcx16
  117. libatomic_la_LIBADD += $(addsuffix _16_1_.lo,$(SIZEOBJS))
  118. endif
  119. endif
  120. libatomic_convenience_la_SOURCES = $(libatomic_la_SOURCES)
  121. libatomic_convenience_la_LIBADD = $(libatomic_la_LIBADD)