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