blob: f47936061ddff792637d13e2c16bde649d21faf9 [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
Patrick Williamsc124f4f2015-09-15 14:41:29 -050075 sed -i -e "/^PKG_/d" ${B}/${TARGET_PREFIX}testgcc
76 sed -i -e "/^POSIXLY_/d" ${B}/${TARGET_PREFIX}testgcc
77 sed -i -e "/^PPID/d" ${B}/${TARGET_PREFIX}testgcc
78 sed -i -e "/^PS4/d" ${B}/${TARGET_PREFIX}testgcc
79 sed -i -e "/^Q/d" ${B}/${TARGET_PREFIX}testgcc
80 sed -i -e "/^SHLVL/d" ${B}/${TARGET_PREFIX}testgcc
81 sed -i -e "/^STAGING/d" ${B}/${TARGET_PREFIX}testgcc
82 sed -i -e "/^LD_LIBRARY_PATH/d" ${B}/${TARGET_PREFIX}testgcc
83 sed -i -e "/^PSEUDO/d" ${B}/${TARGET_PREFIX}testgcc
84
85 # append execution part of the script
86cat >> ${B}/${TARGET_PREFIX}testgcc << STOP
87target="\$1"
88usage () {
89 echo "Usage:"
90 echo "\$0 user@target 'extra options to dejagnu'"
91 echo "\$0 target 'extra options to dejagnu'"
92 echo "\$0 target"
93 echo "e.g. \$0 192.168.7.2 ' dg.exp=visibility-d.c'"
94 echo "will only run visibility-d.c test case"
95 echo "e.g. \$0 192.168.7.2 '/-mthumb dg.exp=visibility-d.c'"
96 echo "will only run visibility-d.c test case in thumb mode"
97 echo "You need to have dejagnu autogen expect installed"
98 echo "on the build host"
99 }
100if [ "x\$target" = "x" ]
101then
102 echo "Please specify the target machine and remote user in form of user@target\n"
103 usage
104 exit 1;
105fi
106
107shift
108
109echo "\$target" | grep "@" 2>&1 > /dev/null
110if [ "x\$?" = "x0" ]
111then
112 user=\$(echo \$target | cut -d '@' -f 1)
113 target=\$(echo \$target | cut -d '@' -f 2)
114else
115 user=\$USER
116fi
117ssh \$user@\$target date 2>&1 > /dev/null
118if [ "x\$?" != "x0" ]
119then
120 echo "Failed connecting to \$user@\$target it could be because"
121 echo "you don't have passwordless ssh setup to access \$target"
122 echo "or sometimes host key has been changed"
123 echo "in such case do something like below on build host"
124 echo "ssh-keygen -f "~/.ssh/known_hosts" -R \$target"
125 echo "and then try ssh \$user@\$target"
126
127 usage
128 exit 1
129fi
130 echo "lappend boards_dir [pwd]/../../.." > ${B}/site.exp
131 echo "load_generic_config \"unix\"" > ${B}/${PACKAGE_ARCH}.exp
132 echo "set_board_info username \$user" >> ${B}/${PACKAGE_ARCH}.exp
133 echo "set_board_info rsh_prog ssh" >> ${B}/${PACKAGE_ARCH}.exp
134 echo "set_board_info rcp_prog scp" >> ${B}/${PACKAGE_ARCH}.exp
135 echo "set_board_info hostname \$target" >> ${B}/${PACKAGE_ARCH}.exp
136 DEJAGNU=${B}/site.exp make -k check RUNTESTFLAGS="--target_board=${PACKAGE_ARCH}\$@"
137
138STOP
139
140 chmod +x ${B}/${TARGET_PREFIX}testgcc
141
142}
143
144INHIBIT_PACKAGE_STRIP = "1"
145
146# Compute how to get from libexecdir to bindir in python (easier than shell)
147BINRELPATH = "${@os.path.relpath(d.expand("${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_SYS}"), d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"))}"
148
149do_install () {
150 ( cd ${B}/${TARGET_SYS}/libgcc; oe_runmake 'DESTDIR=${D}' install-unwind_h )
151 oe_runmake 'DESTDIR=${D}' install-host
152
153 install -d ${D}${target_base_libdir}
154 install -d ${D}${target_libdir}
155
156 # Link gfortran to g77 to satisfy not-so-smart configure or hard coded g77
157 # gfortran is fully backwards compatible. This is a safe and practical solution.
158 ln -sf ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}gfortran ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}g77 || true
159
160
161 # Insert symlinks into libexec so when tools without a prefix are searched for, the correct ones are
162 # found. These need to be relative paths so they work in different locations.
163 dest=${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/
164 install -d $dest
165 for t in ar as ld nm objcopy objdump ranlib strip g77 gcc cpp gfortran; do
166 ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t $dest$t
167 ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t ${dest}${TARGET_PREFIX}$t
168 done
169
170 # Remove things we don't need but keep share/java
171 for d in info man share/doc share/locale share/man share/info; do
172 rm -rf ${D}${STAGING_DIR_NATIVE}${prefix_native}/$d
173 done
174
175 # libquadmath headers need to be available in the gcc libexec dir
176 install -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
177 cp ${S}/libquadmath/quadmath.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
178 cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
179
180 # We use libiberty from binutils
181 find ${D}${exec_prefix}/lib -name libiberty.a | xargs rm -f
182 find ${D}${exec_prefix}/lib -name libiberty.h | xargs rm -f
183
184 # gcc-runtime installs libgcc into a special location in staging since it breaks doing a standalone build
185 case ${PN} in
186 *gcc-cross-${TARGET_ARCH}|*gcc-crosssdk-${TARGET_ARCH})
187 dest=${D}/${includedir}/gcc-build-internal-${TARGET_SYS}
188 hardlinkdir . $dest
189 ;;
190 esac
191}
192
193do_package[noexec] = "1"
194do_packagedata[noexec] = "1"
195do_package_write_ipk[noexec] = "1"
196do_package_write_rpm[noexec] = "1"
197do_package_write_deb[noexec] = "1"