rtems/bsps: Optionally support arch/bsp if used

Updates #4717
This commit is contained in:
Chris Johns 2022-09-30 17:09:57 +10:00
parent d592ee8838
commit 369b60a0b4

View File

@ -39,6 +39,44 @@
%{pkgconfig crosscompile yes} %{pkgconfig crosscompile yes}
%{pkgconfig filter-flags yes} %{pkgconfig filter-flags yes}
#
# We need a BSP from the user.
#
%ifn %{defined with_rtems_bsp}
%if %{rtems_bsp_error}
%error No RTEMS BSP specified: --with-rtems-bsp=bsp
%endif
%define with_rtems_bsp sparc/erc32
%endif
%define rtems_bsp %{with_rtems_bsp}
#
# If the BSP(s) have a '/' it is the arch/bsp notation.
#
%define is_arch_bsp %(echo %{rtems_bsp} | sed -e 's/.*\/.*/yes/g')
%if %{is_arch_bsp} == yes
%define rtems_ab_bsps \
%(x=''; \
for b in %{rtems_bsp}; do x="$x "$(echo $b | sed -e 's/.*\///g'); done; \
echo $x)
%define rtems_ab_archs \
%(x=''; \
for b in %{rtems_bsp}; do x="$x "$(echo $b | sed -e 's/\/.*//g'); done; \
echo $x | tr ' ' '\n' | sort | uniq)
%define rtems_arch_count %(echo %{rtems_ab_archs} | tr ' ' '\n' | wc -l)
%if %{rtems_arch_count} != 1
%error Invalid BSP architecture count
%endif
%define rtems_bsp %{rtems_ab_bsps}
%define rtems_target %{rtems_ab_archs}-rtems%{rtems_version}
%define rtems_host %{rtems_target}
%endif
%define rtems_bsp_count %(echo %{rtems_bsp} | tr ' ' '\n' | wc -l)
%if %{rtems_bsp_count} != 1
%error Building packages with more than one BSP is not supported
%endif
# #
# We need a host from the user to specifiy the RTEMS architecture and major # We need a host from the user to specifiy the RTEMS architecture and major
# version. It can be defined in rtems_host. # version. It can be defined in rtems_host.
@ -52,17 +90,6 @@
%endif %endif
%endif %endif
#
# We need a BSP from the user.
#
%ifn %{defined with_rtems_bsp}
%if %{rtems_bsp_error}
%error No RTEMS BSP specified: --with-rtems-bsp=bsp
%endif
%define with_rtems_bsp sparc/erc32
%endif
%define rtems_bsp %{with_rtems_bsp}
# #
# If no tools or RTEMS provided use the prefix. If staging use the staging # If no tools or RTEMS provided use the prefix. If staging use the staging
# root. # root.
@ -215,14 +242,14 @@
# #
# Note: default BSP flags include the standard RTEMS libraries. # Note: default BSP flags include the standard RTEMS libraries.
# #
%define rtems-dep-check %(%{_sbdir}/sb/rtems-build-dep -c %{with_tools}/bin/%{rtems_bsp_cc} %define rtems-dep-check %{_sbdir}/sb/rtems-build-dep -c %{with_tools}/bin/%{rtems_bsp_cc}
%define rtems-libbsd %{rtems-dep-check} -L %{rtems_bsp_libpath} -l libbsd.a) %define rtems-libbsd %(%{rtems-dep-check} -L %{rtems_bsp_libpath} -l libbsd.a)
%if %{rtems-libbsd} == found %if %{rtems-libbsd} == found
%define rtems_bsp_libs %{rtems_bsp_libs} -lbsd -lm -lz %define rtems_bsp_libs %{rtems_bsp_libs} -lbsd -lm -lz
%endif %endif
%define rtems-defaultconfig %{rtems-dep-check} -L %{rtems_bsp_libpath} -l librtemsdefaultconfig.a) %define rtems-defaultconfig %(%{rtems-dep-check} -L %{rtems_bsp_libpath} -l librtemsdefaultconfig.a)
%if %{rtems-defaultconfig} == found %if %{rtems-defaultconfig} == found
%define rtems_bsp_libs %{rtems_bsp_libs} -lrtemsdefaultconfig %define rtems_bsp_libs %{rtems_bsp_libs} -lrtemsdefaultconfig
%endif %endif