mirror of
https://git.rtems.org/rtems-source-builder
synced 2024-10-09 07:15:10 +08:00
sb: Add support for building RTEMS 3rd party packages.
Remove the 'opt' from various macros and shell variables. Add pkgconfig to the checks to make it clear the check is a pkgconfig check. Add NTP support as the first package to be built using the RSB. Split the RTEMS URL's out from the base bset file into a separate file that be included by other files. Add an RTEMS BSP configuration file to help abstract the process of building 3rd party packages. Clean the cross and canadian cross support up so we can cleanly support cross and canadian cross building. Refactor the pkgconfig support and clean up the PC file handling of loading modules. Add support for %{?..} to return false if a macro is %{nil}. Add %{pkgconfig ..} support to allow better control of access RTEMS pkgconfig files.
This commit is contained in:
parent
339f92f89f
commit
0ffee19316
@ -13,6 +13,6 @@
|
||||
#
|
||||
# The GetText build instructions. We use 0.x.x Release 1.
|
||||
#
|
||||
%ifn %{check gettext}
|
||||
%ifn %{pkgconfig check gettext}
|
||||
%include %{_configdir}/gettext-0-1.cfg
|
||||
%endif
|
||||
|
@ -15,6 +15,6 @@
|
||||
#
|
||||
# The GLib build instructions. We use 2.x.x Release 1.
|
||||
#
|
||||
%ifn %{check glib-2.0}
|
||||
%ifn %{pkgconfig check glib-2.0}
|
||||
%include %{_configdir}/glib-2-1.cfg
|
||||
%endif
|
||||
|
@ -24,6 +24,6 @@
|
||||
#
|
||||
# The LibFFI build instructions. We use 3.x.x Release 1.
|
||||
#
|
||||
%ifn %{check libffi >= 3}
|
||||
%ifn %{pkgconfig check libffi >= 3}
|
||||
%include %{_configdir}/libffi-3-1.cfg
|
||||
%endif
|
||||
|
@ -14,7 +14,7 @@
|
||||
# The Libiconv build instructions. We use 0.x.x Release 1.
|
||||
#
|
||||
%if %{_host_os} == win32
|
||||
%ifn %{check iconv >= %{libiconv_version}}
|
||||
%ifn %{pkgconfig check iconv >= %{libiconv_version}}
|
||||
%include %{_configdir}/libiconv-1-1.cfg
|
||||
%endif
|
||||
%endif
|
||||
|
@ -13,6 +13,6 @@
|
||||
#
|
||||
# The Pixman build instructions. We use 0.x.x Release 1.
|
||||
#
|
||||
%ifn %{check pixman-1}
|
||||
%ifn %{pkgconfig check pixman-1}
|
||||
%include %{_configdir}/pixman-0-1.cfg
|
||||
%endif
|
||||
|
@ -45,7 +45,7 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
|
||||
CFLAGS_FOR_BUILD="-g -O2 -Wall" \
|
||||
%endif
|
||||
CPPFLAGS="-I $SB_TMPPREFIX/include/libusb-1.0" \
|
||||
CFLAGS="$SB_OPT_FLAGS" \
|
||||
CFLAGS="$SB_CFLAGS" \
|
||||
LDFLAGS="-L $SB_TMPPREFIX/lib" \
|
||||
./configure \
|
||||
--build=%{_build} --host=%{_host} \
|
||||
|
20
rtems/config/4.11/net/ntp.bset
Normal file
20
rtems/config/4.11/net/ntp.bset
Normal file
@ -0,0 +1,20 @@
|
||||
#
|
||||
# Build set for NTP
|
||||
#
|
||||
|
||||
%define release 1
|
||||
|
||||
#
|
||||
# RTEMS Version
|
||||
#
|
||||
%define rtems_version 4.11
|
||||
|
||||
#
|
||||
# The RTEMS URL paths.
|
||||
#
|
||||
%include rtems-urls.bset
|
||||
|
||||
#
|
||||
# Build NTP.
|
||||
#
|
||||
net/ntp-4.2.6p5-1
|
24
rtems/config/net/ntp-4.2.6p5-1.cfg
Normal file
24
rtems/config/net/ntp-4.2.6p5-1.cfg
Normal file
@ -0,0 +1,24 @@
|
||||
#
|
||||
# NTP 4.2.6p5
|
||||
#
|
||||
|
||||
%if %{release} == %{nil}
|
||||
%define release 1
|
||||
%endif
|
||||
|
||||
%include %{_configdir}/rtems-bsp.cfg
|
||||
|
||||
#
|
||||
# NTP Version
|
||||
#
|
||||
%define ntp_version 4.2.6p5
|
||||
|
||||
#
|
||||
# Patch for RTEMS support.
|
||||
#
|
||||
%patch add ntp %{rtems_git_tools}/ntp/rtems-ntp-4.2.6p5.diff
|
||||
|
||||
#
|
||||
# NTP Build configuration
|
||||
#
|
||||
%include %{_configdir}/ntp-4-1.cfg
|
@ -18,11 +18,6 @@ package: rtems-%{rtems_version}-%{_target}-%{release}
|
||||
%define gcc_version_message RTEMS %{rtems_version}-RSB-%{_sbgit_id}-%{release},gcc-%{gcc_version}/newlib-%{newlib_version}
|
||||
|
||||
#
|
||||
# The RTEMS http git URL.
|
||||
# Pick up the RTEMS URLs.
|
||||
#
|
||||
%define rtems_http_git http://git.rtems.org
|
||||
%define rtems_git_tools %{rtems_http_git}/rtems-tools/plain/tools/%{rtems_version}
|
||||
%define rtems_binutils_patches %{rtems_git_tools}/binutils
|
||||
%define rtems_gcc_patches %{rtems_git_tools}/gcc
|
||||
%define rtems_newlib_patches %{rtems_git_tools}/newlib
|
||||
%define rtems_gdb_patches %{rtems_git_tools}/gdb
|
||||
%include rtems-urls.bset
|
||||
|
55
rtems/config/rtems-bsp.cfg
Normal file
55
rtems/config/rtems-bsp.cfg
Normal file
@ -0,0 +1,55 @@
|
||||
#
|
||||
# RTEMS BSP Support
|
||||
#
|
||||
|
||||
#
|
||||
# The RTEMS BSP support requires the host turple, 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.
|
||||
#
|
||||
|
||||
%if %{_host} == %{nil}
|
||||
%error No RTEMS target specified: --host=host
|
||||
%endif
|
||||
|
||||
%ifn %{defined with_rtems_bsp}
|
||||
%error No RTEMS BSP specified: --with-rtems-bsp=bsp
|
||||
%endif
|
||||
|
||||
%ifn %{defined with_tools}
|
||||
%error No RTEMS tools specified: --with-tools=path
|
||||
%endif
|
||||
|
||||
#
|
||||
# Set the path to the tools.
|
||||
#
|
||||
%{path prepend %{with_tools}/bin}
|
||||
|
||||
#
|
||||
# Set up how we manage pkgconfig. Set the prefix path to the RTEMS prefix,
|
||||
# enable support when crosscompiling, and filter specific optimisation and
|
||||
# warning from the flags that RTEMS exports.
|
||||
#
|
||||
%{pkgconfig prefix %{_prefix}/lib/pkgconfig}
|
||||
%{pkgconfig crosscompile yes}
|
||||
%{pkgconfig filter-flags yes}
|
||||
|
||||
#
|
||||
# The RTEMS BSP Flags
|
||||
#
|
||||
%define rtems_bsp %{with_rtems_bsp}
|
||||
%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}}
|
||||
|
||||
#
|
||||
# Map to names used for cross compiling.
|
||||
#
|
||||
%define host_cflags %{rtems_bsp_cflags}
|
||||
%define host_ldflags %{rtems_bsp_ldflags}
|
||||
%define host_libs %{rtems_bsp_libs}
|
13
rtems/config/rtems-urls.bset
Normal file
13
rtems/config/rtems-urls.bset
Normal file
@ -0,0 +1,13 @@
|
||||
#
|
||||
# The URLs for RTEMS
|
||||
#
|
||||
|
||||
#
|
||||
# The RTEMS http git URL.
|
||||
#
|
||||
%define rtems_http_git http://git.rtems.org
|
||||
%define rtems_git_tools %{rtems_http_git}/rtems-tools/plain/tools/%{rtems_version}
|
||||
%define rtems_binutils_patches %{rtems_git_tools}/binutils
|
||||
%define rtems_gcc_patches %{rtems_git_tools}/gcc
|
||||
%define rtems_newlib_patches %{rtems_git_tools}/newlib
|
||||
%define rtems_gdb_patches %{rtems_git_tools}/gdb
|
@ -54,7 +54,7 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
|
||||
fi
|
||||
export CFLAGS CFLAGS_FOR_BUILD CC
|
||||
|
||||
CFLAGS="$SB_OPT_FLAGS" \
|
||||
CFLAGS="$SB_CFLAGS" \
|
||||
./configure \
|
||||
--build=%{_build} --host=%{_host} \
|
||||
--verbose --disable-nls \
|
||||
|
@ -54,7 +54,7 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
|
||||
fi
|
||||
export CFLAGS CFLAGS_FOR_BUILD CC
|
||||
|
||||
CFLAGS="$SB_OPT_FLAGS" \
|
||||
CFLAGS="$SB_CFLAGS" \
|
||||
./configure \
|
||||
--build=%{_build} --host=%{_host} \
|
||||
--verbose \
|
||||
|
@ -34,7 +34,7 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
|
||||
%if "%{_build}" != "%{_host}"
|
||||
CFLAGS_FOR_BUILD="-g -O2 -Wall" \
|
||||
%endif
|
||||
CFLAGS="$SB_OPT_FLAGS" \
|
||||
CFLAGS="$SB_CFLAGS" \
|
||||
../gdb-%{gdb_version}/configure \
|
||||
--build=%{_build} --host=%{_host} \
|
||||
--target=%{_target} \
|
||||
|
@ -24,8 +24,8 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
|
||||
#
|
||||
# Fix the mess iconv is on FreeBSD 10.0.
|
||||
#
|
||||
%if %{defined iconv_optincludes}
|
||||
%define optincludes %{iconv_optincludes}
|
||||
%if %{defined iconv_includes}
|
||||
%define includes %{iconv_includes}
|
||||
%endif
|
||||
|
||||
#
|
||||
|
@ -54,7 +54,7 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
|
||||
fi
|
||||
export CFLAGS CFLAGS_FOR_BUILD CC
|
||||
|
||||
CFLAGS="$SB_OPT_FLAGS" \
|
||||
CFLAGS="$SB_CFLAGS" \
|
||||
./configure \
|
||||
--build=%{_build} --host=%{_host} \
|
||||
--verbose --disable-nls \
|
||||
|
@ -36,7 +36,7 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
|
||||
%if "%{_build}" != "%{_host}"
|
||||
CFLAGS_FOR_BUILD="-g -O2 -Wall" \
|
||||
%endif
|
||||
CFLAGS="$SB_OPT_FLAGS" \
|
||||
CFLAGS="$SB_CFLAGS" \
|
||||
./configure \
|
||||
--build=%{_build} --host=%{_host} \
|
||||
--verbose --disable-nls \
|
||||
|
@ -35,7 +35,7 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
|
||||
%if "%{_build}" != "%{_host}"
|
||||
CFLAGS_FOR_BUILD="-g -O2 -Wall" \
|
||||
%endif
|
||||
CFLAGS="$SB_OPT_FLAGS" \
|
||||
CFLAGS="$SB_CxsFLAGS" \
|
||||
./configure \
|
||||
--build=%{_build} --host=%{_host} \
|
||||
--verbose --disable-nls \
|
||||
|
62
source-builder/config/ntp-4-1.cfg
Normal file
62
source-builder/config/ntp-4-1.cfg
Normal file
@ -0,0 +1,62 @@
|
||||
#
|
||||
# NTP 4.x.x Version 1.
|
||||
#
|
||||
# This configuration file configure's, make's and install's NTP.
|
||||
#
|
||||
|
||||
%if %{release} == %{nil}
|
||||
%define release 1
|
||||
%endif
|
||||
|
||||
Name: ntp-%{ntp_version}-%{_host}-%{release}
|
||||
Summary: NTP is the Network Time Protocol.
|
||||
Version: %{ntp_version}
|
||||
Release: %{release}
|
||||
URL: http://www.ntp.org/
|
||||
BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
|
||||
|
||||
#
|
||||
# NTP Source
|
||||
#
|
||||
%source set ntp http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-%{ntp_version}.tar.gz
|
||||
|
||||
#
|
||||
# Prepare the source code.
|
||||
#
|
||||
%prep
|
||||
build_top=$(pwd)
|
||||
|
||||
source_dir_ntp="ntp-%{ntp_version}"
|
||||
%source setup ntp -q -n ntp-%{ntp_version}
|
||||
%patch setup ntp -p1
|
||||
|
||||
cd ${build_top}
|
||||
|
||||
%build
|
||||
build_top=$(pwd)
|
||||
|
||||
%{build_directory}
|
||||
|
||||
mkdir -p ${build_dir}
|
||||
cd ${build_dir}
|
||||
|
||||
%{host_build_flags}
|
||||
|
||||
../${source_dir_ntp}/configure \
|
||||
--host=%{_host} \
|
||||
--prefix=%{_prefix} \
|
||||
--disable-ipv6 \
|
||||
--disable-HOPFPCI
|
||||
|
||||
%{__make} %{?_smp_mflags} all
|
||||
|
||||
cd ${build_top}
|
||||
|
||||
%install
|
||||
build_top=$(pwd)
|
||||
|
||||
%{__rmdir} $SB_BUILD_ROOT
|
||||
|
||||
cd ${build_dir}
|
||||
%{__make} DESTDIR=$SB_BUILD_ROOT install
|
||||
cd ${build_top}
|
@ -56,10 +56,10 @@ _uid: none, convert, '%(%{__id_u} -n)'
|
||||
# Default flags that can be overridded to supply specific host or build
|
||||
# flags and include paths to the tools. The host is the final platform
|
||||
# the tools will run on and build is the host building the tools.
|
||||
optflags_host: none, convert, '-O2 -pipe'
|
||||
optincludes_host: none, convert, ''
|
||||
optflags_build: none, convert, '-O2 -pipe'
|
||||
optincludes_build: none, convert, ''
|
||||
host_cflags: none, convert, '-O2 -pipe'
|
||||
host_includes: none, convert, ''
|
||||
build_cflags: none, convert, '-O2 -pipe'
|
||||
build_includes: none, convert, ''
|
||||
|
||||
# Extra path a platform can override.
|
||||
_extra_path: none, none, '%{_sbdir}'
|
||||
@ -67,6 +67,8 @@ _ld_library_path: none, none, 'LD_LIBRARY_PATH'
|
||||
|
||||
# Paths
|
||||
_host_platform: none, none, '%{_host_cpu}-%{_host_vendor}-%{_host_os}%{?_gnu}'
|
||||
_host_cc: none, none, 'gcc'
|
||||
_host_cxx: none, none, 'g++'
|
||||
_arch: none, none, '%{_host_arch}'
|
||||
_topdir: dir, required, '%{_cwd}'
|
||||
_configdir: dir, optional, '%{_topdir}/config:%{_sbdir}/config:%{_sbtop}/bare/config'
|
||||
@ -102,6 +104,8 @@ _infodir: dir, none, '%{_datarootdir}/info'
|
||||
_localedir: dir, none, '%{_datarootdir}/locale'
|
||||
_localedir: dir, none, '%{_datadir}/locale'
|
||||
_localstatedir: dir, none, '%{_prefix}/var'
|
||||
_pathprepend: none, none, ''
|
||||
_pathpostpend: none, none, ''
|
||||
_prefix: dir, none, '%{_usr}'
|
||||
_usr: dir, none, '/usr/local'
|
||||
_usrsrc: dir, none, '%{_usr}/src'
|
||||
@ -184,15 +188,15 @@ export SB_ORIG_PATH=${PATH}
|
||||
SB_SOURCE_DIR="%{_sourcedir}"
|
||||
SB_BUILD_DIR="%{_builddir}"
|
||||
# host == build, use build; host != build , host uses host and build uses build
|
||||
SB_OPT_HOST_CFLAGS="%{optflags_host} %{optincludes_host}"
|
||||
SB_OPT_HOST_LDFLAGS="%{?_tmproot:-L%{_tmproot}/${SB_PREFIX_CLEAN}/lib}"
|
||||
SB_OPT_BUILD_CFLAGS="%{optflags_build} %{?_tmproot:-I%{_tmproot}/${SB_PREFIX_CLEAN}/include}"
|
||||
SB_OPT_BUILD_LDFLAGS="%{?_tmproot:-L%{_tmproot}/${SB_PREFIX_CLEAN}/lib}"
|
||||
SB_OPT_CFLAGS="${SB_OPT_BUILD_CFLAGS} %{optincludes_build}"
|
||||
SB_HOST_CFLAGS="%{host_cflags} %{host_includes}"
|
||||
SB_HOST_LDFLAGS="%{?host_ldflags:%{host_ldflags}}%{?_tmproot:-L%{_tmproot}/${SB_PREFIX_CLEAN}/lib}"
|
||||
SB_BUILD_CFLAGS="%{build_cflags} %{?_tmproot:-I%{_tmproot}/${SB_PREFIX_CLEAN}/include}"
|
||||
SB_BUILD_LDFLAGS="%{?build_ldflags:%{build_ldflags}}%{?_tmproot:-L%{_tmproot}/${SB_PREFIX_CLEAN}/lib}"
|
||||
SB_CFLAGS="${SB_BUILD_CFLAGS} %{build_includes}"
|
||||
SB_ARCH="%{_arch}"
|
||||
SB_OS="%{_os}"
|
||||
export SB_SOURCE_DIR SB_BUILD_DIR SB_ARCH SB_OS
|
||||
export SB_OPT_HOST_CFLAGS SB_OPT_HOST_LDFLAGS SB_OPT_BUILD_CFLAGS SB_OPT_BUILD_LDFLAGS SB_OPT_CFLAGS
|
||||
export SB_HOST_CFLAGS SB_HOST_LDFLAGS SB_BUILD_CFLAGS SB_BUILD_LDFLAGS SB_CFLAGS
|
||||
# Documentation
|
||||
SB_DOC_DIR="%{_docdir}"
|
||||
export SB_DOC_DIR
|
||||
@ -237,6 +241,8 @@ fi
|
||||
if test -n "${SB_EXTRAPATH}" ; then
|
||||
PATH="${SB_EXTRAPATH}:$PATH"
|
||||
fi
|
||||
%{?_pathprepend:PATH="%{_pathprepend}:$PATH"}
|
||||
%{?_pathpostpend:PATH="$PATH:%{_pathpostpend}"}
|
||||
export PATH
|
||||
# Default environment set up.
|
||||
LANG=C
|
||||
@ -253,9 +259,9 @@ ___build_template: none, none, '''#!%{___build_shell}
|
||||
|
||||
# Configure command
|
||||
configure: none, none, '''
|
||||
CFLAGS="${CFLAGS:-${SB_OPT_CFLAGS}" ; export CFLAGS ;
|
||||
CXXFLAGS="${CXXFLAGS:-${SB_OPT_CFLAGS}}" ; export CXXFLAGS ;
|
||||
FFLAGS="${FFLAGS:-${SB_OPT_CFLAGS}}" ; export FFLAGS ;
|
||||
CFLAGS="${CFLAGS:-${SB_CFLAGS}" ; export CFLAGS ;
|
||||
CXXFLAGS="${CXXFLAGS:-${SB_CFLAGS}}" ; export CXXFLAGS ;
|
||||
FFLAGS="${FFLAGS:-${SB_CFLAGS}}" ; export FFLAGS ;
|
||||
./configure --build=%{_build} --host=%{_host} \
|
||||
--target=%{_target_platform} \
|
||||
--program-prefix=%{?_program_prefix} \
|
||||
@ -276,30 +282,35 @@ FFLAGS="${FFLAGS:-${SB_OPT_CFLAGS}}" ; export FFLAGS ;
|
||||
# Build script support.
|
||||
build_directory: none, none, '''
|
||||
if test "%{_build}" != "%{_host}" ; then
|
||||
build_dir="build-cxc"
|
||||
if test -z "%{_target}" ; then
|
||||
build_dir="build-xc"
|
||||
else
|
||||
build_dir="build-cxc"
|
||||
fi
|
||||
else
|
||||
build_dir="build"
|
||||
fi'''
|
||||
|
||||
# Host/build flags.
|
||||
host_build_flags: none, none, '''
|
||||
# Host and build flags, Cxc build if host and build are different.
|
||||
# Host and build flags, Cross build if host and build are different and
|
||||
# Cxc build idf target is deifned and also different.
|
||||
# Note, gcc is not ready to be compiled with -std=gnu99 (this needs to be checked).
|
||||
if test "%{_build}" != "%{_host}" ; then
|
||||
# Canadian cross build
|
||||
CC=$(echo "%{_host}-gcc ${SB_OPT_HOST_CFLAGS} ${SB_OPT_HOST_LDFLAGS}" | sed -e 's,-std=gnu99 ,,')
|
||||
CXX=$(echo "%{_host}-g++ ${SB_OPT_HOST_CFLAGS} ${SB_OPT_HOST_LDFLAGS}" | sed -e 's,-std=gnu99 ,,')
|
||||
CFLAGS="${SB_OPT_HOST_CFLAGS}"
|
||||
LDFLAGS="${SB_OPT_HOST_LDFLAGS}"
|
||||
CFLAGS_FOR_BUILD="${SB_OPT_BUILD_CFLAGS}"
|
||||
LDFLAGS_FOR_BUILD="${SB_OPT_BUILD_LDFLAGS}"
|
||||
CXXFLAGS_FOR_BUILD="${SB_OPT_BUILD_CFLAGS}"
|
||||
CC_FOR_BUILD=$(echo "%{__cc} ${SB_OPT_BUILD_CFLAGS}" | sed -e 's,-std=gnu99 ,,')
|
||||
CXX_FOR_BUILD=$(echo "%{__cxx} ${SB_OPT_BUILD_CFLAGS}" | sed -e 's,-std=gnu99 ,,')
|
||||
# Cross build
|
||||
CC=$(echo "%{_host}-%{_host_cc}" | sed -e 's,-std=gnu99 ,,')
|
||||
CXX=$(echo "%{_host}-%{_host_cxx}" | sed -e 's,-std=gnu99 ,,')
|
||||
CFLAGS="${SB_HOST_CFLAGS}"
|
||||
LDFLAGS="${SB_HOST_LDFLAGS}"
|
||||
CFLAGS_FOR_BUILD="${SB_BUILD_CFLAGS}"
|
||||
LDFLAGS_FOR_BUILD="${SB_BUILD_LDFLAGS}"
|
||||
CXXFLAGS_FOR_BUILD="${SB_BUILD_CFLAGS}"
|
||||
CC_FOR_BUILD=$(echo "%{__cc} ${SB_BUILD_CFLAGS}" | sed -e 's,-std=gnu99 ,,')
|
||||
CXX_FOR_BUILD=$(echo "%{__cxx} ${SB_BUILD_CFLAGS}" | sed -e 's,-std=gnu99 ,,')
|
||||
else
|
||||
LDFLAGS="${SB_OPT_BUILD_LDFLAGS}"
|
||||
CC=$(echo "%{__cc} ${SB_OPT_BUILD_CFLAGS}" | sed -e 's,-std=gnu99 ,,')
|
||||
CXX=$(echo "%{__cxx} ${SB_OPT_BUILD_CFLAGS}" | sed -e 's,-std=gnu99 ,,')
|
||||
LDFLAGS="${SB_BUILD_LDFLAGS}"
|
||||
CC=$(echo "%{__cc} ${SB_BUILD_CFLAGS}" | sed -e 's,-std=gnu99 ,,')
|
||||
CXX=$(echo "%{__cxx} ${SB_BUILD_CFLAGS}" | sed -e 's,-std=gnu99 ,,')
|
||||
CC_FOR_BUILD=${CC}
|
||||
CXX_FOR_BUILD=${CXX}
|
||||
fi
|
||||
@ -309,9 +320,9 @@ export CC CXX CC_FOR_BUILD CXX_FOR_BUILD CFLAGS CFLAGS_FOR_BUILD CXXFLAGS_FOR_BU
|
||||
build_build_flags: none, none, '''
|
||||
# Build and build flags means force build == host
|
||||
# gcc is not ready to be compiled with -std=gnu99
|
||||
LDFLAGS="${SB_OPT_HOST_LDFLAGS}"
|
||||
CC=$(echo "%{__cc} ${SB_OPT_CFLAGS}" | sed -e 's,-std=gnu99 ,,')
|
||||
CXX=$(echo "%{__cxx} ${SB_OPT_CFLAGS}" | sed -e 's,-std=gnu99 ,,')
|
||||
LDFLAGS="${SB_HOST_LDFLAGS}"
|
||||
CC=$(echo "%{__cc} ${SB_CFLAGS}" | sed -e 's,-std=gnu99 ,,')
|
||||
CXX=$(echo "%{__cxx} ${SB_CFLAGS}" | sed -e 's,-std=gnu99 ,,')
|
||||
CC_FOR_BUILD=${CC}
|
||||
CXX_FOR_BUILD=${CXX}
|
||||
export CC CXX CC_FOR_BUILD CXX_FOR_BUILD CFLAGS LDFLAGS'''
|
||||
|
@ -58,13 +58,18 @@ trace = True
|
||||
trace_stdout = False
|
||||
logfile = 'pkg-config.log'
|
||||
out = None
|
||||
srcfd = None
|
||||
|
||||
#
|
||||
# Write all the package source parsed to a single file.
|
||||
#
|
||||
trace_src = True
|
||||
if trace_src:
|
||||
src = open('pkg-src.txt', 'w')
|
||||
srcfd = open('pkg-src.txt', 'w')
|
||||
|
||||
def src(text):
|
||||
if srcfd:
|
||||
srcfs.writelines(text)
|
||||
|
||||
def log(s, lf = True):
|
||||
global trace, logfile, out
|
||||
@ -83,48 +88,6 @@ def log(s, lf = True):
|
||||
print s,
|
||||
print >> out, s,
|
||||
|
||||
def _check_package(libraries, args):
|
||||
ec = 1
|
||||
pkg = None
|
||||
flags = { 'cflags': '',
|
||||
'libs': '' }
|
||||
log('libraries: %s' % (libraries))
|
||||
libs = pkgconfig.package.splitter(libraries)
|
||||
for lib in libs:
|
||||
log('pkg: %s' % (lib))
|
||||
pkg = pkgconfig.package(lib[0], prefix = args.prefix, output = log, src = src)
|
||||
if args.dump:
|
||||
log(pkg)
|
||||
if pkg.exists():
|
||||
if len(lib) == 1:
|
||||
if args.exact_version:
|
||||
if pkg.check('=', args.exact_version):
|
||||
ec = 0
|
||||
elif args.atleast_version:
|
||||
if pkg.check('>=', args.atleast_version):
|
||||
ec = 0
|
||||
elif args.max_version:
|
||||
if pkg.check('<=', args.max_version):
|
||||
ec = 0
|
||||
else:
|
||||
ec = 0
|
||||
else:
|
||||
if len(lib) != 3:
|
||||
raise error('invalid package check: %s' % (' '.join(lib)))
|
||||
if pkg.check(lib[1], lib[2]):
|
||||
ec = 0
|
||||
if ec == 0:
|
||||
cflags = pkg.get('cflags')
|
||||
if cflags:
|
||||
flags['cflags'] += cflags
|
||||
libs = pkg.get('libs', private = False)
|
||||
if libs:
|
||||
flags['libs'] += libs
|
||||
break
|
||||
if ec > 0:
|
||||
break
|
||||
return ec, pkg, flags
|
||||
|
||||
def run(argv):
|
||||
|
||||
class version_action(argparse.Action):
|
||||
@ -224,7 +187,7 @@ def run(argv):
|
||||
if args.atleast_pkgconfig_version:
|
||||
ec = 0
|
||||
else:
|
||||
ec, pkg, flags = _check_package(args.libraries, args)
|
||||
ec, pkg, flags = pkgconfig.check_package(args.libraries, args, log, src)
|
||||
if ec == 0:
|
||||
if args.cflags:
|
||||
if len(flags['cflags']):
|
||||
|
@ -55,6 +55,13 @@ def _check_bool(value):
|
||||
istrue = None
|
||||
return istrue
|
||||
|
||||
def _check_nil(value):
|
||||
if len(value):
|
||||
istrue = True
|
||||
else:
|
||||
istrue = False
|
||||
return istrue
|
||||
|
||||
class package:
|
||||
|
||||
def __init__(self, name, arch, config):
|
||||
@ -242,10 +249,21 @@ class file:
|
||||
self.sf = re.compile(r'%\([^\)]+\)')
|
||||
for arg in self.opts.args:
|
||||
if arg.startswith('--with-') or arg.startswith('--without-'):
|
||||
label = arg[2:].lower().replace('-', '_')
|
||||
self.macros.define(label)
|
||||
if '=' in arg:
|
||||
label, value = arg.split('=', 1)
|
||||
else:
|
||||
label = arg
|
||||
value = None
|
||||
label = label[2:].lower().replace('-', '_')
|
||||
if value:
|
||||
self.macros.define(label, value)
|
||||
else:
|
||||
self.macros.define(label)
|
||||
self._includes = []
|
||||
self.load_depth = 0
|
||||
self.pkgconfig_prefix = None
|
||||
self.pkgconfig_crosscompile = False
|
||||
self.pkgconfig_filter_flags = False
|
||||
self.load(name)
|
||||
|
||||
def __str__(self):
|
||||
@ -383,37 +401,97 @@ class file:
|
||||
|
||||
def _pkgconfig_check(self, test):
|
||||
ok = False
|
||||
if not self._cross_compile():
|
||||
ts = test.split()
|
||||
pkg = pkgconfig.package(ts[0], output = log.output)
|
||||
if len(ts) != 1 and len(ts) != 3:
|
||||
self._error('malformed check')
|
||||
else:
|
||||
op = '>='
|
||||
ver = '0'
|
||||
if len(ts) == 3:
|
||||
op = ts[1]
|
||||
ver = self.macros.expand(ts[2])
|
||||
try:
|
||||
if type(test) == str:
|
||||
test = test.split()
|
||||
if not self._cross_compile() or self.pkgconfig_crosscompile:
|
||||
try:
|
||||
pkg = pkgconfig.package(test[0],
|
||||
prefix = self.pkgconfig_prefix,
|
||||
output = self._output,
|
||||
src = log.trace)
|
||||
if len(test) != 1 and len(test) != 3:
|
||||
self._error('malformed check: %s' % (' '.join(test)))
|
||||
else:
|
||||
op = '>='
|
||||
ver = '0'
|
||||
if len(test) == 3:
|
||||
op = test[1]
|
||||
ver = self.macros.expand(test[2])
|
||||
ok = pkg.check(op, ver)
|
||||
except pkgconfig.error, pe:
|
||||
self._error('check: %s' % (pe))
|
||||
except:
|
||||
raise error.interal('pkgconfig failure')
|
||||
return ok
|
||||
except pkgconfig.error, pe:
|
||||
self._error('pkgconfig: check: %s' % (pe))
|
||||
except:
|
||||
raise error.internal('pkgconfig failure')
|
||||
if ok:
|
||||
return '1'
|
||||
return '0'
|
||||
|
||||
def _pkgconfig_flags(self, package, flags):
|
||||
pkg_flags = None
|
||||
if not self._cross_compile():
|
||||
pkg = pkgconfig.package(package, output = log.output)
|
||||
if not self._cross_compile() or self.pkgconfig_crosscompile:
|
||||
try:
|
||||
pkg = pkgconfig.package(package,
|
||||
prefix = self.pkgconfig_prefix,
|
||||
output = self._output,
|
||||
src = log.trace)
|
||||
pkg_flags = pkg.get(flags)
|
||||
if pkg_flags and self.pkgconfig_filter_flags:
|
||||
fflags = []
|
||||
for f in pkg_flags.split():
|
||||
if not f.startswith('-f') and not f.startswith('-W'):
|
||||
fflags += [f]
|
||||
pkg_flags = ' '.join(fflags)
|
||||
log.trace('pkgconfig: %s: %s' % (flags, pkg_flags))
|
||||
except pkgconfig.error, pe:
|
||||
self._error('flags:%s: %s' % (flags, pe))
|
||||
self._error('pkgconfig: %s: %s' % (flags, pe))
|
||||
except:
|
||||
raise error.interal('pkgconfig failure')
|
||||
raise error.internal('pkgconfig failure')
|
||||
if pkg_flags is None:
|
||||
pkg_flags = ''
|
||||
return pkg_flags
|
||||
|
||||
def _pkgconfig(self, pcl):
|
||||
ok = False
|
||||
ps = ''
|
||||
if pcl[0] == 'check':
|
||||
ps = self._pkgconfig_check(pcl[1:])
|
||||
elif pcl[0] == 'prefix':
|
||||
if len(pcl) == 2:
|
||||
self.pkgconfig_prefix = pcl[1]
|
||||
else:
|
||||
self._error('prefix error: %s' % (' '.join(pcl)))
|
||||
elif pcl[0] == 'crosscompile':
|
||||
ok = True
|
||||
if len(pcl) == 2:
|
||||
if pcl[1].lower() == 'yes':
|
||||
self.pkgconfig_crosscompile = True
|
||||
elif pcl[1].lower() == 'no':
|
||||
self.pkgconfig_crosscompile = False
|
||||
else:
|
||||
ok = False
|
||||
else:
|
||||
ok = False
|
||||
if not ok:
|
||||
self._error('crosscompile error: %s' % (' '.join(pcl)))
|
||||
elif pcl[0] == 'filter-flags':
|
||||
ok = True
|
||||
if len(pcl) == 2:
|
||||
if pcl[1].lower() == 'yes':
|
||||
self.pkgconfig_filter_flags = True
|
||||
elif pcl[1].lower() == 'no':
|
||||
self.pkgconfig_filter_flags = False
|
||||
else:
|
||||
ok = False
|
||||
else:
|
||||
ok = False
|
||||
if not ok:
|
||||
self._error('crosscompile error: %s' % (' '.join(pcl)))
|
||||
elif pcl[0] in ['ccflags', 'cflags', 'ldflags', 'libs']:
|
||||
ps = self._pkgconfig_flags(pcl[1], pcl[0])
|
||||
else:
|
||||
self._error('pkgconfig error: %s' % (' '.join(pcl)))
|
||||
return ps
|
||||
|
||||
def _expand(self, s):
|
||||
expand_count = 0
|
||||
expanded = True
|
||||
@ -464,7 +542,7 @@ class file:
|
||||
mn = None
|
||||
else:
|
||||
e = self._expand(m[6:-1].strip())
|
||||
log.output('%s' % (self._name_line_msg(e)))
|
||||
log.notice('%s' % (self._name_line_msg(e)))
|
||||
s = ''
|
||||
expanded = True
|
||||
mn = None
|
||||
@ -476,44 +554,45 @@ class file:
|
||||
s = s.replace(m, '0')
|
||||
expanded = True
|
||||
mn = None
|
||||
elif m.startswith('%{check'):
|
||||
if self._pkgconfig_check(m[7:-1].strip()):
|
||||
s = s.replace(m, '1')
|
||||
elif m.startswith('%{path '):
|
||||
pl = m[7:-1].strip().split()
|
||||
ok = False
|
||||
if len(pl) == 2:
|
||||
ok = True
|
||||
epl = []
|
||||
for p in pl[1:]:
|
||||
epl += [self._expand(p)]
|
||||
p = ' '.join(epl)
|
||||
if pl[0].lower() == 'prepend':
|
||||
if len(self.macros['_pathprepend']):
|
||||
self.macros['_pathprepend'] = \
|
||||
'%s:%s' % (p, self.macros['_pathprepend'])
|
||||
else:
|
||||
self.macros['_pathprepend'] = p
|
||||
elif pl[0].lower() == 'postpend':
|
||||
if len(self.macros['_pathprepend']):
|
||||
self.macros['_pathprepend'] = \
|
||||
'%s:%s' % (self.macros['_pathprepend'], p)
|
||||
else:
|
||||
self.macros['_pathprepend'] = p
|
||||
else:
|
||||
ok = False
|
||||
if ok:
|
||||
s = s.replace(m, '')
|
||||
else:
|
||||
s = s.replace(m, '0')
|
||||
expanded = True
|
||||
self._error('path error: %s' % (' '.join(pl)))
|
||||
mn = None
|
||||
elif m.startswith('%{ccflags'):
|
||||
flags = self._pkgconfig_flags(m[9:-1].strip(), 'ccflags')
|
||||
if flags:
|
||||
s = s.replace(m, flags)
|
||||
elif m.startswith('%{pkgconfig '):
|
||||
pcl = m[11:-1].strip().split()
|
||||
if len(pcl):
|
||||
epcl = []
|
||||
for pc in pcl:
|
||||
epcl += [self._expand(pc)]
|
||||
ps = self._pkgconfig(epcl)
|
||||
s = s.replace(m, ps)
|
||||
expanded = True
|
||||
else:
|
||||
self._error('ccflags error: %s' % (m[9:-1].strip()))
|
||||
expanded = True
|
||||
mn = None
|
||||
elif m.startswith('%{cflags'):
|
||||
flags = self._pkgconfig_flags(m[8:-1].strip(), 'cflags')
|
||||
if flags:
|
||||
s = s.replace(m, flags)
|
||||
else:
|
||||
self._error('cflags error: %s' % (m[8:-1].strip()))
|
||||
expanded = True
|
||||
mn = None
|
||||
elif m.startswith('%{ldflags'):
|
||||
flags = self._pkgconfig_flags(m[9:-1].strip(), 'ldflags')
|
||||
if flags:
|
||||
s = s.replace(m, flags)
|
||||
else:
|
||||
self._error('ldflags error: %s' % (m[9:-1].strip()))
|
||||
expanded = True
|
||||
mn = None
|
||||
elif m.startswith('%{libs'):
|
||||
flags = self._pkgconfig_flags(m[6:-1].strip(), 'libs')
|
||||
if flags:
|
||||
s = s.replace(m, flags)
|
||||
else:
|
||||
self._error('libs error: %s' % (m[6:-1].strip()))
|
||||
expanded = True
|
||||
self._error('pkgconfig error: %s' % (m[11:-1].strip()))
|
||||
mn = None
|
||||
elif m.startswith('%{?') or m.startswith('%{!?'):
|
||||
if m[2] == '!':
|
||||
@ -533,10 +612,10 @@ class file:
|
||||
if m.startswith('%{?'):
|
||||
istrue = False
|
||||
if mn in self.macros:
|
||||
# If defined and 0 then it is false.
|
||||
# If defined and 0 or '' then it is false.
|
||||
istrue = _check_bool(self.macros[mn])
|
||||
if istrue is None:
|
||||
istrue = True
|
||||
istrue = _check_nil(self.macros[mn])
|
||||
if colon >= 0 and istrue:
|
||||
s = s.replace(m, m[start + colon + 1:-1])
|
||||
expanded = True
|
||||
|
@ -96,14 +96,14 @@ def load():
|
||||
cxx = '/usr/bin/clang++'
|
||||
if check.check_exe(cxx, cxx):
|
||||
raise error.general('no valid c++ not found')
|
||||
defines['optflags_build'] = '-O2 -pipe -fbracket-depth=1024'
|
||||
defines['build_cflags'] = '-O2 -pipe -fbracket-depth=1024'
|
||||
cvs = 'cvs'
|
||||
if check.check_exe(cvs, cvs):
|
||||
defines['__cvs'] = cvs
|
||||
#
|
||||
# Fix the mess iconv is on FreeBSD 10.0.
|
||||
#
|
||||
defines['iconv_optincludes'] = ('none', 'none', '-I/usr/local/include -L/usr/local/lib')
|
||||
defines['iconv_includes'] = ('none', 'none', '-I/usr/local/include -L/usr/local/lib')
|
||||
|
||||
for gv in ['47', '48', '49']:
|
||||
gcc = '%s-portbld-freebsd%s-gcc%s' % (cpu, version, gv)
|
||||
|
@ -34,6 +34,7 @@
|
||||
# provided by the full pkg-config so packages can configure and build.
|
||||
#
|
||||
|
||||
import copy
|
||||
import os
|
||||
import os.path
|
||||
import re
|
||||
@ -72,6 +73,14 @@ class package(object):
|
||||
lib_list_splitter = re.compile('[\s,]+')
|
||||
loaded = {}
|
||||
|
||||
@staticmethod
|
||||
def _copy(src, dst):
|
||||
dst.name_ = src.name_
|
||||
dst.file_ = src.file_
|
||||
dst.defines = copy.copy(src.defines)
|
||||
dst.fields = copy.copy(src.fields)
|
||||
dst.nodes = copy.copy(src.nodes)
|
||||
|
||||
@staticmethod
|
||||
def is_version(v):
|
||||
for n in v.split('.'):
|
||||
@ -384,7 +393,9 @@ class package(object):
|
||||
|
||||
def load(self, name):
|
||||
if name in package.loaded:
|
||||
raise error('package already loaded: %s' % (name))
|
||||
package._copy(package.loaded[name], self)
|
||||
return
|
||||
self._log('loading: %s' % (name))
|
||||
if self.name_:
|
||||
self._clean()
|
||||
self.name_ = name
|
||||
@ -392,14 +403,14 @@ class package(object):
|
||||
if file:
|
||||
self._log('load: %s (%s)' % (name, file))
|
||||
if self.src:
|
||||
self.src.writelines('==%s%s' % ('=' * 80, os.linesep))
|
||||
self.src.writelines(' %s %s%s' % (file, '=' * (80 - len(file)), os.linesep))
|
||||
self.src.writelines('==%s%s' % ('=' * 80, os.linesep))
|
||||
self.src('==%s%s' % ('=' * 80, os.linesep))
|
||||
self.src(' %s %s%s' % (file, '=' * (80 - len(file)), os.linesep))
|
||||
self.src('==%s%s' % ('=' * 80, os.linesep))
|
||||
f = open(file)
|
||||
tm = False
|
||||
for l in f.readlines():
|
||||
if self.src:
|
||||
self.src.writelines(l)
|
||||
self.src(l)
|
||||
l = l[:-1]
|
||||
hash = l.find('#')
|
||||
if hash >= 0:
|
||||
@ -455,6 +466,7 @@ class package(object):
|
||||
package.loaded[name] = self
|
||||
|
||||
def get(self, label, private = True):
|
||||
self._log('get: %s (%s)' % (label, ','.join(self.fields)))
|
||||
if label.lower() not in self.fields:
|
||||
return None
|
||||
s = ''
|
||||
@ -504,3 +516,46 @@ class package(object):
|
||||
else:
|
||||
self._log('check: %s not found' % (self.name_))
|
||||
return ok
|
||||
|
||||
def check_package(libraries, args, output, src):
|
||||
ec = 1
|
||||
pkg = None
|
||||
flags = { 'cflags': '',
|
||||
'libs': '' }
|
||||
output('libraries: %s' % (libraries))
|
||||
libs = package.splitter(libraries)
|
||||
for lib in libs:
|
||||
output('pkg: %s' % (lib))
|
||||
pkg = package(lib[0], prefix = args.prefix, output = output, src = src)
|
||||
if args.dump:
|
||||
output(pkg)
|
||||
if pkg.exists():
|
||||
if len(lib) == 1:
|
||||
if args.exact_version:
|
||||
if pkg.check('=', args.exact_version):
|
||||
ec = 0
|
||||
elif args.atleast_version:
|
||||
if pkg.check('>=', args.atleast_version):
|
||||
ec = 0
|
||||
elif args.max_version:
|
||||
if pkg.check('<=', args.max_version):
|
||||
ec = 0
|
||||
else:
|
||||
ec = 0
|
||||
else:
|
||||
if len(lib) != 3:
|
||||
raise error('invalid package check: %s' % (' '.join(lib)))
|
||||
if pkg.check(lib[1], lib[2]):
|
||||
ec = 0
|
||||
if ec == 0:
|
||||
cflags = pkg.get('cflags')
|
||||
if cflags:
|
||||
flags['cflags'] += cflags
|
||||
libs = pkg.get('libs', private = False)
|
||||
if libs:
|
||||
flags['libs'] += libs
|
||||
break
|
||||
if ec > 0:
|
||||
break
|
||||
return ec, pkg, flags
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user