From: "Mike Frysinger" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gcc-config:master commit in: /
Date: Sat, 12 Jan 2013 17:05:58 +0000 (UTC) [thread overview]
Message-ID: <1358010456.deaecbb404c8a60f9aec3bc85a4fc1621a561687.vapier@gentoo> (raw)
commit: deaecbb404c8a60f9aec3bc85a4fc1621a561687
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 5 16:12:34 2013 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Jan 12 17:07:36 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gcc-config.git;a=commit;h=deaecbb4
make aware of EPREFIX offset prefix
- changed Makefile to expand @GENTOO_EPREFIX@ for gcc-config
- defined EPREFIX and EROOT in gcc-config, and used them
- made wrapper look in the offset for files
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
---
Makefile | 7 ++++++-
gcc-config | 59 +++++++++++++++++++++++++++++++++--------------------------
wrapper.c | 14 +++++++++-----
3 files changed, 48 insertions(+), 32 deletions(-)
diff --git a/Makefile b/Makefile
index 409d7b0..db14af9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,14 @@
+EPREFIX ?=
+
CFLAGS ?= -O2 -g
CFLAGS += -Wall -Wextra
+CPPFLAGS += '-DEPREFIX="$(EPREFIX)"'
PN = gcc-config
PV = git
P = $(PN)-$(PV)
-PREFIX = /usr
+PREFIX = $(EPREFIX)/usr
BINDIR = $(PREFIX)/bin
SUBLIBDIR = lib
LIBDIR = $(PREFIX)/$(SUBLIBDIR)
@@ -21,6 +24,8 @@ clean:
.gcc-config: gcc-config
sed \
+ -e '1s:/:$(EPREFIX)/:' \
+ -e 's:@GENTOO_EPREFIX@:$(EPREFIX):g' \
-e 's:@GENTOO_LIBDIR@:$(SUBLIBDIR):g' \
-e 's:@PV@:$(PV):g' \
$< > $@
diff --git a/gcc-config b/gcc-config
index 6fb9904..b4ed712 100755
--- a/gcc-config
+++ b/gcc-config
@@ -9,14 +9,17 @@
: ${ROOT:=/}
[[ ${ROOT} != */ ]] && ROOT="${ROOT}/"
[[ ${ROOT} != /* ]] && ROOT="${PWD%/}/${ROOT}"
+EPREFIX="@GENTOO_EPREFIX@"
+[[ ${EPREFIX} == @*@ ]] && EPREFIX=""
+EROOT="${ROOT%/}${EPREFIX}/"
cd /
trap ":" INT QUIT TSTP
argv0=${0##*/}
-source /etc/init.d/functions.sh || {
- echo "${argv0}: Could not source /etc/init.d/functions.sh!" 1>&2
+source "${EPREFIX}"/etc/init.d/functions.sh || {
+ echo "${argv0}: Could not source ${EPREFIX}/etc/init.d/functions.sh!" 1>&2
exit 1
}
esyslog() { :; }
@@ -84,9 +87,9 @@ try_real_hard_to_find_CHOST() {
#
local varname=${1:-CHOST}
- local conf=${ROOT}/etc/portage/make.conf
- if [[ ! -e ${conf} && -e ${ROOT}/etc/make.conf ]] ; then
- conf=${ROOT}/etc/make.conf
+ local conf=${EROOT}/etc/portage/make.conf
+ if [[ ! -e ${conf} && -e ${EROOT}/etc/make.conf ]] ; then
+ conf=${EROOT}/etc/make.conf
fi
local ret=$(source "${conf}" 2>/dev/null ; echo ${!varname})
if [[ -z ${ret} ]] ; then
@@ -109,8 +112,8 @@ try_real_hard_to_find_CHOST() {
#
# Then we try /etc/env.d/gcc/config-${CTARGET}
#
- if [[ -s ${ROOT}/etc/env.d/gcc/config-${CTARGET} ]] ; then
- ret=$(split_gcc_ver $(show_var CURRENT "${ROOT}"/etc/env.d/gcc/config-${CTARGET}))
+ if [[ -s ${EROOT}/etc/env.d/gcc/config-${CTARGET} ]] ; then
+ ret=$(split_gcc_ver $(show_var CURRENT "${EROOT}"/etc/env.d/gcc/config-${CTARGET}))
echo ${ret% *}
fi
}
@@ -133,7 +136,7 @@ get_chost() {
if [[ -z ${CHOST} ]] ; then
eerror "${argv0}: Could not get portage CHOST!"
eerror "${argv0}: You should verify that CHOST is set in one of these places:"
- eerror "${argv0}: - ${ROOT}/etc/portage/make.conf"
+ eerror "${argv0}: - ${EROOT}/etc/portage/make.conf"
eerror "${argv0}: - active environment"
exit 1
fi
@@ -196,7 +199,7 @@ update_wrappers() {
# Find the bin wrapper
local wrapper
for wrapper in ${GENTOO_LIBDIR} lib lib64 lib32 lib ; do
- wrapper="${ROOT}usr/${wrapper}/misc/gcc-config"
+ wrapper="${EROOT}usr/${wrapper}/misc/gcc-config"
[[ -e ${wrapper} ]] && break
done
@@ -222,7 +225,7 @@ update_wrappers() {
# new one does not.
for x in "${old_wrappers[@]}" ; do
has "${x}" "${new_wrappers[@]}" && continue
- rm -f "${ROOT}usr/bin/${x}" "${ROOT}usr/bin/${CTARGET}-${x}"
+ rm -f "${EROOT}usr/bin/${x}" "${EROOT}usr/bin/${CTARGET}-${x}"
done
# For all toolchains, we want to create the fully qualified
@@ -259,19 +262,19 @@ update_wrappers() {
# Now do the actual wrapper copy with paths to the reference binary
if [[ -x ${ref} ]] ; then
- atomic_cp "${wrapper}" "${ROOT}usr/bin" "${x}" "${ref}"
+ atomic_cp "${wrapper}" "${EROOT}usr/bin" "${x}" "${ref}"
else
ewarn "double insanity with ${x} and ${ref}"
# Make sure we have no stale wrappers
- rm -f "${ROOT}usr/bin/${x}"
+ rm -f "${EROOT}usr/bin/${x}"
fi
done
# legacy cruft, make sure we dont leave it laying around #143205
- rm -f "${ROOT}usr/bin/${CTARGET}-cc" "${ROOT}usr/bin"/{${CTARGET}-,}g{cc,++}{32,64}
+ rm -f "${EROOT}usr/bin/${CTARGET}-cc" "${EROOT}usr/bin"/{${CTARGET}-,}g{cc,++}{32,64}
# install the canonical cpp wrapper
if ! is_cross_compiler ; then
- atomic_cp "${wrapper}" "${ROOT}lib" "cpp" "${ROOT}usr/bin/cpp"
+ atomic_cp "${wrapper}" "${EROOT}lib" "cpp" "${EROOT}usr/bin/cpp"
fi
}
@@ -301,11 +304,11 @@ handle_split_usr() {
LDPATH=${LDPATH%%:*}
# If /usr isn't a sep mount, then don't bother with linking stuff.
- if ln "${ROOT}/${LDPATH}/libgcc.a" "${ROOT}"/lib/.gcc.config.$$ 2>/dev/null ; then
- rm -f "${ROOT}"/lib/.gcc.config.$$
- if [[ -n $(find "${ROOT}"/lib*/lib{gcc_s,unwind}.so* 2>/dev/null) ]] ; then
+ if ln "${ROOT}/${LDPATH}/libgcc.a" "${EROOT}"/lib/.gcc.config.$$ 2>/dev/null ; then
+ rm -f "${EROOT}"/lib/.gcc.config.$$
+ if [[ -n $(find "${EROOT}"/lib*/lib{gcc_s,unwind}.so* 2>/dev/null) ]] ; then
# If we previously had stuff in /, make sure ldconfig gets re-run.
- rm -f "${ROOT}"/lib*/lib{gcc_s,unwind}.so*
+ rm -f "${EROOT}"/lib*/lib{gcc_s,unwind}.so*
return 1
fi
return 0
@@ -317,7 +320,7 @@ handle_split_usr() {
# Only bother with this stuff for the native ABI. We assume the user
# doesn't have critical binaries for non-native ABIs which is fair.
local gcclib
- local libdir="${ROOT}${GENTOO_LIBDIR}"
+ local libdir="${EROOT}${GENTOO_LIBDIR}"
mkdir -p "${libdir}"/.gcc.config.new || return 0 # !?!?!
for gcclib in gcc_s unwind ; do
# This assumes that we always have the .so symlink,
@@ -343,7 +346,7 @@ switch_profile() {
# Make sure we have write access to the dirs. Do not require `root`
# so that we work with prefix/cross/etc... setups that run as user.
- [[ ! -w ${ROOT} ]] && die "need write access to ${ROOT}"
+ [[ ! -w ${EROOT} ]] && die "need write access to ${EROOT}"
if is_cross_compiler ; then
ebegin "Switching cross-compiler to ${CC_COMP}"
@@ -429,7 +432,7 @@ switch_profile() {
local x libdir pkgconfdir
local mver=${CC_COMP_VERSION:0:3}
for libdir in ${MULTIOSDIRS//:/ } ; do
- pkgconfdir="${ROOT}/usr/lib/${libdir}/pkgconfig"
+ pkgconfdir="${EROOT}/usr/lib/${libdir}/pkgconfig"
for x in "" "-${mver}" ; do
x="${pkgconfdir}/libgcj${x}.pc"
if [[ -e ${pkgconfdir}/libgcj-${CC_COMP_VERSION}.pc ]] ; then
@@ -477,7 +480,7 @@ switch_profile() {
ewarn "If you intend to use the gcc from the new profile in an already"
ewarn "running shell, please remember to do:"
echo
- ewarn " . /etc/profile"
+ ewarn " . ${EPREFIX}/etc/profile"
echo
fi
@@ -655,7 +658,7 @@ DOIT=""
FORCE="no"
CC_COMP=
-ENV_D="${ROOT}etc/env.d"
+ENV_D="${EROOT}etc/env.d"
GCC_ENV_D="${ENV_D}/gcc"
for x in "$@" ; do
@@ -786,7 +789,11 @@ if [[ -z ${CC_COMP} ]] ; then
fi
if [[ ${DOIT} != "get_current_profile" ]] ; then
- GCC_LIB=$(get_lib_path | awk -F/ '{ print "/"$2"/"$3"/"$4"/" }')
+ GCC_LIB=$(
+ get_lib_path | \
+ ${SED} -e "s|${EPREFIX:-/}/*|/|g" | \
+ awk -F/ '{ print "/"$2"/"$3"/"$4"/" }'
+ )
# For people who insist on using funky version strings ("4.6.x"
# rather than "4.6.2"), allow them to manually specify it.
@@ -799,11 +806,11 @@ if [[ ${DOIT} != "get_current_profile" ]] ; then
CC_COMP_TARGET=${CC_COMP%-${CC_COMP_VERSION}*}
fi
- if [[ ! -d ${ROOT}/${GCC_LIB}/${CC_COMP_TARGET}/${CC_COMP_VERSION} ]]; then
+ if [[ ! -d ${EROOT}/${GCC_LIB}/${CC_COMP_TARGET}/${CC_COMP_VERSION} ]]; then
CC_COMP_VERSION=${CC_COMP_VERSION%-*}
fi
- if [[ ! -d ${ROOT}/${GCC_LIB}/${CC_COMP_TARGET}/${CC_COMP_VERSION} ]] || \
+ if [[ ! -d ${EROOT}/${GCC_LIB}/${CC_COMP_TARGET}/${CC_COMP_VERSION} ]] || \
[[ ! -f ${GCC_ENV_D}/${CC_COMP} ]]
then
eerror "${argv0}: Profile does not exist or invalid setting for ${GCC_ENV_D}/${CC_COMP}" 1>&2
diff --git a/wrapper.c b/wrapper.c
index 65e5317..50c35a4 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -21,8 +21,12 @@
#include <sys/stat.h>
#include <sys/types.h>
-#define GCC_CONFIG "/usr/bin/gcc-config"
-#define ENVD_BASE "/etc/env.d/05gcc"
+#ifndef EPREFIX
+# define EPREFIX ""
+#endif
+
+#define GCC_CONFIG EPREFIX "/usr/bin/gcc-config"
+#define ENVD_BASE EPREFIX "/etc/env.d/05gcc"
#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
@@ -146,7 +150,7 @@ static int find_target_in_envd(struct wrapper_data *data, int cross_compile)
/* for the sake of speed, we'll keep a symlink around for
* the native compiler. #190260
*/
- snprintf(envd_file, sizeof(envd_file)-1, "/etc/env.d/gcc/.NATIVE");
+ snprintf(envd_file, sizeof(envd_file)-1, EPREFIX "/etc/env.d/gcc/.NATIVE");
} else {
char *ctarget, *end = strrchr(data->name, '-');
if (end == NULL)
@@ -289,8 +293,8 @@ int main(int argc, char *argv[])
data.name = wrapper_aliases[i].target;
/* What is the full name of our wrapper? */
- data.fullname = xmalloc(strlen(data.name) + sizeof("/usr/bin/") + 1);
- sprintf(data.fullname, "/usr/bin/%s", data.name);
+ data.fullname = xmalloc(strlen(data.name) + sizeof(EPREFIX "/usr/bin/") + 1);
+ sprintf(data.fullname, EPREFIX "/usr/bin/%s", data.name);
find_wrapper_target(&data);
next reply other threads:[~2013-01-12 20:45 UTC|newest]
Thread overview: 86+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-12 17:05 Mike Frysinger [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-12-08 3:26 [gentoo-commits] proj/gcc-config:master commit in: / Sam James
2024-12-08 3:19 Sam James
2024-12-08 3:18 Sam James
2023-05-31 5:55 Sam James
2023-05-31 5:54 Sam James
2023-05-14 17:25 Sam James
2023-04-30 2:59 Sam James
2023-01-05 0:16 Sam James
2022-12-28 19:12 Sam James
2022-12-28 19:12 Sam James
2022-12-28 19:12 Sam James
2022-10-10 14:09 Sam James
2022-10-09 20:55 Sam James
2022-10-08 22:02 Sam James
2022-09-29 22:36 Sam James
2022-09-29 22:36 Sam James
2022-09-22 23:46 Sam James
2021-11-13 4:49 Sam James
2021-11-13 4:49 Sam James
2021-02-26 9:36 Sergei Trofimovich
2021-02-26 9:36 Sergei Trofimovich
2021-02-26 9:36 Sergei Trofimovich
2021-02-26 9:36 Sergei Trofimovich
2021-02-26 8:40 Sergei Trofimovich
2021-01-23 17:51 Sergei Trofimovich
2020-09-05 18:11 Sergei Trofimovich
2020-06-24 20:47 Sergei Trofimovich
2020-06-21 11:53 Sergei Trofimovich
2020-06-21 11:50 Sergei Trofimovich
2020-05-23 7:28 Sergei Trofimovich
2020-05-22 13:23 Sergei Trofimovich
2020-05-22 13:20 Sergei Trofimovich
2020-05-22 11:33 Sergei Trofimovich
2020-05-22 10:39 Sergei Trofimovich
2020-05-22 10:03 Sergei Trofimovich
2020-05-22 9:40 Sergei Trofimovich
2020-04-10 10:08 Sergei Trofimovich
2020-01-26 13:44 Sergei Trofimovich
2020-01-26 13:26 Sergei Trofimovich
2019-09-08 8:37 Sergei Trofimovich
2019-09-08 8:29 Sergei Trofimovich
2019-09-07 22:08 Sergei Trofimovich
2019-09-07 9:39 Sergei Trofimovich
2019-09-07 9:39 Sergei Trofimovich
2019-09-07 9:15 Sergei Trofimovich
2019-09-07 9:01 Sergei Trofimovich
2019-09-07 8:47 Sergei Trofimovich
2019-09-07 8:22 Sergei Trofimovich
2019-09-06 7:29 Sergei Trofimovich
2019-09-06 7:23 Sergei Trofimovich
2019-09-06 6:53 Sergei Trofimovich
2019-09-06 6:53 Sergei Trofimovich
2019-09-05 22:35 Sergei Trofimovich
2019-09-05 7:24 Sergei Trofimovich
2019-09-05 6:47 Sergei Trofimovich
2019-09-05 6:42 Sergei Trofimovich
2019-09-05 6:28 Sergei Trofimovich
2019-09-04 19:00 Sergei Trofimovich
2019-09-04 19:00 Sergei Trofimovich
2018-08-24 16:40 Sergei Trofimovich
2018-08-24 8:50 Sergei Trofimovich
2018-08-24 0:23 Sergei Trofimovich
2018-08-13 22:39 Sergei Trofimovich
2018-08-13 21:55 Sergei Trofimovich
2017-12-16 21:11 Andreas Hüttel
2017-12-16 20:15 Andreas Hüttel
2017-12-15 8:33 Fabian Groffen
2015-08-05 8:12 Mike Frysinger
2015-08-05 7:52 Mike Frysinger
2015-05-13 4:26 Ryan Hill
2013-05-22 23:54 Mike Frysinger
2013-01-12 17:20 Mike Frysinger
2013-01-12 17:17 Mike Frysinger
2013-01-12 17:14 Mike Frysinger
2013-01-02 18:30 Mike Frysinger
2013-01-02 3:52 Mike Frysinger
2012-12-29 21:08 Mike Frysinger
2012-11-19 6:52 Mike Frysinger
2012-11-19 1:11 Mike Frysinger
2012-11-19 1:11 Mike Frysinger
2012-06-10 4:00 Mike Frysinger
2012-06-10 4:00 Mike Frysinger
2012-04-14 1:22 Mike Frysinger
2012-04-14 1:22 Mike Frysinger
2012-04-14 1:22 Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1358010456.deaecbb404c8a60f9aec3bc85a4fc1621a561687.vapier@gentoo \
--to=vapier@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox