11. Build ICU 4.4.2 using mingw cross compiler - WebKit porting to Mona OS

Porting ICU is a hard and tough work? No I'm busy myself with other things :D

ICU 4.4.2 is what we are looking for which doen't depend on C++ RTTI.
Let's build it for our OS. Since Unicode data files should be generated on compilation time. The library should be cross-compiled.


  1. compile for OSX on OSX
  2. compile for mingw on OSX using 1
  3. get some data files for Mona OS such as icudt44l_dat.s.
  4. compile for Mona OS using mingw cross compiler

ICU doesn't understand "msvc" postfix such as i586-mingw32msvc, so add symlink.

% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-addr2line ~/mona-mingw/bin/i586-mingw32-addr2line
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-ar ~/mona-mingw/bin/i586-mingw32-ar
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-as ~/mona-mingw/bin/i586-mingw32-as
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-c++ ~/mona-mingw/bin/i586-mingw32-c++
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-c++filt ~/mona-mingw/bin/i586-mingw32-c++filt
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-cpp ~/mona-mingw/bin/i586-mingw32-cpp
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-dlltool ~/mona-mingw/bin/i586-mingw32-dlltool
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-dllwrap ~/mona-mingw/bin/i586-mingw32-dllwrap
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-elfedit ~/mona-mingw/bin/i586-mingw32-elfedit
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-g++ ~/mona-mingw/bin/i586-mingw32-g++
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-gcc ~/mona-mingw/bin/i586-mingw32-gcc
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-gcc-4.6.1 ~/mona-mingw/bin/i586-mingw32-gcc-4.6.1
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-gcov ~/mona-mingw/bin/i586-mingw32-gcov
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-gprof ~/mona-mingw/bin/i586-mingw32-gprof
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-ld ~/mona-mingw/bin/i586-mingw32-ld
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-ld.bfd ~/mona-mingw/bin/i586-mingw32-ld.bfd
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-nm ~/mona-mingw/bin/i586-mingw32-nm
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-objcopy ~/mona-mingw/bin/i586-mingw32-objcopy
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-objdump ~/mona-mingw/bin/i586-mingw32-objdump
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-ranlib ~/mona-mingw/bin/i586-mingw32-ranlib
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-readelf ~/mona-mingw/bin/i586-mingw32-readelf
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-size ~/mona-mingw/bin/i586-mingw32-size
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-strings ~/mona-mingw/bin/i586-mingw32-strings
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-strip ~/mona-mingw/bin/i586-mingw32-strip
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-windmc ~/mona-mingw/bin/i586-mingw32-windmc
% ln -sf ~/mona-mingw/bin/i586-mingw32msvc-windres ~/mona-mingw/bin/i586-mingw32-windres
Build on OSX
% cd ~/tmp
% tar vxf icu4c-4_4_2-src.tgz
% mkdir buildA
% cd buildA
% sh ../icu/source/runConfigureICU MacOSX
% gnumake
Build for mingw on OSX

Open icu/source/config/mh-mingw, replace "Dependency rules".

%.d: $(srcdir)/%.c
@echo "generating dependency information for $<"
@$(SHELL) -ec '$(GEN_DEPS.c) $< \
| sed '\''s%\($*\)\.o[ :]*%\1.o $@ : %g'\'' > $@; \
[ -s $@ ] || rm -f $@'

%.d: $(srcdir)/%.cpp
@echo "generating dependency information for $<"
@$(SHELL) -ec '$(GEN_DEPS.cc) $< \
| sed '\''s%\($*\)\.o[ :]*%\1.o $@ : %g'\'' > $@; \
[ -s $@ ] || rm -f $@'

Open icu/source/common/cstring.h, enable following two define.

#   define uprv_stricmp(str1, str2) T_CString_stricmp(str1, str2)
#   define uprv_strnicmp(str1, str2, n) T_CString_strnicmp(str1, str2, n)

Open pwin32.h, add dummy constants. (Ughhh)

#define U_TIMEZONE      0
#define U_TZNAME        "hige"

Open buildBdata/Makefile, and overwrite CURDIR variable.

% cd ..
% mkdir buildB
% cd buildB
% export PATH=/Users/taro/mona-mingw/bin/:$PATH
% sh ../icu/source/configure --host=i586-mingw32 --with-cross-build=/Users/taro/tmp/buildA
% gnumake

Then we have buildB/data/out/tmp/icudt44l_dat.s which exports a symbol _icudt44_dat.

Build for Mona

See mona/core/icu.