Example "cross-zlib" package added to Mercurial

Richard W.M. Jones rjones at redhat.com
Sun Feb 15 09:48:20 UTC 2009


Here is the annotated diff from the current mingw32-zlib.spec file to
the proposed new spec file that would build to multiple architectures.

    --- mingw32-zlib.spec	2009-01-19 19:03:53.000000000 +0000
    +++ mingw32-zlib.spec	2009-02-14 14:06:48.000000000 +0000
    @@ -6,8 +6,8 @@
     
     Name:           mingw32-zlib
     Version:        1.2.3
    -Release:        12%{?dist}
    -Summary:        MinGW Windows zlib compression library
    +Release:        13%{?dist}
    +Summary:        Cross-compiled zlib compression library

As a general cleanup, we need to go through all the summary lines and
remove "Windows" (trademark, see[1]) and "MinGW" (no longer
appropriate for these packages).  At the same time we don't want to
get confused with other cross-compiler packages in Fedora.
Suggestions welcome on a good summary line.

[1] https://www.redhat.com/archives/fedora-devel-announce/2009-January/msg00012.html
     
     License:        zlib
     Group:          Development/Libraries
    @@ -27,19 +27,42 @@
     BuildRequires:  mingw32-filesystem >= 23
     BuildRequires:  mingw32-gcc
     BuildRequires:  mingw32-binutils
    +BuildRequires:  mingw64-filesystem >= 10
    +BuildRequires:  mingw64-gcc
    +BuildRequires:  mingw64-binutils

     %description
    -MinGW Windows zlib compression library.
    +Cross-compiled zlib compression library.
    +
    +
    +%package -n mingw64-zlib
    +Summary:        Cross-compiled zlib compression library
    +Group:          Development/Libraries
    +
    +
    +%description -n mingw64-zlib
    +Cross-compiled zlib compression library.

Since we are going to build for Win32 and Win64, we need the extra
BuildRequires and the extra subpackage.

     %prep
    -%setup -q -n zlib-1.2.3
    +%setup -q -c -n %{name}-%{version} -a 0
    +mv zlib-%{version} mingw32
    +%setup -q -c -D -n %{name}-%{version} -a 0
    +mv zlib-%{version} mingw64

This is one of several ways to set up a directory structure like this:

  mingw32-zlib-1.2.3/
    mingw32     # full copy of the source
    mingw64     # second full copy of the source

zlib has a strange build system with a custom configure script.  For
autoconf packages we could do this more efficiently using a single
copy of the source and separate build directories.

[Which reminds me -- we need to modify %{_mingw32_configure} so that
it looks for a configure script in . and ..]

    +pushd mingw32
    +%patch100 -p1
    +popd
     
    +pushd mingw64
     %patch100 -p1
    +popd

In this case (non-autoconf) we need to apply all patches twice,

     %build
    +pushd mingw32
    +
     CC=%{_mingw32_cc} \
     CFLAGS="%{_mingw32_cflags}" \
     RANLIB=%{_mingw32_ranlib} \
    @@ -49,15 +72,37 @@
       STRIP=%{_mingw32_strip} \
       all
     
    +popd
    +
    +pushd mingw64
    +
    +CC=%{_mingw64_cc} \
    +CFLAGS="%{_mingw64_cflags}" \
    +RANLIB=%{_mingw64_ranlib} \
    +./configure
    +
    +make -f win32/Makefile.gcc \
    +  CFLAGS="%{_mingw64_cflags}" \
    +  CC=%{_mingw64_cc} \
    +  AR=%{_mingw64_ar} \
    +  RC=%{_mingw64_windres} \
    +  DLLWRAP=%{_mingw64_dllwrap} \
    +  STRIP=%{_mingw64_strip} \
    +  all
    +
    +popd
    +

and we do the build twice, using the Win64 cross-compiler in the
second directory.

     %install
     rm -rf $RPM_BUILD_ROOT
     
    +pushd mingw32
    +
     mkdir -p $RPM_BUILD_ROOT%{_mingw32_bindir}
     mkdir -p $RPM_BUILD_ROOT%{_mingw32_includedir}
     mkdir -p $RPM_BUILD_ROOT%{_mingw32_libdir}
    @@ -75,6 +120,29 @@
     # Remove static library.
     rm $RPM_BUILD_ROOT%{_mingw32_libdir}/libz.a
     
    +popd
    +
    +pushd mingw64
    +
    +mkdir -p $RPM_BUILD_ROOT%{_mingw64_bindir}
    +mkdir -p $RPM_BUILD_ROOT%{_mingw64_includedir}
    +mkdir -p $RPM_BUILD_ROOT%{_mingw64_libdir}
    +
    +make -f win32/Makefile.gcc \
    +     INCLUDE_PATH=$RPM_BUILD_ROOT%{_mingw64_includedir} \
    +     LIBRARY_PATH=$RPM_BUILD_ROOT%{_mingw64_libdir} \
    +     BINARY_PATH=$RPM_BUILD_ROOT%{_mingw64_bindir} \
    +     install
    +
    +# .dll.a file is misnamed for some reason - fix that.
    +mv $RPM_BUILD_ROOT%{_mingw64_libdir}/libzdll.a \
    +   $RPM_BUILD_ROOT%{_mingw64_libdir}/libz.dll.a
    +
    +# Remove static library.
    +rm $RPM_BUILD_ROOT%{_mingw64_libdir}/libz.a
    +
    +popd
    +

Again, the install section is duplicated.

     %clean
     rm -rf $RPM_BUILD_ROOT
    @@ -88,6 +156,14 @@
     %{_mingw32_bindir}/zlib1.dll
     
     
    +%files -n mingw64-zlib
    +%defattr(-,root,root)
    +%{_mingw64_includedir}/zconf.h
    +%{_mingw64_includedir}/zlib.h
    +%{_mingw64_libdir}/libz.dll.a
    +%{_mingw64_bindir}/zlib1.dll

and also %files is duplicated for the second subpackage.

Rich.
    
-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top



More information about the mingw mailing list