summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-cross.inc
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-cross.inc')
-rw-r--r--meta/recipes-devtools/gcc/gcc-cross.inc190
1 files changed, 190 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-cross.inc b/meta/recipes-devtools/gcc/gcc-cross.inc
new file mode 100644
index 0000000000..777c970217
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-cross.inc
@@ -0,0 +1,190 @@
1inherit cross
2
3INHIBIT_DEFAULT_DEPS = "1"
4EXTRADEPENDS = ""
5DEPENDS = "virtual/${TARGET_PREFIX}binutils virtual/${TARGET_PREFIX}libc-for-gcc ${EXTRADEPENDS} ${NATIVEDEPS}"
6PROVIDES = "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}g++"
7python () {
8 if d.getVar("TARGET_OS", True).startswith("linux"):
9 d.setVar("EXTRADEPENDS", "linux-libc-headers")
10}
11
12require gcc-configure-common.inc
13
14EXTRA_OECONF += " --enable-poison-system-directories"
15EXTRA_OECONF_append_sh4 = " --with-multilib-list= --enable-incomplete-targets "
16
17EXTRA_OECONF += "--disable-libunwind-exceptions \
18 --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native} \
19 --with-system-zlib "
20
21EXTRA_OECONF_PATHS = " \
22 --with-gxx-include-dir=${STAGING_DIR_TARGET}${target_includedir}/c++ \
23 --with-sysroot=${STAGING_DIR_TARGET} \
24 --with-build-sysroot=${STAGING_DIR_TARGET}"
25
26ARCH_FLAGS_FOR_TARGET += "-isystem${STAGING_DIR_TARGET}${target_includedir}"
27
28do_configure_prepend () {
29 sed -i 's/BUILD_INFO=info/BUILD_INFO=/' ${S}/gcc/configure
30}
31
32do_compile () {
33 export CC="${BUILD_CC}"
34 export AR_FOR_TARGET="${TARGET_SYS}-ar"
35 export RANLIB_FOR_TARGET="${TARGET_SYS}-ranlib"
36 export LD_FOR_TARGET="${TARGET_SYS}-ld"
37 export NM_FOR_TARGET="${TARGET_SYS}-nm"
38 export CC_FOR_TARGET="${CCACHE} ${TARGET_SYS}-gcc ${TARGET_CC_ARCH}"
39 export CFLAGS_FOR_TARGET="${TARGET_CFLAGS}"
40 export CPPFLAGS_FOR_TARGET="${TARGET_CPPFLAGS}"
41 export CXXFLAGS_FOR_TARGET="${TARGET_CXXFLAGS}"
42 export LDFLAGS_FOR_TARGET="${TARGET_LDFLAGS}"
43
44 oe_runmake all-host all-target-libgcc
45 # now generate script to drive testing
46 echo "#!/usr/bin/env sh" >${B}/${TARGET_PREFIX}testgcc
47 set >> ${B}/${TARGET_PREFIX}testgcc
48 # prune out the unneeded vars
49 sed -i -e "/^BASH/d" ${B}/${TARGET_PREFIX}testgcc
50 sed -i -e "/^USER/d" ${B}/${TARGET_PREFIX}testgcc
51 sed -i -e "/^OPT/d" ${B}/${TARGET_PREFIX}testgcc
52 sed -i -e "/^DIRSTACK/d" ${B}/${TARGET_PREFIX}testgcc
53 sed -i -e "/^EUID/d" ${B}/${TARGET_PREFIX}testgcc
54 sed -i -e "/^FUNCNAME/d" ${B}/${TARGET_PREFIX}testgcc
55 sed -i -e "/^GROUPS/d" ${B}/${TARGET_PREFIX}testgcc
56 sed -i -e "/^HOST/d" ${B}/${TARGET_PREFIX}testgcc
57 sed -i -e "/^HOME/d" ${B}/${TARGET_PREFIX}testgcc
58 sed -i -e "/^IFS/d" ${B}/${TARGET_PREFIX}testgcc
59 sed -i -e "/^LC_ALL/d" ${B}/${TARGET_PREFIX}testgcc
60 sed -i -e "/^LOGNAME/d" ${B}/${TARGET_PREFIX}testgcc
61 sed -i -e "/^MACHTYPE/d" ${B}/${TARGET_PREFIX}testgcc
62 sed -i -e "/^OSTYPE/d" ${B}/${TARGET_PREFIX}testgcc
63 sed -i -e "/^PIPE/d" ${B}/${TARGET_PREFIX}testgcc
64 sed -i -e "/^SHELL/d" ${B}/${TARGET_PREFIX}testgcc
65 sed -i -e "/^'/d" ${B}/${TARGET_PREFIX}testgcc
66 sed -i -e "/^UID/d" ${B}/${TARGET_PREFIX}testgcc
67 sed -i -e "/^TERM/d" ${B}/${TARGET_PREFIX}testgcc
68 sed -i -e "/^PATCH_GET/d" ${B}/${TARGET_PREFIX}testgcc
69 sed -i -e "/^PKG_/d" ${B}/${TARGET_PREFIX}testgcc
70 sed -i -e "/^POSIXLY_/d" ${B}/${TARGET_PREFIX}testgcc
71 sed -i -e "/^PPID/d" ${B}/${TARGET_PREFIX}testgcc
72 sed -i -e "/^PS4/d" ${B}/${TARGET_PREFIX}testgcc
73 sed -i -e "/^Q/d" ${B}/${TARGET_PREFIX}testgcc
74 sed -i -e "/^SHLVL/d" ${B}/${TARGET_PREFIX}testgcc
75 sed -i -e "/^STAGING/d" ${B}/${TARGET_PREFIX}testgcc
76 sed -i -e "/^LD_LIBRARY_PATH/d" ${B}/${TARGET_PREFIX}testgcc
77 sed -i -e "/^PSEUDO/d" ${B}/${TARGET_PREFIX}testgcc
78
79 # append execution part of the script
80cat >> ${B}/${TARGET_PREFIX}testgcc << STOP
81target="\$1"
82usage () {
83 echo "Usage:"
84 echo "\$0 user@target 'extra options to dejagnu'"
85 echo "\$0 target 'extra options to dejagnu'"
86 echo "\$0 target"
87 echo "e.g. \$0 192.168.7.2 ' dg.exp=visibility-d.c'"
88 echo "will only run visibility-d.c test case"
89 echo "e.g. \$0 192.168.7.2 '/-mthumb dg.exp=visibility-d.c'"
90 echo "will only run visibility-d.c test case in thumb mode"
91 echo "You need to have dejagnu autogen expect installed"
92 echo "on the build host"
93 }
94if [ "x\$target" = "x" ]
95then
96 echo "Please specify the target machine and remote user in form of user@target\n"
97 usage
98 exit 1;
99fi
100
101shift
102
103echo "\$target" | grep "@" 2>&1 > /dev/null
104if [ "x\$?" = "x0" ]
105then
106 user=\$(echo \$target | cut -d '@' -f 1)
107 target=\$(echo \$target | cut -d '@' -f 2)
108else
109 user=\$USER
110fi
111ssh \$user@\$target date 2>&1 > /dev/null
112if [ "x\$?" != "x0" ]
113then
114 echo "Failed connecting to \$user@\$target it could be because"
115 echo "you don't have passwordless ssh setup to access \$target"
116 echo "or sometimes host key has been changed"
117 echo "in such case do something like below on build host"
118 echo "ssh-keygen -f "~/.ssh/known_hosts" -R \$target"
119 echo "and then try ssh \$user@\$target"
120
121 usage
122 exit 1
123fi
124 echo "lappend boards_dir [pwd]/../../.." > ${B}/site.exp
125 echo "load_generic_config \"unix\"" > ${B}/${PACKAGE_ARCH}.exp
126 echo "set_board_info username \$user" >> ${B}/${PACKAGE_ARCH}.exp
127 echo "set_board_info rsh_prog ssh" >> ${B}/${PACKAGE_ARCH}.exp
128 echo "set_board_info rcp_prog scp" >> ${B}/${PACKAGE_ARCH}.exp
129 echo "set_board_info hostname \$target" >> ${B}/${PACKAGE_ARCH}.exp
130 DEJAGNU=${B}/site.exp make -k check RUNTESTFLAGS="--target_board=${PACKAGE_ARCH}\$@"
131
132STOP
133
134 chmod +x ${B}/${TARGET_PREFIX}testgcc
135
136}
137
138INHIBIT_PACKAGE_STRIP = "1"
139
140# Compute how to get from libexecdir to bindir in python (easier than shell)
141BINRELPATH = "${@os.path.relpath(d.expand("${STAGING_DIR_NATIVE}${prefix_native}/bin/${MULTIMACH_TARGET_SYS}"), d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"))}"
142
143do_install () {
144 oe_runmake 'DESTDIR=${D}' install-host
145
146 install -d ${D}${target_base_libdir}
147 install -d ${D}${target_libdir}
148
149 # Link gfortran to g77 to satisfy not-so-smart configure or hard coded g77
150 # gfortran is fully backwards compatible. This is a safe and practical solution.
151 ln -sf ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}gfortran ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}g77 || true
152
153
154 # Insert symlinks into libexec so when tools without a prefix are searched for, the correct ones are
155 # found. These need to be relative paths so they work in different locations.
156 dest=${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/
157 install -d $dest
158 for t in ar as ld nm objcopy objdump ranlib strip g77 gcc cpp gfortran; do
159 ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t $dest$t
160 ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t ${dest}${TARGET_PREFIX}$t
161 done
162
163 # Remove things we don't need but keep share/java
164 for d in info man share/doc share/locale share/man share/info; do
165 rm -rf ${D}${STAGING_DIR_NATIVE}${prefix_native}/$d
166 done
167
168 # libquadmath headers need to be available in the gcc libexec dir
169 install -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
170 cp ${S}/libquadmath/quadmath.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
171 cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
172
173 # We use libiberty from binutils
174 find ${D}${exec_prefix}/lib -name libiberty.a | xargs rm -f
175 find ${D}${exec_prefix}/lib -name libiberty.h | xargs rm -f
176
177 # gcc-runtime installs libgcc into a special location in staging since it breaks doing a standalone build
178 case ${PN} in
179 *gcc-cross|*gcc-crosssdk)
180 dest=${D}/${includedir}/gcc-build-internal-${MULTIMACH_TARGET_SYS}
181 cp -fpPR . $dest
182 ;;
183 esac
184}
185
186do_package[noexec] = "1"
187do_packagedata[noexec] = "1"
188do_package_write_ipk[noexec] = "1"
189do_package_write_rpm[noexec] = "1"
190do_package_write_deb[noexec] = "1"