Menu

libunicows.a can be built on OS X

Help
Tom Bishop
2005-06-19
2012-10-07
  • Tom Bishop

    Tom Bishop - 2005-06-19

    In case anyone wants to build libunicows.a on OS X (for cross-compiling programs to run on MS-Windows), here's a makefile that seems to work. It's a copy of "makefile.mingw32", renamed "makefile.mingw32_osx". The only changes are adding the prefix i386-mingw32- to a few items, and changing backslash to forward slash (PATHSEP). Included are comments about possible prerequisites (darwinports, mingw, nasm, binutils).

    Makefile for GCC/Mingw32

    June 17, 2005, tbishop modified version of makefile.mingw32, for cross-compiling on OS X.

    built /libunicows-1.1.1/lib/mingw32libunicows.a as follows:

    cd /libunicows-1.1.1/src

    make -fmakefile.mingw32_osx

    prefixed i386-mingw32- to CC, etc. (except nasm).

    (Installed gcc using darwinports: "sudo port -v install i386-mingw32-gcc".)

    (Installed nasm after gcc, also using darwinports: "sudo port install nasm".)

    (Installed binutils-2.16.1 separately from darwinports with "./configure --target=i686-pc-mingw32".)

    CC = i386-mingw32-gcc
    LD = i386-mingw32-ld
    RANLIB = i386-mingw32-ranlib
    AR = i386-mingw32-ar
    NASM = nasm
    STRIP = i386-mingw32-strip

    CC = gcc

    LD = ld

    RANLIB = ranlib

    AR = ar

    NASM = nasm

    STRIP = strip

    CFLAGS =
    ASMFLAGS = -f win32
    AROPTIONS = rcu

    PATHSEP = /

    was PATHSEP = \

    the remainder below is the same as original makefile.mingw32

    LIBNAME = ../lib/mingw32/liblibunicows.a
    LIBNAME_COMPAT = ../lib/mingw32/libunicows.a
    WRAPPERNAME = ../lib/unicows_wrapper.dll

    OBJECTS = build/mingw32/unicows_import.o \
    build/mingw32/unicows_vars0.o \
    build/mingw32/unicows_mutex.o \
    $(WRAPPERS)

    DLLOBJECTS = build/mingw32/dll_wrapper_main.o \
    build/mingw32/dll_wrapper.o \
    build/mingw32/dll_wrapper_alloca_stub.o

    include makefile.mingw32.include

    all: build/mingw32 ../lib/mingw32 $(LIBNAME) $(LIBNAME_COMPAT)

    build/mingw32:
    mkdir build$(PATHSEP)mingw32

    ../lib/mingw32:
    mkdir ..$(PATHSEP)lib$(PATHSEP)mingw32

    $(LIBNAME): $(OBJECTS)
    $(AR) $(AROPTIONS) $@ $(OBJECTS)
    $(RANLIB) $@

    $(LIBNAME_COMPAT): $(LIBNAME)
    cp -f $< $@

    wrapper: $(WRAPPERNAME)

    $(WRAPPERNAME): $(LIBNAME) $(DLLOBJECTS)
    $(CC) -o $@ -shared -nodefaultlibs -nostartfiles \
    $(DLLOBJECTS) $(LIBNAME) -lkernel32 -luser32
    $(STRIP) $@

    clean:
    rm -f build/mingw32/*.o $(LIBNAME) $(WRAPPERNAME)

    build/mingw32/%.o : %.c
    $(CC) -c $(CFLAGS) -o $@ $<

    build/mingw32/%.o : gen_asm/%.asm
    $(NASM) $(ASMFLAGS) -o $@ $<
    build/mingw32/%.o : %.asm
    $(NASM) $(ASMFLAGS) -o $@ $<

     
    • Vaclav Slavik

      Vaclav Slavik - 2005-06-19

      That's what makefile.crossmingw32 is for...

       
      • Tom Bishop

        Tom Bishop - 2005-06-19

        Oh, I didn't see makefile.crossmingw32. That works too! (But I had to change 586 to 386 for some reason.) Thanks!

         
        • Vaclav Slavik

          Vaclav Slavik - 2005-06-19

          The reason is that you named your cross-compiler i386-mingw32 and I i586-mingw ;-)

           

Log in to post a comment.

MongoDB Logo MongoDB