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