1require gcc-configure-common.inc
2
3EXTRA_OECONF_PATHS = "\
4    --with-sysroot=/not/exist \
5    --with-build-sysroot=${STAGING_DIR_TARGET} \
6"
7
8do_configure () {
9	for target in libbacktrace libgfortran
10	do
11		rm -rf ${B}/${TARGET_SYS}/$target/
12		mkdir -p ${B}/${TARGET_SYS}/$target/
13		cd ${B}/${TARGET_SYS}/$target/
14		chmod a+x ${S}/$target/configure
15		relpath=${@os.path.relpath("${S}", "${B}/${TARGET_SYS}")}
16		../$relpath/$target/configure ${CONFIGUREOPTS} ${EXTRA_OECONF}
17		# Easiest way to stop bad RPATHs getting into the library since we have a
18		# broken libtool here
19		sed -i -e 's/hardcode_into_libs=yes/hardcode_into_libs=no/' ${B}/${TARGET_SYS}/$target/libtool
20	done
21}
22EXTRACONFFUNCS += "extract_stashed_builddir"
23do_configure[depends] += "${COMPILERDEP}"
24
25do_compile () {
26	for target in libbacktrace libgfortran
27	do
28		cd ${B}/${TARGET_SYS}/$target/
29		oe_runmake MULTIBUILDTOP=${B}/${TARGET_SYS}/$target/
30	done
31}
32
33do_install () {
34	cd ${B}/${TARGET_SYS}/libgfortran/
35	oe_runmake 'DESTDIR=${D}' MULTIBUILDTOP=${B}/${TARGET_SYS}/libgfortran/ install
36	if [ -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude ]; then
37		rmdir --ignore-fail-on-non-empty -p ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude
38	fi
39	if [ -d ${D}${infodir} ]; then
40		rmdir --ignore-fail-on-non-empty -p ${D}${infodir}
41	fi
42	chown -R root:root ${D}
43}
44
45INHIBIT_DEFAULT_DEPS = "1"
46DEPENDS = "gcc-runtime gcc-cross-${TARGET_ARCH}"
47
48BBCLASSEXTEND = "nativesdk"
49
50PACKAGES = "\
51    ${PN}-dbg \
52    libgfortran \
53    libgfortran-dev \
54    libgfortran-staticdev \
55"
56
57LICENSE:${PN} = "GPL-3.0-with-GCC-exception"
58LICENSE:${PN}-dev = "GPL-3.0-with-GCC-exception"
59LICENSE:${PN}-dbg = "GPL-3.0-with-GCC-exception"
60
61FILES:${PN} = "${libdir}/libgfortran.so.*"
62FILES:${PN}-dev = "\
63    ${libdir}/libgfortran*.so \
64    ${libdir}/libgfortran.spec \
65    ${libdir}/libgfortran.la \
66    ${libdir}/gcc/${TARGET_SYS}/${BINV}/libgfortranbegin.* \
67    ${libdir}/gcc/${TARGET_SYS}/${BINV}/libcaf_single* \
68    ${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude/ \
69    ${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ \
70"
71FILES:${PN}-staticdev = "${libdir}/libgfortran.a"
72
73INSANE_SKIP:${MLPREFIX}libgfortran-dev = "staticdev"
74
75do_package_write_ipk[depends] += "virtual/${MLPREFIX}libc:do_packagedata"
76do_package_write_deb[depends] += "virtual/${MLPREFIX}libc:do_packagedata"
77do_package_write_rpm[depends] += "virtual/${MLPREFIX}libc:do_packagedata"
78
79python __anonymous () {
80    f = d.getVar("FORTRAN")
81    if "fortran" not in f:
82        raise bb.parse.SkipRecipe("libgfortran needs fortran support to be enabled in the compiler")
83}
84