Mac OS X Support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
Here is a patch which mostly enables compilation on Mac OS X. The support is not full as there is still some makefiles issues on which I can't find a *clean* correction and a new issue I discovered in this cvs version related to the libwine_port and the getopt function.


I wasn't sure I had to also include autoconf-ed configure.ac (./configure) in the patch, so I didn't include it as it was space consuming.

ChangeLog:
  * configure.ac
    configure
    Add Mac OS X Support, including Mach-O.
    Fix PowerPC recognition

  * Make.rules.in:
    Add the LDDYLIB definition for Mach-O support.

  * libs/wine/Makefile.in,
    libs/unicode/Makefile.in:
    Add Mach-O support, add target for .dylib

  * dlls/Makedll.rules.in
    Add an entry for .dylib building

* tools/winebuild/import.c
tools/winebuild/spec32.c
Mac OS X linker does not support the same syntax as linux linker, add a case for darwin


  * scheduler/process.c
    Add support for the environ of darwin.

  * scheduler/sysdeps.c
    include/winnt.h
    For darwin the TEB should be in r13, fix it.

  * loader/module.c
    Add Mach-O recognition for executable.

* libs/port/interlocked.c
Add r0 preservation in interlocked functions in order lwarx to be effective and change ';' into '\n'.


Pierre d'Herbemont <stegefin@free.fr>

Thanks.

Index: Make.rules.in
===================================================================
RCS file: /home/wine/wine/Make.rules.in,v
retrieving revision 1.155
diff -r1.155 Make.rules.in
36a37
> LDDYLIB   = @LDDYLIB@
Index: configure.ac
===================================================================
RCS file: /home/wine/wine/configure.ac,v
retrieving revision 1.152
diff -r1.152 configure.ac
779a780
> AC_SUBST(LDDYLIB,"")
794a796,845
>   darwin*|macosx*)
>     AC_CHECK_HEADERS(dlfcn.h,
>         [AC_CHECK_FUNCS(dlopen,,
>           [AC_CHECK_LIB(dl,dlopen,
>              [AC_DEFINE(HAVE_DLOPEN,1,[Define if you have dlopen])
>               DLLIBS="-ldl"],
>           [have_dlcompat="no"])])],
>         [have_dlcompat="no"])
>     if test "$have_dlcompat" = "no"
>     then
>       echo
>       echo "*** Error: No dlcompat found,"
>       echo "***        install it in order to build wine on Mac OS X/Darwin"
>       exit
>     fi
>     
>     AC_CHECK_LIB(poll,poll,
>        [AC_DEFINE(HAVE_DLPOLL,1,[Define if you have lpoll])
>         LIBS="$LIBS -lpoll"],
>        [have_lpoll="no"])
>     
>     if test "$have_lpoll" = "no"
>     then
>       echo
>       echo "*** Error: No lpoll found,"
>       echo "***        install it in order to build wine on Mac OS X/Darwin"
>       exit
>     fi
> 
>     AC_CHECK_HEADERS(mach-o/loader.h,
>        [AC_DEFINE(HAVE_MACHO_LOADER_H,1,[Define if you have mach-o/loader.h])],
>        [have_macho_loader_h="no"])
> 
>     if test "$have_lpoll" = "no"
>     then
>       echo
>       echo "*** Error: No Macho header found,"
>       echo "***        mach-o/loader.h should be installed with the developer tools"
>       echo "***        install them in order to build wine on Mac OS X/Darwin"
>       exit
>     fi
>     AC_DEFINE(USE_MACHO,1,[Define if you use mach-o])
>     
>     CFLAGS="-no-cpp-precomp"
>     LDSHARED="\$(CC) -bundle -flat_namespace -undefined suppress"
>     LDDLLFLAGS=""
>     LIBEXT=dylib
>     AC_SUBST(LDDYLIB,"\$(CC) -dynamiclib -single_module -flat_namespace -undefined suppress")
>     DLLEXT=".so"
>   ;;
870a922,923
>   darwin*|macosx*)
>     AC_SUBST(LDPATH,"DYLD_LIBRARY_PATH=\"\$(TOOLSDIR)/library:\$(TOOLSDIR)/unicode:\$\$PATH\"") ;;
1297a1351,1353
> dnl for the powerpc it seems to be two flags, FIXME : they should be unified
>   *powerpc*)        WINE_CHECK_DEFINE([__powerpc__])
>                     WINE_CHECK_DEFINE([__PPC__]) ;;
1301a1358,1361
> esac
> 
> case $host_os in
>   *darwin*|macosx*) WINE_CHECK_DEFINE([__darwin__]) ;;
Index: dlls/Makedll.rules.in
===================================================================
RCS file: /home/wine/wine/dlls/Makedll.rules.in,v
retrieving revision 1.55
diff -r1.55 Makedll.rules.in
36a37,40
> # Rule for .dylib files
> $(MODULE).dylib: $(MAINSPEC).o $(ALL_OBJS) Makefile.in
> 	$(LDSHARED) $(LDDLLFLAGS) $(MAINSPEC).o $(ALL_OBJS) -o $@ -L$(DLLDIR) $(LDIMPORTS:%=-l%) $(ALL_LIBS) -lc
> 
Index: include/winnt.h
===================================================================
RCS file: /home/wine/wine/include/winnt.h,v
retrieving revision 1.157
diff -r1.157 winnt.h
1634a1635,1637
> # ifdef __darwin
>     __asm__("\tmr %0, r13" : "=r" (teb));
> # else
1635a1639
> # endif
Index: libs/port/interlocked.c
===================================================================
RCS file: /home/wine/wine/libs/port/interlocked.c,v
retrieving revision 1.1
diff -r1.1 interlocked.c
110c110
<         "0:    lwarx %0,0,%2 ;"
---
>         "0:    lwarx %0,0,%2 \n"
112,114c112,114
<         "      bne 1f;"
<         "      stwcx. %3,0,%2;"
<         "      bne- 0b;"
---
>         "      bne 1f\n"
>         "      stwcx. %3,0,%2\n"
>         "      bne- 0b\n"
127,131c127,131
<         "0:    lwarx %0,0,%2 ;"
<         "      xor. %1,%4,%0;"
<         "      bne 1f;"
<         "      stwcx. %3,0,%2;"
<         "      bne- 0b;"
---
>         "0:    lwarx %0,0,%2 \n"
>         "      xor. %1,%4,%0\n"
>         "      bne 1f\n"
>         "      stwcx. %3,0,%2\n"
>         "      bne- 0b\n"
135c135
<         : "cr0","memory");
---
>         : "cr0","memory","r0");
144,147c144,147
<         "0:    lwarx %0, %3, %1;"
<         "      add %0, %2, %0;"
<         "      stwcx. %0, %3, %1;"
<         "      bne- 0b;"
---
>         "0:    lwarx %0, %3, %1\n"
>         "      add %0, %2, %0\n"
>         "      stwcx. %0, %3, %1\n"
>         "      bne- 0b\n"
150c150
<         : "cr0", "memory"
---
>         : "cr0", "memory", "r0"
159,161c159,161
<         "0:    lwarx %0,0,%1 ;"
<         "      stwcx. %2,0,%1;"
<         "      bne- 0b;"
---
>         "0:    lwarx %0,0,%1 \n"
>         "      stwcx. %2,0,%1\n"
>         "      bne- 0b\n"
164c164
<         : "cr0","memory");
---
>         : "cr0","memory","r0");
172,174c172,174
<         "0:    lwarx %0,0,%1 ;"
<         "      stwcx. %2,0,%1;"
<         "      bne- 0b;"
---
>         "0:    lwarx %0,0,%1 \n"
>         "      stwcx. %2,0,%1 \n"
>         "      bne- 0b \n"
177c177
<         : "cr0","memory");
---
>         : "cr0","memory","r0");
Index: libs/unicode/Makefile.in
===================================================================
RCS file: /home/wine/wine/libs/unicode/Makefile.in,v
retrieving revision 1.3
diff -r1.3 Makefile.in
87a88,93
> libwine_unicode.$(SOVERSION).dylib: $(OBJS) Makefile.in
> 	$(LDDYLIB) $(OBJS) -o $@
> 
> libwine_unicode.dylib: libwine_unicode.$(SOVERSION).dylib
> 	$(RM) $@ && $(LN_S) libwine_unicode.$(SOVERSION).dylib $@
> 
100c106,110
< .PHONY: install-lib-so install-lib-dll install-dev-so install-dev-dll
---
> .PHONY: install-lib-dylib install-lib-so install-lib-dll install-dev-so install-dev-dll
> 
> install-lib-dylib: libwine_unicode.$(SOVERSION).dylib dummy
> 	$(MKINSTALLDIRS) $(libdir)
> 	$(INSTALL_PROGRAM) libwine_unicode.$(SOVERSION).dylib $(libdir)/libwine_unicode.$(SOVERSION).dylib
109a120,123
> install-dev-dylib: dummy
> 	$(MKINSTALLDIRS) $(libdir)
> 	cd $(libdir) && $(RM) libwine_unicode.dylib && $(LN_S) libwine_unicode.$(SOVERSION).dylib libwine_unicode.dylib
> 
122c136
< 	$(RM) $(libdir)/libwine_unicode.a $(libdir)/libwine_unicode.dll $(libdir)/libwine_unicode.so $(libdir)/libwine_unicode.so.$(SOVERSION)
---
> 	$(RM) $(libdir)/libwine_unicode.a $(libdir)/libwine_unicode.dll $(libdir)/libwine_unicode.so $(libdir)/libwine_unicode.so.$(SOVERSION) $(libdir)/libwine_unicode.dylib $(libdir)/libwine_unicode.$(SOVERSION).dylib
125c139
< 	$(RM) libwine_unicode.so.$(SOVERSION) libwine_unicode.dll
---
> 	$(RM) libwine_unicode.so.$(SOVERSION) libwine_unicode.dll libwine_unicode.$(SOVERSION).dylib
Index: libs/wine/Makefile.in
===================================================================
RCS file: /home/wine/wine/libs/wine/Makefile.in,v
retrieving revision 1.2
diff -r1.2 Makefile.in
22a23,28
> libwine.$(SOVERSION).dylib: $(OBJS)
> 	$(LDDYLIB) $(OBJS) $(EXTRALIBS) $(LIBS) -o $@
>         
> libwine.dylib: libwine.$(SOVERSION).dylib
> 	$(RM) $@ && $(LN_S) libwine.$(SOVERSION).dylib $@
> 
35c41,45
< .PHONY: install-lib-so install-lib-dll install-dev-so install-dev-dll
---
> .PHONY: install-lib-dylib install-lib-so install-lib-dll install-dev-so install-dev-dll
> 
> install-lib-dylib: libwine.$(SOVERSION).dylib dummy
> 	$(MKINSTALLDIRS) $(libdir)
> 	$(INSTALL_PROGRAM) libwine.$(SOVERSION).dylib $(libdir)/libwine.$(SOVERSION).dylib
44a55,58
> install-dev-dylib: dummy
> 	$(MKINSTALLDIRS) $(libdir)
> 	cd $(libdir) && $(RM) libwine.dylib && $(LN_S) libwine.$(SOVERSION).dylib libwine.dylib
> 
57c71
< 	$(RM) $(libdir)/libwine.a $(libdir)/libwine.dll $(libdir)/libwine.so $(libdir)/libwine.so.$(SOVERSION)
---
> 	$(RM) $(libdir)/libwine.a $(libdir)/libwine.dll $(libdir)/libwine.so $(libdir)/libwine.so.$(SOVERSION) $(libdir)/libwine.dylib $(libdir)/libwine.$(SOVERSION).dylib
60c74
< 	$(RM) libwine.so.$(SOVERSION) libwine.dll
---
> 	$(RM) libwine.so.$(SOVERSION) libwine.dll libwine.$(SOVERSION).dylib
Index: loader/module.c
===================================================================
RCS file: /home/wine/wine/loader/module.c,v
retrieving revision 1.182
diff -r1.182 module.c
32a33,35
> #ifdef HAVE_MACHO_LOADER_H_
> # include <mach-o/loader.h>
> #endif
257a261,272
> #ifdef USE_MACHO
>         struct
>         {
>             unsigned long magic;
>             unsigned long cputype;
>             unsigned long cpusubtype;
>             unsigned long filetype;
>             unsigned long ncmds;
>             unsigned long sizeofcmds;
>             unsigned long flags;
>         } macho;
> #endif /* USE_MACHO */
279a295,318
>     
> #ifdef USE_MACHO
>     /* Mach-o File with Endian set to Big Endian */
>     if (header.macho.magic == 0xfeedface)
>     {
>          /* FIXME: we don't bother to check byte order, architecture, etc. */
>          switch(header.macho.filetype)
>          {
>            case MH_BUNDLE: return BINARY_UNIX_LIB;
>          }
>          return BINARY_UNKNOWN;
>     }
> 
>     /* Mach-o File with Endian set to Little Endian */
>     if (header.macho.magic == 0xecafdeef)
>     {
>          /* FIXME: we don't bother to check byte order, architecture, etc. */
>          switch(header.macho.filetype)
>          {
>            case MH_BUNDLE: return BINARY_UNIX_LIB;
>          }
>          return BINARY_UNKNOWN;
>     }
> #endif /* USE_MACHO */
Index: scheduler/process.c
===================================================================
RCS file: /home/wine/wine/scheduler/process.c,v
retrieving revision 1.213
diff -r1.213 process.c
34a35,39
> #ifdef __darwin__
> # include <crt_externs.h>
> # define environ (*_NSGetEnviron())
> #endif
> 
Index: scheduler/sysdeps.c
===================================================================
RCS file: /home/wine/wine/scheduler/sysdeps.c,v
retrieving revision 1.65
diff -r1.65 sysdeps.c
91a92,94
> # ifdef __darwin__
>     __asm__ __volatile__("mr r13, %0" : : "r" (teb));
> # else /* __darwin__ */
92a96
> # endif
467a472,474
> # ifdef __darwin__
> __ASM_GLOBAL_FUNC( NtCurrentTeb, "\n\tmr r3,r13\n\tblr" );
> # else
468a476
> # endif
Index: tools/winebuild/import.c
===================================================================
RCS file: /home/wine/wine/tools/winebuild/import.c,v
retrieving revision 1.49
diff -r1.49 import.c
821a822,843
> /* Darwin's ld doesn't like the same asm code as linux linker... */
> # ifdef __darwin___
>             fprintf(outfile, "\taddi r1, r1, -0x4\\n\"\n");
>             fprintf(outfile, "\t\"\\tstw r9, 0(r1)\\n\"\n");
>             fprintf(outfile, "\t\"\\taddi r1, r1, -0x4\\n\"\n");
>             fprintf(outfile, "\t\"\\tstw r8, 0(r1)\\n\"\n");
>             fprintf(outfile, "\t\"\\taddi r1, r1, -0x4\\n\"\n");
>             fprintf(outfile, "\t\"\\tstw r7, 0(r1)\\n\"\n");
> 
>             fprintf(outfile, "\t\"\\tlis r9,ha16(_imports+%d)\\n\"\n", pos);
>             fprintf(outfile, "\t\"\\tla r8,lo16(_imports+%d)(r9)\\n\"\n", pos);
>             fprintf(outfile, "\t\"\\tlwz r7, 0(r8)\\n\"\n");
>             fprintf(outfile, "\t\"\\tmtctr r7\\n\"\n");
> 
>             fprintf(outfile, "\t\"\\tlwz r7, 0(r1)\\n\"\n");
>             fprintf(outfile, "\t\"\\taddi r1, r1, 0x4\\n\"\n");
>             fprintf(outfile, "\t\"\\tlwz r8, 0(r1)\\n\"\n");
>             fprintf(outfile, "\t\"\\taddi r1, r1, 0x4\\n\"\n");
>             fprintf(outfile, "\t\"\\tlwz r9, 0(r1)\\n\"\n");
>             fprintf(outfile, "\t\"\\taddi r1, r1, 0x4\\n\"\n");
>             fprintf(outfile, "\t\"\\tbctr\\n");
> # else /* __darwin___ */
840a863
> # endif /* __darwin___ */
847a871,875
> 
> /* darwin and Mach-o have a different behavior */
> #ifdef __darwin__
>     fprintf( outfile, "\".text\");\n#ifndef __GNUC__\n}\n#endif\n\n" );
> #else
848a877
> #endif /* __darwin__ */
970a1000,1004
>     
> #ifdef __darwin__
>     /* darwin likes this one */
>     fprintf( outfile, "\"\\t.data\\n\"" );
> #endif
984a1019,1065
> # ifdef __darwin__
>     /* Save all callee saved registers into a stackframe. */
>     fprintf( outfile, "    \"\\tstwu r1, -48(r1)\\n\"\n" );
>     fprintf( outfile, "    \"\\tstw Êr3, 4(r1)\\n\"\n" );
>     fprintf( outfile, "    \"\\tstw Êr4, 8(r1)\\n\"\n" );
>     fprintf( outfile, "    \"\\tstw Êr5, 12(r1)\\n\"\n" );
>     fprintf( outfile, "    \"\\tstw Êr6, 16(r1)\\n\"\n" );
>     fprintf( outfile, "    \"\\tstw Êr7, 20(r1)\\n\"\n" );
>     fprintf( outfile, "    \"\\tstw Êr8, 24(r1)\\n\"\n" );
>     fprintf( outfile, "    \"\\tstw Êr9, 28(r1)\\n\"\n" );
>     fprintf( outfile, "    \"\\tstw Êr10, 32(r1)\\n\"\n" );
>     fprintf( outfile, "    \"\\tstw Êr11, 36(r1)\\n\"\n" );
>     fprintf( outfile, "    \"\\tstw Êr12, 40(r1)\\n\"\n" );
> 
>     /* r0 -> r3 (arg1) */
>     fprintf( outfile, "    \"\\tmr Êr3, r0\\n\"\n" );
> 
>     /* save return address */
>     fprintf( outfile, "    \"\\tmflr Êr0\\n\"\n" );
>     fprintf( outfile, "    \"\\tstw Êr0, 44(r1)\\n\"\n" );
> 
>     /* Call the __wine_delay_load function, arg1 is arg1. */
>     fprintf( outfile, "    \"\\tbl __wine_delay_load\\n\"\n" );
> 
>     /* Load return value from call into ctr register */
>     fprintf( outfile, "    \"\\tmtctr r3\\n\"\n" );
> 
>     /* restore all saved registers and drop stackframe. */
>     fprintf( outfile, "    \"\\tlwz Êr3, 4(r1)\\n\"\n" );
>     fprintf( outfile, "    \"\\tlwz Êr4, 8(r1)\\n\"\n" );
>     fprintf( outfile, "    \"\\tlwz Êr5, 12(r1)\\n\"\n" );
>     fprintf( outfile, "    \"\\tlwz Êr6, 16(r1)\\n\"\n" );
>     fprintf( outfile, "    \"\\tlwz Êr7, 20(r1)\\n\"\n" );
>     fprintf( outfile, "    \"\\tlwz Êr8, 24(r1)\\n\"\n" );
>     fprintf( outfile, "    \"\\tlwz Êr9, 28(r1)\\n\"\n" );
>     fprintf( outfile, "    \"\\tlwz Êr10, 32(r1)\\n\"\n" );
>     fprintf( outfile, "    \"\\tlwz Êr11, 36(r1)\\n\"\n" );
>     fprintf( outfile, "    \"\\tlwz Êr12, 40(r1)\\n\"\n" );
> 
>     /* Load return value from call into return register */
>     fprintf( outfile, "    \"\\tlwz Êr0, 44(r1)\\n\"\n" );
>     fprintf( outfile, "    \"\\tmtlr r0\\n\"\n" );
>     fprintf( outfile, "    \"\\taddi r1, r1, 48\\n\"\n" );
> 
>     /* branch to ctr register. */
>     fprintf( outfile, "    \"\\tbctr\\n\"\n" );
> # else /* __darwin__ */
1028c1109
< 
---
> # endif /* __darwin__ */
1094a1176,1197
> # ifdef __darwin__
>             fprintf(outfile, "\t\"addi 1, 1, -0x4\\n\"\n");
>             fprintf(outfile, "\t\"\\tstw 9, 0(1)\\n\"\n");
>             fprintf(outfile, "\t\"\\taddi 1, 1, -0x4\\n\"\n");
>             fprintf(outfile, "\t\"\\tstw 8, 0(1)\\n\"\n");
>             fprintf(outfile, "\t\"\\taddi 1, 1, -0x4\\n\"\n");
>             fprintf(outfile, "\t\"\\tstw 7, 0(1)\\n\"\n");
> 
>             fprintf(outfile, "\t\"\\tlis 9,ha16(_delay_imports+%d)\\n\"\n", pos);
>             fprintf(outfile, "\t\"\\tla 8,lo16(_delay_imports+%d)(9)\\n\"\n", pos);
>             fprintf(outfile, "\t\"\\tlwz 7, 0(8)\\n\"\n");
>             fprintf(outfile, "\t\"\\tmtctr 7\\n\"\n");
> 
>             fprintf(outfile, "\t\"\\tlwz 7, 0(1)\\n\"\n");
>             fprintf(outfile, "\t\"\\taddi 1, 1, 0x4\\n\"\n");
>             fprintf(outfile, "\t\"\\tlwz 8, 0(1)\\n\"\n");
>             fprintf(outfile, "\t\"\\taddi 1, 1, 0x4\\n\"\n");
>             fprintf(outfile, "\t\"\\tlwz 9, 0(1)\\n\"\n");
> 
>             fprintf(outfile, "\t\"\\taddi 1, 1, 0x4\\n\"\n");
>             fprintf(outfile, "\t\"\\tbctr\\n\"");
> # else /* __darwine__*/ 
1118a1222
> # endif /* __darwin__ */
1124a1229,1235
>     
> #ifdef __darwin__
>     fprintf( outfile, "\".text\");\n" );
> #else /* __darwin__ */
>     fprintf( outfile, "\".section \\\".text\\\"\");\n" );
> #endif /* __darwin__ */
> 
Index: tools/winebuild/spec32.c
===================================================================
RCS file: /home/wine/wine/tools/winebuild/spec32.c,v
retrieving revision 1.65
diff -r1.65 spec32.c
431a432,445
> # ifdef __darwin__
>     if (constructor)
>     {
>         fprintf( outfile, "asm(\"\\t.section .init,ax\\n\"\n" );
>         fprintf( outfile, "    \"\\tbl " __ASM_NAME("%s") "\\n\"\n", constructor );
>         fprintf( outfile, "    \"\\t.text\\n\");\n" );
>     }
>     if (destructor)
>     {
>         fprintf( outfile, "asm(\"\\t.section .fini,ax\\n\"\n" );
>         fprintf( outfile, "    \"\\tbl " __ASM_NAME("%s") "\\n\"\n", destructor );
>         fprintf( outfile, "    \"\\t.text\\n\");\n" );
>     }
> # else /* __darwin__ */
443a458
> # endif /* __darwin__ */
491a507,509
> #ifdef __darwin__
>     fprintf( outfile, "asm(\".text\\n\\t\"\n" );
> #else
492a511
> #endif
548a568,570
>             fprintf( outfile, "# ifdef __darwin__\n" );
>             fprintf( outfile, "extern void DllMain() __attribute__((weak_import));\n" );
>             fprintf( outfile, "# else\n" );
549a572
>             fprintf( outfile, "# endif\n" );
922a946,948
> # ifdef __darwin__
>     fprintf( outfile, "    \"\\t.text\\n\");\n" );
> # else
923a950
> # endif

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux