Bug 691077 - instructions for cross-compiling mupdf on fedora 12
Summary: instructions for cross-compiling mupdf on fedora 12
Status: RESOLVED FIXED
Alias: None
Product: MuPDF
Classification: Unclassified
Component: mupdf (show other bugs)
Version: unspecified
Hardware: PC Linux
: P4 normal
Assignee: Tor Andersson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-20 17:32 UTC by Hin-Tak Leung
Modified: 2010-07-23 22:09 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
patch to apply (4.92 KB, patch)
2010-01-20 17:38 UTC, Hin-Tak Leung
Details | Diff
zip file of the cross compile, plus dependent dll's (18.23 MB, application/octet-stream)
2010-01-20 17:51 UTC, Hin-Tak Leung
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hin-Tak Leung 2010-01-20 17:32:44 UTC
Here are my notes, etc on cross-compiling mupdf :

1. get the source -
 darcs get http://mupdf.com/repos/mupdf

2. just run 
      jam '-sBUILD=release'
on its own to build the native version, to generate the font_*.c and cmap_*.c
which we'll need later

3. apply the patch (to be attached, and description)

4. jam '-sBUILD=release' '-sOS=MINGW' '-sCC=i686-pc-mingw32-gcc' \
   '-sAR=i686-pc-mingw32-ar -crs' '-sRANLIB=i686-pc-mingw32-ar -rcs'

5. when the build fails due to not finding libfonts.a and libcmaps.a,
   do them manually:
   
   cd build/mingw-amd64-release/
   find ../linux-amd64-release/*.c -type f \
     -exec i686-pc-mingw32-gcc -I ../../fitz/ -I ../../mupdf/ -c {} \;
   i686-pc-mingw32-ar  -crs libfonts.a font*.o
   i686-pc-mingw32-ar  -crs libcmaps.a cmap*.o
   cd ../../

6. do step 4 again.

7. go into mingw-amd64-release/, the files needs a bit of renaming to add the
'.exe' ending.

8. copy libfreetype-6.dll , libjpeg-7.dll and zlib1.dll from 
/usr/i686-pc-mingw32/sys-root/mingw/bin/ to make a release.
   (by default binaries made have dynamic dependencies)

That's it. I tried this myself again on a clean checkout while writing this.
Comment 1 Hin-Tak Leung 2010-01-20 17:38:24 UTC
Created attachment 5894 [details]
patch to apply

Here is a description of what the patch tries to do:
- stripe out and fake the libfonts libcmaps dependencies, since it doesn't work
and we have to build them by hand from the native-generated files.
- modify the include and link paths to point to fedora as shipped
header/library locations for freetype
- the resource compiler is 'i686-pc-mingw32-windres' , instead of 'windres'.

- I tried to build against the fedora-shipped mingw32-openjpeg but it does not
work, for yet unknown reason; so ignore those.
Comment 2 Hin-Tak Leung 2010-01-20 17:51:18 UTC
Created attachment 5895 [details]
zip file of the cross compile, plus dependent dll's


$ zipinfo /tmp/mupdf-crossed.zip
Archive:  /tmp/mupdf-crossed.zip   19110926 bytes   10 files
-rwxr-xr-x  2.3 unx  2301552 b- defX 27-Jul-09 02:43 libfreetype-6.dll
-rwxr-xr-x  2.3 unx   192227 b- defX 18-Sep-09 22:46 libjpeg-7.dll
-rwx--x--x  2.3 unx  6523550 b- defX 21-Jan-10 01:25 npmupdf.dll
-rwxr-xr-x  2.3 unx    69120 b- defX 27-Jul-09 03:04 zlib1.dll
-rwx--x--x  2.3 unx  6527339 b- defX 21-Jan-10 01:25 mupdf.exe
-rwx--x--x  2.3 unx   208978 b- defX 21-Jan-10 01:25 pdfclean.exe
-rwx--x--x  2.3 unx  6476440 b- defX 21-Jan-10 01:25 pdfdraw.exe
-rwx--x--x  2.3 unx  6464038 b- defX 21-Jan-10 01:25 pdfextract.exe
-rwx--x--x  2.3 unx  6477667 b- defX 21-Jan-10 01:25 pdfinfo.exe
-rwx--x--x  2.3 unx   207461 b- defX 21-Jan-10 01:25 pdfshow.exe
10 files, 35448372 bytes uncompressed, 19109908 bytes compressed:  46.1%
Comment 3 Hin-Tak Leung 2010-01-20 22:25:44 UTC
BTW, this is gcc-4 built, so could be dfferent compared to gcc-3 builds
performance-wise. I'd be interested to know if there is any performance differences.
Comment 4 Tor Andersson 2010-07-23 20:35:57 UTC
New instructions for Makefile:

Build natively first to generate cmap and font files:
$ make && mv build/generated pregen && make clean
...or...
$ wget http://mupdf.com/download/source/mupdf-pregen.zip
$ unzip mupdf-pregen.zip

Install third party library package mupdf-thirdparty.zip
$ wget http://mupdf.com/download/source/mupdf-thirdparty.zip
$ unzip mupdf-thirdparty.zip
$ cp thirdparty/jpeg/jconfig.txt thirdparty/jpeg/jconfig.h

Build with cross compiler:
$ make OS=MINGW CC=i586-mingw32msvc-cc AR=i586-mingw32msvc-ar WINDRES=i586-mingw32msvc-windres
Comment 5 Hin-Tak Leung 2010-07-23 22:09:44 UTC
Verifed. Thanks. I must have renamed the files to added the "exe" manually...,

mupdf.exe now has an "exe" extension but the other pdf* executables don't. Would be nice to have .exe for them as well. Just a thought.