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