User:Rhabacker

Jump to: navigation, search

Useful links

Hints

== spec file hints

check for a specific version

%if 0%{?leap_version} <= 420200
...
%endif

find language files

simple case

%define _name kwindowsaddons
... 
%lang_package
...
%prep
...
%install
 # install compiled package
 %_mingw32_find_lang %{_name} || true
... 
%files lang -f %{_name}.lang
%defattr(-,root,root,-)


multiple language files

...
%install
 %_mingw32_find_lang %{_name} || true
 %_mingw32_find_lang onlinequoteseditor %{_name}.lang || true
 %_mingw32_find_lang plasma_applet_onlinequote %{_name}.lang || true
 %_mingw32_find_lang plasma_applet_org.wincak.foreigncurrencies2 %{_name}.lang || true

Provides/Requires basics

  • mingw32(libxxx.dll) specifies that a packages provides or requires a shared library
  • mingw32(lib:xxxx) specifies that a package provides or requires an import or static library
  • mingw32(pkg:xxxx) specifies that a package provides or requires a library specified by pkg config

basic libraries

debugging of internal dependency generator

rpmbuild - single call

sudo rpmbuild -ba --rpmfcdebug /usr/src/packages/SPECS/mingw32-dbus-1.spec 2>&1 | less

rpmbuild - splitted build from checking

sudo rpmbuild -bi --rpmfcdebug /usr/src/packages/SPECS/mingw32-dbus-1.spec 2>&1  | less
sudo rpmbuild -bl --rpmfcdebug /usr/src/packages/SPECS/mingw32-dbus-1.spec 2>&1  | less
sudo rpmbuild -bl --rpmfcdebug /usr/src/packages/SPECS/mingw32-dbus-1.spec 2>&1  | less

Mingw64

Porting native autotools packages to mingw64

%define _name chmlib
Name:           mingw64-%{_name}
...
BuildRequires:  mingw64-cross-gcc 
# mingw64-cross-gcc-c++ in case of c++ project
... 
## if package provides pkg-config files add the following line
BuildRequires:  mingw64-cross-pkg-config
...
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%_mingw64_package_header_debug
BuildArch: noarch
...
%_mingw64_debug_package

%prep
%setup -q -n %{_name}-%{version}

%build

export MINGW32_CFLAGS=... export MINGW32_CXXFLAGS=... export MINGW32_LDFLAGS=...

%_mingw64_configure \
  --options
%make_jobs

%install
%make DESTDIR=%{buildroot} install %{?_smp_mflags}

%files
## rename *.so* -> *.dll
## add .exe to executables
## rename _xxxdir to _mingw64_xxxdir
%{_libdir}/xxx*.so  -> %{_mingw64_bindir}/xxx*.dll

%files devel
%{_libdir}/xxx*.so  -> %{_mingw64_libdir}/xxx*.dll.a

Porting native Qt4/cmake packages to mingw64

%define _name   libalkimia
Name:           mingw64-%{_name}
...
BuildRequires:  cmake >= 3.0.0
BuildRequires:  mingw64-cross-gcc-c++
BuildRequires:  mingw64-cross-qmake
BuildRequires:  mingw64-libqt4-devel
...
%_mingw64_package_header_debug
BuildArch: noarch
...
## for language support
%lang_package
...
## add debug package
%_mingw64_debug_package

%prep
%setup -q -n %{_name}-%{version}

%build
export MINGW64_CFLAGS=...
export MINGW64_CXXFLAGS=...
export MINGW64_LDFLAGS=...
%_mingw64_cmake_qt4 
%make_jobs

%install
%_mingw64_cmake_makeinstall
## for language support
%_mingw64_find_lang %{_name} || true

%files
## rename *.so* -> *.dll
## add .exe to executables
## rename _xxxdir to _mingw64_xxxdir
%{_libdir}/xxx*.so  -> %{_mingw64_bindir}/xxx*.dll

%files devel
%{_libdir}/xxx*.so  -> %{_mingw64_libdir}/xxx*.dll.a

Porting native KDE4 packages to mingw64

%define _name kmymoney
Name:           mingw64-%{_name}
...
BuildRequires:  cmake >= 3.0.0
BuildRequires:  mingw64-cross-gcc-c++
...
## if package provides pkg-config files add the following line
BuildRequires:  mingw64-cross-pkg-config
...
BuildRequires:  mingw64-cross-kde4-tools
BuildRequires:  mingw64-libkde4-devel
..
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%_mingw64_package_header_debug
BuildArch: noarch
...
%lang_package
%_mingw64_debug_package

%prep
%setup -q -n %{_name}-%{version}

%build
## sure ? there are also MINGW32_xxx flags
export CFLAGS=...
export CXXFLAGS=...
export LDFLAGS=...
%_mingw64_cmake_kde4 -d build -- -Dxxx=yyy
%make_jobs

%install
%_mingw64_kde4_makeinstall -C build
%_mingw64_kde4_post_install
%_mingw64_find_lang %{_name} || true

%files
## rename *.so* -> *.dll
## add .exe to executables
## rename _xxxdir to _mingw64_xxxdir
%{_libdir}/xxx*.so  -> %{_mingw64_bindir}/xxx*.dll
%{_kde4_modulesdir}/xxx.so.* %{_mingw64_kde4_modulesdir}/xxx*.dll

%files devel
%{_libdir}/xxx*.so  -> %{_mingw64_libdir}/xxx*.dll.a

Porting native Qt5 packages to mingw64

%define _name grantlee5
Name:           mingw64-%{_name}
...
BuildRequires:  cmake >= 3.0.0
BuildRequires:  mingw64-cross-gcc-c++
...
BuildRequires:  mingw64-libqt5-qtbase-devel
..
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%_mingw64_package_header_debug
BuildArch: noarch
...
%_mingw64_debug_package

%prep
%setup -q -n %{_name}-%{version}

%build
%_mingw64_cmake
%make_jobs

%install
%_mingw64_makeinstall DESTDIR=%{buildroot} %{?_smp_mflags}

%files
## rename *.so* -> *.dll
## add .exe to executables
## rename _xxxdir to _mingw64_xxxdir
%{_libdir}/xxx*.so  -> %{_mingw64_bindir}/xxx*.dll

%files devel
%{_libdir}/xxx*.so  -> %{_mingw64_libdir}/xxx*.dll.a

Mingw32

Porting native autotools packages to mingw32

%define _name chmlib
Name:           mingw32-%{_name}
...
BuildRequires:  mingw32-cross-gcc 
# mingw32-cross-gcc-c++ in case of c++ project
... 
## if package provides pkg-config files add the following line
BuildRequires:  mingw32-cross-pkg-config
...
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%_mingw32_package_header_debug
BuildArch: noarch

...
%_mingw32_debug_package

%prep
%setup -q -n %{_name}-%{version}

%build
## sure ? there are also MINGW32_xxx flags
export CFLAGS=...
export CXXFLAGS=...
export LDFLAGS=...
%_mingw32_configure \
  --options
%make_jobs

%install
%make DESTDIR=%{buildroot} install %{?_smp_mflags}

%files
## rename *.so* -> *.dll
## add .exe to executables
## rename _xxxdir to _mingw32_xxxdir
%{_libdir}/xxx*.so  -> %{_mingw32_bindir}/xxx*.dll

%files devel
%{_libdir}/xxx*.so  -> %{_mingw64_libdir}/xxx*.dll.a

Porting native Qt4/cmake packages to mingw32

%define _name   libalkimia
Name:           mingw32-%{_name}
...
BuildRequires:  cmake >= 3.0.0
BuildRequires:  mingw32-cross-gcc-c++
BuildRequires:  mingw32-cross-qmake
BuildRequires:  mingw32-libqt4-devel
...
%_mingw32_package_header_debug
BuildArch: noarch
...
## for language support
%lang_package
...
## add debug package
%_mingw32_debug_package

%prep
%setup -q -n %{_name}-%{version}

%build
export MINGW32_CFLAGS=...
export MINGW32_CXXFLAGS=...
export MINGW32_LDFLAGS=...
%_mingw32_cmake_qt4 
%make_jobs

%install
%_mingw32_cmake_makeinstall
## for language support
%_mingw32_find_lang %{_name} || true

%files
## rename *.so* -> *.dll
## add .exe to executables
## rename _xxxdir to _mingw32_xxxdir
%{_libdir}/xxx*.so  -> %{_mingw32_bindir}/xxx*.dll

%files devel
%{_libdir}/xxx*.so  -> %{_mingw32_libdir}/xxx*.dll.a

Porting native KDE4 packages to mingw32

%define _name kmymoney
Name:           mingw32-%{_name}
...
BuildRequires:  cmake >= 3.0.0
BuildRequires:  mingw32-cross-gcc-c++
## if package provides pkg-config files add the following line
BuildRequires:  mingw32-cross-pkg-config
BuildRequires:  mingw32-cross-kde4-tools
BuildRequires:  mingw32-libkde4-devel
..
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%_mingw32_package_header_debug
BuildArch: noarch
...
%lang_package
%_mingw32_debug_package

%prep
%setup -q -n %{_name}-%{version}

%build
## sure ? there are also MINGW32_xxx flags
export CFLAGS=...
export CXXFLAGS=...
export LDFLAGS=...
%_mingw32_cmake_kde4 -d build -- -Dxxx=yyy
%make_jobs

%install
%_mingw32_kde4_makeinstall -C build
%_mingw32_kde4_post_install
%_mingw32_find_lang %{_name} || true

%files
## rename *.so* -> *.dll
## add .exe to executables
## rename _xxxdir to _mingw32_xxxdir
%{_libdir}/xxx*.so  -> %{_mingw32_bindir}/xxx*.dll
%{_kde4_modulesdir}/xxx.so.* %{_mingw32_kde4_modulesdir}/xxx*.dll

%files devel
%{_libdir}/xxx*.so  -> %{_mingw32_libdir}/xxx*.dll.a

Porting native Qt5 packages to mingw32

%define _name grantlee5
Name:           mingw32-%{_name}
...
BuildRequires:  cmake >= 3.0.0
BuildRequires:  mingw32-cross-gcc-c++
...
BuildRequires:  mingw32-libqt5-qtbase-devel
..
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%_mingw32_package_header_debug
BuildArch: noarch
...
%_mingw32_debug_package

%prep
%setup -q -n %{_name}-%{version}

%build
%_mingw32_cmake
%make_jobs

%install
%_mingw32_makeinstall DESTDIR=%{buildroot} %{?_smp_mflags}

%files
## rename *.so* -> *.dll
## add .exe to executables
## rename _xxxdir to _mingw32_xxxdir
%{_libdir}/xxx*.so  -> %{_mingw32_bindir}/xxx*.dll

%files devel
%{_libdir}/xxx*.so  -> %{_mingw32_libdir}/xxx*.dll.a

Misc

Conditional builds

%bcond_with     shared
...
%if %{with shared}
...
%endif

Access files in local installation root

%{buildroot}%{_mingwXX_prefix}
%{buildroot}%{_mingwXX_prefix}

Setting compiler flags

Compiler flags for autotools and/or cmake packages

export MINGWxx_CFLAGS=...
export MINGWxx_CXXFLAGS=...
export MINGWxx_LDFLAGS=...
%_mingw32_configure | %_mingw32_cmake | %_mingw32_make

add settings to predefined flags

export MINGWxx_CFLAGS="%_mingwxx_cflags ..."
export MINGWxx_CXXFLAGS="%_mingwxx_cflags ..." [1]
export MINGWxx_LDFLAGS="%_mingwxx_ldflags ..."

[1] Here _mingwxx_cxxflags should be used

KDE4 specific compiler flags settings

by specifing rpm variables

%define _mingwXX_kde4_cxxflags ...
%define _mingwXX_kde4_cflags ...
%define _mingwXX_kde4_ldflags ...

Note: Do not use shell variable MINGWxx_yyFLAGS, they will be overwritten internally

Note2: The value of rpm variable %_mingwxx_yyflags is added by default

by using environment variable

export CFLAGS=...
export CXXFLAGS=...
export LDFLAGS=...

add settings to predefined flags

export CFLAGS="%_mingwxx_cflags ..."
export CXXFLAGS="%_mingwxx_cflags ..."
export LDFLAGS="%_mingwxx_ldflags ..."

KF5 specific compiler flags

by specifing rpm variables

%define _mingwXX_kf5_cxxflags ...
%define _mingwXX_kf5_cflags ...
%define _mingwXX_kf5_ldflags ...

Note: The value of rpm variable %_mingwxx_yyflags is added by default

by using environment variable

export CFLAGS=...
export CXXFLAGS=...
export LDFLAGS=...

add settings to predefined flags

export CFLAGS="%_mingwxx_cflags ..."
export CXXFLAGS="%_mingwxx_cflags ..."
export LDFLAGS="%_mingwxx_ldflags ..."