1# -*- shell-script -*-
2#   Copyright (C) 2011-2019 Free Software Foundation, Inc.
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18# This is the target specific configuration file.  This is invoked by the
19# autoconf generated configure script.  Putting it in a separate shell file
20# lets us skip running autoconf when modifying target specific information.
21
22# This file switches on the shell variable ${target}, and sets the
23# following shell variables:
24#  config_path		An ordered list of directories to search for
25#			sources and headers.  This is relative to the
26#			config subdirectory of the source tree.
27#  XCFLAGS		Add extra compile flags to use.
28#  XLDFLAGS		Add extra link flags to use.
29
30# Optimize TLS usage by avoiding the overhead of dynamic allocation.
31if test "$gcc_cv_have_tls" = yes ; then
32  case "${target}" in
33
34    # For x86, we use slots in the TCB head for most of our TLS.
35    # The setup of those slots in beginTransaction can afford to
36    # use the global-dynamic model.
37    i[456]86-*-linux* | x86_64-*-linux*)
38	;;
39
40    *-*-linux*)
41	XCFLAGS="${XCFLAGS} -ftls-model=initial-exec"
42	;;
43
44  esac
45fi
46
47# Map the target cpu to an ARCH sub-directory.  At the same time,
48# work out any special compilation flags as necessary.
49case "${target_cpu}" in
50  aarch64*)		ARCH=aarch64 ;;
51  alpha*)		ARCH=alpha ;;
52  rs6000 | powerpc*)
53	XCFLAGS="${XCFLAGS} -mhtm"
54	ARCH=powerpc
55	;;
56
57  arm*)		ARCH=arm ;;
58
59  i[3456]86)
60	case " ${CC} ${CFLAGS} " in
61	  *" -m64 "*|*" -mx32 "*)
62	    ;;
63	  *)
64	    if test -z "$with_arch"; then
65	      XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
66	      XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
67	    fi
68	esac
69	XCFLAGS="${XCFLAGS} -mrtm"
70	ARCH=x86
71	;;
72
73  sh*)		ARCH=sh ;;
74
75  sparc)
76	case " ${CC} ${CFLAGS} " in
77	  *" -m64 "*)
78	    ;;
79	  *)
80	    if test -z "$with_cpu"; then
81	      XCFLAGS="${XCFLAGS} -mcpu=v9"
82	    fi
83	esac
84	ARCH=sparc
85	;;
86
87  sparc64|sparcv9)
88	case " ${CC} ${CFLAGS} " in
89	  *" -m32 "*)
90	    XCFLAGS="${XCFLAGS} -mcpu=v9"
91	    ;;
92	  *" -m64 "*)
93	    ;;
94	  *)
95	    if test "x$with_cpu" = xv8; then
96	      XCFLAGS="${XCFLAGS} -mcpu=v9"
97	    fi
98	    ;;
99	esac
100	ARCH=sparc
101	;;
102
103  x86_64)
104	case " ${CC} ${CFLAGS} " in
105	  *" -m32 "*)
106	    XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
107	    XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
108	    ;;
109	esac
110	XCFLAGS="${XCFLAGS} -mrtm"
111	ARCH=x86
112	;;
113  s390|s390x)
114	XCFLAGS="${XCFLAGS} -mzarch -mhtm"
115	ARCH=s390
116	;;
117
118  *)
119	ARCH="${target_cpu}"
120	;;
121esac
122
123# For the benefit of top-level configure, determine if the cpu is supported.
124test -d ${srcdir}/config/$ARCH || UNSUPPORTED=1
125
126# Since we require POSIX threads, assume a POSIX system by default.
127config_path="$ARCH posix generic"
128
129# Other system configury
130case "${target}" in
131  *-*-linux*)
132	if test "$enable_linux_futex" = yes; then
133	  config_path="linux/$ARCH linux $config_path"
134	fi
135	;;
136
137  powerpc*-*-aix* | rs6000-*-aix*)
138	# The system ought to be supported, but sjlj.S has not been ported.
139	UNSUPPORTED=1
140	;;
141
142  *-*-gnu* | *-*-k*bsd*-gnu \
143  | *-*-netbsd* | *-*-freebsd* | *-*-openbsd* \
144  | *-*-solaris2* | *-*-sysv4* | *-*-hpux11* \
145  | *-*-aix* | *-*-dragonfly*)
146	# POSIX system.  The OS is supported.
147	;;
148
149  *-*-darwin*)
150	# The OS is supported, but we need dynamic lookup to support undefined
151	# weak symbols at link-time.
152	XLDFLAGS="${XLDFLAGS} -Wl,-undefined,dynamic_lookup"
153	;;
154
155  *)	# Non-POSIX, or embedded system
156	UNSUPPORTED=1
157	;;
158esac
159