| 1 |
## Copyright (C) 2012-2025 Free Software Foundation, Inc. |
| 2 |
## Contributed by Richard Henderson <[email protected]>. |
| 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 |
|
| 25 |
ACLOCAL_AMFLAGS = -I .. -I ../config |
| 26 |
SUBDIRS = testsuite |
| 27 |
|
| 28 |
## May be used by toolexeclibdir. |
| 29 |
gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER) |
| 30 |
|
| 31 |
config_path= @config_path@ |
| 32 |
search_path = $(addprefix $(top_srcdir)/config/, $(config_path)) \ |
| 33 |
$(top_srcdir) $(top_builddir) |
| 34 |
|
| 35 |
vpath % $(strip $(search_path)) |
| 36 |
|
| 37 |
DEFAULT_INCLUDES = $(addprefix -I, $(search_path)) |
| 38 |
AM_CFLAGS = $(XCFLAGS) |
| 39 |
AM_CCASFLAGS = $(XCFLAGS) |
| 40 |
AM_LDFLAGS = $(XLDFLAGS) $(SECTION_LDFLAGS) $(OPT_LDFLAGS) |
| 41 |
|
| 42 |
toolexeclib_LTLIBRARIES = libatomic.la |
| 43 |
noinst_LTLIBRARIES = libatomic_convenience.la |
| 44 |
|
| 45 |
if LIBAT_BUILD_VERSIONED_SHLIB |
| 46 |
if LIBAT_BUILD_VERSIONED_SHLIB_GNU |
| 47 |
libatomic_version_script = -Wl,--version-script,$(top_srcdir)/libatomic.map |
| 48 |
libatomic_version_dep = $(top_srcdir)/libatomic.map |
| 49 |
endif |
| 50 |
if LIBAT_BUILD_VERSIONED_SHLIB_SUN |
| 51 |
libatomic_version_script = -Wl,-M,libatomic.map-sun |
| 52 |
libatomic_version_dep = libatomic.map-sun |
| 53 |
libatomic.map-sun : $(top_srcdir)/libatomic.map \ |
| 54 |
$(top_srcdir)/../contrib/make_sunver.pl \ |
| 55 |
$(libatomic_la_OBJECTS) $(libatomic_la_LIBADD) |
| 56 |
perl $(top_srcdir)/../contrib/make_sunver.pl \ |
| 57 |
$(top_srcdir)/libatomic.map \ |
| 58 |
$(libatomic_la_OBJECTS) $(libatomic_la_LIBADD) \ |
| 59 |
> $@ || (rm -f $@ ; exit 1) |
| 60 |
endif |
| 61 |
else |
| 62 |
libatomic_version_script = |
| 63 |
libatomic_version_dep = |
| 64 |
endif |
| 65 |
libatomic_version_info = -version-info $(libtool_VERSION) |
| 66 |
if ENABLE_DARWIN_AT_RPATH |
| 67 |
libatomic_darwin_rpath = -Wc,-nodefaultrpaths |
| 68 |
libatomic_darwin_rpath += -Wl,-rpath,@loader_path |
| 69 |
endif |
| 70 |
|
| 71 |
libatomic_la_LDFLAGS = $(libatomic_version_info) $(libatomic_version_script) \ |
| 72 |
$(lt_host_flags) $(libatomic_darwin_rpath) |
| 73 |
libatomic_la_SOURCES = gload.c gstore.c gcas.c gexch.c glfree.c lock.c init.c \ |
| 74 |
fenv.c fence.c flag.c |
| 75 |
|
| 76 |
SIZEOBJS = load store cas exch fadd fsub fand fior fxor fnand tas |
| 77 |
SIZES = @SIZES@ |
| 78 |
|
| 79 |
EXTRA_libatomic_la_SOURCES = $(addsuffix _n.c,$(SIZEOBJS)) |
| 80 |
libatomic_la_DEPENDENCIES = $(libatomic_la_LIBADD) $(libatomic_version_dep) |
| 81 |
|
| 82 |
## And now our custom target patterns that allow us not to have tons of |
| 83 |
## extra source files hanging about. Unfortunately, the complex relation |
| 84 |
## between source and object filenames doesn't allow us to add an explicit |
| 85 |
## dependency here. Fortunately that doesn't matter since auto-generated |
| 86 |
## dependencies do the job just as well: |
| 87 |
-include $(wildcard $(DEPDIR)/*.Ppo) |
| 88 |
|
| 89 |
## Naming pattern: base_n_i_.lo |
| 90 |
## |
| 91 |
## N size of data |
| 92 |
## I IFUNC alternative, index beginning at 1. |
| 93 |
## |
| 94 |
## The trailing _ in the output object file name is required to differentiate |
| 95 |
## these objects from those which should be compiled normally. We can only |
| 96 |
## have one stem in the implicit rule. |
| 97 |
|
| 98 |
empty = |
| 99 |
space = $(empty) $(empty) |
| 100 |
PAT_SPLIT = $(subst _,$(space),$(*F)) |
| 101 |
PAT_BASE = $(word 1,$(PAT_SPLIT)) |
| 102 |
PAT_N = $(word 2,$(PAT_SPLIT)) |
| 103 |
PAT_S = $(word 3,$(PAT_SPLIT)) |
| 104 |
IFUNC_DEF = -DIFUNC_ALT=$(PAT_S) |
| 105 |
IFUNC_OPT = $(word $(PAT_S),$(IFUNC_OPTIONS)) |
| 106 |
|
| 107 |
@AMDEP_TRUE@M_DEPS = -MT $@ -MD -MP -MF $(DEPDIR)/$(@F).Ppo |
| 108 |
@AMDEP_FALSE@M_DEPS = |
| 109 |
|
| 110 |
M_SIZE = -DN=$(PAT_N) |
| 111 |
M_IFUNC = $(if $(PAT_S),$(IFUNC_DEF) $(IFUNC_OPT)) |
| 112 |
M_FILE = $(PAT_BASE)_n.c |
| 113 |
|
| 114 |
# The lack of explicit dependency on the source file means that VPATH cannot |
| 115 |
# work properly. Instead, perform this operation by hand. First, collect a |
| 116 |
# list of all .c files in the search path. |
| 117 |
all_c_files := $(foreach dir,$(search_path),$(wildcard $(dir)/*.c)) |
| 118 |
|
| 119 |
# Then sort through them to find the one we want, and select the first. |
| 120 |
M_SRC = $(firstword $(filter %/$(M_FILE), $(all_c_files))) |
| 121 |
|
| 122 |
%_.lo: Makefile |
| 123 |
$(LTCOMPILE) $(M_DEPS) $(M_SIZE) $(M_IFUNC) -c -o $@ $(M_SRC) |
| 124 |
|
| 125 |
## Include all of the sizes in the "normal" set of compilation flags. |
| 126 |
libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix _$(s)_.lo,$(SIZEOBJS))) |
| 127 |
|
| 128 |
## On a target-specific basis, include alternates to be selected by IFUNC. |
| 129 |
if HAVE_IFUNC |
| 130 |
if ARCH_AARCH64_LINUX |
| 131 |
IFUNC_OPTIONS = -march=armv8-a+lse |
| 132 |
libatomic_la_LIBADD += $(foreach s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS))) |
| 133 |
|
| 134 |
endif |
| 135 |
if ARCH_ARM_LINUX |
| 136 |
IFUNC_OPTIONS = -march=armv7-a+fp -DHAVE_KERNEL64 |
| 137 |
libatomic_la_LIBADD += $(foreach s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS))) |
| 138 |
libatomic_la_LIBADD += $(addsuffix _8_2_.lo,$(SIZEOBJS)) |
| 139 |
libatomic_la_LIBADD += tas_1_2_.lo |
| 140 |
endif |
| 141 |
if ARCH_I386 |
| 142 |
IFUNC_OPTIONS = -march=i586 |
| 143 |
libatomic_la_LIBADD += $(addsuffix _8_1_.lo,$(SIZEOBJS)) |
| 144 |
endif |
| 145 |
if ARCH_X86_64 |
| 146 |
IFUNC_OPTIONS = -mcx16 -mcx16 |
| 147 |
libatomic_la_LIBADD += $(addsuffix _16_1_.lo,$(SIZEOBJS)) \ |
| 148 |
$(addsuffix _16_2_.lo,$(SIZEOBJS)) |
| 149 |
endif |
| 150 |
endif |
| 151 |
|
| 152 |
if ARCH_AARCH64_LINUX |
| 153 |
libatomic_la_SOURCES += atomic_16.S |
| 154 |
endif |
| 155 |
|
| 156 |
libatomic_convenience_la_SOURCES = $(libatomic_la_SOURCES) |
| 157 |
libatomic_convenience_la_LIBADD = $(libatomic_la_LIBADD) |
| 158 |
|
| 159 |
# Amend the automake generated all-multi rule to guarantee that all-multi |
| 160 |
# is not run in parallel with the %_.lo rules which generate $(DEPDIR)/*.Ppo |
| 161 |
# makefile fragments to avoid broken *.Ppo getting included into the Makefile |
| 162 |
# when it is reloaded during the build of all-multi. |
| 163 |
all-multi: $(libatomic_la_LIBADD) |
| 164 |
|
| 165 |
# target overrides |
| 166 |
-include $(tmake_file) |
| 167 |
|
| 168 |
include $(top_srcdir)/../multilib.am |