summaryrefslogtreecommitdiff
blob: 3abbf9dda0a9718bf66fb6df0bdd07315865cc2a (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
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-devel/gcc-config/gcc-config-1.3.3-r2.ebuild,v 1.1 2003/10/18 19:35:48 brad_mssw Exp $

IUSE=""

W_VER="1.4.1"

DISABLE_GEN_GCC_WRAPPERS="yes"

S="${WORKDIR}/${P}"
DESCRIPTION="Utility to change the gcc compiler being used."
SRC_URI=""
HOMEPAGE="http://www.gentoo.org/"

KEYWORDS="-* amd64"
SLOT="0"
LICENSE="GPL-2"

DEPEND="virtual/glibc
	>=sys-apps/portage-2.0.47-r10" # We need portageq ...


src_install() {

	# Setup PATH just in case ...
	if /usr/bin/gcc-config --get-current-profile &> /dev/null || \
	   /usr/sbin/gcc-config --get-current-profile &> /dev/null
	then
		if [ -x /usr/bin/gcc-config ]
		then
			export PATH="`/usr/bin/gcc-config --get-bin-path`:${PATH}"
		else
			export PATH="`/usr/sbin/gcc-config --get-bin-path`:${PATH}"
		fi
	fi

	einfo "Compiling wrapper..."
	${CC:-gcc} -O2 -Wall -o ${WORKDIR}/wrapper \
		${FILESDIR}/wrapper-${W_VER}.c || die

	exeinto /usr/lib/gcc-config
	doexe ${WORKDIR}/wrapper || die

	# Only setup this if we have a proper gcc version installed, else
	# we will nuke the non gcc-config versions ...
	if /usr/bin/gcc-config --get-current-profile &> /dev/null || \
	   /usr/sbin/gcc-config --get-current-profile &> /dev/null
	then
		einfo "Creating wrappers for compiler tools..."
		exeinto /lib
		newexe ${WORKDIR}/wrapper cpp

		exeinto /usr/bin
		for x in gcc cpp cc c++ g++ ${CHOST}-gcc ${CHOST}-c++ ${CHOST}-g++
		do
			newexe ${WORKDIR}/wrapper ${x}
		done
	fi

	einfo "Adding compat symlinks..."
	into /usr
	dodir /usr/sbin
	newbin ${FILESDIR}/${PN}-${PV}-multi-ldpath ${PN}
	dosym ../bin/${PN} /usr/sbin/${PN}
}

pkg_postinst() {

	# Do we have a valid multi ver setup ?
	if ${ROOT}/usr/bin/gcc-config --get-current-profile &> /dev/null
	then
		# We not longer use the /usr/include/g++-v3 hacks, as
		# it is not needed ...
		if [ -L ${ROOT}/usr/include/g++ ]
		then
			rm -f ${ROOT}/usr/include/g++
		fi
		if [ -L ${ROOT}/usr/include/g++-v3 ]
		then
			rm -f ${ROOT}/usr/include/g++-v3
		fi

		if [ ${ROOT} = "/" ]
		then
			/usr/bin/gcc-config $(/usr/bin/gcc-config --get-current-profile)
		fi
	fi
}