summaryrefslogtreecommitdiff
blob: 8288aead9ad7df8355a1684dd6063edc087b698a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Copyright 1999-2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# Author: Martin Schlemmer <azarah@gentoo.org>
# $Header: /var/cvsroot/gentoo-x86/eclass/gcc.eclass,v 1.7 2002/10/25 19:55:52 vapier Exp $
# This eclass contains (or should) functions to get common info about gcc

ECLASS=gcc
INHERITED="$INHERITED $ECLASS"

newdepend sys-devel/gcc

DESCRIPTION="Based on the ${ECLASS} eclass"


# NOTE: To force gcc3 if multi ver install, do:  export WANT_GCC_3="yes"
[ -z "${WANT_GCC_3}" ] && export WANT_GCC_3="no"

# Returns the name of the C compiler binary
gcc-getCC() {

	if [ "${WANT_GCC_3}" = "yes" -o -z "${CC}" ]
	then
		local CC="gcc"

		if [ "$(${CC} -dumpversion | cut -f1 -d.)" -ne 3 ] && \
		   [ "${WANT_GCC_3}" = "yes" ]
		then
			# We use the dual/multiple install of gcc-3.x if the user
			# have 2.95.3 as base
			if [ -x /usr/bin/gcc-3.2 ]
			then
				CC="gcc-3.2"
			elif [ -x /usr/bin/gcc-3.1 ]
			then
				CC="gcc-3.1"
			elif [ -x /usr/bin/gcc-3.0 ]
			then
				CC="gcc-3.0"
			fi
		fi
	fi

	echo "${CC}"
}

# Returns the name of the C++ compiler binary
gcc-getCXX() {

	if [ "${WANT_GCC_3}" = "yes" -o -z "${CXX}" ]
	then
		local CC="$(gcc-getCC)"
	
		if [ "$(${CC} -dumpversion | cut -f1 -d.)" -ge 3 ]
		then
			echo "${CC/gcc/g++}"
		else
			echo "${CC}"
		fi
	else
		echo "${CXX}"
	fi
}

# Returns the version as by `$CC -dumpversion`
gcc-fullversion() {

	echo "$($(gcc-getCC) -dumpversion)"
}

# Returns the version, but only the <major>.<minor>
gcc-version() {

	echo "$(gcc-fullversion | cut -f1,2 -d.)"
}

# Returns the Major version
gcc-major-version() {

	echo "$(gcc-version | cut -f1 -d.)"
}

# Returns the Minor version
gcc-minor-version() {

	echo "$(gcc-version | cut -f2 -d.)"
}

# Returns the Micro version
gcc-micro-version() {

	echo "$(gcc-fullversion | cut -f3 -d.)"
}

# Returns gcc's internal library path
gcc-libpath() {

	echo "/usr/lib/gcc-lib/$($(gcc-getCC) -dumpmachine)/$(gcc-fullversion)"
}

# Returns the full version of libstdc++.so
gcc-libstdcxx-version() {

	if [ "$(gcc-major-version)" -ge 3 ]
	then
		local libstdcxx="$(ls $(gcc-libpath)/libstdc++.so.?.?.?)"

		libstdcxx="${libstdcxx##*/}"
		echo "${libstdcxx/libstdc++.so.}"
	else
		echo
	fi
}

# Returns the Major version of libstdc++.so
gcc-libstdcxx-major-version() {

	echo "$(echo $(gcc-libstdcxx-version) | cut -f1 -d.)"
}