1 # Copyright (C) 2023-2025 Free Software Foundation, Inc.
3 # This file is part of GCC.
5 # GCC is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3, or (at your option)
10 # GCC is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with GCC; see the file COPYING3. If not see
17 # <http://www.gnu.org/licenses/>.
23 exclude_1st = $(wordlist 2,$(words $1),$1)
26 mlib_all := lp64d lp64f lp64s
27 $(foreach i,$(mlib_all),$(eval MULTISUBDIR_$i := base/$i))
29 mlib_default := $(firstword $(subst $(comma), ,$(TM_MULTILIB_CONFIG)))
30 mlib_all := $(filter-out $(mlib_default),$(mlib_all))
32 MULTILIB_OPTIONS := $(subst $(space),/,$(foreach i,$(mlib_all),mabi=$(i)))
33 MULTILIB_DIRNAMES := $(foreach i,$(mlib_all),$(MULTISUBDIR_$(i)))
35 # Customize builds with --with-multilib-list
36 MULTILIB_REQUIRED := $(foreach i,$(call exclude_1st,\
37 $(subst $(comma), ,$(TM_MULTILIB_CONFIG))),\
38 $(firstword $(subst /, ,$(i))))
40 ## spec rules for building libraries, triggered by -fmultiflags
41 gen_mlib_spec = $(if $(word 2,$1),\
42 %{$(firstword $1):$(patsubst %,-%,$(call exclude_1st,$1)}))
44 lib_build_spec = $(foreach mlib,\
45 $(call exclude_1st,$(subst $(comma), ,$(TM_MULTILIB_CONFIG))),\
46 $(call gen_mlib_spec,$(subst /, ,$(mlib))))
48 default_mlib_spec := %{fmultiflags:%{!mabi=*:-mabi=$(mlib_default)}}
49 lib_build_spec := %{fmultiflags:$(lib_build_spec)}
51 ifneq ($(TM_MULTILIB_CONFIG),)
53 @echo "#define MLIB_SELF_SPECS" \
54 "\"$(default_mlib_spec)\"," \
55 "\"$(lib_build_spec)\"," > $@
57 loongarch-multilib.h: ; @touch $@
61 ifneq ($(call if_multiarch,yes),yes)
62 # Define LA_DISABLE_MULTIARCH if multiarch is disabled.
63 tm_defines += LA_DISABLE_MULTIARCH
65 # Only define MULTIARCH_DIRNAME when multiarch is enabled,
66 # or it would always introduce ${target} into the search path.
67 MULTIARCH_DIRNAME = $(LA_MULTIARCH_TRIPLET)