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} -fcanon-prefix-map -fdebug-prefix-map=${S}=${TARGET_DBGSRC_DIR} -fdebug-prefix-map=${B}=${TARGET_DBGSRC_DIR} -gno-record-gcc-switches"
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
50# avoid virtual/libc
51INHIBIT_DEFAULT_DEPS = "1"
52DEPENDS = "virtual/${HOST_PREFIX}gcc virtual/${HOST_PREFIX}compilerlibs"
53
54BBCLASSEXTEND = "nativesdk"
55
56PACKAGES = "\
57    ${PN}-dbg \
58    libgfortran \
59    libgfortran-dev \
60    libgfortran-staticdev \
61"
62
63LICENSE:${PN} = "GPL-3.0-with-GCC-exception"
64LICENSE:${PN}-dev = "GPL-3.0-with-GCC-exception"
65LICENSE:${PN}-dbg = "GPL-3.0-with-GCC-exception"
66
67FILES:${PN} = "${libdir}/libgfortran.so.*"
68FILES:${PN}-dev = "\
69    ${libdir}/libgfortran*.so \
70    ${libdir}/libgfortran.spec \
71    ${libdir}/libgfortran.la \
72    ${libdir}/gcc/${TARGET_SYS}/${BINV}/libgfortranbegin.* \
73    ${libdir}/gcc/${TARGET_SYS}/${BINV}/libcaf_single* \
74    ${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude/ \
75    ${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ \
76"
77FILES:${PN}-staticdev = "${libdir}/libgfortran.a"
78
79INSANE_SKIP:${MLPREFIX}libgfortran-dev = "staticdev"
80
81do_package_write_ipk[depends] += "virtual/${MLPREFIX}libc:do_packagedata"
82do_package_write_deb[depends] += "virtual/${MLPREFIX}libc:do_packagedata"
83do_package_write_rpm[depends] += "virtual/${MLPREFIX}libc:do_packagedata"
84
85python __anonymous () {
86    f = d.getVar("FORTRAN")
87    if "fortran" not in f:
88        raise bb.parse.SkipRecipe("libgfortran needs fortran support to be enabled in the compiler")
89}
90