diff -Naur dmd/src/dmd/backend/cc.h dmd1/src/dmd/backend/cc.h
--- dmd/src/dmd/backend/cc.h	2010-09-14 07:16:00.036962304 +0000
+++ dmd1/src/dmd/backend/cc.h	2010-09-19 15:18:13.894697472 +0000
@@ -82,7 +82,7 @@
         WM_badnumber    = 24,
         WM_ccast        = 25,
         WM_obsolete     = 26,
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         WM_skip_attribute   = 27, // skip GNUC attribute specification
         WM_warning_message  = 28, // preprocessor warning message
         WM_bad_vastart      = 29, // args for builtin va_start bad
@@ -146,7 +146,7 @@
 #include        "msgs2.h"
 #endif
 #include        "ty.h"
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
 #include        "../tk/mem.h"
 #else
 #include        "mem.h"
@@ -745,7 +745,7 @@
         #define Fnteh           0x08    // uses NT Structured EH
         #define Fdoinline       0x40    // do inline walk
         #define Foverridden     0x80    // ignore for overriding purposes
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         #define Fnowrite        0x100   // SCinline should never output definition
 #else
         #define Fjmonitor       0x100   // Jupiter synchronized function
@@ -800,7 +800,7 @@
                                 // of SCftexpspec explicit specializations
     Funcsym *Fsurrogatesym;     // Fsurrogate: surrogate cast function
 
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     char *Fredirect;            // redirect function name to this name in object
 #endif
     TARGET_structFUNC_S
@@ -1325,7 +1325,7 @@
         #define SFLmutable      0x100000        // SCmember or SCfield is mutable
         #define SFLdyninit      0x200000        // symbol has dynamic initializer
         #define SFLtmp          0x400000        // symbol is a generated temporary
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         #define SFLthunk        0x40000 // symbol is temporary for thunk
 #endif
 
@@ -1543,7 +1543,7 @@
         FLallocatmp,    // temp for built-in alloca()
         FLstack,        // offset from ESP rather than EBP
         FLdsymbol,      // it's a Dsymbol
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         // Change this, update debug.c too
         FLgot,          // global offset table entry outside this object file
         FLgotoff,       // global offset table entry inside this object file
diff -Naur dmd/src/dmd/backend/cdef.h dmd1/src/dmd/backend/cdef.h
--- dmd/src/dmd/backend/cdef.h	2010-09-14 07:16:00.023068672 +0000
+++ dmd1/src/dmd/backend/cdef.h	2010-09-19 15:22:37.755236864 +0000
@@ -171,9 +171,14 @@
 #define TARGET_SOLARIS  0               // target is a Solaris executable
 #endif
 
+// Set to 1 using the makefile
+#ifndef TARGET_HAIKU
+#define TARGET_HAIKU  0               // target is a Haiku executable
+#endif
+
 // This is the default
 #ifndef TARGET_WINDOS
-#define TARGET_WINDOS   (!(TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS))
+#define TARGET_WINDOS   (!(TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU))
 #endif
 
 #if __GNUC__
@@ -242,7 +247,7 @@
 
 // Precompiled header variations
 #define MEMORYHX        (_WINDLL && _WIN32)     // HX and SYM files are cached in memory
-#define MMFIO           (_WIN32 || linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4)  // if memory mapped files
+#define MMFIO           (_WIN32 || linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__)  // if memory mapped files
 #define LINEARALLOC     _WIN32  // if we can reserve address ranges
 
 // H_STYLE takes on one of these precompiled header methods
@@ -458,7 +463,7 @@
 #define DOUBLESIZE      8
 #if TARGET_OSX
 #define LNGDBLSIZE      16      // 80 bit reals
-#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
 #define LNGDBLSIZE      12      // 80 bit reals
 #else
 #define LNGDBLSIZE      10      // 80 bit reals
@@ -509,7 +514,7 @@
 #define OMFOBJ          TARGET_WINDOS
 #endif
 #ifndef ELFOBJ
-#define ELFOBJ          (TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS)
+#define ELFOBJ          (TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU)
 #endif
 #ifndef MACHOBJ
 #define MACHOBJ         TARGET_OSX
@@ -696,6 +701,7 @@
 #define EX_SCOUNIX      0x800
 #define EX_UNIXSVR4     0x1000
 #define EX_LINUX        0x2000
+#define EX_HAIKU        0x2000
 #define EX_WIN64        0x4000  // AMD64 and Windows (64 bit mode)
 #define EX_LINUX64      0x8000  // AMD64 and Linux (64 bit mode)
 #define EX_OSX          0x10000
@@ -707,7 +713,7 @@
 
 #define EX_flat         (EX_OS2 | EX_NT | EX_LINUX | EX_WIN64 | EX_LINUX64 | \
                          EX_OSX | EX_OSX64 | EX_FREEBSD | EX_FREEBSD64 | \
-                         EX_SOLARIS | EX_SOLARIS64)
+                         EX_SOLARIS | EX_SOLARIS64 | EX_HAIKU)
 #define EX_dos          (EX_DOSX | EX_ZPM | EX_RATIONAL | EX_PHARLAP | \
                          EX_COM | EX_MZ /*| EX_WIN16*/)
 
@@ -760,7 +766,7 @@
 #define CFG3relax       0x200   // relaxed type checking (C only)
 #define CFG3cpp         0x400   // C++ compile
 #define CFG3igninc      0x800   // ignore standard include directory
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
 #define CFG3mars        0x1000  // use mars libs and headers
 #define NO_FAR          (TRUE)  // always ignore __far and __huge keywords
 #else
@@ -772,7 +778,7 @@
 #define CFG3cppcomment  0x8000  // allow C++ style comments
 #define CFG3wkfloat     0x10000 // make floating point references weak externs
 #define CFG3digraphs    0x20000 // support ANSI C++ digraphs
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
 #define CFG3semirelax   0x40000 // moderate relaxed type checking
 #endif
 #define CFG3pic         0x80000 // position independent code
@@ -975,7 +981,7 @@
 #define SYMBOLZERO
 #endif
 
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
 #define UNIXFIELDS      (unsigned)-1,(unsigned)-1,0,0,
 #elif TARGET_OSX
 #define UNIXFIELDS      (unsigned)-1,(unsigned)-1,0,0,0,
diff -Naur dmd/src/dmd/backend/cg87.c dmd1/src/dmd/backend/cg87.c
--- dmd/src/dmd/backend/cg87.c	2010-09-14 07:16:00.041680896 +0000
+++ dmd1/src/dmd/backend/cg87.c	2010-09-19 16:00:13.923271168 +0000
@@ -619,7 +619,7 @@
     static double dval[7] =
         {0.0,1.0,PI,LOG2T,LOG2E,LOG2,LN2};
     static long double ldval[7] =
-#if __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
 #define M_PIl           0x1.921fb54442d1846ap+1L        // 3.14159 fldpi
 #define M_LOG2T_L       0x1.a934f0979a3715fcp+1L        // 3.32193 fldl2t
 #define M_LOG2El        0x1.71547652b82fe178p+0L        // 1.4427 fldl2e
diff -Naur dmd/src/dmd/backend/cgcod.c dmd1/src/dmd/backend/cgcod.c
--- dmd/src/dmd/backend/cgcod.c	2010-09-14 07:16:00.010223616 +0000
+++ dmd1/src/dmd/backend/cgcod.c	2010-09-19 15:23:23.361496576 +0000
@@ -127,7 +127,7 @@
     csmax = 64;
     csextab = (struct CSE *) util_calloc(sizeof(struct CSE),csmax);
     functy = tybasic(funcsym_p->ty());
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     if (0 && config.flags3 & CFG3pic)
     {
         ALLREGS = ALLREGS_INIT_PIC;
@@ -1002,7 +1002,7 @@
 #endif
                 if (config.flags2 & CFG2seh)
                     c = cat(c,nteh_unwind(0,toindex));
-#if MARS && (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS)
+#if MARS && (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU)
                 else if (toindex + 1 <= fromindex)
                 {
                     //c = cat(c, linux_unwind(0, toindex));
@@ -1089,7 +1089,7 @@
             assert(!getregs(allregs));
             assert(!e);
             assert(!bl->Bcode);
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
             if (config.flags3 & CFG3pic)
             {
                 if (STACKALIGN == 16)
@@ -1553,7 +1553,7 @@
             return mST0;
 
         case TYcfloat:
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
             if (I32 && tybasic(tyf) == TYnfunc)
                 return mDX | mAX;
 #endif
@@ -2492,7 +2492,7 @@
         case OPrelconst:
             c = cdrelconst(e,pretregs);
             break;
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         case OPgot:
             c = cdgot(e,pretregs);
             break;
diff -Naur dmd/src/dmd/backend/cgelem.c dmd1/src/dmd/backend/cgelem.c
--- dmd/src/dmd/backend/cgelem.c	2010-09-14 07:16:00.005242880 +0000
+++ dmd1/src/dmd/backend/cgelem.c	2010-09-19 15:24:12.137101312 +0000
@@ -812,7 +812,7 @@
   e2 = e->E2;
   if (e2->Eoper == OPconst)
   {
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         if (e1->Eoper == OPrelconst && e1->EV.sp.Vsym->Sfl == FLgot)
                 goto ret;
 #endif
@@ -827,7 +827,7 @@
   }
   else if (e1->Eoper == OPconst)
   {
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         if (e2->Eoper == OPrelconst && e2->EV.sp.Vsym->Sfl == FLgot)
                 goto ret;
 #endif
diff -Naur dmd/src/dmd/backend/cod1.c dmd1/src/dmd/backend/cod1.c
--- dmd/src/dmd/backend/cod1.c	2010-09-14 07:16:00.022282240 +0000
+++ dmd1/src/dmd/backend/cod1.c	2010-09-19 15:25:02.416808960 +0000
@@ -1279,7 +1279,7 @@
     case FLextern:
         if (s->Sident[0] == '_' && memcmp(s->Sident + 1,"tls_array",10) == 0)
         {
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
             // Rewrite as GS:[0000], or FS:[0000] for 64 bit
             if (I64)
             {
@@ -1307,7 +1307,7 @@
     case FLdata:
     case FLudata:
     case FLcsdata:
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     case FLgot:
     case FLgotoff:
     case FLtlsdata:
@@ -1338,7 +1338,7 @@
         {
             pcs->Iflags |= CFcs | CFoff;
         }
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         if (I64 && config.flags3 & CFG3pic &&
             (fl == FLtlsdata || s->ty() & mTYthread))
         {
@@ -1923,12 +1923,12 @@
 {
     //printf("callclib(e = %p, clib = %d, *pretregs = %s, keepmask = %s\n", e, clib, regm_str(*pretregs), regm_str(keepmask));
     //elem_print(e);
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
   static symbol lib[] =
   {
 /* Convert destroyed regs into saved regs       */
 #define Z(desregs)      (~(desregs) & (mBP| mES | ALLREGS))
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
 #define N(name) "_" name
 #else
 #define N(name) name
@@ -2149,7 +2149,7 @@
     {DOUBLEREGS_16,DOUBLEREGS_32,0,INFfloat,1,1},       // _INTDBL@     intdbl
     {mAX,mAX,0,INFfloat,1,1},                           // _DBLUNS@     dbluns
     {DOUBLEREGS_16,DOUBLEREGS_32,0,INFfloat,1,1},       // _UNSDBL@     unsdbl
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     {mDX|mAX,mAX,0,INF32|INFfloat,0,1},                 // _DBLULNG@    dblulng
 #else
     {mDX|mAX,mAX,0,INFfloat,1,1},                       // _DBLULNG@    dblulng
@@ -2162,7 +2162,7 @@
 
     {DOUBLEREGS_16,mDX|mAX,0,INFfloat,1,1},             // _DBLLLNG@
     {DOUBLEREGS_16,DOUBLEREGS_32,0,INFfloat,1,1},       // _LLNGDBL@
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     {DOUBLEREGS_16,mDX|mAX,0,INFfloat,2,2},             // _DBLULLNG@
 #else
     {DOUBLEREGS_16,mDX|mAX,0,INFfloat,1,1},             // _DBLULLNG@
diff -Naur dmd/src/dmd/backend/cod2.c dmd1/src/dmd/backend/cod2.c
--- dmd/src/dmd/backend/cod2.c	2010-09-14 07:16:00.049020928 +0000
+++ dmd1/src/dmd/backend/cod2.c	2010-09-19 15:25:43.999292928 +0000
@@ -151,7 +151,7 @@
 
   ty1 = tybasic(e1->Ety);
   if (tyfloating(ty1))
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         return orth87(e,pretregs);
 #else
         return opdouble(e,pretregs,(e->Eoper == OPadd) ? CLIBdadd
@@ -793,7 +793,7 @@
     unsigned grex = rex << 16;
 
     if (tyfloating(tyml))
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         return orth87(e,pretregs);
 #else
         return opdouble(e,pretregs,(oper == OPmul) ? CLIBdmul : CLIBddiv);
@@ -3761,7 +3761,7 @@
         goto L4;
 
     case FLtlsdata:
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     {
       L5:
         if (I64 && config.flags3 & CFG3pic)
@@ -3853,13 +3853,13 @@
         goto L4;
 
     case FLextern:
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         if (e->EV.sp.Vsym->ty() & mTYthread)
             goto L5;
 #endif
     case FLdata:
     case FLudata:
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     case FLgot:
     case FLgotoff:
 #endif
@@ -4141,7 +4141,7 @@
 
   if (tyfloating(tyml))
   {
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         return post87(e,pretregs);
 #else
         if (config.inline8087)
diff -Naur dmd/src/dmd/backend/cod3.c dmd1/src/dmd/backend/cod3.c
--- dmd/src/dmd/backend/cod3.c	2010-09-14 07:16:00.003145728 +0000
+++ dmd1/src/dmd/backend/cod3.c	2010-09-19 15:26:46.276037632 +0000
@@ -534,7 +534,7 @@
             genjmp(c,JNE,FLblock,list_block(b->Bsucc)); /* JNE default  */
         }
         ce = getregs(mCX|mDI);
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         if (config.flags3 & CFG3pic)
         {   // Add in GOT
             code *cx;
@@ -614,7 +614,7 @@
         mod = (disp > 127) ? 2 : 1;     /* 1 or 2 byte displacement     */
         if (config.flags & CFGromable)
                 gen1(ce,SEGCS);         /* table is in code segment     */
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         if (config.flags3 & CFG3pic)
         {                               // ADD EDX,(ncases-1)*2[EDI]
             ct = genc1(CNIL,0x03,modregrm(mod,DX,7),FLconst,disp);
@@ -1092,7 +1092,7 @@
     gen1(c, 0x58 + reg);                // L1: POP reg
 
     return cat(c,fixresult(e,retregs,pretregs));
-#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     regm_t retregs;
     unsigned reg;
     code *c;
@@ -1125,7 +1125,7 @@
 #endif
 }
 
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
 /*****************************
  * Returns:
  *      # of bytes stored
@@ -1401,7 +1401,7 @@
         if (config.wflags & WFincbp && farfunc)
             c = gen1(c,0x40 + BP);      /* INC  BP                      */
         if (config.target_cpu < TARGET_80286 ||
-            config.exe & (EX_LINUX | EX_LINUX64 | EX_OSX | EX_OSX64 | EX_FREEBSD | EX_FREEBSD64 | EX_SOLARIS | EX_SOLARIS64) ||
+            config.exe & (EX_LINUX | EX_LINUX64 | EX_OSX | EX_OSX64 | EX_FREEBSD | EX_FREEBSD64 | EX_SOLARIS | EX_SOLARIS64 | EX_HAIKU) ||
             !localsize ||
             config.flags & CFGstack ||
             (xlocalsize >= 0x1000 && config.exe & EX_flat) ||
@@ -2077,7 +2077,7 @@
 
 code *cod3_load_got()
 {
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     code *c;
     code *cgot;
 
@@ -2259,7 +2259,7 @@
     sthunk->Soffset = thunkoffset;
     sthunk->Ssize = Coffset - thunkoffset; /* size of thunk */
     sthunk->Sseg = cseg;
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     objpubdef(cseg,sthunk,sthunk->Soffset);
 #endif
     searchfixlist(sthunk);              /* resolve forward refs */
@@ -4251,7 +4251,7 @@
             // un-named external with is the start of .rodata or .data
         case FLextern:                      /* external data symbol         */
         case FLtlsdata:
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         case FLgot:
         case FLgotoff:
 #endif
@@ -4344,7 +4344,7 @@
         // un-named external with is the start of .rodata or .data
     case FLextern:                      /* external data symbol         */
     case FLtlsdata:
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     case FLgot:
     case FLgotoff:
 #endif
@@ -4568,7 +4568,7 @@
                 // resolve directly.
                 if (s->Sseg == p->Lseg &&
                     (s->Sclass == SCstatic ||
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
                      (!(config.flags3 & CFG3pic) && s->Sclass == SCglobal)) &&
 #else
                         s->Sclass == SCglobal) &&
diff -Naur dmd/src/dmd/backend/cod4.c dmd1/src/dmd/backend/cod4.c
--- dmd/src/dmd/backend/cod4.c	2010-09-14 07:16:00.025165824 +0000
+++ dmd1/src/dmd/backend/cod4.c	2010-09-19 15:27:05.449576960 +0000
@@ -749,7 +749,7 @@
   byte = (sz == 1);                     // 1 for byte operation, else 0
   if (tyfloating(tyml))
   {
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
       if (op == OPnegass)
             c = cdnegass87(e,pretregs);
         else
@@ -1192,7 +1192,7 @@
 
 
   if (tyfloating(tyml))
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         return opass87(e,pretregs);
 #else
         return opassdbl(e,pretregs,op);
@@ -1685,7 +1685,7 @@
     unsigned rex = (I64 && sz == 8) ? REX_W : 0;
     unsigned grex = rex << 16;          // 64 bit operands
 
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
   if (tyfloating(tym))                  /* if floating operation        */
   {
         retregs = mPSW;
@@ -2427,7 +2427,7 @@
             case OPd_s64:
                 return cnvt87(e,pretregs);
             case OPd_u32:               // use subroutine, not 8087
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
                 retregs = mST0;
 #else
                 retregs = DOUBLEREGS;
diff -Naur dmd/src/dmd/backend/code.h dmd1/src/dmd/backend/code.h
--- dmd/src/dmd/backend/code.h	2010-09-14 07:16:00.039059456 +0000
+++ dmd1/src/dmd/backend/code.h	2010-09-19 15:27:18.326369280 +0000
@@ -110,7 +110,7 @@
 #define RMload  (1 << 30)
 #define RMstore (1 << 31)
 
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     // To support positional independent code,
     // must be able to remove BX from available registers
 extern regm_t ALLREGS;
@@ -669,7 +669,7 @@
 cd_t cdcomma;
 cd_t cdloglog;
 cd_t cdshift;
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
 cd_t cdindpic;
 #endif
 cd_t cdind;
diff -Naur dmd/src/dmd/backend/debug.c dmd1/src/dmd/backend/debug.c
--- dmd/src/dmd/backend/debug.c	2010-09-14 07:16:00.005767168 +0000
+++ dmd1/src/dmd/backend/debug.c	2010-09-19 15:27:38.099876864 +0000
@@ -101,7 +101,7 @@
     if (t & mTYpasobj)
         dbg_printf("mTYpasobj|");
 #endif
-#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
     if (t & mTYtransu)
         dbg_printf("mTYtransu|");
 #endif
@@ -294,7 +294,7 @@
          "ndp   ","farda ","local ","csdat ","tlsdat",
          "bprel ","frameh","asm   ","blocko","alloca",
          "stack ","dsym  ",
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
          "got   ","gotoff",
 #endif
 #endif
diff -Naur dmd/src/dmd/backend/dwarf.c dmd1/src/dmd/backend/dwarf.c
--- dmd/src/dmd/backend/dwarf.c	2010-09-14 07:16:00.007077888 +0000
+++ dmd1/src/dmd/backend/dwarf.c	2010-09-19 15:28:04.921174016 +0000
@@ -22,7 +22,7 @@
 #include        <malloc.h>
 #endif
 
-#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
 #include        <signal.h>
 #include        <unistd.h>
 #include        <errno.h>
@@ -402,7 +402,7 @@
         linebuf->writeString((char *)list_ptr(pl));
         linebuf->writeByte(0);
     }
-#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
     for (pl = pathsyslist; pl; pl = list_next(pl))
     {
         linebuf->writeString((char *)list_ptr(pl));
diff -Naur dmd/src/dmd/backend/el.c dmd1/src/dmd/backend/el.c
--- dmd/src/dmd/backend/el.c	2010-09-14 07:16:00.015728640 +0000
+++ dmd1/src/dmd/backend/el.c	2010-09-19 15:28:43.187170816 +0000
@@ -1329,7 +1329,7 @@
     return e;
 }
 #endif
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
 
 elem *el_picvar(symbol *s)
 {   elem *e;
@@ -1531,10 +1531,10 @@
 
     //printf("el_var(s = '%s')\n", s->Sident);
     //printf("%x\n", s->Stype->Tty);
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     // OSX is currently always pic
     if (config.flags3 & CFG3pic &&
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         (!(s->Stype->Tty & mTYthread) || I64) &&
 #endif
         !tyfunc(s->ty()))
@@ -1553,7 +1553,7 @@
         //printf("thread local %s\n", s->Sident);
 #if TARGET_OSX
         ;
-#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         /* For 32 bit:
          * Generate for var locals:
          *      MOV reg,GS:[00000000]   // add GS: override in back end
@@ -1658,7 +1658,7 @@
 {   elem *e;
 
     //printf("el_var(s = '%s')\n", s->Sident);
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     if (config.flags3 & CFG3pic && !tyfunc(s->ty()))
         return el_picvar(s);
 #endif
@@ -1755,7 +1755,7 @@
         return e;
     }
 #endif
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     if (config.flags3 & CFG3pic && tyfunc(s->ty()))
         e = el_picvar(s);
     else
diff -Naur dmd/src/dmd/backend/elfobj.c dmd1/src/dmd/backend/elfobj.c
--- dmd/src/dmd/backend/elfobj.c	2010-09-14 07:16:00.040632320 +0000
+++ dmd1/src/dmd/backend/elfobj.c	2010-09-19 15:28:59.817364992 +0000
@@ -1863,7 +1863,7 @@
             }
             break;
         case mTYman_std:
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
             if (tyfunc(s->ty()) && !variadic(s->Stype))
 #else
             if (!(config.flags4 & CFG4oldstdmangle) &&
diff -Naur dmd/src/dmd/backend/evalu8.c dmd1/src/dmd/backend/evalu8.c
--- dmd/src/dmd/backend/evalu8.c	2010-09-14 07:16:00.031981568 +0000
+++ dmd1/src/dmd/backend/evalu8.c	2010-09-19 15:29:18.926416896 +0000
@@ -42,7 +42,7 @@
 
 extern void error(const char *filename, unsigned linnum, const char *format, ...);
 
-#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
 int _status87()
 {
     return fetestexcept(FE_ALL_EXCEPT);
@@ -514,7 +514,7 @@
                 if (e2->Eoper == OPconst)
                 {   targ_int i = e2->EV.Vint;
 
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
                     if (i && e1->EV.sp.Vsym->Sfl == FLgot)
                         break;
 #endif
diff -Naur dmd/src/dmd/backend/global.h dmd1/src/dmd/backend/global.h
--- dmd/src/dmd/backend/global.h	2010-09-14 07:16:00.052428800 +0000
+++ dmd1/src/dmd/backend/global.h	2010-09-19 15:29:26.810549248 +0000
@@ -546,7 +546,7 @@
 void dwarf_CFA_args_size(size_t sz);
 #endif
 
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
 void elfobj_gotref(symbol *s);
 symbol *elfobj_getGOTsym();
 void elfobj_refGOTsym();
diff -Naur dmd/src/dmd/backend/machobj.c dmd1/src/dmd/backend/machobj.c
--- dmd/src/dmd/backend/machobj.c	2010-09-14 07:16:00.008650752 +0000
+++ dmd1/src/dmd/backend/machobj.c	2010-09-19 15:29:53.417333248 +0000
@@ -21,7 +21,7 @@
 #include        <malloc.h>
 #endif
 
-#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
 #include        <signal.h>
 #include        <unistd.h>
 #endif
@@ -1615,7 +1615,7 @@
             strupr(dest);               // to upper case
             break;
         case mTYman_std:
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
             if (tyfunc(s->ty()) && !variadic(s->Stype))
 #else
             if (!(config.flags4 & CFG4oldstdmangle) &&
diff -Naur dmd/src/dmd/backend/nteh.c dmd1/src/dmd/backend/nteh.c
--- dmd/src/dmd/backend/nteh.c	2010-09-14 07:16:00.019922944 +0000
+++ dmd1/src/dmd/backend/nteh.c	2010-09-19 15:30:37.083099648 +0000
@@ -415,7 +415,7 @@
         /* An sindex value of -2 is a magic value that tells the
          * stack unwinder to skip this frame.
          */
-        assert(config.exe & (EX_LINUX | EX_LINUX64 | EX_OSX | EX_OSX64 | EX_FREEBSD | EX_FREEBSD64 | EX_SOLARIS | EX_SOLARIS64));
+        assert(config.exe & (EX_LINUX | EX_LINUX64 | EX_OSX | EX_OSX64 | EX_FREEBSD | EX_FREEBSD64 | EX_SOLARIS | EX_SOLARIS64 | EX_HAIKU));
         cs.Iop = 0x68;
         cs.Iflags = 0;
         cs.Irex = 0;
diff -Naur dmd/src/dmd/backend/optabgen.c dmd1/src/dmd/backend/optabgen.c
--- dmd/src/dmd/backend/optabgen.c	2010-09-14 07:16:00.063700992 +0000
+++ dmd1/src/dmd/backend/optabgen.c	2010-09-19 15:30:57.498860032 +0000
@@ -703,7 +703,7 @@
                 case FLctor:    segfl[i] = -1;  break;
                 case FLdtor:    segfl[i] = -1;  break;
                 case FLdsymbol: segfl[i] = -1;  break;
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
                 case FLgot:     segfl[i] = -1;  break;
                 case FLgotoff:  segfl[i] = -1;  break;
 #endif
diff -Naur dmd/src/dmd/backend/os.c dmd1/src/dmd/backend/os.c
--- dmd/src/dmd/backend/os.c	2010-09-14 07:16:00.039321600 +0000
+++ dmd1/src/dmd/backend/os.c	2010-09-19 15:31:43.780664832 +0000
@@ -26,7 +26,7 @@
 #include <sys\stat.h>
 #endif
 
-#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -658,7 +658,7 @@
     if (!find)
         return 0;
     return (find->attribute & FA_DIREC) ? 2 : 1;
-#elif linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#elif linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
     struct stat buf;
 
     return stat(name,&buf) == 0;        /* file exists if stat succeeded */
@@ -735,7 +735,7 @@
 
 int file_write(char *name, void *buffer, unsigned len)
 {
-#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
     int fd;
     ssize_t numwritten;
 
@@ -811,7 +811,7 @@
 
 int file_createdirs(char *name)
 {
-#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
     return 1;
 #endif
 #if _WIN32
@@ -861,7 +861,7 @@
 }
 #endif
 
-#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
 int os_critsecsize()
 {
     return sizeof(pthread_mutex_t);
diff -Naur dmd/src/dmd/backend/out.c dmd1/src/dmd/backend/out.c
--- dmd/src/dmd/backend/out.c	2010-09-14 07:16:00.046661632 +0000
+++ dmd1/src/dmd/backend/out.c	2010-09-19 15:31:52.633077760 +0000
@@ -408,7 +408,7 @@
                     flags = CFoff | CFseg;
                 if (tybasic(dt->Dty) == TYcptr)
                     reftocodseg(seg,offset,dt->DTabytes);
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
                 else
                     reftodatseg(seg,offset,dt->DTabytes,dt->DTseg,flags);
 #else
diff -Naur dmd/src/dmd/backend/parser.h dmd1/src/dmd/backend/parser.h
--- dmd/src/dmd/backend/parser.h	2010-09-14 07:16:00.043515904 +0000
+++ dmd1/src/dmd/backend/parser.h	2010-09-23 20:53:34.909901824 +0000
@@ -156,7 +156,7 @@
 #define FQtop           8       // top level file, already open
 #define FQqual          0x10    // filename is already qualified
 #endif
-#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
 #define FQnext          0x20    // search starts after directory
 #endif                          // of last included file
 
@@ -698,7 +698,7 @@
 
 extern list_t pathlist;                 // include paths
 extern list_t headers;                  // pre-include files
-#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
 extern list_t pathsyslist;              // include path for .h file overrides
 #endif
 
diff -Naur dmd/src/dmd/backend/strtold.c dmd1/src/dmd/backend/strtold.c
--- dmd/src/dmd/backend/strtold.c	2010-09-14 07:16:00.062390272 +0000
+++ dmd1/src/dmd/backend/strtold.c	2010-09-19 15:32:39.060030976 +0000
@@ -20,7 +20,7 @@
 #if _WIN32
 #include        <fltpnt.h>
 #endif
-#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
 #include        <errno.h>
 #endif
 
@@ -30,7 +30,7 @@
 void __pascal __set_errno (int an_errno);
 #endif
 
-#if _WIN32 || linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if _WIN32 || linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
 
 #if 0
 /* This is for compilers that don't support hex float literals,
diff -Naur dmd/src/dmd/backend/token.h dmd1/src/dmd/backend/token.h
--- dmd/src/dmd/backend/token.h	2010-09-14 07:16:00.044302336 +0000
+++ dmd1/src/dmd/backend/token.h	2010-09-19 15:32:54.867958784 +0000
@@ -179,7 +179,7 @@
         TK_stdcall,
         TK_syscall,
         TK_try,
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         TK_attribute,
         TK_extension,
         TK_format,
@@ -211,7 +211,7 @@
         TKandand,TKshl,TKshr,TKrcur,TKeq,TKaddass,TKminass,TKmulass,TKdivass,
         TKmodass,TKshrass,TKshlass,TKandass,TKxorass,TKorass,TKsemi,
         TKadd,TKellipsis,
-#if !TX86 || TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if !TX86 || TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         TKdollar,
 #endif
 
diff -Naur dmd/src/dmd/backend/ty.h dmd1/src/dmd/backend/ty.h
--- dmd/src/dmd/backend/ty.h	2010-09-14 07:16:00.038535168 +0000
+++ dmd1/src/dmd/backend/ty.h	2010-09-19 15:33:02.589299712 +0000
@@ -304,7 +304,7 @@
 /* Array to give the 'relaxed' type for relaxed type checking   */
 extern unsigned char _tyrelax[];
 #define type_relax      (config.flags3 & CFG3relax)     // !=0 if relaxed type checking
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
 #define type_semirelax  (config.flags3 & CFG3semirelax) // !=0 if semi-relaxed type checking
 #else
 #define type_semirelax  type_relax
diff -Naur dmd/src/dmd/backend/type.h dmd1/src/dmd/backend/type.h
--- dmd/src/dmd/backend/type.h	2010-09-14 07:16:00.019136512 +0000
+++ dmd1/src/dmd/backend/type.h	2010-09-19 15:33:16.247988224 +0000
@@ -54,7 +54,7 @@
     unsigned short Tflags;      // TFxxxxx
 
 #if TX86
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
 #define mTYnoret        0x010000        // function has no return
 #define mTYtransu       0x010000        // transparent union
 #else
@@ -68,7 +68,7 @@
 #define mTYsyscall      0x400000
 #define mTYjava         0x800000
 
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
 #define mTYTFF          0xFE0000
 #else
 #define mTYTFF          0xFF0000
diff -Naur dmd/src/dmd/backend/var.c dmd1/src/dmd/backend/var.c
--- dmd/src/dmd/backend/var.c	2010-09-14 07:16:00.006815744 +0000
+++ dmd1/src/dmd/backend/var.c	2010-09-19 15:33:25.649854976 +0000
@@ -58,7 +58,7 @@
 #if MEMMODELS == 1
 tym_t functypetab[LINK_MAXDIM] =
 {
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     TYnfunc,
     TYnpfunc,
     TYnpfunc,
diff -Naur dmd/src/dmd/cond.c dmd1/src/dmd/cond.c
--- dmd/src/dmd/cond.c	2010-09-14 07:16:00.002097152 +0000
+++ dmd1/src/dmd/cond.c	2010-09-19 15:34:06.023855104 +0000
@@ -138,6 +138,7 @@
 #endif
         "OSX", "FreeBSD",
         "Solaris",
+        "Haiku",
         "LittleEndian", "BigEndian",
         "all",
         "none",
diff -Naur dmd/src/dmd/e2ir.c dmd1/src/dmd/e2ir.c
--- dmd/src/dmd/e2ir.c	2010-09-14 07:16:00.029622272 +0000
+++ dmd1/src/dmd/e2ir.c	2010-09-19 15:34:41.236716032 +0000
@@ -174,7 +174,8 @@
         if ((global.params.isLinux ||
              global.params.isOSX ||
              global.params.isFreeBSD ||
-             global.params.isSolaris) && tf->linkage != LINKd)
+             global.params.isSolaris ||
+             global.params.isHaiku) && tf->linkage != LINKd)
             ;   // ehidden goes last on Linux/OSX C++
         else
         {
@@ -1582,7 +1583,7 @@
         if (global.params.useInvariants && t1->ty == Tclass &&
             !((TypeClass *)t1)->sym->isInterfaceDeclaration())
         {
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
             e = el_bin(OPcall, TYvoid, el_var(rtlsym[RTLSYM__DINVARIANT]), e);
 #else
             e = el_bin(OPcall, TYvoid, el_var(rtlsym[RTLSYM_DINVARIANT]), e);
diff -Naur dmd/src/dmd/eh.c dmd1/src/dmd/eh.c
--- dmd/src/dmd/eh.c	2010-09-14 07:16:00.013631488 +0000
+++ dmd1/src/dmd/eh.c	2010-09-19 15:34:56.559153152 +0000
@@ -26,7 +26,7 @@
 symbol *except_gentables()
 {
     //printf("except_gentables()\n");
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     symbol *s;
     int sz;                     // size so far
     dt_t **pdt;
diff -Naur dmd/src/dmd/expression.c dmd1/src/dmd/expression.c
--- dmd/src/dmd/expression.c	2010-09-14 07:16:00.011534336 +0000
+++ dmd1/src/dmd/expression.c	2010-09-23 20:55:42.509083648 +0000
@@ -1625,6 +1625,8 @@
 {
 #if __APPLE__
     return (__inline_isnan(x1) && __inline_isnan(x2)) ||
+#elif __HAIKU__
+    return (__isnan(x1) && __isnan(x2)) ||
 #else
     return (isnan(x1) && isnan(x2)) ||
 #endif
@@ -1734,6 +1736,8 @@
 
 #if __APPLE__
     if (__inline_isnan(value))
+#elif __HAIKU__
+    if (__isnan(value))
 #else
     if (isnan(value))
 #endif
diff -Naur dmd/src/dmd/glue.c dmd1/src/dmd/glue.c
--- dmd/src/dmd/glue.c	2010-09-14 07:16:00.022806528 +0000
+++ dmd1/src/dmd/glue.c	2010-09-19 15:35:50.215220224 +0000
@@ -610,7 +610,7 @@
         // Pull in RTL startup code
         if (func->isMain())
         {   objextdef("_main");
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
             obj_ehsections();   // initialize exception handling sections
 #endif
 #if TARGET_WINDOS
@@ -770,7 +770,7 @@
         pi++;
     }
 
-    if ((global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isSolaris) &&
+    if ((global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isSolaris || global.params.isHaiku) &&
          linkage != LINKd && shidden && sthis)
     {
         /* swap shidden and sthis
@@ -1015,7 +1015,7 @@
         s->toObjFile(0);
     }
 
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     // A hack to get a pointer to this function put in the .dtors segment
     if (ident && memcmp(ident->toChars(), "_STD", 4) == 0)
         obj_staticdtor(s);
@@ -1061,7 +1061,7 @@
         //case Tbit:    t = TYuchar;    break;
         case Tbool:     t = TYbool;     break;
         case Tchar:     t = TYchar;     break;
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         case Twchar:    t = TYwchar_t;  break;
         case Tdchar:    t = TYdchar;    break;
 #else
@@ -1151,7 +1151,7 @@
 
         case LINKc:
             tyf = TYnfunc;
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
             if (retStyle() == RETstack)
                 tyf = TYhfunc;
 #endif
diff -Naur dmd/src/dmd/haiku.mak dmd1/src/dmd/haiku.mak
--- dmd/src/dmd/haiku.mak	1970-01-01 00:00:00.000000000 +0000
+++ dmd1/src/dmd/haiku.mak	2010-09-19 15:16:23.496762880 +0000
@@ -0,0 +1,599 @@
+
+C=backend
+TK=tk
+ROOT=root
+
+MODEL=-m32
+
+CC=g++ $(MODEL)
+
+#OPT=-g -g3
+#OPT=-O2
+
+#COV=-fprofile-arcs -ftest-coverage
+
+WARNINGS=-Wno-deprecated -Wstrict-aliasing
+
+#GFLAGS = $(WARNINGS) -D__near= -D__pascal= -fno-exceptions -g -DDEBUG=1 $(COV)
+GFLAGS = $(WARNINGS) -D__near= -D__pascal= -fno-exceptions -O2
+
+CFLAGS = $(GFLAGS) -I$(ROOT) -D__I86__=1 -DMARS=1 -DTARGET_HAIKU=1 -D_DH
+MFLAGS = $(GFLAGS) -I$C -I$(TK) -D__I86__=1 -DMARS=1 -DTARGET_HAIKU=1 -D_DH
+
+CH= $C/cc.h $C/global.h $C/parser.h $C/oper.h $C/code.h $C/type.h \
+	$C/dt.h $C/cgcv.h $C/el.h $C/iasm.h
+TOTALH=
+
+DMD_OBJS = \
+	access.o array.o attrib.o bcomplex.o bit.o blockopt.o \
+	cast.o code.o cg.o cg87.o cgcod.o cgcs.o cgelem.o cgen.o \
+	cgreg.o cgsched.o class.o cod1.o cod2.o cod3.o cod4.o cod5.o \
+	constfold.o irstate.o dchar.o cond.o debug.o \
+	declaration.o dsymbol.o dt.o dump.o e2ir.o ee.o eh.o el.o \
+	dwarf.o enum.o evalu8.o expression.o func.o gdag.o gflow.o \
+	glocal.o gloop.o glue.o gnuc.o go.o gother.o html.o iasm.o id.o \
+	identifier.o impcnvtab.o import.o inifile.o init.o inline.o \
+	lexer.o link.o lstring.o mangle.o mars.o rmem.o module.o msc.o mtype.o \
+	nteh.o cppmangle.o opover.o optimize.o os.o out.o outbuf.o \
+	parse.o ph.o ptrntab.o root.o rtlsym.o s2ir.o scope.o statement.o \
+	stringtable.o struct.o csymbol.o template.o tk.o tocsym.o todt.o \
+	type.o typinf.o util.o var.o version.o strtold.o utf.o staticassert.o \
+	unialpha.o toobj.o toctype.o toelfdebug.o entity.o doc.o macro.o \
+	hdrgen.o delegatize.o aa.o ti_achar.o toir.o interpret.o traits.o \
+	builtin.o clone.o aliasthis.o \
+	man.o arrayop.o port.o response.o async.o json.o speller.o aav.o unittests.o \
+	imphint.o \
+	libelf.o elfobj.o
+
+SRC = win32.mak linux.mak osx.mak freebsd.mak solaris.mak haiku.mak \
+	mars.c enum.c struct.c dsymbol.c import.c idgen.c impcnvgen.c \
+	identifier.c mtype.c expression.c optimize.c template.h \
+	template.c lexer.c declaration.c cast.c cond.h cond.c link.c \
+	aggregate.h parse.c statement.c constfold.c version.h version.c \
+	inifile.c iasm.c module.c scope.c dump.c init.h init.c attrib.h \
+	attrib.c opover.c class.c mangle.c bit.c tocsym.c func.c inline.c \
+	access.c complex_t.h irstate.h irstate.c glue.c msc.c ph.c tk.c \
+	s2ir.c todt.c e2ir.c util.c identifier.h parse.h \
+	scope.h enum.h import.h mars.h module.h mtype.h dsymbol.h \
+	declaration.h lexer.h expression.h irstate.h statement.h eh.c \
+	utf.h utf.c staticassert.h staticassert.c unialpha.c \
+	typinf.c toobj.c toctype.c tocvdebug.c toelfdebug.c entity.c \
+	doc.h doc.c macro.h macro.c hdrgen.h hdrgen.c arraytypes.h \
+	delegatize.c toir.h toir.c interpret.c traits.c cppmangle.c \
+	builtin.c clone.c lib.h libomf.c libelf.c libmach.c arrayop.c \
+	aliasthis.h aliasthis.c json.h json.c unittests.c imphint.c \
+	$C/cdef.h $C/cc.h $C/oper.h $C/ty.h $C/optabgen.c \
+	$C/global.h $C/parser.h $C/code.h $C/type.h $C/dt.h $C/cgcv.h \
+	$C/el.h $C/iasm.h $C/rtlsym.h $C/html.h \
+	$C/bcomplex.c $C/blockopt.c $C/cg.c $C/cg87.c \
+	$C/cgcod.c $C/cgcs.c $C/cgcv.c $C/cgelem.c $C/cgen.c $C/cgobj.c \
+	$C/cgreg.c $C/var.c $C/strtold.c \
+	$C/cgsched.c $C/cod1.c $C/cod2.c $C/cod3.c $C/cod4.c $C/cod5.c \
+	$C/code.c $C/symbol.c $C/debug.c $C/dt.c $C/ee.c $C/el.c \
+	$C/evalu8.c $C/go.c $C/gflow.c $C/gdag.c \
+	$C/gother.c $C/glocal.c $C/gloop.c $C/html.c $C/newman.c \
+	$C/nteh.c $C/os.c $C/out.c $C/outbuf.c $C/ptrntab.c $C/rtlsym.c \
+	$C/type.c $C/melf.h $C/mach.h $C/bcomplex.h \
+	$C/cdeflnx.h $C/outbuf.h $C/token.h $C/tassert.h \
+	$C/elfobj.c $C/cv4.h $C/dwarf2.h $C/cpp.h $C/exh.h $C/go.h \
+	$C/dwarf.c $C/dwarf.h $C/aa.h $C/aa.c $C/tinfo.h $C/ti_achar.c \
+	$C/machobj.c \
+	$(TK)/filespec.h $(TK)/mem.h $(TK)/list.h $(TK)/vec.h \
+	$(TK)/filespec.c $(TK)/mem.c $(TK)/vec.c $(TK)/list.c \
+	$(ROOT)/dchar.h $(ROOT)/dchar.c $(ROOT)/lstring.h \
+	$(ROOT)/lstring.c $(ROOT)/root.h $(ROOT)/root.c $(ROOT)/array.c \
+	$(ROOT)/rmem.h $(ROOT)/rmem.c $(ROOT)/port.h $(ROOT)/port.c \
+	$(ROOT)/gnuc.h $(ROOT)/gnuc.c $(ROOT)/man.c \
+	$(ROOT)/stringtable.h $(ROOT)/stringtable.c \
+	$(ROOT)/response.c $(ROOT)/async.h $(ROOT)/async.c \
+	$(ROOT)/aav.h $(ROOT)/aav.c \
+	$(ROOT)/speller.h $(ROOT)/speller.c
+
+
+all: dmd
+
+dmd: $(DMD_OBJS)
+	gcc $(MODEL) -lstdc++ -lroot $(COV) $(DMD_OBJS) -o dmd
+
+clean:
+	rm -f $(DMD_OBJS) dmd optab.o id.o impcnvgen idgen id.c id.h \
+	impcnvtab.c optabgen debtab.c optab.c cdxxx.c elxxx.c fltables.c \
+	tytab.c core \
+	*.cov *.gcda *.gcno
+
+######## optabgen generates some source
+
+optabgen: $C/optabgen.c $C/cc.h $C/oper.h
+	$(CC) $(MFLAGS) $< -o optabgen
+	./optabgen
+
+optabgen_output = debtab.c optab.c cdxxx.c elxxx.c fltables.c tytab.c
+$(optabgen_output) : optabgen
+
+######## idgen generates some source
+
+idgen_output = id.h id.c
+$(idgen_output) : idgen
+
+idgen : idgen.c
+	$(CC) idgen.c -o idgen
+	./idgen
+
+######### impcnvgen generates some source
+
+impcnvtab_output = impcnvtab.c
+$(impcnvtab_output) : impcnvgen
+
+impcnvgen : mtype.h impcnvgen.c
+	$(CC) $(CFLAGS) impcnvgen.c -o impcnvgen
+	./impcnvgen
+
+#########
+
+$(DMD_OBJS) : $(idgen_output) $(optabgen_output) $(impcnvgen_output)
+
+aa.o: $C/aa.h $C/tinfo.h $C/aa.c
+	$(CC) -c $(MFLAGS) -I. $C/aa.c
+
+aav.o: $(ROOT)/aav.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $<
+
+access.o: access.c
+	$(CC) -c $(CFLAGS) $<
+
+aliasthis.o: aliasthis.c
+	$(CC) -c $(CFLAGS) $<
+
+array.o: $(ROOT)/array.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $<
+
+arrayop.o: arrayop.c
+	$(CC) -c $(CFLAGS) $<
+
+async.o: $(ROOT)/async.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $<
+
+attrib.o: attrib.c
+	$(CC) -c $(CFLAGS) $<
+
+bcomplex.o: $C/bcomplex.c
+	$(CC) -c $(MFLAGS) $<
+
+bit.o: expression.h bit.c
+	$(CC) -c -I$(ROOT) $(MFLAGS) bit.c
+
+blockopt.o: $C/blockopt.c
+	$(CC) -c $(MFLAGS) $C/blockopt.c
+
+builtin.o: builtin.c
+	$(CC) -c $(CFLAGS) $<
+
+cast.o: cast.c
+	$(CC) -c $(CFLAGS) $< 
+
+cg.o: fltables.c $C/cg.c
+	$(CC) -c $(MFLAGS) -I. $C/cg.c
+
+cg87.o: $C/cg87.c
+	$(CC) -c $(MFLAGS) $<
+
+cgcod.o: $C/cgcod.c
+	$(CC) -c $(MFLAGS) -I. $<
+
+cgcs.o: $C/cgcs.c
+	$(CC) -c $(MFLAGS) $<
+
+cgcv.o: $C/cgcv.c
+	$(CC) -c $(MFLAGS) $<
+
+cgelem.o: $C/rtlsym.h $C/cgelem.c
+	$(CC) -c $(MFLAGS) -I. $C/cgelem.c
+
+cgen.o: $C/rtlsym.h $C/cgen.c
+	$(CC) -c $(MFLAGS) $C/cgen.c
+
+cgobj.o: $C/cgobj.c
+	$(CC) -c $(MFLAGS) $<
+
+cgreg.o: $C/cgreg.c
+	$(CC) -c $(MFLAGS) $<
+
+cgsched.o: $C/rtlsym.h $C/cgsched.c
+	$(CC) -c $(MFLAGS) $C/cgsched.c
+
+class.o: class.c
+	$(CC) -c $(CFLAGS) $<
+
+clone.o: clone.c
+	$(CC) -c $(CFLAGS) $<
+
+cod1.o: $C/rtlsym.h $C/cod1.c
+	$(CC) -c $(MFLAGS) $C/cod1.c
+
+cod2.o: $C/rtlsym.h $C/cod2.c
+	$(CC) -c $(MFLAGS) $C/cod2.c
+
+cod3.o: $C/rtlsym.h $C/cod3.c
+	$(CC) -c $(MFLAGS) $C/cod3.c
+
+cod4.o: $C/cod4.c
+	$(CC) -c $(MFLAGS) $<
+
+cod5.o: $C/cod5.c
+	$(CC) -c $(MFLAGS) $<
+
+code.o: $C/code.c
+	$(CC) -c $(MFLAGS) $<
+
+constfold.o: constfold.c
+	$(CC) -c $(CFLAGS) $<
+
+irstate.o: irstate.h irstate.c
+	$(CC) -c $(MFLAGS) -I$(ROOT) irstate.c
+
+csymbol.o : $C/symbol.c
+	$(CC) -c $(MFLAGS) $C/symbol.c -o csymbol.o
+
+dchar.o: $(ROOT)/dchar.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $<
+
+cond.o: cond.c
+	$(CC) -c $(CFLAGS) $<
+
+cppmangle.o: cppmangle.c
+	$(CC) -c $(CFLAGS) $<
+
+debug.o: $C/debug.c
+	$(CC) -c $(MFLAGS) -I. $<
+
+declaration.o: declaration.c
+	$(CC) -c $(CFLAGS) $<
+
+delegatize.o: delegatize.c
+	$(CC) -c $(CFLAGS) $<
+
+doc.o: doc.c
+	$(CC) -c $(CFLAGS) $<
+
+dsymbol.o: dsymbol.c
+	$(CC) -c $(CFLAGS) $<
+
+dt.o: $C/dt.h $C/dt.c
+	$(CC) -c $(MFLAGS) $C/dt.c
+
+dump.o: dump.c
+	$(CC) -c $(CFLAGS) $<
+
+dwarf.o: $C/dwarf.h $C/dwarf.c
+	$(CC) -c $(MFLAGS) -I. $C/dwarf.c
+
+e2ir.o: $C/rtlsym.h expression.h toir.h e2ir.c
+	$(CC) -c -I$(ROOT) $(MFLAGS) e2ir.c
+
+ee.o: $C/ee.c
+	$(CC) -c $(MFLAGS) $<
+
+eh.o : $C/cc.h $C/code.h $C/type.h $C/dt.h eh.c
+	$(CC) -c $(MFLAGS) eh.c
+
+el.o: $C/rtlsym.h $C/el.h $C/el.c
+	$(CC) -c $(MFLAGS) $C/el.c
+
+elfobj.o: $C/elfobj.c
+	$(CC) -c $(MFLAGS) $<
+
+entity.o: entity.c
+	$(CC) -c $(CFLAGS) $<
+
+enum.o: enum.c
+	$(CC) -c $(CFLAGS) $<
+
+evalu8.o: $C/evalu8.c
+	$(CC) -c $(MFLAGS) $<
+
+expression.o: expression.c
+	$(CC) -c $(CFLAGS) $<
+
+func.o: func.c
+	$(CC) -c $(CFLAGS) $<
+
+gdag.o: $C/gdag.c
+	$(CC) -c $(MFLAGS) $<
+
+gflow.o: $C/gflow.c
+	$(CC) -c $(MFLAGS) $<
+
+#globals.o: globals.c
+#	$(CC) -c $(CFLAGS) $<
+
+glocal.o: $C/rtlsym.h $C/glocal.c
+	$(CC) -c $(MFLAGS) $C/glocal.c
+
+gloop.o: $C/gloop.c
+	$(CC) -c $(MFLAGS) $<
+
+glue.o: $(CH) $(TOTALH) $C/rtlsym.h mars.h module.h glue.c
+	$(CC) -c $(MFLAGS) -I$(ROOT) glue.c
+
+gnuc.o: $(ROOT)/gnuc.h $(ROOT)/gnuc.c
+	$(CC) -c $(GFLAGS) $(ROOT)/gnuc.c
+
+go.o: $C/go.c
+	$(CC) -c $(MFLAGS) $<
+
+gother.o: $C/gother.c
+	$(CC) -c $(MFLAGS) $<
+
+hdrgen.o: hdrgen.c
+	$(CC) -c $(CFLAGS) $<
+
+html.o: $(CH) $(TOTALH) $C/html.h $C/html.c
+	$(CC) -c -I$(ROOT) $(MFLAGS) $C/html.c
+
+iasm.o : $(CH) $(TOTALH) $C/iasm.h iasm.c
+	$(CC) -c $(MFLAGS) -I$(ROOT) iasm.c
+
+id.o : id.h id.c
+	$(CC) -c $(CFLAGS) id.c
+
+identifier.o: identifier.c
+	$(CC) -c $(CFLAGS) $<
+
+impcnvtab.o: mtype.h impcnvtab.c
+	$(CC) -c $(CFLAGS) -I$(ROOT) impcnvtab.c
+
+imphint.o: imphint.c
+	$(CC) -c $(CFLAGS) $<
+
+import.o: import.c
+	$(CC) -c $(CFLAGS) $<
+
+inifile.o: inifile.c
+	$(CC) -c $(CFLAGS) $<
+
+init.o: init.c
+	$(CC) -c $(CFLAGS) $<
+
+inline.o: inline.c
+	$(CC) -c $(CFLAGS) $<
+
+interpret.o: interpret.c
+	$(CC) -c $(CFLAGS) $<
+
+json.o: json.c
+	$(CC) -c $(CFLAGS) $<
+
+lexer.o: lexer.c
+	$(CC) -c $(CFLAGS) $<
+
+libelf.o: libelf.c $C/melf.h
+	$(CC) -c $(CFLAGS) -I$C $<
+
+libmach.o: libmach.c $C/mach.h
+	$(CC) -c $(CFLAGS) -I$C $<
+
+link.o: link.c
+	$(CC) -c $(CFLAGS) $<
+
+lstring.o: $(ROOT)/lstring.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $<
+
+machobj.o: $C/machobj.c
+	$(CC) -c $(MFLAGS) $<
+
+macro.o: macro.c
+	$(CC) -c $(CFLAGS) $<
+
+man.o: $(ROOT)/man.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $<
+
+mangle.o: mangle.c
+	$(CC) -c $(CFLAGS) $<
+
+mars.o: mars.c
+	$(CC) -c $(CFLAGS) $<
+
+rmem.o: $(ROOT)/rmem.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $(ROOT)/rmem.c
+	
+module.o: $(TOTALH) $C/html.h module.c
+	$(CC) -c $(CFLAGS) -I$C module.c
+
+msc.o: $(CH) mars.h msc.c
+	$(CC) -c $(MFLAGS) msc.c
+
+mtype.o: mtype.c
+	$(CC) -c $(CFLAGS) $<
+
+nteh.o: $C/rtlsym.h $C/nteh.c
+	$(CC) -c $(MFLAGS) $C/nteh.c
+
+opover.o: opover.c
+	$(CC) -c $(CFLAGS) $<
+
+optimize.o: optimize.c
+	$(CC) -c $(CFLAGS) $<
+
+os.o: $C/os.c
+	$(CC) -c $(MFLAGS) $<
+
+out.o: $C/out.c
+	$(CC) -c $(MFLAGS) $<
+
+outbuf.o : $C/outbuf.h $C/outbuf.c
+	$(CC) -c $(MFLAGS) $C/outbuf.c
+
+parse.o: parse.c
+	$(CC) -c $(CFLAGS) $<
+
+ph.o: ph.c
+	$(CC) -c $(MFLAGS) $<
+
+port.o: $(ROOT)/port.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $<
+
+ptrntab.o: $C/iasm.h $C/ptrntab.c
+	$(CC) -c $(MFLAGS) $C/ptrntab.c
+
+response.o: $(ROOT)/response.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $<
+
+root.o: $(ROOT)/root.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $<
+
+rtlsym.o: $C/rtlsym.h $C/rtlsym.c
+	$(CC) -c $(MFLAGS) $C/rtlsym.c
+
+s2ir.o : $C/rtlsym.h statement.h s2ir.c
+	$(CC) -c -I$(ROOT) $(MFLAGS) s2ir.c
+
+scope.o: scope.c
+	$(CC) -c $(CFLAGS) $<
+
+speller.o: $(ROOT)/speller.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $<
+
+statement.o: statement.c
+	$(CC) -c $(CFLAGS) $<
+
+staticassert.o: staticassert.h staticassert.c
+	$(CC) -c $(CFLAGS) staticassert.c
+
+stringtable.o: $(ROOT)/stringtable.c
+	$(CC) -c $(GFLAGS) -I$(ROOT) $<
+
+strtold.o: $C/strtold.c
+	gcc $(MODEL) -c $C/strtold.c
+
+struct.o: struct.c
+	$(CC) -c $(CFLAGS) $<
+
+template.o: template.c
+	$(CC) -c $(CFLAGS) $<
+
+ti_achar.o: $C/tinfo.h $C/ti_achar.c
+	$(CC) -c $(MFLAGS) -I. $C/ti_achar.c
+
+tk.o: tk.c
+	$(CC) -c $(MFLAGS) tk.c
+
+tocsym.o: $(CH) $(TOTALH) mars.h module.h tocsym.c
+	$(CC) -c $(MFLAGS) -I$(ROOT) tocsym.c
+
+toctype.o: $(CH) $(TOTALH) $C/rtlsym.h mars.h module.h toctype.c
+	$(CC) -c $(MFLAGS) -I$(ROOT) toctype.c
+
+todt.o : mtype.h expression.h $C/dt.h todt.c
+	$(CC) -c -I$(ROOT) $(MFLAGS) todt.c
+
+toelfdebug.o: $(CH) $(TOTALH) mars.h toelfdebug.c
+	$(CC) -c $(MFLAGS) -I$(ROOT) toelfdebug.c
+
+toir.o: $C/rtlsym.h expression.h toir.h toir.c
+	$(CC) -c -I$(ROOT) $(MFLAGS) toir.c
+
+toobj.o: $(CH) $(TOTALH) mars.h module.h toobj.c
+	$(CC) -c $(MFLAGS) -I$(ROOT) toobj.c
+
+traits.o: $(TOTALH) traits.c
+	$(CC) -c $(CFLAGS) $<
+
+type.o: $C/type.c
+	$(CC) -c $(MFLAGS) $C/type.c
+
+typinf.o: $(CH) $(TOTALH) mars.h module.h mtype.h typinf.c
+	$(CC) -c $(MFLAGS) -I$(ROOT) typinf.c
+
+util.o: util.c
+	$(CC) -c $(MFLAGS) $<
+
+utf.o: utf.h utf.c
+	$(CC) -c $(CFLAGS) utf.c
+
+unialpha.o: unialpha.c
+	$(CC) -c $(CFLAGS) $<
+
+unittests.o: unittests.c
+	$(CC) -c $(CFLAGS) $<
+
+var.o: $C/var.c optab.c
+	$(CC) -c $(MFLAGS) -I. $C/var.c
+
+version.o: version.c
+	$(CC) -c $(CFLAGS) $<
+
+######################################################
+
+gcov:
+	gcov access.c
+	gcov aliasthis.c
+	gcov arrayop.c
+	gcov attrib.c
+	gcov bit.c
+	gcov builtin.c
+	gcov cast.c
+	gcov class.c
+	gcov clone.c
+	gcov cond.c
+	gcov constfold.c
+	gcov declaration.c
+	gcov delegatize.c
+	gcov doc.c
+	gcov dsymbol.c
+	gcov dump.c
+	gcov e2ir.c
+	gcov eh.c
+	gcov entity.c
+	gcov enum.c
+	gcov expression.c
+	gcov func.c
+	gcov glue.c
+	gcov iasm.c
+	gcov identifier.c
+	gcov imphint.c
+	gcov import.c
+	gcov inifile.c
+	gcov init.c
+	gcov inline.c
+	gcov interpret.c
+	gcov irstate.c
+	gcov json.c
+	gcov lexer.c
+	gcov libelf.c
+	gcov link.c
+	gcov macro.c
+	gcov mangle.c
+	gcov mars.c
+	gcov module.c
+	gcov msc.c
+	gcov mtype.c
+	gcov opover.c
+	gcov optimize.c
+	gcov parse.c
+	gcov ph.c
+	gcov scope.c
+	gcov statement.c
+	gcov staticassert.c
+	gcov s2ir.c
+	gcov struct.c
+	gcov template.c
+	gcov tk.c
+	gcov tocsym.c
+	gcov todt.c
+	gcov toobj.c
+	gcov toctype.c
+	gcov toelfdebug.c
+	gcov typinf.c
+	gcov unialpha.c
+	gcov utf.c
+	gcov util.c
+	gcov version.c
+
+#	gcov hdrgen.c
+#	gcov tocvdebug.c
+
+######################################################
+
+zip:
+	-rm -f dmdsrc.zip
+	zip dmdsrc $(SRC)
diff -Naur dmd/src/dmd/inifile.c dmd1/src/dmd/inifile.c
--- dmd/src/dmd/inifile.c	2010-09-14 07:16:00.055312384 +0000
+++ dmd1/src/dmd/inifile.c	2010-09-19 15:37:02.201064448 +0000
@@ -111,8 +111,8 @@
                 filename = (char *)FileName::replaceName(argv0, inifile);
                 if (!FileName::exists(filename))
                 {
-#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
-#if __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun&&__SVR4   // This fix by Thomas Kuehne
+#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
+#if __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__ // This fix by Thomas Kuehne
                     /* argv0 might be a symbolic link,
                      * so try again looking past it to the real path
                      */
diff -Naur dmd/src/dmd/link.c dmd1/src/dmd/link.c
--- dmd/src/dmd/link.c	2010-09-14 07:16:00.028835840 +0000
+++ dmd1/src/dmd/link.c	2010-09-26 22:44:20.477626368 +0000
@@ -19,7 +19,7 @@
 #include        <process.h>
 #endif
 
-#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
 #include        <sys/types.h>
 #include        <sys/wait.h>
 #include        <unistd.h>
@@ -198,7 +198,7 @@
         delete lnkfilename;
     }
     return status;
-#elif linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#elif linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
     pid_t childpid;
     int i;
     int status;
@@ -348,8 +348,12 @@
     argv.push((void *)buf);             // turns into /usr/lib/libphobos2.a
 
 //    argv.push((void *)"-ldruntime");
-    argv.push((void *)"-lpthread");
-    argv.push((void *)"-lm");
+    #if __HAIKU__
+      argv.push((void *)"-lroot");
+    #else
+      argv.push((void *)"-lpthread");
+      argv.push((void *)"-lm");
+    #endif
 
     if (!global.params.quiet || global.params.verbose)
     {
@@ -486,7 +490,7 @@
     //printf("spawning '%s'\n",file);
 #if _WIN32
     return spawnl(0,file,file,args,NULL);
-#elif linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#elif linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
     char *full;
     int cmdl = strlen(cmd);
 
@@ -549,7 +553,7 @@
     else
         ex = global.params.exefile;
     return spawnv(0,ex,(char **)argv.data);
-#elif linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#elif linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
     pid_t childpid;
     int status;
 
diff -Naur dmd/src/dmd/mangle.c dmd1/src/dmd/mangle.c
--- dmd/src/dmd/mangle.c	2010-09-14 07:16:00.008126464 +0000
+++ dmd1/src/dmd/mangle.c	2010-09-19 15:39:32.027525120 +0000
@@ -24,7 +24,7 @@
 #include "id.h"
 #include "module.h"
 
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
 char *cpp_mangle(Dsymbol *s);
 #endif
 
@@ -119,7 +119,7 @@
                     return ident->toChars();
 
                 case LINKcpp:
-#if DMDV2 && (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS)
+#if DMDV2 && (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU)
                     return cpp_mangle(this);
 #else
                     // Windows C++ mangling is done by C++ back end
diff -Naur dmd/src/dmd/mars.c dmd1/src/dmd/mars.c
--- dmd/src/dmd/mars.c	2010-09-14 07:16:00.036700160 +0000
+++ dmd1/src/dmd/mars.c	2010-09-26 21:50:22.656932864 +0000
@@ -14,7 +14,7 @@
 #include <assert.h>
 #include <limits.h>
 
-#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
 #include <errno.h>
 #endif
 
@@ -59,7 +59,7 @@
 
 #if TARGET_WINDOS
     obj_ext  = "obj";
-#elif TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#elif TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     obj_ext  = "o";
 #elif TARGET_NET
 #else
@@ -68,7 +68,7 @@
 
 #if TARGET_WINDOS
     lib_ext  = "lib";
-#elif TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#elif TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     lib_ext  = "a";
 #elif TARGET_NET
 #else
@@ -77,7 +77,7 @@
 
 #if TARGET_WINDOS
     dll_ext  = "dll";
-#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     dll_ext  = "so";
 #elif TARGET_OSX
     dll_ext = "dylib";
@@ -354,7 +354,7 @@
 
 #if TARGET_WINDOS
     global.params.defaultlibname = "phobos";
-#elif TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#elif TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
     global.params.defaultlibname = "phobos";
 #elif TARGET_NET
 #else
@@ -375,6 +375,10 @@
     VersionCondition::addPredefinedGlobalIdent("Posix");
     VersionCondition::addPredefinedGlobalIdent("linux");
     global.params.isLinux = 1;
+#elif TARGET_HAIKU
+    VersionCondition::addPredefinedGlobalIdent("Posix");
+    VersionCondition::addPredefinedGlobalIdent("Haiku");
+    global.params.isHaiku = 1;
 #elif TARGET_OSX
     VersionCondition::addPredefinedGlobalIdent("Posix");
     VersionCondition::addPredefinedGlobalIdent("OSX");
@@ -403,7 +407,7 @@
 
 #if _WIN32
     inifilename = inifile(argv[0], "sc.ini");
-#elif linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#elif linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
     inifilename = inifile(argv[0], "dmd.conf");
 #else
 #error "fix this"
@@ -428,7 +432,7 @@
                 global.params.link = 0;
             else if (strcmp(p + 1, "cov") == 0)
                 global.params.cov = 1;
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
             else if (strcmp(p + 1, "fPIC") == 0)
                 global.params.pic = 1;
 #endif
diff -Naur dmd/src/dmd/mars.h dmd1/src/dmd/mars.h
--- dmd/src/dmd/mars.h	2010-09-14 07:16:00.038273024 +0000
+++ dmd1/src/dmd/mars.h	2010-09-19 15:53:13.589824000 +0000
@@ -86,7 +86,7 @@
 #define MODULEINFO_IS_STRUCT DMDV2   // if ModuleInfo is a struct rather than a class
 
 // Set if C++ mangling is done by the front end
-#define CPP_MANGLE (DMDV2 && (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS))
+#define CPP_MANGLE (DMDV2 && (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU))
 
 /* Other targets are TARGET_LINUX, TARGET_OSX, TARGET_FREEBSD and
  * TARGET_SOLARIS, which are
@@ -98,7 +98,7 @@
 #define OMFOBJ 1
 #endif
 
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
 #ifndef ELFOBJ
 #define ELFOBJ 1
 #endif
@@ -133,6 +133,7 @@
     char cpu;           // target CPU
     char isX86_64;      // generate X86_64 bit code
     char isLinux;       // generate code for linux
+    char isHaiku;       // generate code for Haiku
     char isOSX;         // generate code for Mac OSX
     char isWindows;     // generate code for Windows
     char isFreeBSD;     // generate code for FreeBSD
diff -Naur dmd/src/dmd/msc.c dmd1/src/dmd/msc.c
--- dmd/src/dmd/msc.c	2010-09-14 07:16:00.040632320 +0000
+++ dmd1/src/dmd/msc.c	2010-09-19 15:54:02.013107200 +0000
@@ -81,6 +81,13 @@
     if (params->pic)
         config.flags3 |= CFG3pic;
 #endif
+#if TARGET_HAIKU
+    config.exe = EX_HAIKU;
+    config.flags |= CFGnoebp;
+    config.flags |= CFGalwaysframe;
+    if (params->pic)
+        config.flags3 |= CFG3pic;
+#endif
 #if TARGET_OSX
     if (params->isX86_64)
         config.exe = EX_OSX64;
diff -Naur dmd/src/dmd/mtype.c dmd1/src/dmd/mtype.c
--- dmd/src/dmd/mtype.c	2010-09-14 07:16:00.028049408 +0000
+++ dmd1/src/dmd/mtype.c	2010-09-19 15:54:47.708050944 +0000
@@ -71,7 +71,7 @@
 int REALSIZE = 16;
 int REALPAD = 6;
 int REALALIGNSIZE = 16;
-#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
 int REALSIZE = 12;
 int REALPAD = 2;
 int REALALIGNSIZE = 4;
@@ -236,7 +236,7 @@
     if (global.params.isX86_64)
     {
         PTRSIZE = 8;
-        if (global.params.isLinux || global.params.isFreeBSD || global.params.isSolaris)
+        if (global.params.isLinux || global.params.isFreeBSD || global.params.isSolaris || global.params.isHaiku)
         {
             REALSIZE = 16;
             REALPAD = 6;
@@ -251,7 +251,7 @@
 #if TARGET_OSX
         REALSIZE = 16;
         REALPAD = 6;
-#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         REALSIZE = 12;
         REALPAD = 2;
 #else
@@ -1077,7 +1077,7 @@
             sz = REALALIGNSIZE;
             break;
 
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         case Tint64:
         case Tuns64:
         case Tfloat64:
diff -Naur dmd/src/dmd/root/man.c dmd1/src/dmd/root/man.c
--- dmd/src/dmd/root/man.c	2010-09-14 07:16:00.030408704 +0000
+++ dmd1/src/dmd/root/man.c	2010-09-19 15:55:15.172228608 +0000
@@ -26,7 +26,7 @@
 
 #endif
 
-#if linux || __FreeBSD__ || __sun&&__SVR4
+#if linux || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
 
 #include        <sys/types.h>
 #include        <sys/wait.h>
diff -Naur dmd/src/dmd/root/port.c dmd1/src/dmd/root/port.c
--- dmd/src/dmd/root/port.c	2010-09-14 07:16:00.046661632 +0000
+++ dmd1/src/dmd/root/port.c	2010-09-23 21:00:14.377487360 +0000
@@ -315,7 +315,7 @@
 
 #endif
 
-#if linux || __APPLE__ || __FreeBSD__
+#if linux || __APPLE__ || __FreeBSD__ || __HAIKU__
 
 #include <math.h>
 #if linux
@@ -373,6 +373,8 @@
 {
 #if __APPLE__
     return __inline_isnan(r);
+#elif __HAIKU__
+    return ::__isnan(r);
 #else
     return ::isnan(r);
 #endif
@@ -382,6 +384,8 @@
 {
 #if __APPLE__
     return __inline_isnan(r);
+#elif __HAIKU__
+    return ::__isnan(r);
 #else
     return ::isnan(r);
 #endif
@@ -414,6 +418,8 @@
 {
 #if __APPLE__
     return fpclassify(r) == FP_INFINITE;
+#elif __HAIKU__
+    return ::__isinf(r);
 #else
     return ::isinf(r);
 #endif
diff -Naur dmd/src/dmd/root/response.c dmd1/src/dmd/root/response.c
--- dmd/src/dmd/root/response.c	2010-09-14 07:16:00.022282240 +0000
+++ dmd1/src/dmd/root/response.c	2010-09-19 15:56:08.390332416 +0000
@@ -19,7 +19,7 @@
 #include <io.h>
 #endif
 
-#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <fcntl.h>
diff -Naur dmd/src/dmd/root/rmem.c dmd1/src/dmd/root/rmem.c
--- dmd/src/dmd/root/rmem.c	2010-09-14 07:16:00.052690944 +0000
+++ dmd1/src/dmd/root/rmem.c	2010-09-19 15:56:26.385875968 +0000
@@ -6,7 +6,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
 #include "../root/rmem.h"
 #else
 #include "rmem.h"
diff -Naur dmd/src/dmd/root/root.c dmd1/src/dmd/root/root.c
--- dmd/src/dmd/root/root.c	2010-09-14 07:16:00.025427968 +0000
+++ dmd1/src/dmd/root/root.c	2010-09-19 15:56:47.602931200 +0000
@@ -7,7 +7,7 @@
 // in artistic.txt, or the GNU General Public License in gnu.txt.
 // See the included readme.txt for details.
 
-#define POSIX (linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4)
+#define POSIX (linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__)
 
 #include <stdio.h>
 #include <stdlib.h>
diff -Naur dmd/src/dmd/tk/filespec.c dmd1/src/dmd/tk/filespec.c
--- dmd/src/dmd/tk/filespec.c	2010-09-14 07:16:00.017301504 +0000
+++ dmd1/src/dmd/tk/filespec.c	2010-09-19 15:57:58.566755328 +0000
@@ -25,7 +25,7 @@
 #include        <ctype.h>
 #endif
 
-#if M_UNIX || M_XENIX || linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if M_UNIX || M_XENIX || linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
 #include        <stdlib.h>
 #include        <unistd.h>
 #endif
@@ -87,7 +87,7 @@
 /**********************/
 char * filespecrootpath(char *filespec)
 {
-#if SUN || M_UNIX || M_XENIX || linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if SUN || M_UNIX || M_XENIX || linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
 #define DIRCHAR '/'
 #endif
 #if MSDOS || __OS2__ || __NT__ || _WIN32
@@ -112,7 +112,7 @@
 #endif
 
     /* get current working directory path */
-#if SUN || M_UNIX || M_XENIX || linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if SUN || M_UNIX || M_XENIX || linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
     cwd_t = (char *)getcwd(NULL, 256);
 #endif
 #if MSDOS || __OS2__ || __NT__ || _WIN32
@@ -133,7 +133,7 @@
     if (cwd[strlen(cwd) - 1] == DIRCHAR)
         cwd[strlen(cwd) - 1] = '\0';
 #endif
-#if SUN || M_UNIX || M_XENIX || linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if SUN || M_UNIX || M_XENIX || linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
     free(cwd_t);
 #endif
     p = filespec;
@@ -150,7 +150,7 @@
             {
                 cwd_t = cwd;
                 cwd = (char *)mem_calloc(strlen(cwd_t) + 1 + strlen(p) + 1);
-#if SUN || M_UNIX || M_XENIX || linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if SUN || M_UNIX || M_XENIX || linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
                 sprintf(cwd, "%s/%s", cwd_t, p);  /* add relative directory */
 #endif
 #if MSDOS || __OS2__ || __NT__ || _WIN32
@@ -171,7 +171,7 @@
         {   /* ... save remaining string */
             cwd_t = cwd;
             cwd = (char *)mem_calloc(strlen(cwd_t) + 1 + strlen(p) + 1);
-#if SUN || M_UNIX || M_XENIX || linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if SUN || M_UNIX || M_XENIX || linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
             sprintf(cwd, "%s/%s", cwd_t, p);  /* add relative directory */
 #endif
 #if MSDOS || __OS2__ || __NT__ || _WIN32
@@ -402,7 +402,7 @@
 #if MSDOS || __OS2__ || __NT__ || _WIN32
     return filespecforceext(filespec,"BAK");
 #endif
-#if BSDUNIX || linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if BSDUNIX || linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
     char *p,*f;
 
     /* Prepend .B to file name, if it isn't already there       */
diff -Naur dmd/src/dmd/tk/mem.c dmd1/src/dmd/tk/mem.c
--- dmd/src/dmd/tk/mem.c	2010-09-14 07:16:00.064225280 +0000
+++ dmd1/src/dmd/tk/mem.c	2010-09-19 15:58:19.705691648 +0000
@@ -296,7 +296,7 @@
         11111,
         0,
         BEFOREVAL,
-#if !(linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4)
+#if !(linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__)
         AFTERVAL
 #endif
 };
@@ -804,7 +804,7 @@
                 mem_numalloc = 0;
                 mem_maxalloc = 0;
                 mem_alloclist.Mnext = NULL;
-#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
                 *(long *) &(mem_alloclist.data[0]) = AFTERVAL;
 #endif
 #endif
diff -Naur dmd/src/dmd/toir.c dmd1/src/dmd/toir.c
--- dmd/src/dmd/toir.c	2010-09-14 07:16:00.028835840 +0000
+++ dmd1/src/dmd/toir.c	2010-09-19 15:58:55.091226112 +0000
@@ -676,7 +676,7 @@
         }
         return RETstack;
     }
-    else if ((global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isSolaris) &&
+    else if ((global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isSolaris || global.params.isHaiku) &&
              linkage == LINKc &&
              tn->iscomplex())
     {
diff -Naur dmd/src/dmd/util.c dmd1/src/dmd/util.c
--- dmd/src/dmd/util.c	2010-09-14 07:16:00.055312384 +0000
+++ dmd1/src/dmd/util.c	2010-09-19 15:59:11.752877568 +0000
@@ -131,7 +131,7 @@
 
 #endif
 
-#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
+#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __HAIKU__
 void util_progress()
 {
 }
diff -Naur dmd/src/phobos/etc/c/zlib/haiku.mak dmd1/src/phobos/etc/c/zlib/haiku.mak
--- dmd/src/phobos/etc/c/zlib/haiku.mak	1970-01-01 00:00:00.000000000 +0000
+++ dmd1/src/phobos/etc/c/zlib/haiku.mak	2010-09-14 07:16:06.000000000 +0000
@@ -0,0 +1,79 @@
+# Makefile for zlib
+
+MODEL=32
+CC=gcc
+LD=link
+CFLAGS=-O -m$(MODEL)
+LDFLAGS=
+O=.o
+
+.c.o:
+	$(CC) -c $(CFLAGS) $*
+
+.d.o:
+	$(DMD) -c $(DFLAGS) $*
+
+# variables
+OBJS = adler32$(O) compress$(O) crc32$(O) gzio$(O) uncompr$(O) deflate$(O) \
+       trees$(O) zutil$(O) inflate$(O) infback$(O) inftrees$(O) inffast$(O)
+
+all:  zlib.a example minigzip
+
+adler32.o: adler32.c zlib.h zconf.h
+	$(CC) -c $(cvarsdll) $(CFLAGS) $*.c
+
+compress.o: compress.c zlib.h zconf.h
+	$(CC) -c $(cvarsdll) $(CFLAGS) $*.c
+
+crc32.o: crc32.c zlib.h zconf.h
+	$(CC) -c $(cvarsdll) $(CFLAGS) $*.c
+
+deflate.o: deflate.c deflate.h zutil.h zlib.h zconf.h
+	$(CC) -c $(cvarsdll) $(CFLAGS) $*.c
+
+gzio.o: gzio.c zutil.h zlib.h zconf.h
+	$(CC) -c $(cvarsdll) $(CFLAGS) $*.c
+
+infback.o: infback.c zlib.h zconf.h inftrees.h inflate.h inffast.h
+	$(CC) -c $(cvarsdll) $(CFLAGS) $*.c
+
+inflate.o: inflate.c zlib.h zconf.h inftrees.h inflate.h inffast.h
+	$(CC) -c $(cvarsdll) $(CFLAGS) $*.c
+
+inftrees.o: inftrees.c zlib.h zconf.h inftrees.h
+	$(CC) -c $(cvarsdll) $(CFLAGS) $*.c
+
+inffast.o: inffast.c zlib.h zconf.h inftrees.h inflate.h inffast.h
+	$(CC) -c $(cvarsdll) $(CFLAGS) $*.c
+
+trees.o: trees.c deflate.h zutil.h zlib.h zconf.h trees.h
+	$(CC) -c $(cvarsdll) $(CFLAGS) $*.c
+
+uncompr.o: uncompr.c zlib.h zconf.h
+	$(CC) -c $(cvarsdll) $(CFLAGS) $*.c
+
+zutil.o: zutil.c zutil.h zlib.h zconf.h
+	$(CC) -c $(cvarsdll) $(CFLAGS) $*.c
+
+example.o: example.c zlib.h zconf.h
+	$(CC) -c $(cvarsdll) $(CFLAGS) $*.c
+
+minigzip.o: minigzip.c zlib.h zconf.h
+	$(CC) -c $(cvarsdll) $(CFLAGS) $*.c
+
+zlib.a: $(OBJS)
+	ar -r $@ $(OBJS)
+
+example: example.o zlib.a
+	$(CC) $(CFLAGS) -o $@ example.o zlib.a -g
+
+minigzip: minigzip.o zlib.a
+	$(CC) $(CFLAGS) -o $@ minigzip.o zlib.a -g
+
+test: example minigzip
+	./example
+	echo hello world | minigzip | minigzip -d
+
+clean:
+	$(RM) $(OBJS) zlib.a example.o example minigzip minigzip.o test foo.gz
+
diff -Naur dmd/src/phobos/haiku.mak dmd1/src/phobos/haiku.mak
--- dmd/src/phobos/haiku.mak	1970-01-01 00:00:00.000000000 +0000
+++ dmd1/src/phobos/haiku.mak	2010-09-23 21:08:26.131858432 +0000
@@ -0,0 +1,650 @@
+# Makefile to build Haiku D runtime library libphobos.a.
+# Targets:
+#	make
+#		Same as make unittest
+#	make libphobos.a
+#		Build libphobos.a
+#	make clean
+#		Delete unneeded files created by build process
+#	make unittest
+#		Build libphobos.a, build and run unit tests
+
+LIB=libphobos.a
+
+MAKEFILE=haiku.mak
+MODEL=32
+
+CFLAGS=-O -m$(MODEL)
+#CFLAGS=-g -m$(MODEL)
+
+DFLAGS=-O -release -w -m$(MODEL)
+#DFLAGS=-unittest -w -m$(MODEL)
+
+CC=gcc
+#DMD=/dmd/bin/dmd
+DMD=dmd
+
+.SUFFIXES: .c .o .cpp .d .asm
+
+.c.o:
+	$(CC) -c $(CFLAGS) $*.c
+
+.cpp.o:
+	g++ -c $(CFLAGS) $*.cpp
+
+.d.o:
+	$(DMD) -c $(DFLAGS) $*.d
+
+.asm.o:
+	$(CC) -c $*.asm
+
+targets : $(LIB)
+
+test.o : test.d
+	$(DMD) -c test -g
+
+test : test.o $(LIB)
+	$(CC) -o $@ test.o $(LIB) -lroot
+
+OBJS = complex.o gcstats.o \
+	critical.o object.o monitor.o \
+	linux.o linuxsocket.o \
+	posix.o posixsocket.o posixpthread.o \
+	Dcrc32.o errno.o \
+	std_c_stdarg.o \
+	Czlib.o \
+	pthread.o
+
+ALLMAKEFILES= \
+	win32.mak linux.mak osx.mak freebsd.mak solaris.mak haiku.mak
+
+ZLIB_OBJS = etc/c/zlib/adler32.o etc/c/zlib/compress.o \
+	etc/c/zlib/crc32.o etc/c/zlib/gzio.o \
+	etc/c/zlib/uncompr.o etc/c/zlib/deflate.o \
+	etc/c/zlib/trees.o etc/c/zlib/zutil.o \
+	etc/c/zlib/inflate.o etc/c/zlib/infback.o \
+	etc/c/zlib/inftrees.o etc/c/zlib/inffast.o
+
+GC_OBJS= internal/gc/gc.o internal/gc/gcold.o internal/gc/gcx.o \
+	internal/gc/gcbits.o internal/gc/gclinux.o
+
+SRC=	errno.c object.d unittest.d crc32.d gcstats.d
+
+SRC_STD= std/zlib.d std/zip.d std/stdint.d std/conv.d std/utf.d std/uri.d \
+	std/math.d std/string.d std/path.d std/date.d \
+	std/ctype.d std/file.d std/compiler.d std/system.d std/moduleinit.d \
+	std/outbuffer.d std/math2.d std/thread.d std/md5.d std/base64.d \
+	std/asserterror.d std/dateparse.d std/outofmemory.d std/mmfile.d \
+	std/intrinsic.d std/array.d std/switcherr.d std/syserror.d \
+	std/regexp.d std/random.d std/stream.d std/process.d \
+	std/socket.d std/socketstream.d std/loader.d std/stdarg.d \
+	std/stdio.d std/format.d std/perf.d std/openrj.d std/uni.d \
+	std/boxer.d std/cstream.d std/demangle.d std/cover.d std/bitarray.d \
+	std/signals.d std/cpuid.d std/typetuple.d std/traits.d std/bind.d \
+	std/metastrings.d
+
+SRC_STD_C= std/c/process.d std/c/stdlib.d std/c/time.d std/c/stdio.d \
+	std/c/math.d std/c/stdarg.d std/c/stddef.d std/c/fenv.d std/c/string.d \
+	std/d/locale.d
+
+SRC_TI=	\
+	std/typeinfo/ti_wchar.d std/typeinfo/ti_uint.d \
+	std/typeinfo/ti_short.d std/typeinfo/ti_ushort.d \
+	std/typeinfo/ti_byte.d std/typeinfo/ti_ubyte.d \
+	std/typeinfo/ti_long.d std/typeinfo/ti_ulong.d \
+	std/typeinfo/ti_ptr.d \
+	std/typeinfo/ti_float.d std/typeinfo/ti_double.d \
+	std/typeinfo/ti_real.d std/typeinfo/ti_delegate.d \
+	std/typeinfo/ti_creal.d std/typeinfo/ti_ireal.d \
+	std/typeinfo/ti_cfloat.d std/typeinfo/ti_ifloat.d \
+	std/typeinfo/ti_cdouble.d std/typeinfo/ti_idouble.d \
+	std/typeinfo/ti_Ashort.d \
+	std/typeinfo/ti_Ag.d \
+	std/typeinfo/ti_AC.d std/typeinfo/ti_C.d \
+	std/typeinfo/ti_int.d std/typeinfo/ti_char.d \
+	std/typeinfo/ti_dchar.d \
+	std/typeinfo/ti_Aint.d \
+	std/typeinfo/ti_Along.d \
+	std/typeinfo/ti_Afloat.d std/typeinfo/ti_Adouble.d \
+	std/typeinfo/ti_Areal.d \
+	std/typeinfo/ti_Acfloat.d std/typeinfo/ti_Acdouble.d \
+	std/typeinfo/ti_Acreal.d \
+	std/typeinfo/ti_void.d
+
+SRC_INTC=	\
+	internal/complex.c internal/critical.c \
+	internal/minit.asm internal/deh.c \
+	internal/monitor.c \
+	internal/mars.h
+
+
+SRC_INT=	\
+	internal/switch.d \
+	internal/alloca.d internal/llmath.d \
+	internal/arraycat.d internal/invariant.d \
+	internal/memset.d internal/arraycast.d internal/aaA.d internal/adi.d \
+	internal/dmain2.d internal/cast.d internal/qsort.d internal/deh2.d \
+	internal/cmath2.d internal/obj.d internal/aApply.d \
+	internal/aApplyR.d internal/object.d internal/trace.d internal/qsort2.d
+
+SRC_STD_WIN= std/windows/registry.d \
+	std/windows/iunknown.d std/windows/charset.d
+
+SRC_STD_C_WIN= std/c/windows/windows.d std/c/windows/com.d \
+	std/c/windows/winsock.d std/c/windows/stat.d
+
+SRC_STD_C_LINUX= std/c/linux/linux.d std/c/linux/linuxextern.d \
+	std/c/linux/socket.d std/c/linux/pthread.d
+
+SRC_STD_C_OSX= std/c/osx/osx.d
+
+SRC_STD_C_FREEBSD= std/c/freebsd/freebsd.d \
+	std/c/freebsd/socket.d std/c/freebsd/pthread.d \
+	std/c/freebsd/math.d
+
+SRC_STD_C_SOLARIS= std/c/solaris/solaris.d \
+       std/c/solaris/socket.d std/c/solaris/pthread.d
+
+SRC_STD_C_POSIX= std/c/posix/posix.d \
+	std/c/posix/socket.d std/c/posix/pthread.d
+
+SRC_ETC=  etc/gamma.d
+
+SRC_ETC_C= etc/c/zlib.d
+
+SRC_ZLIB= etc/c/zlib/trees.h \
+	etc/c/zlib/inffixed.h \
+	etc/c/zlib/inffast.h \
+	etc/c/zlib/crc32.h \
+	etc/c/zlib/algorithm.txt \
+	etc/c/zlib/uncompr.c \
+	etc/c/zlib/compress.c \
+	etc/c/zlib/deflate.h \
+	etc/c/zlib/inftrees.h \
+	etc/c/zlib/infback.c \
+	etc/c/zlib/zutil.c \
+	etc/c/zlib/crc32.c \
+	etc/c/zlib/inflate.h \
+	etc/c/zlib/example.c \
+	etc/c/zlib/inffast.c \
+	etc/c/zlib/trees.c \
+	etc/c/zlib/inflate.c \
+	etc/c/zlib/gzio.c \
+	etc/c/zlib/zconf.h \
+	etc/c/zlib/zconf.in.h \
+	etc/c/zlib/minigzip.c \
+	etc/c/zlib/deflate.c \
+	etc/c/zlib/inftrees.c \
+	etc/c/zlib/zutil.h \
+	etc/c/zlib/zlib.3 \
+	etc/c/zlib/zlib.h \
+	etc/c/zlib/adler32.c \
+	etc/c/zlib/ChangeLog \
+	etc/c/zlib/README \
+	etc/c/zlib/win32.mak \
+	etc/c/zlib/linux.mak \
+	etc/c/zlib/haiku.mak \
+	etc/c/zlib/osx.mak \
+	etc/c/zlib/freebsd.mak \
+	etc/c/zlib/solaris.mak
+
+SRC_GC= internal/gc/gc.d \
+	internal/gc/gcold.d \
+	internal/gc/gcx.d \
+	internal/gc/gcstub.d \
+	internal/gc/gcbits.d \
+	internal/gc/win32.d \
+	internal/gc/gclinux.d \
+	internal/gc/gcosxc.c \
+	internal/gc/testgc.d \
+	internal/gc/win32.mak \
+	internal/gc/linux.mak \
+	internal/gc/haiku.mak \
+	internal/gc/osx.mak \
+	internal/gc/freebsd.mak \
+	internal/gc/solaris.mak
+
+ALLSRCS = $(SRC) $(SRC_STD) std/gc.d $(SRC_STD_C) $(SRC_TI) $(SRC_INTC) $(SRC_INT) $(SRC_STD_WIN) \
+	$(SRC_STD_C_WIN) $(SRC_STD_C_LINUX) $(SRC_ETC) $(SRC_ETC_C) \
+	$(SRC_ZLIB) $(SRC_GC) $(SRC_STD_C_FREEBSD) $(SRC_STD_C_SOLARIS) \
+	$(SRC_STD_C_POSIX)
+
+
+SRCS= \
+	internal/aaA.d internal/adi.d \
+	internal/aApply.d internal/aApplyR.d internal/memset.d \
+	internal/arraycast.d internal/arraycat.d \
+	internal/switch.d internal/qsort.d internal/invariant.d \
+	internal/dmain2.d internal/cast.d internal/obj.d \
+	internal/arrayfloat.d internal/arraydouble.d internal/arrayreal.d \
+	internal/arraybyte.d internal/arrayshort.d internal/arrayint.d \
+	internal/deh2.d internal/llmath.d \
+	internal/trace.d internal/cmath2.d \
+	internal/alloca.d \
+	$(SRC_STD) \
+	$(SRC_TI)
+
+
+$(LIB) : $(OBJS) $(GC_OBJS) $(ZLIB_OBJS) $(SRCS) $(MAKEFILE)
+#	rm -f $(LIB)
+#	ar -r $@ $(OBJS) $(ZLIB_OBJS) $(GC_OBJS)
+	$(DMD) -lib -of$(LIB) $(DFLAGS) $(SRCS) $(OBJS) $(ZLIB_OBJS) $(GC_OBJS)
+
+unittest :
+	$(DMD) $(DFLAGS) -unittest -version=Unittest unittest.d $(SRCS) $(LIB) -L-ldl
+	./unittest
+
+cov : $(SRCS) $(LIB)
+	$(DMD) -cov -unittest -ofcov -m$(MODEL) unittest.d $(SRCS) $(LIB)
+	./cov
+
+
+###########################################################
+
+$(GC_OBJS):
+#	cd internal/gc
+#	make -f $(MAKEFILE) dmgc.a
+#	cd ../..
+	make DMD=$(DMD) MODEL=$(MODEL) -C ./internal/gc -f $(MAKEFILE)
+
+$(ZLIB_OBJS):
+#	cd etc/c/zlib
+#	make -f $(MAKEFILE)
+#	cd ../../..
+	make -C ./etc/c/zlib -f $(MAKEFILE) MODEL=$(MODEL)
+
+###
+
+Dcrc32.o : crc32.d
+	$(DMD) -c $(DFLAGS) crc32.d -ofDcrc32.o
+
+errno.o : errno.c
+
+gcstats.o : gcstats.d
+	$(DMD) -c $(DFLAGS) gcstats.d
+
+### internal
+
+aaA.o : internal/aaA.d
+	$(DMD) -c $(DFLAGS) internal/aaA.d
+
+aApply.o : internal/aApply.d
+	$(DMD) -c $(DFLAGS) internal/aApply.d
+
+aApplyR.o : internal/aApplyR.d
+	$(DMD) -c $(DFLAGS) internal/aApplyR.d
+
+adi.o : internal/adi.d
+	$(DMD) -c $(DFLAGS) internal/adi.d
+
+alloca.o : internal/alloca.d
+	$(DMD) -c $(DFLAGS) internal/alloca.d
+
+arraycast.o : internal/arraycast.d
+	$(DMD) -c $(DFLAGS) internal/arraycast.d
+
+arraycat.o : internal/arraycat.d
+	$(DMD) -c $(DFLAGS) internal/arraycat.d
+
+cast.o : internal/cast.d
+	$(DMD) -c $(DFLAGS) internal/cast.d
+
+cmath2.o : internal/cmath2.d
+	$(DMD) -c $(DFLAGS) internal/cmath2.d
+
+complex.o : internal/complex.c
+	$(CC) -c $(CFLAGS) internal/complex.c
+
+critical.o : internal/critical.c
+	$(CC) -c $(CFLAGS) internal/critical.c
+
+#deh.o : internal/mars.h internal/deh.cA
+#	$(CC) -c $(CFLAGS) internal/deh.c
+
+deh2.o : internal/deh2.d
+	$(DMD) -c $(DFLAGS) -release internal/deh2.d
+
+dmain2.o : internal/dmain2.d
+	$(DMD) -c $(DFLAGS) internal/dmain2.d
+
+invariant.o : internal/invariant.d
+	$(DMD) -c $(DFLAGS) internal/invariant.d
+
+llmath.o : internal/llmath.d
+	$(DMD) -c $(DFLAGS) internal/llmath.d
+
+memset.o : internal/memset.d
+	$(DMD) -c $(DFLAGS) internal/memset.d
+
+#minit.o : internal/minit.asm
+#	$(CC) -c internal/minit.asm
+
+monitor.o : internal/mars.h internal/monitor.c
+	$(CC) -c $(CFLAGS) internal/monitor.c
+
+obj.o : internal/obj.d
+	$(DMD) -c $(DFLAGS) internal/obj.d
+
+object.o : internal/object.d
+	$(DMD) -c $(DFLAGS) internal/object.d
+
+qsort.o : internal/qsort.d
+	$(DMD) -c $(DFLAGS) internal/qsort.d
+
+switch.o : internal/switch.d
+	$(DMD) -c $(DFLAGS) internal/switch.d
+
+trace.o : internal/trace.d
+	$(DMD) -c $(DFLAGS) internal/trace.d
+
+### std
+
+array.o : std/array.d
+	$(DMD) -c $(DFLAGS) std/array.d
+
+asserterror.o : std/asserterror.d
+	$(DMD) -c $(DFLAGS) std/asserterror.d
+
+base64.o : std/base64.d
+	$(DMD) -c $(DFLAGS) std/base64.d
+
+bind.o : std/bind.d
+	$(DMD) -c $(DFLAGS) std/bind.d
+
+bitarray.o : std/bitarray.d
+	$(DMD) -c $(DFLAGS) std/bitarray.d
+
+boxer.o : std/boxer.d
+	$(DMD) -c $(DFLAGS) std/boxer.d
+
+compiler.o : std/compiler.d
+	$(DMD) -c $(DFLAGS) std/compiler.d
+
+conv.o : std/conv.d
+	$(DMD) -c $(DFLAGS) std/conv.d
+
+cover.o : std/cover.d
+	$(DMD) -c $(DFLAGS) std/cover.d
+
+cpuid.o : std/cpuid.d
+	$(DMD) -c $(DFLAGS) std/cpuid.d
+
+cstream.o : std/cstream.d
+	$(DMD) -c $(DFLAGS) std/cstream.d
+
+ctype.o : std/ctype.d
+	$(DMD) -c $(DFLAGS) std/ctype.d
+
+date.o : std/dateparse.d std/date.d
+	$(DMD) -c $(DFLAGS) std/date.d
+
+dateparse.o : std/dateparse.d std/date.d
+	$(DMD) -c $(DFLAGS) std/dateparse.d
+
+demangle.o : std/demangle.d
+	$(DMD) -c $(DFLAGS) std/demangle.d
+
+file.o : std/file.d
+	$(DMD) -c $(DFLAGS) std/file.d
+
+format.o : std/format.d
+	$(DMD) -c $(DFLAGS) std/format.d
+
+gc.o : std/gc.d
+	$(DMD) -c $(DFLAGS) std/gc.d
+
+loader.o : std/loader.d
+	$(DMD) -c $(DFLAGS) std/loader.d
+
+math.o : std/math.d
+	$(DMD) -c $(DFLAGS) std/math.d
+
+math2.o : std/math2.d
+	$(DMD) -c $(DFLAGS) std/math2.d
+
+md5.o : std/md5.d
+	$(DMD) -c $(DFLAGS) std/md5.d
+
+metastrings.o : std/metastrings.d
+	$(DMD) -c $(DFLAGS) std/metastrings.d
+
+mmfile.o : std/mmfile.d
+	$(DMD) -c $(DFLAGS) std/mmfile.d
+
+moduleinit.o : std/moduleinit.d
+	$(DMD) -c $(DFLAGS) std/moduleinit.d
+
+openrj.o : std/openrj.d
+	$(DMD) -c $(DFLAGS) std/openrj.d
+
+outbuffer.o : std/outbuffer.d
+	$(DMD) -c $(DFLAGS) std/outbuffer.d
+
+outofmemory.o : std/outofmemory.d
+	$(DMD) -c $(DFLAGS) std/outofmemory.d
+
+path.o : std/path.d
+	$(DMD) -c $(DFLAGS) std/path.d
+
+perf.o : std/perf.d
+	$(DMD) -c $(DFLAGS) std/perf.d
+
+process.o : std/process.d
+	$(DMD) -c $(DFLAGS) std/process.d
+
+random.o : std/random.d
+	$(DMD) -c $(DFLAGS) std/random.d
+
+regexp.o : std/regexp.d
+	$(DMD) -c $(DFLAGS) std/regexp.d
+
+signals.o : std/signals.d
+	$(DMD) -c $(DFLAGS) std/signals.d
+
+socket.o : std/socket.d
+	$(DMD) -c $(DFLAGS) std/socket.d
+
+socketstream.o : std/socketstream.d
+	$(DMD) -c $(DFLAGS) std/socketstream.d
+
+stdio.o : std/stdio.d
+	$(DMD) -c $(DFLAGS) std/stdio.d
+
+stream.o : std/stream.d
+	$(DMD) -c $(DFLAGS) -d std/stream.d
+
+string.o : std/string.d
+	$(DMD) -c $(DFLAGS) std/string.d
+
+switcherr.o : std/switcherr.d
+	$(DMD) -c $(DFLAGS) std/switcherr.d
+
+system.o : std/system.d
+	$(DMD) -c $(DFLAGS) std/system.d
+
+syserror.o : std/syserror.d
+	$(DMD) -c $(DFLAGS) std/syserror.d
+
+thread.o : std/thread.d
+	$(DMD) -c $(DFLAGS) std/thread.d
+
+traits.o : std/traits.d
+	$(DMD) -c $(DFLAGS) std/traits.d
+
+typetuple.o : std/typetuple.d
+	$(DMD) -c $(DFLAGS) std/typetuple.d
+
+uri.o : std/uri.d
+	$(DMD) -c $(DFLAGS) std/uri.d
+
+uni.o : std/uni.d
+	$(DMD) -c $(DFLAGS) std/uni.d
+
+utf.o : std/utf.d
+	$(DMD) -c $(DFLAGS) std/utf.d
+
+Dzlib.o : std/zlib.d
+	$(DMD) -c $(DFLAGS) std/zlib.d -ofDzlib.o
+
+zip.o : std/zip.d
+	$(DMD) -c $(DFLAGS) std/zip.d
+
+### std/c
+
+std_c_stdarg.o : std/c/stdarg.d
+	$(DMD) -c $(DFLAGS) std/c/stdarg.d -ofstd_c_stdarg.o
+
+### std/c/linux
+
+linux.o : std/c/linux/linux.d
+	$(DMD) -c $(DFLAGS) std/c/linux/linux.d
+
+linuxsocket.o : std/c/linux/socket.d
+	$(DMD) -c $(DFLAGS) std/c/linux/socket.d -oflinuxsocket.o
+
+pthread.o : std/c/linux/pthread.d
+	$(DMD) -c $(DFLAGS) std/c/linux/pthread.d
+
+### std/c/posix
+
+posix.o : std/c/posix/posix.d
+	$(DMD) -c $(DFLAGS) std/c/posix/posix.d
+
+posixsocket.o : std/c/posix/socket.d
+	$(DMD) -c $(DFLAGS) std/c/posix/socket.d -ofposixsocket.o
+
+posixpthread.o : std/c/posix/pthread.d
+	$(DMD) -c $(DFLAGS) std/c/posix/pthread.d -ofposixpthread.o
+
+### etc
+
+### etc/c
+
+Czlib.o : etc/c/zlib.d
+	$(DMD) -c $(DFLAGS) etc/c/zlib.d -ofCzlib.o
+
+### std/typeinfo
+
+ti_void.o : std/typeinfo/ti_void.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_void.d
+
+ti_wchar.o : std/typeinfo/ti_wchar.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_wchar.d
+
+ti_dchar.o : std/typeinfo/ti_dchar.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_dchar.d
+
+ti_uint.o : std/typeinfo/ti_uint.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_uint.d
+
+ti_short.o : std/typeinfo/ti_short.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_short.d
+
+ti_ushort.o : std/typeinfo/ti_ushort.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_ushort.d
+
+ti_byte.o : std/typeinfo/ti_byte.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_byte.d
+
+ti_ubyte.o : std/typeinfo/ti_ubyte.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_ubyte.d
+
+ti_long.o : std/typeinfo/ti_long.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_long.d
+
+ti_ulong.o : std/typeinfo/ti_ulong.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_ulong.d
+
+ti_ptr.o : std/typeinfo/ti_ptr.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_ptr.d
+
+ti_float.o : std/typeinfo/ti_float.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_float.d
+
+ti_double.o : std/typeinfo/ti_double.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_double.d
+
+ti_real.o : std/typeinfo/ti_real.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_real.d
+
+ti_delegate.o : std/typeinfo/ti_delegate.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_delegate.d
+
+ti_creal.o : std/typeinfo/ti_creal.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_creal.d
+
+ti_ireal.o : std/typeinfo/ti_ireal.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_ireal.d
+
+ti_cfloat.o : std/typeinfo/ti_cfloat.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_cfloat.d
+
+ti_ifloat.o : std/typeinfo/ti_ifloat.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_ifloat.d
+
+ti_cdouble.o : std/typeinfo/ti_cdouble.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_cdouble.d
+
+ti_idouble.o : std/typeinfo/ti_idouble.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_idouble.d
+
+ti_AC.o : std/typeinfo/ti_AC.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_AC.d
+
+ti_Ag.o : std/typeinfo/ti_Ag.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_Ag.d
+
+ti_Abit.o : std/typeinfo/ti_Abit.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_Abit.d
+
+ti_Ashort.o : std/typeinfo/ti_Ashort.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_Ashort.d
+
+ti_Aint.o : std/typeinfo/ti_Aint.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_Aint.d
+
+ti_Along.o : std/typeinfo/ti_Along.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_Along.d
+
+ti_Afloat.o : std/typeinfo/ti_Afloat.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_Afloat.d
+
+ti_Adouble.o : std/typeinfo/ti_Adouble.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_Adouble.d
+
+ti_Areal.o : std/typeinfo/ti_Areal.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_Areal.d
+
+ti_Acfloat.o : std/typeinfo/ti_Acfloat.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_Acfloat.d
+
+ti_Acdouble.o : std/typeinfo/ti_Acdouble.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_Acdouble.d
+
+ti_Acreal.o : std/typeinfo/ti_Acreal.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_Acreal.d
+
+ti_C.o : std/typeinfo/ti_C.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_C.d
+
+ti_char.o : std/typeinfo/ti_char.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_char.d
+
+ti_int.o : std/typeinfo/ti_int.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_int.d
+
+ti_bit.o : std/typeinfo/ti_bit.d
+	$(DMD) -c $(DFLAGS) std/typeinfo/ti_bit.d
+
+
+##########################################################
+
+zip : $(ALLSRCS) $(ALLMAKEFILES) phoboslicense.txt
+	$(RM) phobos.zip
+	zip phobos $(ALLSRCS) $(ALLMAKEFILES) phoboslicense.txt
+
+clean:
+	$(RM) $(LIB) $(OBJS) unittest unittest.o
+	make -C ./internal/gc -f $(MAKEFILE) clean
+	make -C ./etc/c/zlib -f $(MAKEFILE) clean
+
diff -Naur dmd/src/phobos/internal/gc/haiku.mak dmd1/src/phobos/internal/gc/haiku.mak
--- dmd/src/phobos/internal/gc/haiku.mak	1970-01-01 00:00:00.000000000 +0000
+++ dmd1/src/phobos/internal/gc/haiku.mak	2010-09-20 16:41:30.325582848 +0000
@@ -0,0 +1,56 @@
+
+# makefile to build linux D garbage collector
+
+MODEL=32
+#DMD=../../../dmd
+DMD=dmd
+CFLAGS=-g -m$(MODEL)
+#DFLAGS=-unittest -g -release
+DFLAGS=-release -O -inline -m$(MODEL) -I../..
+#DFLAGS=-release -inline -O
+CC=gcc
+MAKEFILE=haiku.mak
+
+OBJS= gc.o gcx.o gcbits.o gclinux.o gcold.o
+
+SRC= gc.d gcx.d gcbits.d win32.d gclinux.d gcold.d testgc.d \
+	win32.mak osx.mak linux.mak freebsd.mak solaris.mak
+
+.c.o:
+	$(CC) -c $(CFLAGS) $*
+
+.d.o:
+	$(DMD) -c $(DFLAGS) $*
+
+targets : dmgc.a
+
+testgc : testgc.o $(OBJS) $(MAKEFILE)
+	$(DMD) -of$@ -m$(MODEL) testgc.o gc.o gcx.o gcbits.o gclinux.o -g
+
+testgc.o : testgc.d
+	$(DMD) -c $(DFLAGS) testgc.d
+
+dmgc.a : $(OBJS) $(MAKEFILE)
+	ar -r $@ $(OBJS)
+
+gc.o : gc.d
+	$(DMD) -c $(DFLAGS) gc.d
+
+gcold.o : gcold.d
+	$(DMD) -c $(DFLAGS) gcold.d
+
+gcx.o : gcx.d
+	$(DMD) -c $(DFLAGS) gcx.d gcbits.d
+
+#gcbits.o : gcbits.d
+#       $(DMD) -c $(DFLAGS) gcbits.d
+
+gclinux.o : gclinux.d
+	$(DMD) -c $(DFLAGS) gclinux.d
+
+zip : $(SRC)
+	$(RM) dmgc.zip
+	zip dmgc $(SRC)
+
+clean:
+	$(RM) $(OBJS) dmgc.a testgc testgc.o
