blob: 801cd5cc21fbbf3816289590401651247354c6fe (
plain) (
tree)
|
|
#
# RTEMS BSP Support
#
#
# The RTEMS BSP support requires the host tuple, the RTEMS BSP and the path to
# the tools. The prefix is set to an installed RTEMS. The built package is
# installed into the prefix.
#
# Keeping the package's installed path in the RTEMS install path and separate
# to the tools lets the tools version vary independently.
#
# Provide the path to the RTEMS tools if not in the prefix with the
# --with-tools option. If --with-tools is not provided use the prefix.
#
# Provide the path to the installed RTEMS kernel if not in the prefix with the
# --with-rtems option. If --with-rtems is not provided use the prefix.
#
# Note, only a single path (--with-rtems) for the RTEMS kernel and any other
# add on or 3rd party libraries is supported.
#
#
# If a dry-run and with download ignore errors and correct setting for tools
# and BSPs. Only after the source to download.
#
%if %{_dry_run}
%log BSP configuration errors ignored
%define rtems_bsp_error 0
%else
%define rtems_bsp_error 1
%endif
#
# Set up how we manage pkgconfig. Enable support when crosscompiling,
# and filter specific optimisation and warning from the flags that
# RTEMS exports.
#
%{pkgconfig crosscompile yes}
%{pkgconfig filter-flags yes}
#
# We need a host from the user to specifiy the RTEMS architecture and major
# version. It can be defined in rtems_host.
#
%if %{defined rtems_host}
%{triplet _host %{rtems_host}}
%endif
%if %{rtems_bsp_error}
%if %{_host} == %{nil} || %{_host} == %{_build}
%error No RTEMS host or BSP specified: --host=<arch>-rtems<ver>
%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
# root.
#
%ifn %{defined with_tools}
%if %{install_mode} == staging && \
%{path check isfile %{stagingroot}/bin/%{_host}-%{_host_cc}}
%define rtems_tools_staged 1
%define with_tools %{stagingroot}
%define rtems_waf_tools --rtems-tools=%{with_tools}
%else
%define rtems_tools_staged 1
%define with_tools %{_prefix}
%define rtems_waf_tools %{nil}
%endif
%else
%define rtems_waf_tools --rtems-tools=%{with_tools}
%endif
%define rtems_host_cc_valid \
%{path check isfile %{with_tools}/bin/%{_host}-%{_host_cc}}
%if !%{rtems_host_cc_valid} && %{rtems_bsp_error} && !%{_rsb_getting_source}
%error RTEMS tools not found (%{_host}-%{_host_cc}) found; Please check the --with-tools option or --prefix.
%endif
%ifn %{defined with_rtems}
%{pkgconfig prefix %{stagingroot}/lib/pkgconfig}
%if %{install_mode} == staging && %{pkgconfig check %{_host}-%{rtems_bsp}}
%define rtems_bsp_staged 1
%define with_rtems %{stagingroot}
%define rtems_waf_rtems --rtems=%{with_rtems}
%else
%define rtems_bsp_staged 0
%define with_rtems %{_prefix}
%define rtems_waf_rtems %{nil}
%endif
%else
%define rtems_waf_rtems --rtems=%{with_rtems}
%endif
#
# Set the pkgconfig prefix path to the RTEMS prefix.
#
%{pkgconfig prefix %{with_rtems}/lib/pkgconfig}
#
# Check we can find the BSP's pkgconfig file.
#
%if !%{pkgconfig check %{_host}-%{rtems_bsp}} && %{rtems_bsp_error} && !%{_rsb_getting_source}
%error RTEMS BSP not found (%{_host}-%{rtems_bsp}.pc); Please check the --with-rtems option or --prefix.
%endif
#
# Set the path to the tools.
#
%{path prepend %{with_tools}/bin}
#
# Update the configure paths to be BSP specific.
#
%define rtems_bsp_prefix %{_prefix}/%{_host}/%{rtems_bsp}
%define _exec_prefix %{rtems_bsp_prefix}
%define _bindir %{_exec_prefix}/bin
%define _sbindir %{_exec_prefix}/sbin
%define _libexecdir %{_exec_prefix}/libexec
%define _datarootdir %{_exec_prefix}/share
%define _datadir %{_datarootdir}
%define _sysconfdir %{_exec_prefix}/etc
%define _sharedstatedir %{_exec_prefix}/com
%define _localstatedir %{_exec_prefix}/var
%define _includedir %{_libdir}/include
%define _lib lib
%define _libdir %{_exec_prefix}/%{_lib}
%define _libexecdir %{_exec_prefix}/libexec
%define _mandir %{_datarootdir}/man
%define _infodir %{_datarootdir}/info
%define _localedir %{_datarootdir}/locale
%define _localedir %{_datadir}/locale
%define _localstatedir %{_exec_prefix}/var
#
# The RTEMS BSP Flags
#
%define rtems_bsp_includes -I%{_includedir}
%define rtems_bsp_ccflags %{pkgconfig ccflags %{_host}-%{rtems_bsp}}
%define rtems_bsp_cflags %{pkgconfig cflags %{_host}-%{rtems_bsp}}
%define rtems_bsp_ldflags %{pkgconfig ldflags %{_host}-%{rtems_bsp}}
%define rtems_bsp_libs %{pkgconfig libs %{_host}-%{rtems_bsp}}
%if %{rtems_bsp_cflags} == %{nil} && %{rtems_bsp_error} && !%{_rsb_getting_source}
%error No RTEMS BSP CFLAGS found; Please check the --with-rtems-bsp option.
%endif
#
# C++ flags are the C flags.
#
%if %{rtems_bsp_ccflags} == %{nil}
%define rtems_bsp_ccflags %{rtems_bsp_cflags}
%endif
#
# If there are no LDFLAGS create a path to RTEMS.
#
%if %{rtems_bsp_ldflags} == %{nil}
%define rtems_bsp_ldflags -L%{rtems_bsp_prefix}/lib
%endif
#
# Support for RTEMS's Makefile.inc support.
#
%define rtems_bsp_makefile_inc %{rtems_bsp_prefix}
%define rtems_bsp_rtems_root %{_prefix}
#
# Filter the flags converting any prefix to the staging path if this is a
# staging build of the BSP.
#
%if %{rtems_bsp_staged}
%define staging_filter sed -e 's|%{_prefix}|%{stagingroot}|g'
%define rtems_bsp_prefix $(echo %{rtems_bsp_prefix} | %{staging_filter})
%define rtems_bsp_includes $(echo %{rtems_bsp_includes} | %{staging_filter})
%define rtems_bsp_ccflags $(echo %{rtems_bsp_ccflags} | %{staging_filter})
%define rtems_bsp_cflags $(echo %{rtems_bsp_cflags} | %{staging_filter})
%define rtems_bsp_ldflags $(echo %{rtems_bsp_ldflags} | %{staging_filter})
%define rtems_bsp_rtems_root %{stagingroot}
%endif
%if %{rtems_bsp_ccflags} == %{nil}
%define rtems_bsp_ccflags %{rtems_bsp_cflags}
%endif
#
# The RTEMS BSP architecture/bsp.
#
%define rtems_bsp_arch_bsp %{_host_arch}/%{rtems_bsp}
#
# RTEMS BSP paths
#
%define rtems_bsp_cc %{_host}-gcc
%define rtems_bsp_cxx %{_host}-g++
%define rtems_bsp_incpath %{with_rtems}/%{_host}/%{rtems_bsp}/include
%define rtems_bsp_libpath %{with_rtems}/%{_host}/%{rtems_bsp}/lib
#
# Check for installed libraries.
#
# - Check is LibBSD is install
# - Add librtemsdefaultconfig so configure scripts work.
#
# 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-libbsd %{rtems-dep-check} -L %{rtems_bsp_libpath} -l libbsd.a)
%if %{rtems-libbsd} == found
%define rtems_bsp_libs %{rtems_bsp_libs} -lbsd -lm -lz
%endif
%define rtems-defaultconfig %{rtems-dep-check} -L %{rtems_bsp_libpath} -l librtemsdefaultconfig.a)
%if %{rtems-defaultconfig} == found
%define rtems_bsp_libs %{rtems_bsp_libs} -lrtemsdefaultconfig
%endif
#
# Define any extra flags we may need.
#
%define rtems_bsp_ldflags_extra \
%{?rtems_bsp_ldflags_extra: %{rtems_bsp_ldflags_extra}} \
-Wl,--gc-sections
#
# The linker flags need to include the machine options for the BSP.
#
%define mflags_filter awk '{for (i=1;i<NF;++i) if ($i ~ /\-m/) printf("%s ",$i);}'
%define rtems_bsp_ldflags %{rtems_bsp_ldflags} \
$(echo "%{rtems_bsp_cflags}" | %{mflags_filter}) \
%{rtems_bsp_ldflags_extra}
#
# Map to names used for cross compiling.
#
%define host_cc %{rtems_bsp_cc}
%define host_cxx %{rtems_bsp_cxx}
%define host_includes %{rtems_bsp_includes}
%define host_cflags %{rtems_bsp_cflags}
%define host_cxxflags %{rtems_bsp_ccflags}
%define host_ldflags %{rtems_bsp_ldflags}
%define host_libs %{rtems_bsp_libs}
#
# Handle the Waf install root.
#
%ifos win32 mingw ming32
%define rtems_waf_build_root_suffix %{waf_build_root_suffix}
%else
%define rtems_waf_build_root_suffix %{nil}
%endif
|