Merge 14551:14980 from trunk
authorCasper Hornstrup <chorns@users.sourceforge.net>
Thu, 5 May 2005 19:15:25 +0000 (19:15 +0000)
committerCasper Hornstrup <chorns@users.sourceforge.net>
Thu, 5 May 2005 19:15:25 +0000 (19:15 +0000)
svn path=/branches/xmlbuildsystem/; revision=15017

40 files changed:
1  2 
reactos/apps/utils/net/finger/net.c
reactos/drivers/dd/serial/devctrl.c
reactos/drivers/dd/serial/pnp.c
reactos/drivers/input/directory.xml
reactos/drivers/input/i8042prt/i8042prt.xml
reactos/drivers/input/kbdclass/kbdclass.xml
reactos/drivers/net/tcpip/tcpip/main.c
reactos/drivers/video/displays/vga/objects/copybits.c
reactos/hal/hal/hal.c
reactos/hal/halx86/generic/adapter.c
reactos/hal/halx86/generic/spinlock.c
reactos/include/idl/idl.xml
reactos/lib/advapi32/advapi32.xml
reactos/lib/cpl/intl/intl.xml
reactos/lib/cpl/intl/locale.c
reactos/lib/directory.xml
reactos/lib/iphlpapi/ifenum_reactos.c
reactos/lib/msi/msi.xml
reactos/lib/ntdll/ntdll.xml
reactos/lib/rtl/rtl.xml
reactos/lib/wininet/wininet.xml
reactos/ntoskrnl/io/deviface.c
reactos/ntoskrnl/io/pnpnotify.c
reactos/ntoskrnl/kd/wrappers/gdbstub.c
reactos/ntoskrnl/ntoskrnl.xml
reactos/services/eventlog/eventlog.c
reactos/services/umpnpmgr/umpnpmgr.c
reactos/subsys/system/cmd/cmd.xml
reactos/subsys/system/explorer/taskbar/startmenu.cpp
reactos/subsys/system/services/services.xml
reactos/subsys/system/usetup/usetup.xml
reactos/subsys/win32k/main/dllmain.c
reactos/tools/cabman/cabinet.cxx
reactos/tools/rbuild/backend/mingw/modulehandler.cpp
reactos/tools/rbuild/backend/mingw/modulehandler.h
reactos/tools/rbuild/module.cpp
reactos/tools/rbuild/rbuild.h
reactos/tools/winebuild/main.c
reactos/tools/wrc/parser.y
reactos/tools/wrc/y.tab.c

   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   */
 -
 -#ifndef lint
 -static char sccsid[] = "@(#)net.c     8.4 (Berkeley) 4/28/95";
 -#endif /* not lint */
--
  #include <sys/types.h>
  #include <winsock2.h>
  #include "unistd.h"
@@@ -195,6 -200,7 +200,7 @@@ SerialGetPerfStats(IN PIRP pIrp
        PSERIAL_DEVICE_EXTENSION pDeviceExtension;
        pDeviceExtension = (PSERIAL_DEVICE_EXTENSION)
                IoGetCurrentIrpStackLocation(pIrp)->DeviceObject->DeviceExtension;
 -      ASSERT(DeviceExtension);
++      ASSERT(pDeviceExtension);
        /*
         * we assume buffer is big enough to hold SerialPerfStats structure
         * caller must verify this
@@@ -26,12 -26,14 +26,14 @@@ SerialAddDeviceInternal
        NTSTATUS Status;
        WCHAR DeviceNameBuffer[32];
        UNICODE_STRING DeviceName;
-       //UNICODE_STRING SymbolicLinkName;
        static ULONG DeviceNumber = 0;
        static ULONG ComPortNumber = 1;
+       
        DPRINT("Serial: SerialAddDeviceInternal called\n");
-    
+       
 -      ASSERT(DeviceObject);
++      ASSERT(DriverObject);
+       ASSERT(Pdo);
+       
        /* Create new device object */
        swprintf(DeviceNameBuffer, L"\\Device\\Serial%lu", DeviceNumber);
        RtlInitUnicodeString(&DeviceName, DeviceNameBuffer);
index 19e345a,0000000..b4a50d0
mode 100644,000000..100644
--- /dev/null
@@@ -1,12 -1,0 +1,12 @@@
- <directory name="keyboard">\r
-       <xi:include href="keyboard/keyboard.xml" />\r
++<directory name="i8042prt">\r
++      <xi:include href="i8042prt/i8042prt.xml" />\r
++</directory>\r
++<directory name="kbdclass">\r
++      <xi:include href="kbdclass/kbdclass.xml" />\r
 +</directory>\r
 +<directory name="mouclass">\r
 +      <xi:include href="mouclass/mouclass.xml" />\r
 +</directory>\r
- <directory name="psaux">\r
-       <xi:include href="psaux/psaux.xml" />\r
- </directory>\r
 +<directory name="sermouse">\r
 +      <xi:include href="sermouse/sermouse.xml" />\r
 +</directory>\r
index 0000000,0000000..0a19173
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,13 @@@
++<module name="i8042prt" type="kernelmodedriver" installbase="system32/drivers" installname="i8042prt.sys">
++      <bootstrap base="reactos" />
++      <include base="i8042prt">.</include>
++      <define name="__USE_W32API" />
++      <library>ntoskrnl</library>
++      <library>hal</library>
++      <file>i8042prt.c</file>
++      <file>keyboard.c</file>
++      <file>mouse.c</file>
++      <file>ps2pp.c</file>
++      <file>registry.c</file>
++      <file>i8042prt.rc</file>
++</module>
index 0000000,0000000..b0c8348
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,9 @@@
++<module name="kbdclass" type="kernelmodedriver" installbase="system32/drivers" installname="kbdclass.sys">
++      <bootstrap base="reactos" />
++      <include base="kbdclass">.</include>
++      <define name="__USE_W32API" />
++      <library>ntoskrnl</library>
++      <library>hal</library>
++      <file>kbdclass.c</file>
++      <file>kbdclass.rc</file>
++</module>
@@@ -1,7 -1,7 +1,5 @@@
  #include "../vgaddi.h"
  #include "../vgavideo/vgavideo.h"
--
--#define DBG
  #include <debug.h>
  
  BOOL STDCALL
Simple merge
@@@ -19,6 -19,6 +19,9 @@@
  #include <internal/debug.h>
  #include <hal.h>
  
++/* Hmm, needed for KDBG := 1. Why? */
++#undef KeGetCurrentIrql
++
  /* FUNCTIONS *****************************************************************/
  
  /* NOTE: IoAllocateAdapterChannel in NTOSKRNL.EXE */
@@@ -21,6 -21,6 +21,9 @@@
  
  #include <internal/debug.h>
  
++/* Hmm, needed for KDBG := 1. Why? */
++#undef KeGetCurrentIrql
++
  /* FUNCTIONS ***************************************************************/
  
  VOID STDCALL
index 57f5d45,0000000..3febc40
mode 100644,000000..100644
--- /dev/null
@@@ -1,12 -1,0 +1,24 @@@
 +<module name="pnp_server" type="rpcserver">
 +      <include base="ReactOS">.</include>
 +      <include base="ReactOS">w32api/include</include>
 +      <define name="_X86_" />
 +      <file>pnp.idl</file>
 +</module>
 +<module name="pnp_client" type="rpcclient">
 +      <include base="ReactOS">.</include>
 +      <include base="ReactOS">w32api/include</include>
 +      <define name="_X86_" />
 +      <file>pnp.idl</file>
 +</module>
++<module name="scm_server" type="rpcserver">
++      <include base="ReactOS">.</include>
++      <include base="ReactOS">w32api/include</include>
++      <define name="_X86_" />
++      <file switches="-o">svcctl.idl</file>
++</module>
++<module name="scm_client" type="rpcclient">
++      <include base="ReactOS">.</include>
++      <include base="ReactOS">w32api/include</include>
++      <define name="_X86_" />
++      <file switches="-o">svcctl.idl</file>
++</module>
index b80dbfd,0000000..e7d5b0b
mode 100644,000000..100644
--- /dev/null
@@@ -1,49 -1,0 +1,52 @@@
 +<module name="advapi32" type="win32dll" baseaddress="${BASEADDRESS_ADVAPI32}"  installbase="system32" installname="advapi32.dll">\r
 +      <importlibrary definition="advapi32.def" />\r
 +      <include base="advapi32">.</include>\r
++      <include base="ReactOS">include/idl</include>\r
 +      <define name="__USE_W32API" />\r
 +      <define name="WINVER">0x600</define>\r
 +      <define name="_WIN32_IE">0x0500</define>\r
 +      <define name="_WIN32_WINNT">0x0501</define>\r
++      <library>scm_client</library>\r
 +      <library>ntdll</library>\r
 +      <library>kernel32</library>\r
++      <library>rpcrt4</library>\r
 +      <pch>advapi32.h</pch>\r
 +      <directory name="crypt">\r
 +              <file>crypt.c</file>\r
 +              <file>crypt_des.c</file>\r
 +              <file>crypt_lmhash.c</file>\r
 +              <file>crypt_md4.c</file>\r
 +              <file>crypt_md5.c</file>\r
 +              <file>crypt_sha.c</file>\r
 +      </directory>\r
 +      <directory name="misc">\r
 +              <file>dllmain.c</file>\r
 +              <file>hwprofiles.c</file>\r
 +              <file>logon.c</file>\r
 +              <file>shutdown.c</file>\r
 +              <file>sysfunc.c</file>\r
 +      </directory>\r
 +      <directory name="reg">\r
 +              <file>reg.c</file>\r
 +      </directory>\r
 +      <directory name="sec">\r
 +              <file>ac.c</file>\r
 +              <file>audit.c</file>\r
 +              <file>lsa.c</file>\r
 +              <file>misc.c</file>\r
 +              <file>sec.c</file>\r
 +              <file>sid.c</file>\r
 +              <file>trustee.c</file>\r
 +      </directory>\r
 +      <directory name="service">\r
 +              <file>eventlog.c</file>\r
 +              <file>scm.c</file>\r
 +              <file>sctrl.c</file>\r
 +              <file>undoc.c</file>\r
 +      </directory>\r
 +      <directory name="token">\r
 +              <file>privilege.c</file>\r
 +              <file>token.c</file>\r
 +      </directory>\r
 +      <file>advapi32.rc</file>\r
 +</module>\r
index cc89345,0000000..2ffa77e
mode 100644,000000..100644
--- /dev/null
@@@ -1,21 -1,0 +1,21 @@@
- <module name="intl" type="win32dll" extension=".cpl" baseaddress="${BASEADDRESS_INTL}" installbase="system32" installname="intl.cpl">\r
++<module name="intl" type="win32dll" extension=".cpl" baseaddress="${BASEADDRESS_INTL}" installbase="system32" installname="intl.cpl" usewrc="false">\r
 +      <importlibrary definition="intl.def" />\r
 +      <include base="intl">.</include>\r
 +      <define name="UNICODE" />\r
 +      <define name="_UNICODE" />\r
 +      <define name="__REACTOS__" />\r
 +      <define name="__USE_W32API" />\r
 +      <define name="_WIN32_IE">0x600</define>\r
 +      <define name="_WIN32_WINNT">0x501</define>\r
 +      <library>kernel32</library>\r
 +      <library>user32</library>\r
 +      <library>comctl32</library>\r
 +      <file>currency.c</file>\r
 +      <file>date.c</file>\r
 +      <file>general.c</file>\r
 +      <file>intl.c</file>\r
 +      <file>locale.c</file>\r
 +      <file>numbers.c</file>\r
 +      <file>time.c</file>\r
 +      <file>intl.rc</file>\r
 +</module>\r
@@@ -292,16 -125,59 +125,59 @@@ LocalePageProc(HWND hwndDlg
               WPARAM wParam,
               LPARAM lParam)
  {
-   switch(uMsg)
-   {
-     case WM_INITDIALOG:
-       CreateTimeZoneList();
-       ShowTimeZoneList(GetDlgItem(hwndDlg, IDC_LANGUAGELIST));
+       switch(uMsg)
+       {
+       case WM_INITDIALOG:
+               CreateLanguagesList(GetDlgItem(hwndDlg, IDC_LANGUAGELIST));
+               break;
+       case WM_COMMAND:
+               switch (LOWORD(wParam))
+               {
+               case IDC_LANGUAGELIST:
+                       if (HIWORD(wParam) == CBN_SELCHANGE)
+                       {
+                               PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
+                       }
+                       break;
+               }
+               break;
  
-       break;
-   }
-   return FALSE;
+       case WM_NOTIFY:
+               {
+                       LPNMHDR lpnm = (LPNMHDR)lParam;
+                       if (lpnm->code == PSN_APPLY)
+                       {
+                               // Apply changes
+                               LCID NewLcid;
+                               int iCurSel;
+                               char tmp[100];
+                               // Acquire new value
+                               iCurSel = SendMessageW(hList,
+                                       CB_GETCURSEL,
+                                       0,
+                                       0);
+                               if (iCurSel == CB_ERR)
+                                       break;
+                               NewLcid = SendMessageW(hList,
+                                       CB_GETITEMDATA,
+                                       iCurSel,
+                                       0);
+                               if (NewLcid == CB_ERR)
+                                       break;
+                               //TOOD: Actually set new locale
 -                              sprintf(tmp, "%x, cursel=%d", NewLcid, iCurSel);
++                              sprintf(tmp, "%lx, cursel=%d", NewLcid, iCurSel);
+                               MessageBoxA(hwndDlg, tmp, "debug", MB_OK);
+                       }
+               }
+               break;
+       }
+       return FALSE;
  }
  
  
index 05fd22a,0000000..a8ce08f
mode 100644,000000..100644
--- /dev/null
@@@ -1,285 -1,0 +1,291 @@@
 +<directory name="acledit">\r
 +      <xi:include href="acledit/acledit.xml" />\r
 +</directory>\r
 +<directory name="aclui">\r
 +      <xi:include href="aclui/aclui.xml" />\r
 +</directory>\r
 +<directory name="adns">\r
 +      <xi:include href="adns/adns.xml" />\r
 +</directory>\r
 +<directory name="advapi32">\r
 +      <xi:include href="advapi32/advapi32.xml" />\r
 +</directory>\r
 +<directory name="advpack">\r
 +      <xi:include href="advpack/advpack.xml" />\r
 +</directory>\r
 +<directory name="cabinet">\r
 +      <xi:include href="cabinet/cabinet.xml" />\r
 +</directory>\r
 +<directory name="cards">\r
 +      <xi:include href="cards/cards.xml" />\r
 +</directory>\r
 +<directory name="comctl32">\r
 +      <xi:include href="comctl32/comctl32.xml" />\r
 +</directory>\r
 +<directory name="comdlg32">\r
 +      <xi:include href="comdlg32/comdlg32.xml" />\r
 +</directory>\r
 +<directory name="cpl">\r
 +      <xi:include href="cpl/directory.xml" />\r
 +</directory>\r
 +<directory name="crt">\r
 +      <xi:include href="crt/crt.xml" />\r
 +</directory>\r
 +<directory name="crtdll">\r
 +      <xi:include href="crtdll/crtdll.xml" />\r
 +</directory>\r
 +<directory name="dbghelp">\r
 +      <xi:include href="dbghelp/dbghelp.xml" />\r
 +</directory>\r
 +<directory name="devenum">\r
 +      <xi:include href="devenum/devenum.xml" />\r
 +</directory>\r
 +<directory name="dinput">\r
 +      <xi:include href="dinput/dinput.xml" />\r
 +</directory>\r
 +<directory name="dinput8">\r
 +      <xi:include href="dinput8/dinput8.xml" />\r
 +</directory>\r
 +<directory name="dnsapi">\r
 +      <xi:include href="dnsapi/dnsapi.xml" />\r
 +</directory>\r
 +<directory name="dsound">\r
 +      <xi:include href="dsound/dsound.xml" />\r
 +</directory>\r
 +<directory name="dxdiagn">\r
 +      <xi:include href="dxdiagn/dxdiagn.xml" />\r
 +</directory>\r
 +<directory name="dxguid">\r
 +      <xi:include href="dxguid/dxguid.xml" />\r
 +</directory>\r
 +<directory name="epsapi">\r
 +      <xi:include href="epsapi/epsapi.xml" />\r
 +</directory>\r
 +<directory name="expat">\r
 +      <xi:include href="expat/expat.xml" />\r
 +</directory>\r
 +<directory name="fmifs">\r
 +      <xi:include href="fmifs/fmifs.xml" />\r
 +</directory>\r
 +<directory name="freetype">\r
 +      <xi:include href="freetype/freetype.xml" />\r
 +</directory>\r
 +<directory name="fslib">\r
 +      <xi:include href="fslib/directory.xml" />\r
 +</directory>\r
 +<directory name="gdi32">\r
 +      <xi:include href="gdi32/gdi32.xml" />\r
 +</directory>\r
 +<directory name="gdiplus">\r
 +      <xi:include href="gdiplus/gdiplus.xml" />\r
 +</directory>\r
 +<directory name="glu32">\r
 +      <xi:include href="glu32/glu32.xml" />\r
 +</directory>\r
 +<directory name="imagehlp">\r
 +      <xi:include href="imagehlp/imagehlp.xml" />\r
 +</directory>\r
 +<directory name="imm32">\r
 +      <xi:include href="imm32/imm32.xml" />\r
 +</directory>\r
 +<directory name="iphlpapi">\r
 +      <xi:include href="iphlpapi/iphlpapi.xml" />\r
 +</directory>\r
 +<directory name="kbdda">\r
 +      <xi:include href="kbdda/kbdda.xml" />\r
 +</directory>\r
 +<directory name="kbddv">\r
 +      <xi:include href="kbddv/kbddv.xml" />\r
 +</directory>\r
 +<directory name="kbdes">\r
 +      <xi:include href="kbdes/kbdes.xml" />\r
 +</directory>\r
 +<directory name="kbdfr">\r
 +      <xi:include href="kbdfr/kbdfr.xml" />\r
 +</directory>\r
 +<directory name="kbdgr">\r
 +      <xi:include href="kbdgr/kbdgr.xml" />\r
 +</directory>\r
++<directory name="kbdru">\r
++      <xi:include href="kbdru/kbdru.xml" />\r
++</directory>\r
 +<directory name="kbdse">\r
 +      <xi:include href="kbdse/kbdse.xml" />\r
 +</directory>\r
++<directory name="kbdsg">\r
++      <xi:include href="kbdsg/kbdsg.xml" />\r
++</directory>\r
 +<directory name="kbduk">\r
 +      <xi:include href="kbduk/kbduk.xml" />\r
 +</directory>\r
 +<directory name="kbdus">\r
 +      <xi:include href="kbdus/kbdus.xml" />\r
 +</directory>\r
 +<directory name="kernel32">\r
 +      <xi:include href="kernel32/kernel32.xml" />\r
 +</directory>\r
 +<directory name="kjs">\r
 +      <xi:include href="kjs/kjs.xml" />\r
 +</directory>\r
 +<directory name="libwine">\r
 +      <xi:include href="libwine/libwine.xml" />\r
 +</directory>\r
 +<directory name="lzexpand">\r
 +      <xi:include href="lzexpand/lz32.xml" />\r
 +</directory>\r
 +<directory name="mesa32">\r
 +      <xi:include href="mesa32/mesa32.xml" />\r
 +</directory>\r
 +<directory name="midimap">\r
 +      <xi:include href="midimap/midimap.xml" />\r
 +</directory>\r
 +<directory name="mmdrv">\r
 +      <xi:include href="mmdrv/mmdrv.xml" />\r
 +</directory>\r
 +<directory name="mpr">\r
 +      <xi:include href="mpr/mpr.xml" />\r
 +</directory>\r
 +<directory name="msacm">\r
 +      <xi:include href="msacm/msacm32.xml" />\r
 +</directory>\r
 +<directory name="msafd">\r
 +      <xi:include href="msafd/msafd.xml" />\r
 +</directory>\r
 +<directory name="msgina">\r
 +      <xi:include href="msgina/msgina.xml" />\r
 +</directory>\r
 +<directory name="msi">\r
 +      <xi:include href="msi/msi.xml" />\r
 +</directory>\r
 +<directory name="msimg32">\r
 +      <xi:include href="msimg32/msimg32.xml" />\r
 +</directory>\r
 +<directory name="msvcrt">\r
 +      <xi:include href="msvcrt/msvcrt.xml" />\r
 +</directory>\r
 +<directory name="msvcrt20">\r
 +      <xi:include href="msvcrt20/msvcrt20.xml" />\r
 +</directory>\r
 +<directory name="netapi32">\r
 +      <xi:include href="netapi32/netapi32.xml" />\r
 +</directory>\r
 +<directory name="ntdll">\r
 +      <xi:include href="ntdll/ntdll.xml" />\r
 +</directory>\r
 +<directory name="ole32">\r
 +      <xi:include href="ole32/ole32.xml" />\r
 +</directory>\r
 +<directory name="oleaut32">\r
 +      <xi:include href="oleaut32/oleaut32.xml" />\r
 +</directory>\r
 +<directory name="olepro32">\r
 +      <xi:include href="olepro32/olepro32.xml" />\r
 +</directory>\r
 +<directory name="opengl32">\r
 +      <xi:include href="opengl32/opengl32.xml" />\r
 +</directory>\r
 +<directory name="psapi">\r
 +      <xi:include href="psapi/psapi.xml" />\r
 +</directory>\r
 +<directory name="pseh">\r
 +      <xi:include href="pseh/pseh.xml" />\r
 +</directory>\r
 +<directory name="richedit">\r
 +      <xi:include href="richedit/riched32.xml" />\r
 +</directory>\r
 +<directory name="riched20">\r
 +      <xi:include href="riched20/riched20.xml" />\r
 +</directory>\r
 +<directory name="rosrtl">\r
 +      <xi:include href="rosrtl/rosrtl.xml" />\r
 +</directory>\r
 +<directory name="rossym">\r
 +      <xi:include href="rossym/rossym.xml" />\r
 +</directory>\r
 +<directory name="rpcrt4">\r
 +      <xi:include href="rpcrt4/rpcrt4.xml" />\r
 +</directory>\r
 +<directory name="rtl">\r
 +      <xi:include href="rtl/rtl.xml" />\r
 +</directory>\r
 +<directory name="samlib">\r
 +      <xi:include href="samlib/samlib.xml" />\r
 +</directory>\r
 +<directory name="secur32">\r
 +      <xi:include href="secur32/secur32.xml" />\r
 +</directory>\r
 +<directory name="serialui">\r
 +      <xi:include href="serialui/serialui.xml" />\r
 +</directory>\r
 +<directory name="setupapi">\r
 +      <xi:include href="setupapi/setupapi.xml" />\r
 +</directory>\r
 +<directory name="shdocvw">\r
 +      <xi:include href="shdocvw/shdocvw.xml" />\r
 +</directory>\r
 +<directory name="shell32">\r
 +      <xi:include href="shell32/shell32.xml" />\r
 +</directory>\r
 +<directory name="shlwapi">\r
 +      <xi:include href="shlwapi/shlwapi.xml" />\r
 +</directory>\r
 +<directory name="snmpapi">\r
 +      <xi:include href="snmpapi/snmpapi.xml" />\r
 +</directory>\r
 +<directory name="smdll">\r
 +      <xi:include href="smdll/smdll.xml" />\r
 +</directory>\r
 +<directory name="smlib">\r
 +      <xi:include href="smlib/smlib.xml" />\r
 +</directory>\r
 +<directory name="string">\r
 +      <xi:include href="string/string.xml" />\r
 +</directory>\r
 +<directory name="strmiids">\r
 +      <xi:include href="strmiids/strmiids.xml" />\r
 +</directory>\r
 +<directory name="syssetup">\r
 +      <xi:include href="syssetup/syssetup.xml" />\r
 +</directory>\r
 +<directory name="twain">\r
 +      <xi:include href="twain/twain_32.xml" />\r
 +</directory>\r
 +<directory name="urlmon">\r
 +      <xi:include href="urlmon/urlmon.xml" />\r
 +</directory>\r
 +<directory name="user32">\r
 +      <xi:include href="user32/user32.xml" />\r
 +</directory>\r
 +<directory name="userenv">\r
 +      <xi:include href="userenv/userenv.xml" />\r
 +</directory>\r
 +<directory name="uuid">\r
 +      <xi:include href="uuid/uuid.xml" />\r
 +</directory>\r
 +<directory name="version">\r
 +      <xi:include href="version/version.xml" />\r
 +</directory>\r
 +<directory name="wininet">\r
 +      <xi:include href="wininet/wininet.xml" />\r
 +</directory>\r
 +<directory name="winmm">\r
 +      <xi:include href="winmm/winmm.xml" />\r
 +</directory>\r
 +<directory name="winspool">\r
 +      <xi:include href="winspool/winspool.xml" />\r
 +</directory>\r
 +<directory name="ws2_32">\r
 +      <xi:include href="ws2_32/ws2_32.xml" />\r
 +</directory>\r
 +<directory name="ws2help">\r
 +      <xi:include href="ws2help/ws2help.xml" />\r
 +</directory>\r
 +<directory name="wshirda">\r
 +      <xi:include href="wshirda/wshirda.xml" />\r
 +</directory>\r
 +<directory name="wsock32">\r
 +      <xi:include href="wsock32/wsock32.xml" />\r
 +</directory>\r
 +<directory name="zlib">\r
 +      <xi:include href="zlib/zlib.xml" />\r
 +</directory>\r
Simple merge
index 1514fca,0000000..221c50f
mode 100644,000000..100644
--- /dev/null
@@@ -1,52 -1,0 +1,53 @@@
 +<module name="msi" type="win32dll" baseaddress="${BASEADDRESS_MSI}" installbase="system32" installname="msi.dll" warnings="true">
 +      <importlibrary definition="msi.spec.def" />
 +      <include base="msi">.</include>
 +      <include base="ReactOS">include/wine</include>
 +      <define name="__REACTOS__" />
 +      <define name="__USE_W32API" />
 +      <define name="_WIN32_IE">0x600</define>
 +      <define name="_WIN32_WINNT">0x501</define>
 +      <define name="WINVER">0x501</define>
 +      <library>wine</library>
 +      <library>uuid</library>
 +      <library>ntdll</library>
 +      <library>kernel32</library>
 +      <library>user32</library>
 +      <library>gdi32</library>
 +      <library>advapi32</library>
 +      <library>shell32</library>
 +      <library>winmm</library>
 +      <library>cabinet</library>
 +      <library>ole32</library>
 +      <library>oleaut32</library>
 +      <library>version</library>
 +      <file>action.c</file>
 +      <file>appsearch.c</file>
 +      <file>cond.tab.c</file>
 +      <file>create.c</file>
 +      <file>custom.c</file>
++      <file>database.c</file>
 +      <file>delete.c</file>
 +      <file>dialog.c</file>
 +      <file>distinct.c</file>
 +      <file>format.c</file>
 +      <file>handle.c</file>
 +      <file>insert.c</file>
 +      <file>msi.c</file>
 +      <file>msiquery.c</file>
 +      <file>order.c</file>
 +      <file>package.c</file>
 +      <file>preview.c</file>
 +      <file>record.c</file>
 +      <file>registry.c</file>
 +      <file>regsvr.c</file>
 +      <file>select.c</file>
 +      <file>sql.tab.c</file>
 +      <file>string.c</file>
 +      <file>suminfo.c</file>
 +      <file>table.c</file>
 +      <file>tokenize.c</file>
 +      <file>update.c</file>
 +      <file>where.c</file>
 +      <file>msi.spec</file>
 +      <file>msi.rc</file>
 +</module>
index fcb08f1,0000000..96ac96c
mode 100644,000000..100644
--- /dev/null
@@@ -1,107 -1,0 +1,96 @@@
-                       <file>alldiv.s</file>\r
-                       <file>allmul.s</file>\r
-                       <file>allrem.s</file>\r
-                       <file>allshl.s</file>\r
-                       <file>allshr.s</file>\r
-                       <file>aulldiv.s</file>\r
-                       <file>aullrem.s</file>\r
-                       <file>aullshr.s</file>\r
-                       <file>exception.c</file>\r
-                       <file>float.c</file>\r
 +<module name="ntdll" type="nativedll" baseaddress="${BASEADDRESS_NTDLL}" installbase="system32" installname="ntdll.dll">\r
 +      <bootstrap base="reactos/system32" />\r
 +      <importlibrary definition="def/ntdll.def" />\r
 +      <define name="__NTDLL__" />\r
 +      <define name="_DISABLE_TIDENTS" />\r
 +      <library>rtl</library>\r
 +      <library>rosrtl</library>\r
 +      <library>string</library>\r
 +      <linkerflag>-lgcc</linkerflag>\r
 +      <directory name="csr">\r
 +              <file>capture.c</file>\r
 +              <file>lpc.c</file>\r
 +              <file>probe.c</file>\r
 +              <file>thread.c</file>\r
 +      </directory>\r
 +      <directory name="dbg">\r
 +              <file>brkpoint.c</file>\r
 +              <file>debug.c</file>\r
 +              <file>print.c</file>\r
 +      </directory>\r
 +      <directory name="ldr">\r
 +              <file>entry.S</file>\r
 +              <file>res.c</file>\r
 +              <file>startup.c</file>\r
 +              <file>utils.c</file>\r
 +      </directory>\r
 +      <directory name="main">\r
 +              <file>dllmain.c</file>\r
 +      </directory>\r
 +      <directory name="rtl">\r
 +              <directory name="i386">\r
-               <file>access.c</file>\r
 +                      <file>ftol.c</file>\r
 +              </directory>\r
 +              <file>apc.c</file>\r
 +              <file>atom.c</file>\r
 +              <file>callback.c</file>\r
 +              <file>crc32.c</file>\r
 +              <file>critical.c</file>\r
 +              <file>dbgbuffer.c</file>\r
 +              <file>exception.c</file>\r
 +              <file>handle.c</file>\r
 +              <file>intrlck.c</file>\r
 +              <file>libsupp.c</file>\r
 +              <file>math.c</file>\r
 +              <file>message.c</file>\r
 +              <file>misc.c</file>\r
 +              <file>path.c</file>\r
 +              <file>process.c</file>\r
 +              <file>propvar.c</file>\r
 +              <file>rangelist.c</file>\r
 +              <file>resource.c</file>\r
 +              <file>teb.c</file>\r
 +              <file>timerqueue.c</file>\r
 +      </directory>\r
 +      <directory name="stdio">\r
 +              <file>sprintf.c</file>\r
 +              <file>sscanf.c</file>\r
 +              <file>swprintf.c</file>\r
 +      </directory>\r
 +      <directory name="stdlib">\r
 +              <file>abs.c</file>\r
 +              <file>atoi64.c</file>\r
 +              <file>atoi.c</file>\r
 +              <file>atol.c</file>\r
 +              <file>bsearch.c</file>\r
 +              <file>itoa.c</file>\r
 +              <file>itow.c</file>\r
 +              <file>labs.c</file>\r
 +              <file>lfind.c</file>\r
 +              <file>mbstowcs.c</file>\r
 +              <file>splitp.c</file>\r
 +              <file>strtol.c</file>\r
 +              <file>strtoul.c</file>\r
 +              <file>wcstol.c</file>\r
 +              <file>wcstombs.c</file>\r
 +              <file>wcstoul.c</file>\r
 +              <file>wtoi64.c</file>\r
 +              <file>wtoi.c</file>\r
 +              <file>wtol.c</file>\r
 +      </directory>\r
 +      <directory name="string">\r
 +              <file>ctype.c</file>\r
 +              <file>memicmp.c</file>\r
 +              <file>stricmp.c</file>\r
 +              <file>strlwr.c</file>\r
 +              <file>strnicmp.c</file>\r
 +              <file>strpbrk.c</file>\r
 +              <file>strstr.c</file>\r
 +              <file>strupr.c</file>\r
 +              <file>wstring.c</file>\r
 +      </directory>\r
 +      <directory name="def">\r
 +              <file>ntdll.rc</file>\r
 +      </directory>\r
 +      <file>napi.S</file>\r
 +</module>\r
index 9a68976,0000000..189d288
mode 100644,000000..100644
--- /dev/null
@@@ -1,39 -1,0 +1,48 @@@
 +<module name="rtl" type="staticlibrary">\r
 +      <directory name="i386">\r
++              <file>allshl.s</file>\r
++              <file>aulldiv.s</file>\r
++              <file>aullrem.s</file>\r
++              <file>allshr.s</file>\r
++              <file>allmul.s</file>\r
++              <file>aullshr.s</file>\r
++              <file>alldiv.s</file>\r
++              <file>allrem.s</file>\r
 +              <file>chkstk.s</file>\r
 +              <file>except.s</file>\r
 +              <file>exception.c</file>\r
 +      </directory>\r
++      <file>access.c</file>\r
 +      <file>acl.c</file>\r
 +      <file>bit.c</file>\r
 +      <file>bitmap.c</file>\r
 +      <file>bootdata.c</file>\r
 +      <file>compress.c</file>\r
 +      <file>dos8dot3.c</file>\r
 +      <file>encode.c</file>\r
 +      <file>env.c</file>\r
 +      <file>error.c</file>\r
 +      <file>exception.c</file>\r
 +      <file>generictable.c</file>\r
 +      <file>heap.c</file>\r
 +      <file>image.c</file>\r
 +      <file>largeint.c</file>\r
 +      <file>luid.c</file>\r
 +      <file>mem.c</file>\r
 +      <file>network.c</file>\r
 +      <file>nls.c</file>\r
 +      <file>ppb.c</file>\r
 +      <file>process.c</file>\r
 +      <file>random.c</file>\r
 +      <file>registry.c</file>\r
 +      <file>sd.c</file>\r
 +      <file>security.c</file>\r
 +      <file>sid.c</file>\r
 +      <file>splaytree.c</file>\r
 +      <file>thread.c</file>\r
 +      <file>time.c</file>\r
 +      <file>timezone.c</file>\r
 +      <file>unicode.c</file>\r
 +      <file>unicodeprefix.c</file>\r
 +      <file>version.c</file>\r
 +</module>\r
index 0000000,0000000..cf0a497
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,34 @@@
++<module name="wininet" type="win32dll" baseaddress="${BASEADDRESS_WININET}" installbase="system32" installname="wininet.dll" warnings="true">
++      <importlibrary definition="wininet.spec.def" />
++      <include base="wininet">.</include>
++      <include base="ReactOS">include/wine</include>
++      <define name="UNICODE" />
++      <define name="_UNICODE" />
++      <define name="__REACTOS__" />
++      <define name="__USE_W32API" />
++      <define name="_WIN32_IE">0x600</define>
++      <define name="_WIN32_WINNT">0x501</define>
++      <define name="WINVER">0x501</define>
++      <library>wine</library>
++      <library>ntdll</library>
++      <library>kernel32</library>
++      <library>user32</library>
++      <library>advapi32</library>
++      <library>shell32</library>
++      <library>shlwapi</library>
++      <library>mpr</library>
++      <library>ws2_32</library>
++      <file>cookie.c</file>
++      <file>dialogs.c</file>
++      <file>ftp.c</file>
++      <file>gopher.c</file>
++      <file>http.c</file>
++      <file>internet.c</file>
++      <file>netconnection.c</file>
++      <file>urlcache.c</file>
++      <file>utility.c</file>
++      <file>wininet_main.c</file>
++      <file>rsrc.rc</file>
++      <file>version.rc</file>
++      <file>wininet.spec</file>
++</module>
Simple merge
Simple merge
@@@ -150,19 -165,68 +165,19 @@@ static CPU_REGISTER GspRegisters[NUMREG
    { 4, FIELD_OFFSET (KTRAP_FRAME_X86, Fs), FIELD_OFFSET (CONTEXT, SegFs), TRUE },
    { 4, FIELD_OFFSET (KTRAP_FRAME_X86, Gs), FIELD_OFFSET (CONTEXT, SegGs), TRUE }
  };
- static PCHAR GspThreadStates[THREAD_STATE_MAX] =
- {
-   "Initialized",  /* THREAD_STATE_INITIALIZED */
-   "Ready",        /* THREAD_STATE_READY */
-   "Running",      /* THREAD_STATE_RUNNING */
-   "Suspended",    /* THREAD_STATE_SUSPENDED */
-   "Frozen",       /* THREAD_STATE_FROZEN */
-   "Terminated 1", /* THREAD_STATE_TERMINATED_1 */
-   "Terminated 2", /* THREAD_STATE_TERMINATED_2 */
-   "Blocked"       /* THREAD_STATE_BLOCKED */
+                                                                                 
+ static PCHAR GspThreadStates[DeferredReady+1] =
+ { "Initialized", 
+   "Ready", 
+   "Running",
+   "Standby", 
+   "Terminated", 
+   "Waiting",
+   "Transition", 
+   "DeferredReady" 
  };
  
 -char *
 -strtok(char *s, const char *delim)
 -{
 -  const char *spanp;
 -  int c, sc;
 -  char *tok;
 -  static char *last;
 -
 -
 -  if (s == NULL && (s = last) == NULL)
 -    return (NULL);
 -
 -  /*
 -   * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
 -   */
 - cont:
 -  c = *s++;
 -  for (spanp = delim; (sc = *spanp++) != 0;) {
 -    if (c == sc)
 -      goto cont;
 -  }
 -
 -  if (c == 0) {                       /* no non-delimiter characters */
 -    last = NULL;
 -    return (NULL);
 -  }
 -  tok = s - 1;
 -
 -  /*
 -   * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
 -   * Note that delim must have one NUL; we stop if we see that, too.
 -   */
 -  for (;;) {
 -    c = *s++;
 -    spanp = delim;
 -    do {
 -      if ((sc = *spanp++) == c) {
 -      if (c == 0)
 -        s = NULL;
 -      else
 -        s[-1] = 0;
 -      last = s;
 -      return (tok);
 -      }
 -    } while (sc != 0);
 -  }
 -  /* NOTREACHED */
 -}
 -
  LONG
  HexValue (CHAR ch)
  {
index d9aa917,0000000..50a97cb
mode 100644,000000..100644
--- /dev/null
@@@ -1,367 -1,0 +1,348 @@@
-                               <file>bthread.S</file>\r
 +<module name="ntoskrnl" type="kernel" installbase="system32" installname="ntoskrnl.exe">\r
 +      <bootstrap base="reactos" />\r
 +      <importlibrary definition="ntoskrnl.def" />\r
 +      <define name="_SEH_NO_NATIVE_NLG" />\r
 +      <define name="_DISABLE_TIDENTS" />\r
 +      <define name="__NTOSKRNL__" />\r
 +      <define name="__3GB__" />\r
 +      <include base="kjs">include</include>\r
 +      <include base="ntoskrnl">include</include>\r
 +      <library>csq</library>\r
 +      <library>hal</library>\r
 +      <library>kjs</library>\r
 +      <library>pseh</library>\r
 +      <library>rtl</library>\r
 +      <library>rosrtl</library>\r
 +      <library>string</library>\r
 +      <library>rossym</library>\r
 +      <directory name="include">\r
 +              <pch>ntoskrnl.h</pch>\r
 +      </directory>\r
 +      <directory name="ke">\r
 +              <if property="ARCH" value="i386">\r
 +                      <directory name="i386">\r
 +                              <file first="true">main.S</file>\r
 +                              <file>bios.c</file>\r
 +                              <file>brkpoint.c</file>\r
-                               <file>i386-mcount.S</file>\r
++                              <file>ctxswitch.S</file>\r
 +                              <file>exp.c</file>\r
 +                              <file>fpu.c</file>\r
 +                              <file>gdt.c</file>\r
-                               <file>tskswitch.S</file>\r
 +                              <file>idt.c</file>\r
 +                              <file>irq.c</file>\r
 +                              <file>irqhand.s</file>\r
 +                              <file>kernel.c</file>\r
 +                              <file>ldt.c</file>\r
 +                              <file>stkswitch.S</file>\r
 +                              <file>syscall.S</file>\r
 +                              <file>thread.c</file>\r
 +                              <file>tlbflush.S</file>\r
 +                              <file>trap.s</file>\r
-       <directory name="dbg">\r
 +                              <file>tss.c</file>\r
 +                              <file>usercall.S</file>\r
 +                              <file>usertrap.c</file>\r
 +                              <file>v86m.c</file>\r
 +                              <file>v86m_sup.S</file>\r
 +                              <file>vdm.c</file>\r
 +                      </directory>\r
 +              </if>\r
 +              <file>apc.c</file>\r
 +              <file>bug.c</file>\r
 +              <file>catch.c</file>\r
 +              <file>clock.c</file>\r
 +              <file>device.c</file>\r
 +              <file>dpc.c</file>\r
 +              <file>event.c</file>\r
++              <file>gate.c</file>\r
 +              <file>gmutex.c</file>\r
 +              <file>ipi.c</file>\r
 +              <file>kqueue.c</file>\r
 +              <file>kthread.c</file>\r
 +              <file>main.c</file>\r
 +              <file>mutex.c</file>\r
 +              <file>process.c</file>\r
 +              <file>profile.c</file>\r
 +              <file>queue.c</file>\r
 +              <file>sem.c</file>\r
 +              <file>spinlock.c</file>\r
 +              <file>timer.c</file>\r
 +              <file>usercall.c</file>\r
 +              <file>wait.c</file>\r
 +      </directory>\r
 +      <directory name="cc">\r
 +              <file>cacheman.c</file>\r
 +              <file>copy.c</file>\r
 +              <file>fs.c</file>\r
 +              <file>mdl.c</file>\r
 +              <file>pin.c</file>\r
 +              <file>view.c</file>\r
 +      </directory>\r
 +      <directory name="cm">\r
 +              <file>import.c</file>\r
 +              <file>ntfunc.c</file>\r
 +              <file>regfile.c</file>\r
 +              <file>registry.c</file>\r
 +              <file>regobj.c</file>\r
 +      </directory>\r
-                       <file>rdebug.c</file>\r
++      <directory name="kdbg">\r
 +              <if property="ARCH" value="i386">\r
 +                      <directory name="i386">\r
 +                              <if property="KDBG" value="1">\r
 +                                      <group>\r
 +                                              <file>i386-dis.c</file>\r
 +                                              <file>kdb_help.S</file>\r
++                                              <file>longjmp.S</file>\r
++                                              <file>setjmp.S</file>\r
 +                                      </group>\r
 +                              </if>\r
 +                      </directory>\r
 +              </if>\r
 +              <if property="KDBG" value="1">\r
 +                      <file>kdb.c</file>\r
++                      <file>kdb_cli.c</file>\r
++                      <file>kdb_expr.c</file>\r
 +                      <file>kdb_keyboard.c</file>\r
 +                      <file>kdb_serial.c</file>\r
-                       <file>profile.c</file>\r
++                      <file>kdb_string.c</file>\r
 +              </if>\r
 +              <if property="DBG_OR_KDBG" value="true">\r
 +                      <file>kdb_symbols.c</file>\r
-               <file>dbgctrl.c</file>\r
-               <file>errinfo.c</file>\r
-               <file>print.c</file>\r
-               <file>user.c</file>\r
 +              </if>\r
-               <file>buildirp.c</file>\r
-               <file>cancel.c</file>\r
-               <file>cleanup.c</file>\r
-               <file>cntrller.c</file>\r
-               <file>create.c</file>\r
++      </directory>\r
++      <directory name="dbgk">\r
++              <file>dbgkutil.c</file>\r
++              <file>debug.c</file>\r
 +      </directory>\r
 +      <directory name="ex">\r
 +              <if property="ARCH" value="i386">\r
 +                      <directory name="i386">\r
 +                              <file>interlck.c</file>\r
 +                      </directory>\r
 +              </if>\r
 +              <file>callback.c</file>\r
++              <file>dbgctrl.c</file>\r
 +              <file>error.c</file>\r
 +              <file>event.c</file>\r
 +              <file>evtpair.c</file>\r
 +              <file>fmutex.c</file>\r
 +              <file>handle.c</file>\r
 +              <file>init.c</file>\r
 +              <file>interlck.c</file>\r
 +              <file>list.c</file>\r
 +              <file>lookas.c</file>\r
 +              <file>mutant.c</file>\r
 +              <file>power.c</file>\r
 +              <file>profile.c</file>\r
 +              <file>resource.c</file>\r
 +              <file>rundown.c</file>\r
 +              <file>sem.c</file>\r
 +              <file>synch.c</file>\r
 +              <file>sysinfo.c</file>\r
 +              <file>time.c</file>\r
 +              <file>timer.c</file>\r
 +              <file>util.c</file>\r
 +              <file>uuid.c</file>\r
 +              <file>win32k.c</file>\r
 +              <file>work.c</file>\r
 +              <file>zone.c</file>\r
 +              <file>zw.S</file>\r
 +      </directory>\r
 +      <directory name="fs">\r
 +              <file>dbcsname.c</file>\r
 +              <file>filelock.c</file>\r
 +              <file>mcb.c</file>\r
 +              <file>mdl.c</file>\r
 +              <file>name.c</file>\r
 +              <file>notify.c</file>\r
 +              <file>oplock.c</file>\r
 +              <file>pool.c</file>\r
 +              <file>tunnel.c</file>\r
 +              <file>unc.c</file>\r
 +              <file>util.c</file>\r
 +      </directory>\r
 +      <directory name="inbv">\r
 +              <file>inbv.c</file>\r
 +      </directory>\r
 +      <directory name="io">\r
 +              <file>adapter.c</file>\r
 +              <file>arcname.c</file>\r
 +              <file>bootlog.c</file>\r
-               <file>dir.c</file>\r
++              <file>controller.c</file>\r
 +              <file>device.c</file>\r
 +              <file>deviface.c</file>\r
-               <file>errlog.c</file>\r
++              <file>disk.c</file>\r
 +              <file>driver.c</file>\r
 +              <file>efi.c</file>\r
-               <file>flush.c</file>\r
 +              <file>error.c</file>\r
 +              <file>event.c</file>\r
 +              <file>file.c</file>\r
-               <file>ioctrl.c</file>\r
 +              <file>fs.c</file>\r
 +              <file>iocomp.c</file>\r
-               <file>lock.c</file>\r
-               <file>mailslot.c</file>\r
 +              <file>iomgr.c</file>\r
 +              <file>iowork.c</file>\r
 +              <file>irp.c</file>\r
 +              <file>irq.c</file>\r
-               <file>npipe.c</file>\r
-               <file>page.c</file>\r
-               <file>parttab.c</file>\r
 +              <file>mdl.c</file>\r
-               <file>process.c</file>\r
-               <file>queue.c</file>\r
 +              <file>plugplay.c</file>\r
 +              <file>pnpdma.c</file>\r
 +              <file>pnpmgr.c</file>\r
 +              <file>pnpnotify.c</file>\r
 +              <file>pnpreport.c</file>\r
 +              <file>pnproot.c</file>\r
-               <file>rw.c</file>\r
 +              <file>rawfs.c</file>\r
 +              <file>remlock.c</file>\r
 +              <file>resource.c</file>\r
-               <file>shutdown.c</file>\r
 +              <file>share.c</file>\r
-               <file>wdm.c</file>\r
 +              <file>symlink.c</file>\r
 +              <file>timer.c</file>\r
 +              <file>vpb.c</file>\r
-               <file>xhaldisp.c</file>\r
-               <file>xhaldrv.c</file>\r
 +              <file>wmi.c</file>\r
-               <file>dlog.c</file>\r
-               <file>gdbstub.c</file>\r
-               <file>kdebug.c</file>\r
-               <file>mda.c</file>\r
-               <file>service.c</file>\r
 +      </directory>\r
 +      <directory name="kd">\r
-               <file>create.c</file>\r
++              <directory name="wrappers">\r
++                      <file>bochs.c</file>\r
++                      <file>gdbstub.c</file>\r
++              </directory>\r
++              <file>kdinit.c</file>\r
++              <file>kdio.c</file>\r
++              <file>kdmain.c</file>\r
 +      </directory>\r
 +      <directory name="ldr">\r
 +              <file>init.c</file>\r
 +              <file>loader.c</file>\r
 +              <file>resource.c</file>\r
 +              <file>rtl.c</file>\r
 +              <file>sysdll.c</file>\r
 +              <file>userldr.c</file>\r
 +      </directory>\r
 +      <directory name="lpc">\r
 +              <file>close.c</file>\r
 +              <file>complete.c</file>\r
 +              <file>connect.c</file>\r
 +              <file>create.c</file>\r
 +              <file>listen.c</file>\r
 +              <file>port.c</file>\r
 +              <file>query.c</file>\r
 +              <file>queue.c</file>\r
 +              <file>receive.c</file>\r
 +              <file>reply.c</file>\r
 +              <file>send.c</file>\r
 +      </directory>\r
 +      <directory name="mm">\r
 +              <if property="ARCH" value="i386">\r
 +                      <directory name="i386">\r
 +                              <file>memsafe.s</file>\r
 +                              <file>page.c</file>\r
 +                              <file>pfault.c</file>\r
 +                      </directory>\r
 +              </if>\r
 +              <file>anonmem.c</file>\r
 +              <file>aspace.c</file>\r
 +              <file>balance.c</file>\r
 +              <file>cont.c</file>\r
 +              <file>drvlck.c</file>\r
 +              <file>elf32.c</file>\r
 +              <file>elf64.c</file>\r
 +              <file>freelist.c</file>\r
 +              <file>iospace.c</file>\r
 +              <file>kmap.c</file>\r
 +              <file>marea.c</file>\r
 +              <file>mdl.c</file>\r
 +              <file>mm.c</file>\r
++              <file>process.c</file>\r
 +              <file>mminit.c</file>\r
 +              <file>mpw.c</file>\r
 +              <file>ncache.c</file>\r
 +              <file>npool.c</file>\r
 +              <file>pagefile.c</file>\r
 +              <file>pageop.c</file>\r
 +              <file>pager.c</file>\r
 +              <file>pagfault.c</file>\r
 +              <file>paging.c</file>\r
 +              <file>pe.c</file>\r
 +              <file>physical.c</file>\r
 +              <file>pool.c</file>\r
 +              <file>ppool.c</file>\r
 +              <file>region.c</file>\r
 +              <file>rmap.c</file>\r
 +              <file>section.c</file>\r
 +              <file>verifier.c</file>\r
 +              <file>virtual.c</file>\r
 +              <file>wset.c</file>\r
 +      </directory>\r
 +      <directory name="ob">\r
 +              <file>dirobj.c</file>\r
 +              <file>handle.c</file>\r
 +              <file>namespc.c</file>\r
 +              <file>ntobj.c</file>\r
 +              <file>object.c</file>\r
 +              <file>sdcache.c</file>\r
 +              <file>security.c</file>\r
 +              <file>symlink.c</file>\r
 +              <file>wait.c</file>\r
 +      </directory>\r
 +      <directory name="po">\r
 +              <file>power.c</file>\r
 +      </directory>\r
 +      <directory name="ps">\r
 +              <if property="ARCH" value="i386">\r
 +                      <directory name="i386">\r
 +                              <file>continue.c</file>\r
 +                      </directory>\r
 +              </if>\r
 +              <file>cid.c</file>\r
-                               <file>alldiv.s</file>\r
-                               <file>allmul.s</file>\r
-                               <file>allrem.s</file>\r
-                               <file>allshl.s</file>\r
-                               <file>allshr.s</file>\r
-                               <file>aulldiv.s</file>\r
-                               <file>aullrem.s</file>\r
-                               <file>aullshr.s</file>\r
 +              <file>debug.c</file>\r
 +              <file>idle.c</file>\r
 +              <file>job.c</file>\r
 +              <file>kill.c</file>\r
 +              <file>locale.c</file>\r
++              <file>notify.c</file>\r
 +              <file>process.c</file>\r
 +              <file>psmgr.c</file>\r
 +              <file>query.c</file>\r
++              <file>quota.c</file>\r
 +              <file>security.c</file>\r
 +              <file>suspend.c</file>\r
 +              <file>thread.c</file>\r
 +              <file>win32.c</file>\r
 +      </directory>\r
 +      <directory name="rtl">\r
 +              <if property="ARCH" value="i386">\r
 +                      <directory name="i386">\r
 +                              <file>exception.c</file>\r
 +                              <file>seh.s</file>\r
 +                      </directory>\r
 +              </if>\r
 +              <file>atom.c</file>\r
 +              <file>capture.c</file>\r
 +              <file>ctype.c</file>\r
++              <file>debug.c</file>\r
 +              <file>handle.c</file>\r
 +              <file>libsupp.c</file>\r
 +              <file>message.c</file>\r
 +              <file>misc.c</file>\r
 +              <file>nls.c</file>\r
 +              <file>purecall.c</file>\r
 +              <file>rangelist.c</file>\r
 +              <file>regio.c</file>\r
 +              <file>sprintf.c</file>\r
 +              <file>stdlib.c</file>\r
 +              <file>string.c</file>\r
 +              <file>strtok.c</file>\r
 +              <file>swprintf.c</file>\r
 +              <file>wstring.c</file>\r
 +      </directory>\r
 +      <directory name="se">\r
 +              <file>access.c</file>\r
 +              <file>acl.c</file>\r
 +              <file>audit.c</file>\r
 +              <file>lsa.c</file>\r
 +              <file>luid.c</file>\r
 +              <file>priv.c</file>\r
 +              <file>sd.c</file>\r
 +              <file>semgr.c</file>\r
 +              <file>sid.c</file>\r
 +              <file>token.c</file>\r
 +      </directory>\r
 +      <file>ntoskrnl.rc</file>\r
 +</module>\r
@@@ -36,7 -36,7 +36,6 @@@
  
  #include "eventlog.h"
  
--#define DBG
  #define NDEBUG
  #include <debug.h>
  
@@@ -38,9 -38,9 +38,8 @@@
  #include <rpc.h>\r
  #include <rpcdce.h>\r
  \r
 -#include "pnp.h"\r
 +#include "pnp_s.h"\r
  \r
--#define DBG\r
  #define NDEBUG\r
  #include <debug.h>\r
  \r
index 2f372fd,0000000..66e4a9d
mode 100644,000000..100644
--- /dev/null
@@@ -1,63 -1,0 +1,63 @@@
- <module name="cmd" type="win32cui" installbase="system32" installname="cmd.exe">\r
++<module name="cmd" type="win32cui" installbase="system32" installname="cmd.exe" usewrc="false">\r
 +      <include base="ReactOS">include/wine</include>\r
 +      <include base="cmd">.</include>\r
 +      <define name="__USE_W32API" />\r
 +      <define name="ANONYMOUSUNIONS" />\r
 +      <define name="_WIN32_WINNT">0x0501</define>\r
 +      <library>kernel32</library>\r
 +      <pch>precomp.h</pch>\r
 +      <file>alias.c</file>\r
 +      <file>attrib.c</file>\r
 +      <file>batch.c</file>\r
 +      <file>beep.c</file>\r
 +      <file>call.c</file>\r
 +      <file>chcp.c</file>\r
 +      <file>choice.c</file>\r
 +      <file>cls.c</file>\r
 +      <file>cmd.c</file>\r
 +      <file>cmdinput.c</file>\r
 +      <file>cmdtable.c</file>\r
 +      <file>color.c</file>\r
 +      <file>console.c</file>\r
 +      <file>copy.c</file>\r
 +      <file>date.c</file>\r
 +      <file>del.c</file>\r
 +      <file>delay.c</file>\r
 +      <file>dir.c</file>\r
 +      <file>dirstack.c</file>\r
 +      <file>echo.c</file>\r
 +      <file>error.c</file>\r
 +      <file>filecomp.c</file>\r
 +      <file>for.c</file>\r
 +      <file>free.c</file>\r
 +      <file>goto.c</file>\r
 +      <file>history.c</file>\r
 +      <file>if.c</file>\r
 +      <file>internal.c</file>\r
 +      <file>label.c</file>\r
 +      <file>locale.c</file>\r
 +      <file>memory.c</file>\r
 +      <file>misc.c</file>\r
 +      <file>move.c</file>\r
 +      <file>msgbox.c</file>\r
 +      <file>path.c</file>\r
 +      <file>pause.c</file>\r
 +      <file>prompt.c</file>\r
 +      <file>redir.c</file>\r
 +      <file>ren.c</file>\r
 +      <file>screen.c</file>\r
 +      <file>set.c</file>\r
 +      <file>shift.c</file>\r
 +      <file>start.c</file>\r
 +      <file>strtoclr.c</file>\r
 +      <file>time.c</file>\r
 +      <file>timer.c</file>\r
 +      <file>title.c</file>\r
 +      <file>type.c</file>\r
 +      <file>ver.c</file>\r
 +      <file>verify.c</file>\r
 +      <file>vol.c</file>\r
 +      <file>where.c</file>\r
 +      <file>window.c</file>\r
 +      <file>cmd.rc</file>\r
 +</module>\r
index 46004e1,0000000..8073ff8
mode 100644,000000..100644
--- /dev/null
@@@ -1,11 -1,0 +1,17 @@@
-       <file>services.c</file>\r
 +<module name="services" type="win32cui">\r
 +      <include base="services">.</include>\r
++      <include base="ReactOS">include/idl</include>\r
 +      <define name="__USE_W32API" />\r
++      <define name="UNICODE" />\r
++      <define name="_UNICODE" />\r
++      <library>scm_server</library>\r
 +      <library>ntdll</library>\r
 +      <library>kernel32</library>\r
 +      <library>user32</library>\r
 +      <library>advapi32</library>\r
++      <library>rpcrt4</library>\r
 +      <file>database.c</file>\r
++      <file>rpcserver.c</file>\r
++      <file>services.c</file>\r
 +      <file>services.rc</file>\r
 +</module>\r
index 68b920b,0000000..98a1a31
mode 100644,000000..100644
--- /dev/null
@@@ -1,28 -1,0 +1,29 @@@
 +<module name="usetup" type="nativecui" installbase="system32" installname="usetup.exe" warnings="true">\r
 +      <bootstrap base="reactos/system32" nameoncd="smss.exe" />\r
 +      <include base="usetup">.</include>\r
 +      <include base="zlib">.</include>\r
 +      <define name="_DISABLE_TIDENTS" />\r
 +      <linkerflag>-lgcc</linkerflag>\r
 +      <library>zlib</library>\r
 +      <library>vfatlib</library>\r
 +      <library>ntdll</library>\r
 +      <pch>precomp.h</pch>\r
 +      <file>bootsup.c</file>\r
 +      <file>cabinet.c</file>\r
 +      <file>console.c</file>\r
 +      <file>drivesup.c</file>\r
 +      <file>filequeue.c</file>\r
 +      <file>filesup.c</file>\r
 +      <file>format.c</file>\r
 +      <file>fslist.c</file>\r
 +      <file>genlist.c</file>\r
 +      <file>infcache.c</file>\r
 +      <file>inicache.c</file>\r
++      <file>keytrans.c</file>\r
 +      <file>partlist.c</file>\r
 +      <file>progress.c</file>\r
 +      <file>registry.c</file>\r
 +      <file>settings.c</file>\r
 +      <file>usetup.c</file>\r
 +      <file>usetup.rc</file>\r
 +</module>\r
Simple merge
Simple merge
index d18cf9e,0000000..a8c0c49
mode 100644,000000..100644
--- /dev/null
@@@ -1,2912 -1,0 +1,2919 @@@
-       const string& sourceFilename,\r
 +#include "../../pch.h"\r
 +#include <assert.h>\r
 +\r
 +#include "../../rbuild.h"\r
 +#include "mingw.h"\r
 +#include "modulehandler.h"\r
 +\r
 +using std::string;\r
 +using std::vector;\r
 +\r
 +#define CLEAN_FILE(f) clean_files.push_back ( f );\r
 +\r
 +static string ros_temp = "$(TEMPORARY)";\r
 +MingwBackend*\r
 +MingwModuleHandler::backend = NULL;\r
 +FILE*\r
 +MingwModuleHandler::fMakefile = NULL;\r
 +bool\r
 +MingwModuleHandler::use_pch = false;\r
 +\r
 +string\r
 +PrefixFilename (\r
 +      const string& filename,\r
 +      const string& prefix )\r
 +{\r
 +      if ( !prefix.length() )\r
 +              return filename;\r
 +      string out;\r
 +      const char* pfilename = filename.c_str();\r
 +      const char* p1 = strrchr ( pfilename, '/' );\r
 +      const char* p2 = strrchr ( pfilename, '\\' );\r
 +      if ( p1 || p2 )\r
 +      {\r
 +              if ( p2 > p1 )\r
 +                      p1 = p2;\r
 +              out += string(pfilename,p1-pfilename) + CSEP;\r
 +              pfilename = p1 + 1;\r
 +      }\r
 +      out += prefix + pfilename;\r
 +      return out;\r
 +}\r
 +\r
 +string\r
 +GetTargetMacro ( const Module& module, bool with_dollar )\r
 +{\r
 +      string s ( module.name );\r
 +      strupr ( &s[0] );\r
 +      s += "_TARGET";\r
 +      if ( with_dollar )\r
 +              return ssprintf ( "$(%s)", s.c_str() );\r
 +      return s;\r
 +}\r
 +\r
 +MingwModuleHandler::MingwModuleHandler (\r
 +      const Module& module_ )\r
 +\r
 +      : module(module_)\r
 +{\r
 +}\r
 +\r
 +MingwModuleHandler::~MingwModuleHandler()\r
 +{\r
 +}\r
 +\r
 +/*static*/ void\r
 +MingwModuleHandler::SetBackend ( MingwBackend* backend_ )\r
 +{\r
 +      backend = backend_;\r
 +}\r
 +\r
 +/*static*/ void\r
 +MingwModuleHandler::SetMakefile ( FILE* f )\r
 +{\r
 +      fMakefile = f;\r
 +}\r
 +\r
 +/*static*/ void\r
 +MingwModuleHandler::SetUsePch ( bool b )\r
 +{\r
 +      use_pch = b;\r
 +}\r
 +\r
 +/* static*/ string\r
 +MingwModuleHandler::RemoveVariables ( string path)\r
 +{\r
 +      size_t i = path.find ( '$' );\r
 +      if ( i != string::npos )\r
 +      {\r
 +              size_t j = path.find ( ')', i );\r
 +              if ( j != string::npos )\r
 +              {\r
 +                      if ( j + 2 < path.length () && path[j + 1] == CSEP )\r
 +                              return path.substr ( j + 2);\r
 +                      else\r
 +                              return path.substr ( j + 1);\r
 +              }\r
 +      }\r
 +      return path;\r
 +}\r
 +\r
 +/*static*/ string\r
 +MingwModuleHandler::PassThruCacheDirectory (\r
 +      const string &file,\r
 +      Directory* directoryTree )\r
 +{\r
 +      string directory ( GetDirectory ( RemoveVariables ( file ) ) );\r
 +      string generatedFilesDirectory = backend->AddDirectoryTarget ( directory,\r
 +                                                                     directoryTree );\r
 +      if ( directory.find ( generatedFilesDirectory ) != string::npos )\r
 +              /* This path already includes the generated files directory variable */\r
 +              return file;\r
 +      else\r
 +              return generatedFilesDirectory + SSEP + file;\r
 +}\r
 +\r
 +/*static*/ string\r
 +MingwModuleHandler::GetTargetFilename (\r
 +      const Module& module,\r
 +      string_list* pclean_files )\r
 +{\r
 +      string target = PassThruCacheDirectory (\r
 +              NormalizeFilename ( module.GetPath () ),\r
 +              backend->outputDirectory );\r
 +      if ( pclean_files )\r
 +      {\r
 +              string_list& clean_files = *pclean_files;\r
 +              CLEAN_FILE ( target );\r
 +      }\r
 +      return target;\r
 +}\r
 +\r
 +/*static*/ string\r
 +MingwModuleHandler::GetImportLibraryFilename (\r
 +      const Module& module,\r
 +      string_list* pclean_files )\r
 +{\r
 +      string target = PassThruCacheDirectory (\r
 +              NormalizeFilename ( module.GetDependencyPath () ),\r
 +              backend->outputDirectory );\r
 +      if ( pclean_files )\r
 +      {\r
 +              string_list& clean_files = *pclean_files;\r
 +              CLEAN_FILE ( target );\r
 +      }\r
 +      return target;\r
 +}\r
 +\r
 +/*static*/ MingwModuleHandler*\r
 +MingwModuleHandler::InstanciateHandler (\r
 +      const Module& module,\r
 +      MingwBackend* backend )\r
 +{\r
 +      MingwModuleHandler* handler;\r
 +      switch ( module.type )\r
 +      {\r
 +              case BuildTool:\r
 +                      handler = new MingwBuildToolModuleHandler ( module );\r
 +                      break;\r
 +              case StaticLibrary:\r
 +                      handler = new MingwStaticLibraryModuleHandler ( module );\r
 +                      break;\r
 +              case ObjectLibrary:\r
 +                      handler = new MingwObjectLibraryModuleHandler ( module );\r
 +                      break;\r
 +              case Kernel:\r
 +                      handler = new MingwKernelModuleHandler ( module );\r
 +                      break;\r
 +              case NativeCUI:\r
 +                      handler = new MingwNativeCUIModuleHandler ( module );\r
 +                      break;\r
 +              case Win32CUI:\r
 +                      handler = new MingwWin32CUIModuleHandler ( module );\r
 +                      break;\r
 +              case Win32GUI:\r
 +                      handler = new MingwWin32GUIModuleHandler ( module );\r
 +                      break;\r
 +              case KernelModeDLL:\r
 +                      handler = new MingwKernelModeDLLModuleHandler ( module );\r
 +                      break;\r
 +              case NativeDLL:\r
 +                      handler = new MingwNativeDLLModuleHandler ( module );\r
 +                      break;\r
 +              case Win32DLL:\r
 +                      handler = new MingwWin32DLLModuleHandler ( module );\r
 +                      break;\r
 +              case KernelModeDriver:\r
 +                      handler = new MingwKernelModeDriverModuleHandler ( module );\r
 +                      break;\r
 +              case BootLoader:\r
 +                      handler = new MingwBootLoaderModuleHandler ( module );\r
 +                      break;\r
 +              case BootSector:\r
 +                      handler = new MingwBootSectorModuleHandler ( module );\r
 +                      break;\r
 +              case Iso:\r
 +                      handler = new MingwIsoModuleHandler ( module );\r
 +                      break;\r
 +              case LiveIso:\r
 +                      handler = new MingwLiveIsoModuleHandler ( module );\r
 +                      break;\r
 +              case Test:\r
 +                      handler = new MingwTestModuleHandler ( module );\r
 +                      break;\r
 +              case RpcServer:\r
 +                      handler = new MingwRpcServerModuleHandler ( module );\r
 +                      break;\r
 +              case RpcClient:\r
 +                      handler = new MingwRpcClientModuleHandler ( module );\r
 +                      break;\r
 +              default:\r
 +                      throw UnknownModuleTypeException (\r
 +                              module.node.location,\r
 +                              module.type );\r
 +                      break;\r
 +      }\r
 +      return handler;\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GetWorkingDirectory () const\r
 +{\r
 +      return ".";\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GetBasename ( const string& filename ) const\r
 +{\r
 +      size_t index = filename.find_last_of ( '.' );\r
 +      if ( index != string::npos )\r
 +              return filename.substr ( 0, index );\r
 +      return "";\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GetActualSourceFilename (\r
 +      const string& filename ) const\r
 +{\r
 +      string extension = GetExtension ( filename );\r
 +      if ( extension == ".spec" || extension == ".SPEC" )\r
 +      {\r
 +              string basename = GetBasename ( filename );\r
 +              return PassThruCacheDirectory ( NormalizeFilename ( basename + ".stubs.c" ),\r
 +                                              backend->intermediateDirectory );\r
 +      }\r
 +      else if ( extension == ".idl" || extension == ".IDL" )\r
 +      {\r
 +              string basename = GetBasename ( filename );\r
 +              string newname;\r
 +              if ( module.type == RpcServer )\r
 +                      newname = basename + "_s.c";\r
 +              else\r
 +                      newname = basename + "_c.c";\r
 +              return PassThruCacheDirectory ( NormalizeFilename ( newname ),\r
 +                                              backend->intermediateDirectory );\r
 +      }\r
 +      else\r
 +              return filename;\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GetModuleArchiveFilename () const\r
 +{\r
 +      if ( module.type == StaticLibrary )\r
 +              return GetTargetFilename ( module, NULL );\r
 +      return PassThruCacheDirectory ( ReplaceExtension (\r
 +              NormalizeFilename ( module.GetPath () ),\r
 +              ".temp.a" ),\r
 +              backend->intermediateDirectory );\r
 +}\r
 +\r
 +bool\r
 +MingwModuleHandler::IsGeneratedFile ( const File& file ) const\r
 +{\r
 +      string extension = GetExtension ( file.name );\r
 +      return ( extension == ".spec" || extension == ".SPEC" );\r
 +}\r
 +\r
 +/*static*/ bool\r
 +MingwModuleHandler::ReferenceObjects (\r
 +      const Module& module )\r
 +{\r
 +      if ( module.type == ObjectLibrary )\r
 +              return true;\r
 +      if ( module.type == RpcServer )\r
 +              return true;\r
 +      if ( module.type == RpcClient )\r
 +              return true;\r
 +      return false;\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GetImportLibraryDependency (\r
 +      const Module& importedModule )\r
 +{\r
 +      string dep;\r
 +      if ( ReferenceObjects ( importedModule ) )\r
 +              dep = GetTargetMacro ( importedModule );\r
 +      else\r
 +              dep = GetImportLibraryFilename ( importedModule, NULL );\r
 +      return dep;\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GetTargets ( const Module& dependencyModule,\r
 +                                   string_list& targets )\r
 +{\r
 +      if ( dependencyModule.invocations.size () > 0 )\r
 +      {\r
 +              for ( size_t i = 0; i < dependencyModule.invocations.size (); i++ )\r
 +              {\r
 +                      Invoke& invoke = *dependencyModule.invocations[i];\r
 +                      invoke.GetTargets ( targets );\r
 +              }\r
 +      }\r
 +      else\r
 +              targets.push_back ( GetImportLibraryDependency ( dependencyModule ) );\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GetModuleDependencies (\r
 +      string_list& dependencies )\r
 +{\r
 +      size_t iend = module.dependencies.size ();\r
 +\r
 +      if ( iend == 0 )\r
 +              return;\r
 +      \r
 +      for ( size_t i = 0; i < iend; i++ )\r
 +      {\r
 +              const Dependency& dependency = *module.dependencies[i];\r
 +              const Module& dependencyModule = *dependency.dependencyModule;\r
 +              GetTargets ( dependencyModule,\r
 +                           dependencies );\r
 +      }\r
 +      GetDefinitionDependencies ( dependencies );\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GetSourceFilenames (\r
 +      string_list& list,\r
 +      bool includeGeneratedFiles ) const\r
 +{\r
 +      size_t i;\r
 +\r
 +      const vector<File*>& files = module.non_if_data.files;\r
 +      for ( i = 0; i < files.size (); i++ )\r
 +      {\r
 +              if ( includeGeneratedFiles || !IsGeneratedFile ( *files[i] ) )\r
 +              {\r
 +                      list.push_back (\r
 +                              GetActualSourceFilename ( files[i]->name ) );\r
 +              }\r
 +      }\r
 +      // intentionally make a copy so that we can append more work in\r
 +      // the middle of processing without having to go recursive\r
 +      vector<If*> v = module.non_if_data.ifs;\r
 +      for ( i = 0; i < v.size (); i++ )\r
 +      {\r
 +              size_t j;\r
 +              If& rIf = *v[i];\r
 +              // check for sub-ifs to add to list\r
 +              const vector<If*>& ifs = rIf.data.ifs;\r
 +              for ( j = 0; j < ifs.size (); j++ )\r
 +                      v.push_back ( ifs[j] );\r
 +              const vector<File*>& files = rIf.data.files;\r
 +              for ( j = 0; j < files.size (); j++ )\r
 +              {\r
 +                      File& file = *files[j];\r
 +                      if ( includeGeneratedFiles || !IsGeneratedFile ( file ) )\r
 +                      {\r
 +                              list.push_back (\r
 +                                      GetActualSourceFilename ( file.name ) );\r
 +                      }\r
 +              }\r
 +      }\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GetSourceFilenamesWithoutGeneratedFiles (\r
 +      string_list& list ) const\r
 +{\r
 +      GetSourceFilenames ( list, false );\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GetObjectFilename (\r
 +      const string& sourceFilename,\r
 +      string_list* pclean_files ) const\r
 +{\r
 +      Directory* directoryTree;\r
 +\r
 +      string newExtension;\r
 +      string extension = GetExtension ( sourceFilename );\r
 +      if ( extension == ".rc" || extension == ".RC" )\r
 +              newExtension = ".coff";\r
 +      else if ( extension == ".spec" || extension == ".SPEC" )\r
 +              newExtension = ".stubs.o";\r
 +      else if ( extension == ".idl" || extension == ".IDL" )\r
 +      {\r
 +              if ( module.type == RpcServer )\r
 +                      newExtension = "_s.o";\r
 +              else\r
 +                      newExtension = "_c.o";\r
 +      }\r
 +      else\r
 +              newExtension = ".o";\r
 +      \r
 +      if ( module.type == BootSector )\r
 +              directoryTree = backend->outputDirectory;\r
 +      else\r
 +              directoryTree = backend->intermediateDirectory;\r
 +\r
 +      string obj_file = PassThruCacheDirectory (\r
 +              NormalizeFilename ( ReplaceExtension (\r
 +                      RemoveVariables ( sourceFilename ),\r
 +                                        newExtension ) ),\r
 +                      directoryTree );\r
 +      if ( pclean_files )\r
 +      {\r
 +              string_list& clean_files = *pclean_files;\r
 +              CLEAN_FILE ( obj_file );\r
 +      }\r
 +      return obj_file;\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateCleanTarget () const\r
 +{\r
 +      if ( 0 == clean_files.size() )\r
 +              return;\r
 +      fprintf ( fMakefile, ".PHONY: %s_clean\n", module.name.c_str() );\r
 +      fprintf ( fMakefile, "%s_clean:\n\t-@${rm}", module.name.c_str() );\r
 +      for ( size_t i = 0; i < clean_files.size(); i++ )\r
 +      {\r
 +              if ( 9==((i+1)%10) )\r
 +                      fprintf ( fMakefile, " 2>$(NUL)\n\t-@${rm}" );\r
 +              fprintf ( fMakefile, " %s", clean_files[i].c_str() );\r
 +      }\r
 +      fprintf ( fMakefile, " 2>$(NUL)\n" );\r
 +      fprintf ( fMakefile, "clean: %s_clean\n\n", module.name.c_str() );\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GetObjectFilenames ()\r
 +{\r
 +      const vector<File*>& files = module.non_if_data.files;\r
 +      if ( files.size () == 0 )\r
 +              return "";\r
 +      \r
 +      string objectFilenames ( "" );\r
 +      for ( size_t i = 0; i < files.size (); i++ )\r
 +      {\r
 +              if ( objectFilenames.size () > 0 )\r
 +                      objectFilenames += " ";\r
 +              objectFilenames +=\r
 +                      GetObjectFilename ( files[i]->name, NULL );\r
 +      }\r
 +      return objectFilenames;\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GenerateGccDefineParametersFromVector (\r
 +      const vector<Define*>& defines ) const\r
 +{\r
 +      string parameters;\r
 +      for ( size_t i = 0; i < defines.size (); i++ )\r
 +      {\r
 +              Define& define = *defines[i];\r
 +              if (parameters.length () > 0)\r
 +                      parameters += " ";\r
 +              parameters += "-D";\r
 +              parameters += define.name;\r
 +              if (define.value.length () > 0)\r
 +              {\r
 +                      parameters += "=";\r
 +                      parameters += define.value;\r
 +              }\r
 +      }\r
 +      return parameters;\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GenerateGccDefineParameters () const\r
 +{\r
 +      string parameters = GenerateGccDefineParametersFromVector ( module.project.non_if_data.defines );\r
 +      string s = GenerateGccDefineParametersFromVector ( module.non_if_data.defines );\r
 +      if ( s.length () > 0 )\r
 +      {\r
 +              parameters += " ";\r
 +              parameters += s;\r
 +      }\r
 +      return parameters;\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::ConcatenatePaths (\r
 +      const string& path1,\r
 +      const string& path2 ) const\r
 +{\r
 +      if ( ( path1.length () == 0 ) || ( path1 == "." ) || ( path1 == "./" ) )\r
 +              return path2;\r
 +      if ( path1[path1.length ()] == CSEP )\r
 +              return path1 + path2;\r
 +      else\r
 +              return path1 + CSEP + path2;\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector<Include*>& includes ) const\r
 +{\r
 +      string parameters;\r
 +      for ( size_t i = 0; i < includes.size (); i++ )\r
 +      {\r
 +              Include& include = *includes[i];\r
 +              if ( parameters.length () > 0 )\r
 +                      parameters += " ";\r
 +              parameters += "-I" + include.directory;\r
 +      }\r
 +      return parameters;\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GenerateGccIncludeParameters () const\r
 +{\r
 +      string parameters = GenerateGccIncludeParametersFromVector ( module.non_if_data.includes );\r
 +      string s = GenerateGccIncludeParametersFromVector ( module.project.non_if_data.includes );\r
 +      if ( s.length () > 0 )\r
 +      {\r
 +              parameters += " ";\r
 +              parameters += s;\r
 +      }\r
 +      return parameters;\r
 +}\r
 +\r
 +\r
 +string\r
 +MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector<CompilerFlag*>& compilerFlags ) const\r
 +{\r
 +      string parameters;\r
 +      for ( size_t i = 0; i < compilerFlags.size (); i++ )\r
 +      {\r
 +              CompilerFlag& compilerFlag = *compilerFlags[i];\r
 +              if ( parameters.length () > 0 )\r
 +                      parameters += " ";\r
 +              parameters += compilerFlag.flag;\r
 +      }\r
 +      return parameters;\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector<LinkerFlag*>& linkerFlags ) const\r
 +{\r
 +      string parameters;\r
 +      for ( size_t i = 0; i < linkerFlags.size (); i++ )\r
 +      {\r
 +              LinkerFlag& linkerFlag = *linkerFlags[i];\r
 +              if ( parameters.length () > 0 )\r
 +                      parameters += " ";\r
 +              parameters += linkerFlag.flag;\r
 +      }\r
 +      return parameters;\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (\r
 +      const vector<Library*>& libraries )\r
 +{\r
 +      string dependencies ( "" );\r
 +      int wrap_count = 0;\r
 +      for ( size_t i = 0; i < libraries.size (); i++ )\r
 +      {\r
 +              if ( wrap_count++ == 5 )\r
 +                      dependencies += " \\\n\t\t", wrap_count = 0;\r
 +              else if ( dependencies.size () > 0 )\r
 +                      dependencies += " ";\r
 +              dependencies += GetImportLibraryDependency ( *libraries[i]->imported_module );\r
 +      }\r
 +      return dependencies;\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GenerateLinkerParameters () const\r
 +{\r
 +      return GenerateLinkerParametersFromVector ( module.linkerFlags );\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateMacro (\r
 +      const char* assignmentOperation,\r
 +      const string& macro,\r
 +      const IfableData& data,\r
 +      const vector<CompilerFlag*>* compilerFlags )\r
 +{\r
 +      size_t i;\r
 +\r
 +      fprintf (\r
 +              fMakefile,\r
 +              "%s %s",\r
 +              macro.c_str(),\r
 +              assignmentOperation );\r
 +      \r
 +      if ( compilerFlags != NULL )\r
 +      {\r
 +              string compilerParameters = GenerateCompilerParametersFromVector ( *compilerFlags );\r
 +              if ( compilerParameters.size () > 0 )\r
 +              {\r
 +                      fprintf (\r
 +                              fMakefile,\r
 +                              " %s",\r
 +                              compilerParameters.c_str () );\r
 +              }\r
 +      }\r
 +\r
 +      for ( i = 0; i < data.includes.size(); i++ )\r
 +      {\r
 +              fprintf (\r
 +                      fMakefile,\r
 +                      " -I%s",\r
 +                      data.includes[i]->directory.c_str() );\r
 +      }\r
 +      for ( i = 0; i < data.defines.size(); i++ )\r
 +      {\r
 +              Define& d = *data.defines[i];\r
 +              fprintf (\r
 +                      fMakefile,\r
 +                      " -D%s",\r
 +                      d.name.c_str() );\r
 +              if ( d.value.size() )\r
 +                      fprintf (\r
 +                              fMakefile,\r
 +                              "=%s",\r
 +                              d.value.c_str() );\r
 +      }\r
 +      fprintf ( fMakefile, "\n" );\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateMacros (\r
 +      const char* assignmentOperation,\r
 +      const IfableData& data,\r
 +      const vector<CompilerFlag*>* compilerFlags,\r
 +      const vector<LinkerFlag*>* linkerFlags )\r
 +{\r
 +      size_t i;\r
 +\r
 +      if ( data.includes.size () > 0 || data.defines.size () > 0 )\r
 +      {\r
 +              GenerateMacro ( assignmentOperation,\r
 +                              cflagsMacro,\r
 +                              data,\r
 +                              compilerFlags );\r
 +              GenerateMacro ( assignmentOperation,\r
 +                              windresflagsMacro,\r
 +                              data,\r
 +                              compilerFlags );\r
 +      }\r
 +      \r
 +      if ( linkerFlags != NULL )\r
 +      {\r
 +              string linkerParameters = GenerateLinkerParametersFromVector ( *linkerFlags );\r
 +              if ( linkerParameters.size () > 0 )\r
 +              {\r
 +                      fprintf (\r
 +                              fMakefile,\r
 +                              "%s %s %s\n",\r
 +                              linkerflagsMacro.c_str (),\r
 +                              assignmentOperation,\r
 +                              linkerParameters.c_str() );\r
 +              }\r
 +      }\r
 +\r
 +      if ( data.libraries.size () > 0 )\r
 +      {\r
 +              string deps = GenerateImportLibraryDependenciesFromVector ( data.libraries );\r
 +              if ( deps.size () > 0 )\r
 +              {\r
 +                      fprintf (\r
 +                              fMakefile,\r
 +                              "%s %s %s\n",\r
 +                              libsMacro.c_str(),\r
 +                              assignmentOperation,\r
 +                              deps.c_str() );\r
 +              }\r
 +      }\r
 +\r
 +      const vector<If*>& ifs = data.ifs;\r
 +      for ( i = 0; i < ifs.size(); i++ )\r
 +      {\r
 +              If& rIf = *ifs[i];\r
 +              if ( rIf.data.defines.size()\r
 +                      || rIf.data.includes.size()\r
 +                      || rIf.data.libraries.size()\r
 +                      || rIf.data.files.size()\r
 +                      || rIf.data.ifs.size() )\r
 +              {\r
 +                      fprintf (\r
 +                              fMakefile,\r
 +                              "ifeq (\"$(%s)\",\"%s\")\n",\r
 +                              rIf.property.c_str(),\r
 +                              rIf.value.c_str() );\r
 +                      GenerateMacros (\r
 +                              "+=",\r
 +                              rIf.data,\r
 +                              NULL,\r
 +                              NULL );\r
 +                      fprintf ( \r
 +                              fMakefile,\r
 +                              "endif\n\n" );\r
 +              }\r
 +      }\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateObjectMacros (\r
 +      const char* assignmentOperation,\r
 +      const IfableData& data,\r
 +      const vector<CompilerFlag*>* compilerFlags,\r
 +      const vector<LinkerFlag*>* linkerFlags )\r
 +{\r
 +      size_t i;\r
 +\r
 +      const vector<File*>& files = data.files;\r
 +      if ( files.size () > 0 )\r
 +      {\r
 +              for ( i = 0; i < files.size (); i++ )\r
 +              {\r
 +                      File& file = *files[i];\r
 +                      if ( file.first )\r
 +                      {\r
 +                              fprintf ( fMakefile,\r
 +                                      "%s := %s $(%s)\n",\r
 +                                      objectsMacro.c_str(),\r
 +                                      GetObjectFilename (\r
 +                                              file.name, NULL ).c_str (),\r
 +                                      objectsMacro.c_str() );\r
 +                      }\r
 +              }\r
 +              fprintf (\r
 +                      fMakefile,\r
 +                      "%s %s",\r
 +                      objectsMacro.c_str (),\r
 +                      assignmentOperation );\r
 +              for ( i = 0; i < files.size(); i++ )\r
 +              {\r
 +                      File& file = *files[i];\r
 +                      if ( !file.first )\r
 +                      {\r
 +                              fprintf (\r
 +                                      fMakefile,\r
 +                                      "%s%s",\r
 +                                      ( i%10 == 9 ? " \\\n\t" : " " ),\r
 +                                      GetObjectFilename (\r
 +                                              file.name, NULL ).c_str () );\r
 +                      }\r
 +              }\r
 +              fprintf ( fMakefile, "\n" );\r
 +      }\r
 +\r
 +      const vector<If*>& ifs = data.ifs;\r
 +      for ( i = 0; i < ifs.size(); i++ )\r
 +      {\r
 +              If& rIf = *ifs[i];\r
 +              if ( rIf.data.defines.size()\r
 +                      || rIf.data.includes.size()\r
 +                      || rIf.data.libraries.size()\r
 +                      || rIf.data.files.size()\r
 +                      || rIf.data.ifs.size() )\r
 +              {\r
 +                      fprintf (\r
 +                              fMakefile,\r
 +                              "ifeq (\"$(%s)\",\"%s\")\n",\r
 +                              rIf.property.c_str(),\r
 +                              rIf.value.c_str() );\r
 +                      GenerateObjectMacros (\r
 +                              "+=",\r
 +                              rIf.data,\r
 +                              NULL,\r
 +                              NULL );\r
 +                      fprintf ( \r
 +                              fMakefile,\r
 +                              "endif\n\n" );\r
 +              }\r
 +      }\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateGccCommand (\r
 +      const string& sourceFilename,\r
 +      const string& cc,\r
 +      const string& cflagsMacro )\r
 +{\r
 +      string dependencies = sourceFilename;\r
 +      if ( module.pch && use_pch )\r
 +              dependencies += " " + module.pch->header + ".gch";\r
 +      \r
 +      /* WIDL generated headers may be used */\r
 +      dependencies += " " + GetLinkingDependenciesMacro ();\r
 +      dependencies += " " + NormalizeFilename ( module.xmlbuildFile );\r
 +\r
 +      string objectFilename = GetObjectFilename (\r
 +              sourceFilename, &clean_files );\r
 +      fprintf ( fMakefile,\r
 +                "%s: %s | %s\n",\r
 +                objectFilename.c_str (),\r
 +                dependencies.c_str (),\r
 +                GetDirectory ( objectFilename ).c_str () );\r
 +      fprintf ( fMakefile, "\t$(ECHO_CC)\n" );\r
 +      fprintf ( fMakefile,\r
 +               "\t%s -c $< -o $@ %s\n",\r
 +               cc.c_str (),\r
 +               cflagsMacro.c_str () );\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateGccAssemblerCommand (\r
 +      const string& sourceFilename,\r
 +      const string& cc,\r
 +      const string& cflagsMacro )\r
 +{\r
 +      string dependencies = sourceFilename;\r
 +      dependencies += " " + NormalizeFilename ( module.xmlbuildFile );\r
 +      string objectFilename = GetObjectFilename (\r
 +              sourceFilename, &clean_files );\r
 +      fprintf ( fMakefile,\r
 +                "%s: %s | %s\n",\r
 +                objectFilename.c_str (),\r
 +                dependencies.c_str (),\r
 +                GetDirectory ( objectFilename ).c_str () );\r
 +      fprintf ( fMakefile, "\t$(ECHO_GAS)\n" );\r
 +      fprintf ( fMakefile,\r
 +                "\t%s -x assembler-with-cpp -c $< -o $@ -D__ASM__ %s\n",\r
 +                cc.c_str (),\r
 +                cflagsMacro.c_str () );\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateNasmCommand (\r
 +      const string& sourceFilename,\r
 +      const string& nasmflagsMacro )\r
 +{\r
 +      string dependencies = sourceFilename;\r
 +      dependencies += " " + NormalizeFilename ( module.xmlbuildFile );\r
 +      string objectFilename = GetObjectFilename (\r
 +              sourceFilename, &clean_files );\r
 +      fprintf ( fMakefile,\r
 +                "%s: %s | %s\n",\r
 +                objectFilename.c_str (),\r
 +                dependencies.c_str (),\r
 +                GetDirectory ( objectFilename ).c_str () );\r
 +      fprintf ( fMakefile, "\t$(ECHO_NASM)\n" );\r
 +      fprintf ( fMakefile,\r
 +                "\t%s -f win32 $< -o $@ %s\n",\r
 +                "$(Q)nasm",\r
 +                nasmflagsMacro.c_str () );\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateWindresCommand (\r
 +      const string& sourceFilename,\r
 +      const string& windresflagsMacro )\r
 +{\r
 +      string dependencies = sourceFilename;\r
 +      dependencies += " " + NormalizeFilename ( module.xmlbuildFile );\r
 +      string objectFilename =\r
 +              GetObjectFilename ( sourceFilename, &clean_files );\r
 +      string rciFilename = ros_temp + module.name + ".rci.tmp";\r
 +      string resFilename = ros_temp + module.name + ".res.tmp";\r
 +      if ( module.useWRC )\r
 +      {\r
 +              fprintf ( fMakefile,\r
 +                        "%s: %s $(WRC_TARGET) | %s\n",\r
 +                        objectFilename.c_str (),\r
 +                        dependencies.c_str (),\r
 +                        GetDirectory ( objectFilename ).c_str () );\r
 +              fprintf ( fMakefile, "\t$(ECHO_WRC)\n" );\r
 +              fprintf ( fMakefile,\r
 +                       "\t${gcc} -xc -E -DRC_INVOKED ${%s} %s > %s\n",\r
 +                       windresflagsMacro.c_str (),\r
 +                       sourceFilename.c_str (),\r
 +                       rciFilename.c_str () );\r
 +              fprintf ( fMakefile,\r
 +                       "\t$(Q)$(WRC_TARGET) ${%s} %s %s\n",\r
 +                       windresflagsMacro.c_str (),\r
 +                       rciFilename.c_str (),\r
 +                       resFilename.c_str () );\r
 +              fprintf ( fMakefile,\r
 +                       "\t-@${rm} %s 2>$(NUL)\n",\r
 +                       rciFilename.c_str () );\r
 +              fprintf ( fMakefile,\r
 +                       "\t${windres} %s -o $@\n",\r
 +                       resFilename.c_str () );\r
 +              fprintf ( fMakefile,\r
 +                       "\t-@${rm} %s 2>$(NUL)\n",\r
 +                       resFilename.c_str () );\r
 +      }\r
 +      else\r
 +      {\r
 +              fprintf ( fMakefile,\r
 +                        "%s: %s $(WRC_TARGET) | %s\n",\r
 +                        objectFilename.c_str (),\r
 +                        dependencies.c_str (),\r
 +                        GetDirectory ( objectFilename ).c_str () );\r
 +              fprintf ( fMakefile, "\t$(ECHO_WRC)\n" );\r
 +              fprintf ( fMakefile,\r
 +                       "\t${windres} $(%s) %s -o $@\n",\r
 +                       windresflagsMacro.c_str (),\r
 +                       sourceFilename.c_str () );\r
 +      }\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateWinebuildCommands (\r
 +      const string& sourceFilename )\r
 +{\r
 +      string dependencies = sourceFilename;\r
 +      dependencies += " " + NormalizeFilename ( module.xmlbuildFile );\r
 +\r
 +      string basename = GetBasename ( sourceFilename );\r
 +      string def_file = PassThruCacheDirectory (\r
 +              basename + ".spec.def",\r
 +              backend->intermediateDirectory );\r
 +      CLEAN_FILE(def_file);\r
 +\r
 +      string stub_file = PassThruCacheDirectory (\r
 +              basename + ".stubs.c",\r
 +              backend->intermediateDirectory );\r
 +      CLEAN_FILE(stub_file)\r
 +\r
 +      fprintf ( fMakefile,\r
 +                "%s: %s $(WINEBUILD_TARGET)\n",\r
 +                def_file.c_str (),\r
 +                dependencies.c_str () );\r
 +      fprintf ( fMakefile, "\t$(ECHO_WINEBLD)\n" );\r
 +      fprintf ( fMakefile,\r
 +                "\t%s --def=%s -o %s\n",\r
 +                "$(Q)$(WINEBUILD_TARGET)",\r
 +                sourceFilename.c_str (),\r
 +                def_file.c_str () );\r
 +\r
 +      fprintf ( fMakefile,\r
 +                "%s: %s $(WINEBUILD_TARGET)\n",\r
 +                stub_file.c_str (),\r
 +                sourceFilename.c_str () );\r
 +      fprintf ( fMakefile, "\t$(ECHO_WINEBLD)\n" );\r
 +      fprintf ( fMakefile,\r
 +                "\t%s --pedll=%s -o %s\n",\r
 +                "$(Q)$(WINEBUILD_TARGET)",\r
 +                sourceFilename.c_str (),\r
 +                stub_file.c_str () );\r
 +}\r
 +\r
++string\r
++MingwModuleHandler::GetWidlFlags ( const File& file )\r
++{\r
++      return file.switches;\r
++}\r
++              \r
 +void\r
 +MingwModuleHandler::GenerateWidlCommandsServer (\r
-       string dependencies = sourceFilename;\r
++      const File& file,\r
 +      const string& widlflagsMacro )\r
 +{\r
-       string basename = GetBasename ( sourceFilename );\r
++      string dependencies = file.name;\r
 +      dependencies += " " + NormalizeFilename ( module.xmlbuildFile );\r
 +\r
-                 "\t%s %s -h -H %s -s -S %s %s\n",\r
++      string basename = GetBasename ( file.name );\r
 +\r
 +      /*string generatedHeaderFilename = PassThruCacheDirectory (\r
 +              basename + ".h",\r
 +              backend->intermediateDirectory );\r
 +      CLEAN_FILE(generatedHeaderFilename);\r
 +      */\r
 +      string generatedHeaderFilename = basename + "_s.h";\r
 +      CLEAN_FILE(generatedHeaderFilename);\r
 +\r
 +      string generatedServerFilename = PassThruCacheDirectory (\r
 +              basename + "_s.c",\r
 +              backend->intermediateDirectory );\r
 +      CLEAN_FILE(generatedServerFilename);\r
 +\r
 +      fprintf ( fMakefile,\r
 +                "%s %s: %s $(WIDL_TARGET) | %s\n",\r
 +                generatedServerFilename.c_str (),\r
 +                generatedHeaderFilename.c_str (),\r
 +                dependencies.c_str (),\r
 +                GetDirectory ( generatedServerFilename ).c_str () );\r
 +      fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" );\r
 +      fprintf ( fMakefile,\r
-                 sourceFilename.c_str () );\r
++                "\t%s %s %s -h -H %s -s -S %s %s\n",\r
 +                "$(Q)$(WIDL_TARGET)",\r
++                GetWidlFlags ( file ).c_str (),\r
 +                widlflagsMacro.c_str (),\r
 +                generatedHeaderFilename.c_str (),\r
 +                generatedServerFilename.c_str (),\r
-       const string& sourceFilename,\r
++                file.name.c_str () );\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateWidlCommandsClient (\r
-       string dependencies = sourceFilename;\r
++      const File& file,\r
 +      const string& widlflagsMacro )\r
 +{\r
-       string basename = GetBasename ( sourceFilename );\r
++      string dependencies = file.name;\r
 +      dependencies += " " + NormalizeFilename ( module.xmlbuildFile );\r
 +\r
-                 "\t%s %s -h -H %s -c -C %s %s\n",\r
++      string basename = GetBasename ( file.name );\r
 +\r
 +      /*string generatedHeaderFilename = PassThruCacheDirectory (\r
 +              basename + ".h",\r
 +              backend->intermediateDirectory );\r
 +      CLEAN_FILE(generatedHeaderFilename);\r
 +      */\r
 +      string generatedHeaderFilename = basename + "_c.h";\r
 +      CLEAN_FILE(generatedHeaderFilename);\r
 +\r
 +      string generatedClientFilename = PassThruCacheDirectory (\r
 +              basename + "_c.c",\r
 +              backend->intermediateDirectory );\r
 +      CLEAN_FILE(generatedClientFilename);\r
 +\r
 +      fprintf ( fMakefile,\r
 +                "%s %s: %s $(WIDL_TARGET) | %s\n",\r
 +                generatedClientFilename.c_str (),\r
 +                generatedHeaderFilename.c_str (),\r
 +                dependencies.c_str (),\r
 +                GetDirectory ( generatedClientFilename ).c_str () );\r
 +      fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" );\r
 +      fprintf ( fMakefile,\r
-                 sourceFilename.c_str () );\r
++                "\t%s %s %s -h -H %s -c -C %s %s\n",\r
 +                "$(Q)$(WIDL_TARGET)",\r
++                GetWidlFlags ( file ).c_str (),\r
 +                widlflagsMacro.c_str (),\r
 +                generatedHeaderFilename.c_str (),\r
 +                generatedClientFilename.c_str (),\r
-       const string& sourceFilename,\r
++                file.name.c_str () );\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateWidlCommands (\r
-               GenerateWidlCommandsServer ( sourceFilename,\r
++      const File& file,\r
 +      const string& widlflagsMacro )\r
 +{\r
 +      if ( module.type == RpcServer )\r
-               GenerateWidlCommandsClient ( sourceFilename,\r
++              GenerateWidlCommandsServer ( file,\r
 +                                           widlflagsMacro );\r
 +      else\r
-       const string& sourceFilename,\r
++              GenerateWidlCommandsClient ( file,\r
 +                                           widlflagsMacro );\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateCommands (\r
-       string extension = GetExtension ( sourceFilename );\r
++      const File& file,\r
 +      const string& cc,\r
 +      const string& cppc,\r
 +      const string& cflagsMacro,\r
 +      const string& nasmflagsMacro,\r
 +      const string& windresflagsMacro,\r
 +      const string& widlflagsMacro )\r
 +{\r
-               GenerateGccCommand ( sourceFilename,\r
++      string extension = GetExtension ( file.name );\r
 +      if ( extension == ".c" || extension == ".C" )\r
 +      {\r
-               GenerateGccCommand ( sourceFilename,\r
++              GenerateGccCommand ( file.name,\r
 +                                   cc,\r
 +                                   cflagsMacro );\r
 +              return;\r
 +      }\r
 +      else if ( extension == ".cc" || extension == ".CC" ||\r
 +                extension == ".cpp" || extension == ".CPP" ||\r
 +                extension == ".cxx" || extension == ".CXX" )\r
 +      {\r
-               GenerateGccAssemblerCommand ( sourceFilename,\r
++              GenerateGccCommand ( file.name,\r
 +                                   cppc,\r
 +                                   cflagsMacro );\r
 +              return;\r
 +      }\r
 +      else if ( extension == ".s" || extension == ".S" )\r
 +      {\r
-               GenerateNasmCommand ( sourceFilename,\r
++              GenerateGccAssemblerCommand ( file.name,\r
 +                                            cc,\r
 +                                            cflagsMacro );\r
 +              return;\r
 +      }\r
 +      else if ( extension == ".asm" || extension == ".ASM" )\r
 +      {\r
-               GenerateWindresCommand ( sourceFilename,\r
++              GenerateNasmCommand ( file.name,\r
 +                                    nasmflagsMacro );\r
 +              return;\r
 +      }\r
 +      else if ( extension == ".rc" || extension == ".RC" )\r
 +      {\r
-               GenerateWinebuildCommands ( sourceFilename );\r
-               GenerateGccCommand ( GetActualSourceFilename ( sourceFilename ),\r
++              GenerateWindresCommand ( file.name,\r
 +                                       windresflagsMacro );\r
 +              return;\r
 +      }\r
 +      else if ( extension == ".spec" || extension == ".SPEC" )\r
 +      {\r
-               GenerateWidlCommands ( sourceFilename,\r
++              GenerateWinebuildCommands ( file.name );\r
++              GenerateGccCommand ( GetActualSourceFilename ( file.name ),\r
 +                                   cc,\r
 +                                   cflagsMacro );\r
 +              return;\r
 +      }\r
 +      else if ( extension == ".idl" || extension == ".IDL" )\r
 +      {\r
-               GenerateGccCommand ( GetActualSourceFilename ( sourceFilename ),\r
++              GenerateWidlCommands ( file,\r
 +                                     widlflagsMacro );\r
-                                         sourceFilename.c_str () );\r
++              GenerateGccCommand ( GetActualSourceFilename ( file.name ),\r
 +                                   cc,\r
 +                                   cflagsMacro );\r
 +              return;\r
 +      }\r
 +\r
 +      throw InvalidOperationException ( __FILE__,\r
 +                                        __LINE__,\r
 +                                        "Unsupported filename extension '%s' in file '%s'",\r
 +                                        extension.c_str (),\r
-               string sourceFilename = files[i]->name;\r
-               GenerateCommands ( sourceFilename,\r
++                                        file.name.c_str () );\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateBuildMapCode ()\r
 +{\r
 +      fprintf ( fMakefile,\r
 +                "ifeq ($(ROS_BUILDMAP),full)\n" );\r
 +\r
 +      string mapFilename = PassThruCacheDirectory (\r
 +              GetBasename ( module.GetPath () ) + ".map",\r
 +              backend->outputDirectory );\r
 +      CLEAN_FILE ( mapFilename );\r
 +      \r
 +      fprintf ( fMakefile,\r
 +                "\t$(ECHO_OBJDUMP)\n" );\r
 +      fprintf ( fMakefile,\r
 +                "\t$(Q)${objdump} -d -S $@ > %s\n",\r
 +                mapFilename.c_str () );\r
 +\r
 +      fprintf ( fMakefile,\r
 +                "else\n" );\r
 +      fprintf ( fMakefile,\r
 +                "ifeq ($(ROS_BUILDMAP),yes)\n" );\r
 +\r
 +      fprintf ( fMakefile,\r
 +                "\t$(ECHO_NM)\n" );\r
 +      fprintf ( fMakefile,\r
 +                "\t$(Q)${nm} --numeric-sort $@ > %s\n",\r
 +                mapFilename.c_str () );\r
 +\r
 +      fprintf ( fMakefile,\r
 +                "endif\n" );\r
 +\r
 +      fprintf ( fMakefile,\r
 +                "endif\n" );\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()\r
 +{\r
 +      fprintf ( fMakefile,\r
 +                "ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );\r
 +\r
 +      string filename = module.GetPath ();\r
 +      string outputFilename = PassThruCacheDirectory (\r
 +              filename,\r
 +              backend->outputDirectory );\r
 +      string nostripFilename = PassThruCacheDirectory (\r
 +              GetBasename ( filename ) + ".nostrip" + GetExtension ( filename ),\r
 +              backend->outputDirectory );\r
 +      CLEAN_FILE ( nostripFilename );\r
 +      \r
 +      fprintf ( fMakefile,\r
 +                "\t$(ECHO_CP)\n" );\r
 +      fprintf ( fMakefile,\r
 +                        "\t${cp} %s %s 1>$(NUL)\n",\r
 +                        outputFilename.c_str (),\r
 +                nostripFilename.c_str () );\r
 +      \r
 +      fprintf ( fMakefile,\r
 +                "endif\n" );\r
 +}\r
 +\r
 +void\r
 +MergeStringVector ( const vector<string>& input,\r
 +                      vector<string>& output )\r
 +{\r
 +      int wrap_at = 25;\r
 +      string s;\r
 +      int wrap_count = -1;\r
 +      for ( size_t i = 0; i < input.size (); i++ )\r
 +      {\r
 +              if ( input[i].size () == 0 )\r
 +                      continue;\r
 +              if ( wrap_count++ == wrap_at )\r
 +              {\r
 +                      output.push_back ( s );\r
 +                      s = "";\r
 +                      wrap_count = 0;\r
 +              }\r
 +              else if ( s.size () > 0)\r
 +                      s += " ";\r
 +              s += input[i];\r
 +      }\r
 +      if ( s.length () > 0 )\r
 +              output.push_back ( s );\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GetObjectsVector ( const IfableData& data,\r
 +                                       vector<string>& objectFiles ) const\r
 +{\r
 +      for ( size_t i = 0; i < data.files.size (); i++ )\r
 +      {\r
 +              File& file = *data.files[i];\r
 +              objectFiles.push_back ( GetObjectFilename ( file.name, NULL ) );\r
 +      }\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const\r
 +{\r
 +      if ( backend->cleanAsYouGo )\r
 +      {\r
 +              vector<string> objectFiles;\r
 +              GetObjectsVector ( module.non_if_data,\r
 +                           objectFiles );\r
 +              vector<string> lines;\r
 +              MergeStringVector ( objectFiles,\r
 +                              lines );\r
 +              for ( size_t i = 0; i < lines.size (); i++ )\r
 +              {\r
 +                      fprintf ( fMakefile,\r
 +                                "\t-@${rm} %s 2>$(NUL)\n",\r
 +                                lines[i].c_str () );\r
 +              }\r
 +      }\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateLinkerCommand (\r
 +      const string& dependencies,\r
 +      const string& linker,\r
 +      const string& linkerParameters,\r
 +      const string& objectsMacro,\r
 +      const string& libsMacro )\r
 +{\r
 +      string target ( GetTargetMacro ( module ) );\r
 +      string target_folder ( GetDirectory ( GetTargetFilename ( module, NULL ) ) );\r
 +\r
 +      fprintf ( fMakefile,\r
 +              "%s: %s $(RSYM_TARGET) | %s\n",\r
 +              target.c_str (),\r
 +              dependencies.c_str (),\r
 +              target_folder.c_str () );\r
 +      fprintf ( fMakefile, "\t$(ECHO_LD)\n" );\r
 +      string targetName ( module.GetTargetName () );\r
 +      if ( module.importLibrary != NULL )\r
 +      {\r
 +              string base_tmp = ros_temp + module.name + ".base.tmp";\r
 +              CLEAN_FILE ( base_tmp );\r
 +              string junk_tmp = ros_temp + module.name + ".junk.tmp";\r
 +              CLEAN_FILE ( junk_tmp );\r
 +              string temp_exp = ros_temp + module.name + ".temp.exp";\r
 +              CLEAN_FILE ( temp_exp );\r
 +              string def_file = GetDefinitionFilename ();\r
 +\r
 +              fprintf ( fMakefile,\r
 +                        "\t%s %s -Wl,--base-file,%s -o %s %s %s %s\n",\r
 +                        linker.c_str (),\r
 +                        linkerParameters.c_str (),\r
 +                        base_tmp.c_str (),\r
 +                        junk_tmp.c_str (),\r
 +                        objectsMacro.c_str (),\r
 +                        libsMacro.c_str (),\r
 +                        GetLinkerMacro ().c_str () );\r
 +\r
 +              fprintf ( fMakefile,\r
 +                        "\t-@${rm} %s 2>$(NUL)\n",\r
 +                        junk_tmp.c_str () );\r
 +\r
 +              string killAt = module.mangledSymbols ? "" : "--kill-at";\r
 +              fprintf ( fMakefile,\r
 +                        "\t${dlltool} --dllname %s --base-file %s --def %s --output-exp %s %s\n",\r
 +                        targetName.c_str (),\r
 +                        base_tmp.c_str (),\r
 +                        def_file.c_str (),\r
 +                        temp_exp.c_str (),\r
 +                        killAt.c_str () );\r
 +\r
 +              fprintf ( fMakefile,\r
 +                        "\t-@${rm} %s 2>$(NUL)\n",\r
 +                        base_tmp.c_str () );\r
 +\r
 +              fprintf ( fMakefile,\r
 +                        "\t%s %s %s -o %s %s %s %s\n",\r
 +                        linker.c_str (),\r
 +                        linkerParameters.c_str (),\r
 +                        temp_exp.c_str (),\r
 +                        target.c_str (),\r
 +                        objectsMacro.c_str (),\r
 +                        libsMacro.c_str (),\r
 +                        GetLinkerMacro ().c_str () );\r
 +\r
 +              fprintf ( fMakefile,\r
 +                        "\t-@${rm} %s 2>$(NUL)\n",\r
 +                        temp_exp.c_str () );\r
 +              \r
 +              GenerateCleanObjectsAsYouGoCode ();\r
 +      }\r
 +      else\r
 +      {\r
 +              fprintf ( fMakefile,\r
 +                        "\t%s %s -o %s %s %s %s\n",\r
 +                        linker.c_str (),\r
 +                        linkerParameters.c_str (),\r
 +                        target.c_str (),\r
 +                        objectsMacro.c_str (),\r
 +                        libsMacro.c_str (),\r
 +                        GetLinkerMacro ().c_str () );\r
 +\r
 +              GenerateCleanObjectsAsYouGoCode ();\r
 +      }\r
 +\r
 +      GenerateBuildMapCode ();\r
 +\r
 +      GenerateBuildNonSymbolStrippedCode ();\r
 +\r
 +      fprintf ( fMakefile,\r
 +                "\t$(ECHO_RSYM)\n" );\r
 +      fprintf ( fMakefile,\r
 +                "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GeneratePhonyTarget() const\r
 +{\r
 +      string targetMacro ( GetTargetMacro(module) );\r
 +      fprintf ( fMakefile, ".PHONY: %s\n\n",\r
 +                targetMacro.c_str ());\r
 +      fprintf ( fMakefile, "%s: | %s\n",\r
 +                targetMacro.c_str (),\r
 +                GetDirectory(GetTargetFilename(module,NULL)).c_str () );\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateObjectFileTargets (\r
 +      const IfableData& data,\r
 +      const string& cc,\r
 +      const string& cppc,\r
 +      const string& cflagsMacro,\r
 +      const string& nasmflagsMacro,\r
 +      const string& windresflagsMacro,\r
 +      const string& widlflagsMacro )\r
 +{\r
 +      size_t i;\r
 +      \r
 +      const vector<File*>& files = data.files;\r
 +      for ( i = 0; i < files.size (); i++ )\r
 +      {\r
++              GenerateCommands ( *files[i],\r
 +                                 cc,\r
 +                                 cppc,\r
 +                                 cflagsMacro,\r
 +                                 nasmflagsMacro,\r
 +                                 windresflagsMacro,\r
 +                                 widlflagsMacro );\r
 +              fprintf ( fMakefile,\r
 +                        "\n" );\r
 +      }\r
 +\r
 +      const vector<If*>& ifs = data.ifs;\r
 +      for ( i = 0; i < ifs.size(); i++ )\r
 +      {\r
 +              GenerateObjectFileTargets ( ifs[i]->data,\r
 +                                          cc,\r
 +                                          cppc,\r
 +                                          cflagsMacro,\r
 +                                          nasmflagsMacro,\r
 +                                          windresflagsMacro,\r
 +                                          widlflagsMacro );\r
 +      }\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateObjectFileTargets (\r
 +      const string& cc,\r
 +      const string& cppc,\r
 +      const string& cflagsMacro,\r
 +      const string& nasmflagsMacro,\r
 +      const string& windresflagsMacro,\r
 +      const string& widlflagsMacro )\r
 +{\r
 +      if ( module.pch )\r
 +      {\r
 +              const string& pch_file = module.pch->header;\r
 +              string gch_file = pch_file + ".gch";\r
 +              CLEAN_FILE(gch_file);\r
 +              if ( use_pch )\r
 +              {\r
 +                      fprintf (\r
 +                              fMakefile,\r
 +                              "%s: %s\n",\r
 +                              gch_file.c_str(),\r
 +                              pch_file.c_str() );\r
 +                      fprintf ( fMakefile, "\t$(ECHO_PCH)\n" );\r
 +                      fprintf (\r
 +                              fMakefile,\r
 +                              "\t%s -o %s %s -g %s\n\n",\r
 +                              ( module.cplusplus ? cppc.c_str() : cc.c_str() ),\r
 +                              gch_file.c_str(),\r
 +                              cflagsMacro.c_str(),\r
 +                              pch_file.c_str() );\r
 +              }\r
 +      }\r
 +\r
 +      GenerateObjectFileTargets ( module.non_if_data,\r
 +                                  cc,\r
 +                                  cppc,\r
 +                                  cflagsMacro,\r
 +                                  nasmflagsMacro,\r
 +                                  windresflagsMacro,\r
 +                                  widlflagsMacro );\r
 +      fprintf ( fMakefile, "\n" );\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GenerateArchiveTarget ( const string& ar,\r
 +                                            const string& objs_macro ) const\r
 +{\r
 +      string archiveFilename ( GetModuleArchiveFilename () );\r
 +      \r
 +      fprintf ( fMakefile,\r
 +                "%s: %s | %s\n",\r
 +                archiveFilename.c_str (),\r
 +                objs_macro.c_str (),\r
 +                GetDirectory(archiveFilename).c_str() );\r
 +\r
 +      fprintf ( fMakefile, "\t$(ECHO_AR)\n" );\r
 +\r
 +      fprintf ( fMakefile,\r
 +                "\t%s -rc $@ %s\n",\r
 +                ar.c_str (),\r
 +                objs_macro.c_str ());\r
 +\r
 +      GenerateCleanObjectsAsYouGoCode ();\r
 +\r
 +      fprintf ( fMakefile, "\n" );\r
 +\r
 +      return archiveFilename;\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GetCFlagsMacro () const\r
 +{\r
 +      return ssprintf ( "$(%s_CFLAGS)",\r
 +                        module.name.c_str () );\r
 +}\r
 +\r
 +/*static*/ string\r
 +MingwModuleHandler::GetObjectsMacro ( const Module& module )\r
 +{\r
 +      return ssprintf ( "$(%s_OBJS)",\r
 +                        module.name.c_str () );\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GetLinkingDependenciesMacro () const\r
 +{\r
 +      return ssprintf ( "$(%s_LINKDEPS)", module.name.c_str () );\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GetLibsMacro () const\r
 +{\r
 +      return ssprintf ( "$(%s_LIBS)", module.name.c_str () );\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GetLinkerMacro () const\r
 +{\r
 +      return ssprintf ( "$(%s_LFLAGS)",\r
 +                        module.name.c_str () );\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GetModuleTargets ( const Module& module )\r
 +{\r
 +      if ( ReferenceObjects ( module ) )\r
 +              return GetObjectsMacro ( module );\r
 +      else\r
 +              return GetTargetFilename ( module, NULL );\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateObjectMacro ()\r
 +{\r
 +      objectsMacro = ssprintf ("%s_OBJS", module.name.c_str ());\r
 +\r
 +      GenerateObjectMacros (\r
 +              "=",\r
 +              module.non_if_data,\r
 +              &module.compilerFlags,\r
 +              &module.linkerFlags );\r
 +\r
 +      // future references to the macro will be to get its values\r
 +      objectsMacro = ssprintf ("$(%s)", objectsMacro.c_str ());\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateTargetMacro ()\r
 +{\r
 +      fprintf ( fMakefile,\r
 +              "%s := %s\n",\r
 +              GetTargetMacro ( module, false ).c_str (),\r
 +              GetModuleTargets ( module ).c_str () );\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateOtherMacros ()\r
 +{\r
 +      cflagsMacro = ssprintf ("%s_CFLAGS", module.name.c_str ());\r
 +      nasmflagsMacro = ssprintf ("%s_NASMFLAGS", module.name.c_str ());\r
 +      windresflagsMacro = ssprintf ("%s_RCFLAGS", module.name.c_str ());\r
 +      widlflagsMacro = ssprintf ("%s_WIDLFLAGS", module.name.c_str ());\r
 +      linkerflagsMacro = ssprintf ("%s_LFLAGS", module.name.c_str ());\r
 +      libsMacro = ssprintf("%s_LIBS", module.name.c_str ());\r
 +      linkDepsMacro = ssprintf ("%s_LINKDEPS", module.name.c_str ());\r
 +\r
 +      GenerateMacros (\r
 +              "=",\r
 +              module.non_if_data,\r
 +              &module.compilerFlags,\r
 +              &module.linkerFlags );\r
 +\r
 +      if ( module.importLibrary )\r
 +      {\r
 +              string_list s;\r
 +              const vector<File*>& files = module.non_if_data.files;\r
 +              for ( size_t i = 0; i < files.size (); i++ )\r
 +              {\r
 +                      File& file = *files[i];\r
 +                      string extension = GetExtension ( file.name );\r
 +                      if ( extension == ".spec" || extension == ".SPEC" )\r
 +                              GetSpecObjectDependencies ( s, file.name );\r
 +              }\r
 +              if ( s.size () > 0 )\r
 +              {\r
 +                      fprintf (\r
 +                              fMakefile,\r
 +                              "%s +=",\r
 +                              linkDepsMacro.c_str() );\r
 +                      for ( size_t i = 0; i < s.size(); i++ )\r
 +                              fprintf ( fMakefile,\r
 +                                        " %s",\r
 +                                        s[i].c_str () );\r
 +                      fprintf ( fMakefile, "\n" );\r
 +              }\r
 +      }\r
 +\r
 +      string globalCflags = "-g";\r
 +      if ( backend->usePipe )\r
 +              globalCflags += " -pipe";\r
 +      if ( !module.enableWarnings )\r
 +              globalCflags += " -Werror";\r
 +      \r
 +      fprintf (\r
 +              fMakefile,\r
 +              "%s += $(PROJECT_CFLAGS) %s\n",\r
 +              cflagsMacro.c_str (),\r
 +              globalCflags.c_str () );\r
 +\r
 +      fprintf (\r
 +              fMakefile,\r
 +              "%s += $(PROJECT_RCFLAGS)\n",\r
 +              windresflagsMacro.c_str () );\r
 +\r
 +      fprintf (\r
 +              fMakefile,\r
 +              "%s += $(PROJECT_WIDLFLAGS)\n",\r
 +              widlflagsMacro.c_str () );\r
 +\r
 +      fprintf (\r
 +              fMakefile,\r
 +              "%s_LFLAGS += $(PROJECT_LFLAGS) -g\n",\r
 +              module.name.c_str () );\r
 +\r
 +      fprintf (\r
 +              fMakefile,\r
 +              "%s += $(%s)\n",\r
 +              linkDepsMacro.c_str (),\r
 +              libsMacro.c_str () );\r
 +\r
 +      string cflags = TypeSpecificCFlags();\r
 +      if ( cflags.size() > 0 )\r
 +      {\r
 +              fprintf ( fMakefile,\r
 +                        "%s += %s\n\n",\r
 +                        cflagsMacro.c_str (),\r
 +                        cflags.c_str () );\r
 +      }\r
 +\r
 +      string nasmflags = TypeSpecificNasmFlags();\r
 +      if ( nasmflags.size () > 0 )\r
 +      {\r
 +              fprintf ( fMakefile,\r
 +                        "%s += %s\n\n",\r
 +                        nasmflagsMacro.c_str (),\r
 +                        nasmflags.c_str () );\r
 +      }\r
 +\r
 +      string linkerflags = TypeSpecificLinkerFlags();\r
 +      if ( linkerflags.size() > 0 )\r
 +      {\r
 +              fprintf ( fMakefile,\r
 +                        "%s += %s\n\n",\r
 +                        linkerflagsMacro.c_str (),\r
 +                        linkerflags.c_str () );\r
 +      }\r
 +\r
 +      fprintf ( fMakefile, "\n\n" );\r
 +\r
 +      // future references to the macros will be to get their values\r
 +      cflagsMacro = ssprintf ("$(%s)", cflagsMacro.c_str ());\r
 +      nasmflagsMacro = ssprintf ("$(%s)", nasmflagsMacro.c_str ());\r
 +      widlflagsMacro = ssprintf ("$(%s)", widlflagsMacro.c_str ());\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateRules ()\r
 +{\r
 +      string cc = ( module.host == HostTrue ? "${host_gcc}" : "${gcc}" );\r
 +      string cppc = ( module.host == HostTrue ? "${host_gpp}" : "${gpp}" );\r
 +      string ar = ( module.host == HostTrue ? "${host_ar}" : "${ar}" );\r
 +\r
 +      string targetMacro = GetTargetMacro ( module );\r
 +\r
 +      CLEAN_FILE ( targetMacro );\r
 +\r
 +      // generate phony target for module name\r
 +      fprintf ( fMakefile, ".PHONY: %s\n",\r
 +              module.name.c_str () );\r
 +      fprintf ( fMakefile, "%s: %s\n\n",\r
 +              module.name.c_str (),\r
 +              GetTargetMacro ( module ).c_str () );\r
 +\r
 +      if ( !ReferenceObjects ( module ) )\r
 +      {\r
 +              string ar_target ( GenerateArchiveTarget ( ar, objectsMacro ) );\r
 +              if ( targetMacro != ar_target )\r
 +              {\r
 +                      CLEAN_FILE ( ar_target );\r
 +              }\r
 +      }\r
 +\r
 +      GenerateObjectFileTargets ( cc,\r
 +                                                              cppc,\r
 +                                                              cflagsMacro,\r
 +                                                              nasmflagsMacro,\r
 +                                                              windresflagsMacro,\r
 +                                                          widlflagsMacro );\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GetInvocationDependencies (\r
 +      const Module& module,\r
 +      string_list& dependencies )\r
 +{\r
 +      for ( size_t i = 0; i < module.invocations.size (); i++ )\r
 +      {\r
 +              Invoke& invoke = *module.invocations[i];\r
 +              if ( invoke.invokeModule == &module )\r
 +                      /* Protect against circular dependencies */\r
 +                      continue;\r
 +              invoke.GetTargets ( dependencies );\r
 +      }\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateInvocations () const\r
 +{\r
 +      if ( module.invocations.size () == 0 )\r
 +              return;\r
 +      \r
 +      size_t iend = module.invocations.size ();\r
 +      for ( size_t i = 0; i < iend; i++ )\r
 +      {\r
 +              const Invoke& invoke = *module.invocations[i];\r
 +\r
 +              if ( invoke.invokeModule->type != BuildTool )\r
 +              {\r
 +                      throw InvalidBuildFileException ( module.node.location,\r
 +                                                        "Only modules of type buildtool can be invoked." );\r
 +              }\r
 +\r
 +              string invokeTarget = module.GetInvocationTarget ( i );\r
 +              string_list invoke_targets;\r
 +              assert ( invoke_targets.size() );\r
 +              invoke.GetTargets ( invoke_targets );\r
 +              fprintf ( fMakefile,\r
 +                        ".PHONY: %s\n\n",\r
 +                        invokeTarget.c_str () );\r
 +              fprintf ( fMakefile,\r
 +                        "%s:",\r
 +                        invokeTarget.c_str () );\r
 +              size_t j, jend = invoke_targets.size();\r
 +              for ( j = 0; j < jend; j++ )\r
 +              {\r
 +                      fprintf ( fMakefile,\r
 +                                " %s",\r
 +                                invoke_targets[i].c_str () );\r
 +              }\r
 +              fprintf ( fMakefile, "\n\n%s", invoke_targets[0].c_str () );\r
 +              for ( j = 1; j < jend; j++ )\r
 +                      fprintf ( fMakefile,\r
 +                                " %s",\r
 +                                invoke_targets[i].c_str () );\r
 +              fprintf ( fMakefile,\r
 +                        ": %s\n",\r
 +                        NormalizeFilename ( invoke.invokeModule->GetPath () ).c_str () );\r
 +              fprintf ( fMakefile, "\t$(ECHO_INVOKE)\n" );\r
 +              fprintf ( fMakefile,\r
 +                        "\t%s %s\n\n",\r
 +                        NormalizeFilename ( invoke.invokeModule->GetPath () ).c_str (),\r
 +                        invoke.GetParameters ().c_str () );\r
 +      }\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GetPreconditionDependenciesName () const\r
 +{\r
 +      return module.name + "_precondition";\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GetDefaultDependencies (\r
 +      string_list& dependencies ) const\r
 +{\r
 +      /* Avoid circular dependency */\r
 +      if ( module.type != BuildTool\r
 +              && module.name != "zlib"\r
 +              && module.name != "hostzlib" )\r
 +\r
 +              dependencies.push_back ( "$(INIT)" );\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GeneratePreconditionDependencies ()\r
 +{\r
 +      string preconditionDependenciesName = GetPreconditionDependenciesName ();\r
 +      string_list sourceFilenames;\r
 +      GetSourceFilenamesWithoutGeneratedFiles ( sourceFilenames );\r
 +      string_list dependencies;\r
 +      GetDefaultDependencies ( dependencies );\r
 +      GetModuleDependencies ( dependencies );\r
 +\r
 +      GetInvocationDependencies ( module, dependencies );\r
 +      \r
 +      if ( dependencies.size() )\r
 +      {\r
 +              fprintf ( fMakefile,\r
 +                        "%s =",\r
 +                        preconditionDependenciesName.c_str () );\r
 +              for ( size_t i = 0; i < dependencies.size(); i++ )\r
 +                      fprintf ( fMakefile,\r
 +                                " %s",\r
 +                                dependencies[i].c_str () );\r
 +              fprintf ( fMakefile, "\n\n" );\r
 +      }\r
 +\r
 +      for ( size_t i = 0; i < sourceFilenames.size(); i++ )\r
 +      {\r
 +              fprintf ( fMakefile,\r
 +                        "%s: ${%s}\n",\r
 +                        sourceFilenames[i].c_str(),\r
 +                        preconditionDependenciesName.c_str ());\r
 +      }\r
 +      fprintf ( fMakefile, "\n" );\r
 +}\r
 +\r
 +bool\r
 +MingwModuleHandler::IsWineModule () const\r
 +{\r
 +      if ( module.importLibrary == NULL)\r
 +              return false;\r
 +\r
 +      size_t index = module.importLibrary->definition.rfind ( ".spec.def" );\r
 +      return ( index != string::npos );\r
 +}\r
 +\r
 +string\r
 +MingwModuleHandler::GetDefinitionFilename () const\r
 +{\r
 +      string defFilename = module.GetBasePath () + SSEP + module.importLibrary->definition;\r
 +      if ( IsWineModule () )\r
 +              return PassThruCacheDirectory ( NormalizeFilename ( defFilename ),\r
 +                                              backend->intermediateDirectory );\r
 +      else\r
 +              return defFilename;\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()\r
 +{\r
 +      if ( module.importLibrary != NULL )\r
 +      {\r
 +              string library_target (\r
 +                      GetImportLibraryFilename ( module, &clean_files ) );\r
 +\r
 +              string_list deps;\r
 +              GetDefinitionDependencies ( deps );\r
 +\r
 +              fprintf ( fMakefile, "# IMPORT LIBRARY RULE:\n" );\r
 +\r
 +              fprintf ( fMakefile, "%s:",\r
 +                        library_target.c_str () );\r
 +\r
 +              size_t i, iend = deps.size();\r
 +              for ( i = 0; i < iend; i++ )\r
 +                      fprintf ( fMakefile, " %s",\r
 +                                deps[i].c_str () );\r
 +\r
 +              fprintf ( fMakefile, " | %s\n",\r
 +                        GetDirectory ( GetTargetFilename ( module, NULL ) ).c_str () );\r
 +\r
 +              fprintf ( fMakefile, "\t$(ECHO_DLLTOOL)\n" );\r
 +\r
 +              string killAt = module.mangledSymbols ? "" : "--kill-at";\r
 +              fprintf ( fMakefile,\r
 +                        "\t${dlltool} --dllname %s --def %s --output-lib %s %s\n\n",\r
 +                        module.GetTargetName ().c_str (),\r
 +                        GetDefinitionFilename ().c_str (),\r
 +                        library_target.c_str (),\r
 +                        killAt.c_str () );\r
 +      }\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GetSpecObjectDependencies (\r
 +      string_list& dependencies,\r
 +      const string& filename ) const\r
 +{\r
 +      string basename = GetBasename ( filename );\r
 +      string defDependency = PassThruCacheDirectory (\r
 +              NormalizeFilename ( basename + ".spec.def" ),\r
 +              backend->intermediateDirectory );\r
 +      dependencies.push_back ( defDependency );\r
 +      string stubsDependency = PassThruCacheDirectory (\r
 +              NormalizeFilename ( basename + ".stubs.c" ),\r
 +              backend->intermediateDirectory );\r
 +      dependencies.push_back ( stubsDependency );\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GetWidlObjectDependencies (\r
 +      string_list& dependencies,\r
 +      const string& filename ) const\r
 +{\r
 +      string basename = GetBasename ( filename );\r
 +      string serverDependency = PassThruCacheDirectory (\r
 +              NormalizeFilename ( basename + "_s.c" ),\r
 +              backend->intermediateDirectory );\r
 +      dependencies.push_back ( serverDependency );\r
 +}\r
 +\r
 +void\r
 +MingwModuleHandler::GetDefinitionDependencies (\r
 +      string_list& dependencies ) const\r
 +{\r
 +      string dkNkmLibNoFixup = "dk/nkm/lib";\r
 +      const vector<File*>& files = module.non_if_data.files;\r
 +      for ( size_t i = 0; i < files.size (); i++ )\r
 +      {\r
 +              File& file = *files[i];\r
 +              string extension = GetExtension ( file.name );\r
 +              if ( extension == ".spec" || extension == ".SPEC" )\r
 +              {\r
 +                      GetSpecObjectDependencies ( dependencies, file.name );\r
 +              }\r
 +              if ( extension == ".idl" || extension == ".IDL" )\r
 +              {\r
 +                      GetWidlObjectDependencies ( dependencies, file.name );\r
 +              }\r
 +      }\r
 +}\r
 +\r
 +\r
 +MingwBuildToolModuleHandler::MingwBuildToolModuleHandler ( const Module& module_ )\r
 +      : MingwModuleHandler ( module_ )\r
 +{\r
 +}\r
 +\r
 +void\r
 +MingwBuildToolModuleHandler::Process ()\r
 +{\r
 +      GenerateBuildToolModuleTarget ();\r
 +}\r
 +\r
 +void\r
 +MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ()\r
 +{\r
 +      string targetMacro ( GetTargetMacro (module) );\r
 +      string objectsMacro = GetObjectsMacro ( module );\r
 +      string linkDepsMacro = GetLinkingDependenciesMacro ();\r
 +      string libsMacro = GetLibsMacro ();\r
 +\r
 +      GenerateRules ();\r
 +\r
 +      string linker;\r
 +      if ( module.cplusplus )\r
 +              linker = "${host_gpp}";\r
 +      else\r
 +              linker = "${host_gcc}";\r
 +      \r
 +      fprintf ( fMakefile, "%s: %s %s | %s\n",\r
 +                targetMacro.c_str (),\r
 +                objectsMacro.c_str (),\r
 +                linkDepsMacro.c_str (),\r
 +                GetDirectory(GetTargetFilename(module,NULL)).c_str () );\r
 +      fprintf ( fMakefile, "\t$(ECHO_LD)\n" );\r
 +      fprintf ( fMakefile,\r
 +                "\t%s %s -o $@ %s %s\n\n",\r
 +                linker.c_str (),\r
 +                GetLinkerMacro ().c_str (),\r
 +                objectsMacro.c_str (),\r
 +                libsMacro.c_str () );\r
 +}\r
 +\r
 +\r
 +MingwKernelModuleHandler::MingwKernelModuleHandler (\r
 +      const Module& module_ )\r
 +\r
 +      : MingwModuleHandler ( module_ )\r
 +{\r
 +}\r
 +\r
 +void\r
 +MingwKernelModuleHandler::Process ()\r
 +{\r
 +      GenerateKernelModuleTarget ();\r
 +}\r
 +\r
 +void\r
 +MingwKernelModuleHandler::GenerateKernelModuleTarget ()\r
 +{\r
 +      string targetName ( module.GetTargetName () ); // i.e. "ntoskrnl.exe"\r
 +      string targetMacro ( GetTargetMacro ( module ) ); // i.e. "$(NTOSKRNL_TARGET)"\r
 +      string workingDirectory = GetWorkingDirectory ();\r
 +      string objectsMacro = GetObjectsMacro ( module );\r
 +      string linkDepsMacro = GetLinkingDependenciesMacro ();\r
 +      string libsMacro = GetLibsMacro ();\r
 +      string base_tmp = ros_temp + module.name + ".base.tmp";\r
 +      CLEAN_FILE ( base_tmp );\r
 +      string junk_tmp = ros_temp + module.name + ".junk.tmp";\r
 +      CLEAN_FILE ( junk_tmp );\r
 +      string temp_exp = ros_temp + module.name + ".temp.exp";\r
 +      CLEAN_FILE ( temp_exp );\r
 +      string gccOptions = ssprintf ("-Wl,-T,%s" SSEP "ntoskrnl.lnk -Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",\r
 +                                    module.GetBasePath ().c_str (),\r
 +                                    module.entrypoint.c_str (),\r
 +                                    module.baseaddress.c_str () );\r
 +\r
 +      GenerateRules ();\r
 +\r
 +      GenerateImportLibraryTargetIfNeeded ();\r
 +\r
 +      fprintf ( fMakefile, "%s: %s %s $(RSYM_TARGET) | %s\n",\r
 +                targetMacro.c_str (),\r
 +                objectsMacro.c_str (),\r
 +                linkDepsMacro.c_str (),\r
 +                GetDirectory(GetTargetFilename(module,NULL)).c_str () );\r
 +      fprintf ( fMakefile, "\t$(ECHO_LD)\n" );\r
 +      fprintf ( fMakefile,\r
 +                "\t${gcc} %s %s -Wl,--base-file,%s -o %s %s %s\n",\r
 +                GetLinkerMacro ().c_str (),\r
 +                gccOptions.c_str (),\r
 +                base_tmp.c_str (),\r
 +                junk_tmp.c_str (),\r
 +                objectsMacro.c_str (),\r
 +                linkDepsMacro.c_str () );\r
 +      fprintf ( fMakefile,\r
 +                "\t-@${rm} %s 2>$(NUL)\n",\r
 +                junk_tmp.c_str () );\r
 +      string killAt = module.mangledSymbols ? "" : "--kill-at";\r
 +      fprintf ( fMakefile,\r
 +                "\t${dlltool} --dllname %s --base-file %s --def ntoskrnl/ntoskrnl.def --output-exp %s %s\n",\r
 +                targetName.c_str (),\r
 +                base_tmp.c_str (),\r
 +                temp_exp.c_str (),\r
 +                killAt.c_str () );\r
 +      fprintf ( fMakefile,\r
 +                "\t-@${rm} %s 2>$(NUL)\n",\r
 +                base_tmp.c_str () );\r
 +      fprintf ( fMakefile,\r
 +                "\t${gcc} %s %s -Wl,%s -o $@ %s %s\n",\r
 +                GetLinkerMacro ().c_str (),\r
 +                gccOptions.c_str (),\r
 +                temp_exp.c_str (),\r
 +                objectsMacro.c_str (),\r
 +                linkDepsMacro.c_str () );\r
 +      fprintf ( fMakefile,\r
 +                "\t-@${rm} %s 2>$(NUL)\n",\r
 +                temp_exp.c_str () );\r
 +      fprintf ( fMakefile, "\t$(ECHO_RSYM)\n" );\r
 +      fprintf ( fMakefile,\r
 +                "\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );\r
 +}\r
 +\r
 +\r
 +MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler (\r
 +      const Module& module_ )\r
 +\r
 +      : MingwModuleHandler ( module_ )\r
 +{\r
 +}\r
 +\r
 +void\r
 +MingwStaticLibraryModuleHandler::Process ()\r
 +{\r
 +      GenerateStaticLibraryModuleTarget ();\r
 +}\r
 +\r
 +void\r
 +MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ()\r
 +{\r
 +      GenerateRules ();\r
 +}\r
 +\r
 +\r
 +MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler (\r
 +      const Module& module_ )\r
 +\r
 +      : MingwModuleHandler ( module_ )\r
 +{\r
 +}\r
 +\r
 +void\r
 +MingwObjectLibraryModuleHandler::Process ()\r
 +{\r
 +      GenerateObjectLibraryModuleTarget ();\r
 +}\r
 +\r
 +void\r
 +MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ()\r
 +{\r
 +      GenerateRules ();\r
 +}\r
 +\r
 +\r
 +MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (\r
 +      const Module& module_ )\r
 +\r
 +      : MingwModuleHandler ( module_ )\r
 +{\r
 +}\r
 +\r
 +void\r
 +MingwKernelModeDLLModuleHandler::Process ()\r
 +{\r
 +      GenerateKernelModeDLLModuleTarget ();\r
 +}\r
 +\r
 +void\r
 +MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()\r
 +{\r
 +      string targetMacro ( GetTargetMacro ( module ) );\r
 +      string workingDirectory = GetWorkingDirectory ( );\r
 +      string objectsMacro = GetObjectsMacro ( module );\r
 +      string linkDepsMacro = GetLinkingDependenciesMacro ();\r
 +      string libsMacro = GetLibsMacro ();\r
 +\r
 +      GenerateImportLibraryTargetIfNeeded ();\r
 +\r
 +      if ( module.non_if_data.files.size () > 0 )\r
 +      {\r
 +              GenerateRules ();\r
 +\r
 +              string dependencies = linkDepsMacro + " " + objectsMacro;\r
 +\r
 +              string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",\r
 +                                                   module.entrypoint.c_str (),\r
 +                                                   module.baseaddress.c_str () );\r
 +              GenerateLinkerCommand ( dependencies,\r
 +                                      "${gcc}",\r
 +                                      linkerParameters,\r
 +                                      objectsMacro,\r
 +                                      libsMacro );\r
 +      }\r
 +      else\r
 +      {\r
 +              GeneratePhonyTarget();\r
 +      }\r
 +}\r
 +\r
 +\r
 +MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler (\r
 +      const Module& module_ )\r
 +\r
 +      : MingwModuleHandler ( module_ )\r
 +{\r
 +}\r
 +\r
 +void\r
 +MingwKernelModeDriverModuleHandler::Process ()\r
 +{\r
 +      GenerateKernelModeDriverModuleTarget ();\r
 +}\r
 +\r
 +\r
 +void\r
 +MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ()\r
 +{\r
 +      string targetMacro ( GetTargetMacro (module) );\r
 +      string workingDirectory = GetWorkingDirectory ();\r
 +      string objectsMacro = GetObjectsMacro ( module );\r
 +      string linkDepsMacro = GetLinkingDependenciesMacro ();\r
 +      string libsMacro = GetLibsMacro ();\r
 +\r
 +      GenerateImportLibraryTargetIfNeeded ();\r
 +\r
 +      if ( module.non_if_data.files.size () > 0 )\r
 +      {\r
 +              GenerateRules ();\r
 +\r
 +              string dependencies = linkDepsMacro + " " + objectsMacro;\r
 +\r
 +              string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",\r
 +                                                   module.entrypoint.c_str (),\r
 +                                                   module.baseaddress.c_str () );\r
 +              GenerateLinkerCommand ( dependencies,\r
 +                                      "${gcc}",\r
 +                                      linkerParameters,\r
 +                                      objectsMacro,\r
 +                                      libsMacro );\r
 +      }\r
 +      else\r
 +      {\r
 +              GeneratePhonyTarget();\r
 +      }\r
 +}\r
 +\r
 +\r
 +MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (\r
 +      const Module& module_ )\r
 +\r
 +      : MingwModuleHandler ( module_ )\r
 +{\r
 +}\r
 +\r
 +void\r
 +MingwNativeDLLModuleHandler::Process ()\r
 +{\r
 +      GenerateNativeDLLModuleTarget ();\r
 +}\r
 +\r
 +void\r
 +MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()\r
 +{\r
 +      string targetMacro ( GetTargetMacro (module) );\r
 +      string workingDirectory = GetWorkingDirectory ( );\r
 +      string objectsMacro = GetObjectsMacro ( module );\r
 +      string linkDepsMacro = GetLinkingDependenciesMacro ();\r
 +      string libsMacro = GetLibsMacro ();\r
 +      \r
 +      GenerateImportLibraryTargetIfNeeded ();\r
 +\r
 +      if ( module.non_if_data.files.size () > 0 )\r
 +      {\r
 +              GenerateRules ();\r
 +\r
 +              string dependencies = linkDepsMacro + " " + objectsMacro;\r
 +\r
 +              string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll",\r
 +                                                   module.entrypoint.c_str (),\r
 +                                                   module.baseaddress.c_str () );\r
 +              GenerateLinkerCommand ( dependencies,\r
 +                                      "${gcc}",\r
 +                                      linkerParameters,\r
 +                                      objectsMacro,\r
 +                                      libsMacro );\r
 +      }\r
 +      else\r
 +      {\r
 +              GeneratePhonyTarget();\r
 +      }\r
 +}\r
 +\r
 +\r
 +MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (\r
 +      const Module& module_ )\r
 +\r
 +      : MingwModuleHandler ( module_ )\r
 +{\r
 +}\r
 +\r
 +void\r
 +MingwNativeCUIModuleHandler::Process ()\r
 +{\r
 +      GenerateNativeCUIModuleTarget ();\r
 +}\r
 +\r
 +void\r
 +MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()\r
 +{\r
 +      string targetMacro ( GetTargetMacro (module) );\r
 +      string workingDirectory = GetWorkingDirectory ( );\r
 +      string objectsMacro = GetObjectsMacro ( module );\r
 +      string linkDepsMacro = GetLinkingDependenciesMacro ();\r
 +      string libsMacro = GetLibsMacro ();\r
 +      \r
 +      GenerateImportLibraryTargetIfNeeded ();\r
 +\r
 +      if ( module.non_if_data.files.size () > 0 )\r
 +      {\r
 +              GenerateRules ();\r
 +\r
 +              string dependencies = linkDepsMacro + " " + objectsMacro;\r
 +\r
 +              string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib",\r
 +                                                   module.entrypoint.c_str (),\r
 +                                                   module.baseaddress.c_str () );\r
 +              GenerateLinkerCommand ( dependencies,\r
 +                                      "${gcc}",\r
 +                                      linkerParameters,\r
 +                                      objectsMacro,\r
 +                                      libsMacro );\r
 +      }\r
 +      else\r
 +      {\r
 +              GeneratePhonyTarget();\r
 +      }\r
 +}\r
 +\r
 +\r
 +MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (\r
 +      const Module& module_ )\r
 +\r
 +      : MingwModuleHandler ( module_ )\r
 +{\r
 +}\r
 +\r
 +void\r
 +MingwWin32DLLModuleHandler::Process ()\r
 +{\r
 +      GenerateExtractWineDLLResourcesTarget ();\r
 +      GenerateWin32DLLModuleTarget ();\r
 +}\r
 +\r
 +void\r
 +MingwWin32DLLModuleHandler::GenerateExtractWineDLLResourcesTarget ()\r
 +{\r
 +      fprintf ( fMakefile, ".PHONY: %s_extractresources\n\n",\r
 +                module.name.c_str () );\r
 +      fprintf ( fMakefile, "%s_extractresources: $(BIN2RES_TARGET)\n",\r
 +                module.name.c_str () );\r
 +      const vector<File*>& files = module.non_if_data.files;\r
 +      for ( size_t i = 0; i < files.size (); i++ )\r
 +      {\r
 +              File& file = *files[i];\r
 +              string extension = GetExtension ( file.name );\r
 +              if ( extension == ".rc" || extension == ".RC" )\r
 +              {\r
 +                      string resource = NormalizeFilename ( file.name );\r
 +                      fprintf ( fMakefile, "\t$(ECHO_BIN2RES)\n" );\r
 +                      fprintf ( fMakefile, "\t@:echo ${bin2res} -f -x %s\n",\r
 +                                resource.c_str () );\r
 +              }\r
 +      }\r
 +      fprintf ( fMakefile, "\n");\r
 +}\r
 +\r
 +void\r
 +MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()\r
 +{\r
 +      string targetMacro ( GetTargetMacro (module) );\r
 +      string workingDirectory = GetWorkingDirectory ( );\r
 +      string objectsMacro = GetObjectsMacro ( module );\r
 +      string linkDepsMacro = GetLinkingDependenciesMacro ();\r
 +      string libsMacro = GetLibsMacro ();\r
 +\r
 +      GenerateImportLibraryTargetIfNeeded ();\r
 +\r
 +      if ( module.non_if_data.files.size () > 0 )\r
 +      {\r
 +              GenerateRules ();\r
 +\r
 +              string dependencies = linkDepsMacro + " " + objectsMacro;\r
 +\r
 +              string linker;\r
 +              if ( module.cplusplus )\r
 +                      linker = "${gpp}";\r
 +              else\r
 +                      linker = "${gcc}";\r
 +\r
 +              string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -mdll",\r
 +                                                   module.entrypoint.c_str (),\r
 +                                                   module.baseaddress.c_str () );\r
 +              GenerateLinkerCommand ( dependencies,\r
 +                                      linker,\r
 +                                      linkerParameters,\r
 +                                      objectsMacro,\r
 +                                      libsMacro );\r
 +      }\r
 +      else\r
 +      {\r
 +              GeneratePhonyTarget();\r
 +      }\r
 +}\r
 +\r
 +\r
 +MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (\r
 +      const Module& module_ )\r
 +\r
 +      : MingwModuleHandler ( module_ )\r
 +{\r
 +}\r
 +\r
 +void\r
 +MingwWin32CUIModuleHandler::Process ()\r
 +{\r
 +      GenerateWin32CUIModuleTarget ();\r
 +}\r
 +\r
 +void\r
 +MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()\r
 +{\r
 +      string targetMacro ( GetTargetMacro (module) );\r
 +      string workingDirectory = GetWorkingDirectory ( );\r
 +      string objectsMacro = GetObjectsMacro ( module );\r
 +      string linkDepsMacro = GetLinkingDependenciesMacro ();\r
 +      string libsMacro = GetLibsMacro ();\r
 +\r
 +      GenerateImportLibraryTargetIfNeeded ();\r
 +\r
 +      if ( module.non_if_data.files.size () > 0 )\r
 +      {\r
 +              GenerateRules ();\r
 +\r
 +              string dependencies = linkDepsMacro + " " + objectsMacro;\r
 +\r
 +              string linker;\r
 +              if ( module.cplusplus )\r
 +                      linker = "${gpp}";\r
 +              else\r
 +                      linker = "${gcc}";\r
 +\r
 +              string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",\r
 +                                                   module.entrypoint.c_str (),\r
 +                                                   module.baseaddress.c_str () );\r
 +              GenerateLinkerCommand ( dependencies,\r
 +                                      linker,\r
 +                                      linkerParameters,\r
 +                                      objectsMacro,\r
 +                                      libsMacro );\r
 +      }\r
 +      else\r
 +      {\r
 +              GeneratePhonyTarget();\r
 +      }\r
 +}\r
 +\r
 +\r
 +MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (\r
 +      const Module& module_ )\r
 +\r
 +      : MingwModuleHandler ( module_ )\r
 +{\r
 +}\r
 +\r
 +void\r
 +MingwWin32GUIModuleHandler::Process ()\r
 +{\r
 +      GenerateWin32GUIModuleTarget ();\r
 +}\r
 +\r
 +void\r
 +MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()\r
 +{\r
 +      string targetMacro ( GetTargetMacro (module) );\r
 +      string workingDirectory = GetWorkingDirectory ( );\r
 +      string objectsMacro = GetObjectsMacro ( module );\r
 +      string linkDepsMacro = GetLinkingDependenciesMacro ();\r
 +      string libsMacro = GetLibsMacro ();\r
 +\r
 +      GenerateImportLibraryTargetIfNeeded ();\r
 +\r
 +      if ( module.non_if_data.files.size () > 0 )\r
 +      {\r
 +              GenerateRules ();\r
 +\r
 +              string dependencies = linkDepsMacro + " " + objectsMacro;\r
 +\r
 +              string linker;\r
 +              if ( module.cplusplus )\r
 +                      linker = "${gpp}";\r
 +              else\r
 +                      linker = "${gcc}";\r
 +\r
 +              string linkerParameters = ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",\r
 +                                                   module.entrypoint.c_str (),\r
 +                                                   module.baseaddress.c_str () );\r
 +              GenerateLinkerCommand ( dependencies,\r
 +                                      linker,\r
 +                                      linkerParameters,\r
 +                                      objectsMacro,\r
 +                                      libsMacro );\r
 +      }\r
 +      else\r
 +      {\r
 +              GeneratePhonyTarget();\r
 +      }\r
 +}\r
 +\r
 +\r
 +MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (\r
 +      const Module& module_ )\r
 +\r
 +      : MingwModuleHandler ( module_ )\r
 +{\r
 +}\r
 +\r
 +void\r
 +MingwBootLoaderModuleHandler::Process ()\r
 +{\r
 +      GenerateBootLoaderModuleTarget ();\r
 +}\r
 +\r
 +void\r
 +MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()\r
 +{\r
 +      string targetName ( module.GetTargetName () );\r
 +      string targetMacro ( GetTargetMacro (module) );\r
 +      string workingDirectory = GetWorkingDirectory ();\r
 +      string junk_tmp = ros_temp + module.name + ".junk.tmp";\r
 +      CLEAN_FILE ( junk_tmp );\r
 +      string objectsMacro = GetObjectsMacro ( module );\r
 +      string linkDepsMacro = GetLinkingDependenciesMacro ();\r
 +      string libsMacro = GetLibsMacro ();\r
 +\r
 +      GenerateRules ();\r
 +\r
 +      fprintf ( fMakefile, "%s: %s %s | %s\n",\r
 +                targetMacro.c_str (),\r
 +                objectsMacro.c_str (),\r
 +                linkDepsMacro.c_str (),\r
 +                GetDirectory(GetTargetFilename(module,NULL)).c_str () );\r
 +\r
 +      fprintf ( fMakefile, "\t$(ECHO_LD)\n" );\r
 +\r
 +      fprintf ( fMakefile,\r
 +                "\t${ld} %s -N -Ttext=0x8000 -o %s %s %s\n",\r
 +                GetLinkerMacro ().c_str (),\r
 +                junk_tmp.c_str (),\r
 +                objectsMacro.c_str (),\r
 +                linkDepsMacro.c_str () );\r
 +      fprintf ( fMakefile,\r
 +                "\t${objcopy} -O binary %s $@\n",\r
 +                junk_tmp.c_str () );\r
 +      fprintf ( fMakefile,\r
 +                "\t-@${rm} %s 2>$(NUL)\n",\r
 +                junk_tmp.c_str () );\r
 +}\r
 +\r
 +\r
 +MingwBootSectorModuleHandler::MingwBootSectorModuleHandler (\r
 +      const Module& module_ )\r
 +\r
 +      : MingwModuleHandler ( module_ )\r
 +{\r
 +}\r
 +\r
 +void\r
 +MingwBootSectorModuleHandler::Process ()\r
 +{\r
 +      GenerateBootSectorModuleTarget ();\r
 +}\r
 +\r
 +void\r
 +MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ()\r
 +{\r
 +      string objectsMacro = GetObjectsMacro ( module );\r
 +\r
 +      GenerateRules ();\r
 +\r
 +      fprintf ( fMakefile, ".PHONY: %s\n\n",\r
 +                module.name.c_str ());\r
 +      fprintf ( fMakefile,\r
 +                "%s: %s\n",\r
 +                module.name.c_str (),\r
 +                objectsMacro.c_str () );\r
 +}\r
 +\r
 +\r
 +MingwIsoModuleHandler::MingwIsoModuleHandler (\r
 +      const Module& module_ )\r
 +\r
 +      : MingwModuleHandler ( module_ )\r
 +{\r
 +}\r
 +\r
 +void\r
 +MingwIsoModuleHandler::Process ()\r
 +{\r
 +      GenerateIsoModuleTarget ();\r
 +}\r
 +\r
 +void\r
 +MingwIsoModuleHandler::OutputBootstrapfileCopyCommands (\r
 +      const string& bootcdDirectory )\r
 +{\r
 +      for ( size_t i = 0; i < module.project.modules.size (); i++ )\r
 +      {\r
 +              const Module& m = *module.project.modules[i];\r
 +              if ( m.bootstrap != NULL )\r
 +              {\r
 +                      string sourceFilename = PassThruCacheDirectory (\r
 +                              NormalizeFilename ( m.GetPath () ),\r
 +                              backend->outputDirectory );\r
 +                      string targetFilenameNoFixup ( bootcdDirectory + SSEP + m.bootstrap->base + SSEP + m.bootstrap->nameoncd );\r
 +                      string targetFilename = MingwModuleHandler::PassThruCacheDirectory (\r
 +                              NormalizeFilename ( targetFilenameNoFixup ),\r
 +                              backend->outputDirectory );\r
 +                      fprintf ( fMakefile,\r
 +                                "\t$(ECHO_CP)\n" );\r
 +                      fprintf ( fMakefile,\r
 +                                "\t${cp} %s %s 1>$(NUL)\n",\r
 +                                sourceFilename.c_str (),\r
 +                                targetFilename.c_str () );\r
 +              }\r
 +      }\r
 +}\r
 +\r
 +void\r
 +MingwIsoModuleHandler::OutputCdfileCopyCommands (\r
 +      const string& bootcdDirectory )\r
 +{\r
 +      for ( size_t i = 0; i < module.project.cdfiles.size (); i++ )\r
 +      {\r
 +              const CDFile& cdfile = *module.project.cdfiles[i];\r
 +              string targetFilenameNoFixup = bootcdDirectory + SSEP + cdfile.base + SSEP + cdfile.nameoncd;\r
 +              string targetFilename = MingwModuleHandler::PassThruCacheDirectory (\r
 +                      NormalizeFilename ( targetFilenameNoFixup ),\r
 +                      backend->outputDirectory );\r
 +              fprintf ( fMakefile,\r
 +                        "\t$(ECHO_CP)\n" );\r
 +              fprintf ( fMakefile,\r
 +                        "\t${cp} %s %s 1>$(NUL)\n",\r
 +                        cdfile.GetPath ().c_str (),\r
 +                        targetFilename.c_str () );\r
 +      }\r
 +}\r
 +\r
 +string\r
 +MingwIsoModuleHandler::GetBootstrapCdDirectories ( const string& bootcdDirectory )\r
 +{\r
 +      string directories;\r
 +      for ( size_t i = 0; i < module.project.modules.size (); i++ )\r
 +      {\r
 +              const Module& m = *module.project.modules[i];\r
 +              if ( m.bootstrap != NULL )\r
 +              {\r
 +                      string targetDirectory ( bootcdDirectory + SSEP + m.bootstrap->base );\r
 +                      if ( directories.size () > 0 )\r
 +                              directories += " ";\r
 +                      directories += PassThruCacheDirectory (\r
 +                              NormalizeFilename ( targetDirectory ),\r
 +                              backend->outputDirectory );\r
 +              }\r
 +      }\r
 +      return directories;\r
 +}\r
 +\r
 +string\r
 +MingwIsoModuleHandler::GetNonModuleCdDirectories ( const string& bootcdDirectory )\r
 +{\r
 +      string directories;\r
 +      for ( size_t i = 0; i < module.project.cdfiles.size (); i++ )\r
 +      {\r
 +              const CDFile& cdfile = *module.project.cdfiles[i];\r
 +              string targetDirectory ( bootcdDirectory + SSEP + cdfile.base );\r
 +              if ( directories.size () > 0 )\r
 +                      directories += " ";\r
 +              directories += PassThruCacheDirectory (\r
 +                      NormalizeFilename ( targetDirectory ),\r
 +                      backend->outputDirectory );\r
 +      }\r
 +      return directories;\r
 +}\r
 +\r
 +string\r
 +MingwIsoModuleHandler::GetCdDirectories ( const string& bootcdDirectory )\r
 +{\r
 +      string directories = GetBootstrapCdDirectories ( bootcdDirectory );\r
 +      directories += " " + GetNonModuleCdDirectories ( bootcdDirectory );\r
 +      return directories;\r
 +}\r
 +\r
 +void\r
 +MingwIsoModuleHandler::GetBootstrapCdFiles (\r
 +      vector<string>& out ) const\r
 +{\r
 +      for ( size_t i = 0; i < module.project.modules.size (); i++ )\r
 +      {\r
 +              const Module& m = *module.project.modules[i];\r
 +              if ( m.bootstrap != NULL )\r
 +              {\r
 +                      string filename = PassThruCacheDirectory (\r
 +                              NormalizeFilename ( m.GetPath () ),\r
 +                              backend->outputDirectory );\r
 +                      out.push_back ( filename );\r
 +              }\r
 +      }\r
 +}\r
 +\r
 +void\r
 +MingwIsoModuleHandler::GetNonModuleCdFiles (\r
 +      vector<string>& out ) const\r
 +{\r
 +      for ( size_t i = 0; i < module.project.cdfiles.size (); i++ )\r
 +      {\r
 +              const CDFile& cdfile = *module.project.cdfiles[i];\r
 +              out.push_back ( cdfile.GetPath () );\r
 +      }\r
 +}\r
 +\r
 +void\r
 +MingwIsoModuleHandler::GetCdFiles (\r
 +      vector<string>& out ) const\r
 +{\r
 +      GetBootstrapCdFiles ( out );\r
 +      GetNonModuleCdFiles ( out );\r
 +}\r
 +\r
 +void\r
 +MingwIsoModuleHandler::GenerateIsoModuleTarget ()\r
 +{\r
 +      string bootcdDirectory = "cd";\r
 +      string bootcd = PassThruCacheDirectory (\r
 +              NormalizeFilename ( bootcdDirectory + SSEP ),\r
 +              backend->outputDirectory );\r
 +      string isoboot = PassThruCacheDirectory (\r
 +              NormalizeFilename ( "boot" SSEP "freeldr" SSEP "bootsect" SSEP "isoboot.o" ),\r
 +              backend->outputDirectory );\r
 +      string bootcdReactosNoFixup = bootcdDirectory + SSEP "reactos";\r
 +      string bootcdReactos = PassThruCacheDirectory (\r
 +              NormalizeFilename ( bootcdReactosNoFixup + SSEP ),\r
 +              backend->outputDirectory );\r
 +      CLEAN_FILE ( bootcdReactos );\r
 +      string reactosInf = PassThruCacheDirectory (\r
 +              NormalizeFilename ( bootcdReactosNoFixup + SSEP "reactos.inf" ),\r
 +              backend->outputDirectory );\r
 +      string reactosDff = NormalizeFilename ( "bootdata" SSEP "packages" SSEP "reactos.dff" );\r
 +      string cdDirectories = GetCdDirectories ( bootcdDirectory );\r
 +      vector<string> vCdFiles;\r
 +      GetCdFiles ( vCdFiles );\r
 +      string cdFiles = v2s ( vCdFiles, 5 );\r
 +\r
 +      fprintf ( fMakefile, ".PHONY: %s\n\n",\r
 +                module.name.c_str ());\r
 +      fprintf ( fMakefile,\r
 +                "%s: all %s %s %s %s $(CABMAN_TARGET) $(CDMAKE_TARGET)\n",\r
 +                module.name.c_str (),\r
 +                isoboot.c_str (),\r
 +                bootcdReactos.c_str (),\r
 +                cdDirectories.c_str (),\r
 +                cdFiles.c_str () );\r
 +      fprintf ( fMakefile, "\t$(ECHO_CABMAN)\n" );\r
 +      fprintf ( fMakefile,\r
 +                "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",\r
 +                reactosDff.c_str (),\r
 +                bootcdReactos.c_str () );\r
 +      fprintf ( fMakefile,\r
 +                "\t$(Q)$(CABMAN_TARGET) -C %s -RC %s -L %s -N -P $(OUTPUT)\n",\r
 +                reactosDff.c_str (),\r
 +                reactosInf.c_str (),\r
 +                bootcdReactos.c_str ());\r
 +      fprintf ( fMakefile,\r
 +                "\t-@${rm} %s 2>$(NUL)\n",\r
 +                reactosInf.c_str () );\r
 +      OutputBootstrapfileCopyCommands ( bootcdDirectory );\r
 +      OutputCdfileCopyCommands ( bootcdDirectory );\r
 +      fprintf ( fMakefile, "\t$(ECHO_CDMAKE)\n" );\r
 +      fprintf ( fMakefile,\r
 +                "\t$(Q)$(CDMAKE_TARGET) -v -m -b %s %s REACTOS ReactOS.iso\n",\r
 +                isoboot.c_str (),\r
 +                bootcd.c_str () );\r
 +      fprintf ( fMakefile,\r
 +                "\n" );\r
 +}\r
 +\r
 +\r
 +MingwLiveIsoModuleHandler::MingwLiveIsoModuleHandler (\r
 +      const Module& module_ )\r
 +\r
 +      : MingwModuleHandler ( module_ )\r
 +{\r
 +}\r
 +\r
 +void\r
 +MingwLiveIsoModuleHandler::Process ()\r
 +{\r
 +      GenerateLiveIsoModuleTarget ();\r
 +}\r
 +\r
 +void\r
 +MingwLiveIsoModuleHandler::CreateDirectory ( const string& directory )\r
 +{\r
 +      string normalizedDirectory = MingwModuleHandler::PassThruCacheDirectory (\r
 +              NormalizeFilename ( directory ) + SSEP,\r
 +              backend->outputDirectory );\r
 +}\r
 +\r
 +void\r
 +MingwLiveIsoModuleHandler::OutputCopyCommand ( const string& sourceFilename,\r
 +                                                 const string& targetFilename,\r
 +                                                 const string& targetDirectory )\r
 +{\r
 +      string normalizedTargetFilename = MingwModuleHandler::PassThruCacheDirectory (\r
 +              NormalizeFilename ( targetDirectory + SSEP + targetFilename ),\r
 +              backend->outputDirectory );\r
 +      fprintf ( fMakefile,\r
 +                "\t$(ECHO_CP)\n" );\r
 +      fprintf ( fMakefile,\r
 +                "\t${cp} %s %s 1>$(NUL)\n",\r
 +                sourceFilename.c_str (),\r
 +                normalizedTargetFilename.c_str () );\r
 +}\r
 +\r
 +void\r
 +MingwLiveIsoModuleHandler::OutputModuleCopyCommands ( string& livecdDirectory,\r
 +                                                        string& reactosDirectory )\r
 +{\r
 +      for ( size_t i = 0; i < module.project.modules.size (); i++ )\r
 +      {\r
 +              const Module& m = *module.project.modules[i];\r
 +              if ( m.installName.length () > 0 )\r
 +              {\r
 +                      string sourceFilename = MingwModuleHandler::PassThruCacheDirectory (\r
 +                              NormalizeFilename ( m.GetPath () ),\r
 +                              backend->outputDirectory );\r
 +                      OutputCopyCommand ( sourceFilename,\r
 +                                      m.installName,\r
 +                                      livecdDirectory + SSEP + reactosDirectory + SSEP + m.installBase );\r
 +              }\r
 +      }\r
 +}\r
 +\r
 +void\r
 +MingwLiveIsoModuleHandler::OutputNonModuleCopyCommands ( string& livecdDirectory,\r
 +                                                           string& reactosDirectory )\r
 +{\r
 +      for ( size_t i = 0; i < module.project.installfiles.size (); i++ )\r
 +      {\r
 +              const InstallFile& installfile = *module.project.installfiles[i];\r
 +              OutputCopyCommand ( installfile.GetPath (),\r
 +                              installfile.newname,\r
 +                              livecdDirectory + SSEP + reactosDirectory + SSEP + installfile.base );\r
 +      }\r
 +}\r
 +\r
 +void\r
 +MingwLiveIsoModuleHandler::OutputProfilesDirectoryCommands ( string& livecdDirectory )\r
 +{\r
 +      CreateDirectory ( livecdDirectory + SSEP "Profiles" );\r
 +      CreateDirectory ( livecdDirectory + SSEP "Profiles" SSEP "All Users") ;\r
 +      CreateDirectory ( livecdDirectory + SSEP "Profiles" SSEP "All Users" SSEP "Desktop" );\r
 +      CreateDirectory ( livecdDirectory + SSEP "Profiles" SSEP "Default User" );\r
 +      CreateDirectory ( livecdDirectory + SSEP "Profiles" SSEP "Default User" SSEP "Desktop" );\r
 +      CreateDirectory ( livecdDirectory + SSEP "Profiles" SSEP "Default User" SSEP "My Documents" );\r
 +\r
 +      string livecdIni = "bootdata" SSEP "livecd.ini";\r
 +      OutputCopyCommand ( livecdIni,\r
 +                        "freeldr.ini",\r
 +                        livecdDirectory );\r
 +}\r
 +\r
 +void\r
 +MingwLiveIsoModuleHandler::OutputLoaderCommands ( string& livecdDirectory )\r
 +{\r
 +      string freeldr = PassThruCacheDirectory (\r
 +              NormalizeFilename ( "boot" SSEP "freeldr" SSEP "freeldr" SSEP "freeldr.sys" ),\r
 +              backend->outputDirectory );\r
 +      CreateDirectory ( livecdDirectory + SSEP "loader" );\r
 +      OutputCopyCommand ( freeldr,\r
 +                        "setupldr.sys",\r
 +                        livecdDirectory + SSEP + "loader" );\r
 +}\r
 +\r
 +void\r
 +MingwLiveIsoModuleHandler::OutputRegistryCommands ( string& livecdDirectory )\r
 +{\r
 +      string reactosSystem32ConfigDirectory = NormalizeFilename (\r
 +              MingwModuleHandler::PassThruCacheDirectory (\r
 +              livecdDirectory + SSEP "reactos" SSEP "system32" SSEP "config" SSEP,\r
 +              backend->outputDirectory ) );\r
 +      fprintf ( fMakefile,\r
 +                "\t$(ECHO_MKHIVE)\n" );\r
 +      fprintf ( fMakefile,\r
 +                "\t$(MKHIVE_TARGET) bootdata %s bootdata" SSEP "livecd.inf bootdata" SSEP "hiveinst.inf\n",\r
 +                reactosSystem32ConfigDirectory.c_str () );\r
 +}\r
 +\r
 +void\r
 +MingwLiveIsoModuleHandler::GenerateLiveIsoModuleTarget ()\r
 +{\r
 +      string livecdDirectory = "livecd";\r
 +      string livecd = PassThruCacheDirectory (\r
 +              NormalizeFilename ( livecdDirectory + SSEP ),\r
 +              backend->outputDirectory );\r
 +      string isoboot = PassThruCacheDirectory (\r
 +              NormalizeFilename ( "boot" SSEP "freeldr" SSEP "bootsect" SSEP "isoboot.o" ),\r
 +              backend->outputDirectory );\r
 +      string reactosDirectory = "reactos";\r
 +      string livecdReactosNoFixup = livecdDirectory + SSEP + reactosDirectory;\r
 +      string livecdReactos = NormalizeFilename ( PassThruCacheDirectory (\r
 +              NormalizeFilename ( livecdReactosNoFixup + SSEP ),\r
 +              backend->outputDirectory ) );\r
 +      CLEAN_FILE ( livecdReactos );\r
 +\r
 +      fprintf ( fMakefile, ".PHONY: %s\n\n",\r
 +                module.name.c_str ());\r
 +      fprintf ( fMakefile,\r
 +                "%s: all %s %s $(MKHIVE_TARGET) $(CDMAKE_TARGET)\n",\r
 +                module.name.c_str (),\r
 +                isoboot.c_str (),\r
 +                livecdReactos.c_str () );\r
 +      OutputModuleCopyCommands ( livecdDirectory,\r
 +                                 reactosDirectory );\r
 +      OutputNonModuleCopyCommands ( livecdDirectory,\r
 +                                    reactosDirectory );\r
 +      OutputProfilesDirectoryCommands ( livecdDirectory );\r
 +      OutputLoaderCommands ( livecdDirectory );\r
 +      OutputRegistryCommands ( livecdDirectory );\r
 +      fprintf ( fMakefile, "\t$(ECHO_CDMAKE)\n" );\r
 +      fprintf ( fMakefile,\r
 +                "\t$(Q)$(CDMAKE_TARGET) -v -m -j -b %s %s REACTOS ReactOS-LiveCD.iso\n",\r
 +                isoboot.c_str (),\r
 +                livecd.c_str () );\r
 +      fprintf ( fMakefile,\r
 +                "\n" );\r
 +}\r
 +\r
 +\r
 +MingwTestModuleHandler::MingwTestModuleHandler (\r
 +      const Module& module_ )\r
 +\r
 +      : MingwModuleHandler ( module_ )\r
 +{\r
 +}\r
 +\r
 +void\r
 +MingwTestModuleHandler::Process ()\r
 +{\r
 +      GenerateTestModuleTarget ();\r
 +}\r
 +\r
 +void\r
 +MingwTestModuleHandler::GenerateTestModuleTarget ()\r
 +{\r
 +      string targetMacro ( GetTargetMacro ( module ) );\r
 +      string workingDirectory = GetWorkingDirectory ( );\r
 +      string objectsMacro = GetObjectsMacro ( module );\r
 +      string linkDepsMacro = GetLinkingDependenciesMacro ();\r
 +      string libsMacro = GetLibsMacro ();\r
 +\r
 +      GenerateImportLibraryTargetIfNeeded ();\r
 +\r
 +      if ( module.non_if_data.files.size () > 0 )\r
 +      {\r
 +              GenerateRules ();\r
 +\r
 +              string dependencies = linkDepsMacro + " " + objectsMacro;\r
 +\r
 +              string linker;\r
 +              if ( module.cplusplus )\r
 +                      linker = "${gpp}";\r
 +              else\r
 +                      linker = "${gcc}";\r
 +\r
 +              string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",\r
 +                                                   module.entrypoint.c_str (),\r
 +                                                   module.baseaddress.c_str () );\r
 +              GenerateLinkerCommand ( dependencies,\r
 +                                      linker,\r
 +                                      linkerParameters,\r
 +                                      objectsMacro,\r
 +                                      libsMacro );\r
 +      }\r
 +      else\r
 +      {\r
 +              GeneratePhonyTarget();\r
 +      }\r
 +}\r
 +\r
 +\r
 +MingwRpcServerModuleHandler::MingwRpcServerModuleHandler (\r
 +      const Module& module_ )\r
 +\r
 +      : MingwModuleHandler ( module_ )\r
 +{\r
 +}\r
 +\r
 +void\r
 +MingwRpcServerModuleHandler::Process ()\r
 +{\r
 +      GenerateRules ();\r
 +}\r
 +\r
 +MingwRpcClientModuleHandler::MingwRpcClientModuleHandler (\r
 +      const Module& module_ )\r
 +\r
 +      : MingwModuleHandler ( module_ )\r
 +{\r
 +}\r
 +\r
 +void\r
 +MingwRpcClientModuleHandler::Process ()\r
 +{\r
 +      GenerateRules ();\r
 +}\r
index 8b63e48,0000000..567d4ac
mode 100644,000000..100644
--- /dev/null
@@@ -1,411 -1,0 +1,412 @@@
-               const std::string& sourceFilename,\r
 +#ifndef MINGW_MODULEHANDLER_H\r
 +#define MINGW_MODULEHANDLER_H\r
 +\r
 +#include "../backend.h"\r
 +#include "mingw.h"\r
 +\r
 +class MingwBackend;\r
 +\r
 +extern std::string\r
 +GetTargetMacro ( const Module&, bool with_dollar = true );\r
 +\r
 +extern std::string\r
 +PrefixFilename (\r
 +      const std::string& filename,\r
 +      const std::string& prefix );\r
 +\r
 +class MingwModuleHandler\r
 +{\r
 +public:\r
 +      MingwModuleHandler ( const Module& module_ );\r
 +      virtual ~MingwModuleHandler();\r
 +\r
 +      static void SetBackend ( MingwBackend* backend_ );\r
 +      static void SetMakefile ( FILE* f );\r
 +      static void SetUsePch ( bool use_pch );\r
 +\r
 +      static std::string PassThruCacheDirectory (\r
 +              const std::string &f,\r
 +              Directory* directoryTree );\r
 +\r
 +      static std::string GetTargetFilename (\r
 +              const Module& module,\r
 +              string_list* pclean_files );\r
 +\r
 +      static std::string\r
 +      GetImportLibraryFilename (\r
 +              const Module& module,\r
 +              string_list* pclean_files );\r
 +\r
 +      std::string GetModuleTargets ( const Module& module );\r
 +      void GetObjectsVector ( const IfableData& data,\r
 +                              std::vector<std::string>& objectFiles ) const;\r
 +      void GenerateObjectMacro();\r
 +      void GenerateTargetMacro();\r
 +      void GenerateOtherMacros();\r
 +\r
 +      static MingwModuleHandler* InstanciateHandler ( const Module& module_,\r
 +                                                      MingwBackend* backend_ );\r
 +      virtual HostType DefaultHost() = 0;\r
 +      void GeneratePreconditionDependencies ();\r
 +      virtual void Process () = 0;\r
 +      virtual std::string TypeSpecificCFlags() { return ""; }\r
 +      virtual std::string TypeSpecificNasmFlags() { return ""; }\r
 +      virtual std::string TypeSpecificLinkerFlags() { return ""; }\r
 +      void GenerateInvocations () const;\r
 +      void GenerateCleanTarget () const;\r
 +      static bool ReferenceObjects ( const Module& module );\r
 +protected:\r
 +      std::string GetWorkingDirectory () const;\r
 +      std::string GetBasename ( const std::string& filename ) const;\r
 +      std::string GetActualSourceFilename ( const std::string& filename ) const;\r
 +      std::string GetModuleArchiveFilename () const;\r
 +      bool IsGeneratedFile ( const File& file ) const;\r
 +      std::string GetImportLibraryDependency ( const Module& importedModule );\r
 +      void GetTargets ( const Module& dependencyModule,\r
 +                        string_list& targets );\r
 +      void GetModuleDependencies ( string_list& dependencies );\r
 +      std::string GetAllDependencies () const;\r
 +      void GetSourceFilenames ( string_list& list, bool includeGeneratedFiles = true ) const;\r
 +      void GetSourceFilenamesWithoutGeneratedFiles ( string_list& list ) const;\r
 +      std::string GetObjectFilename ( const std::string& sourceFilename,\r
 +                                      string_list* pclean_files ) const;\r
 +\r
 +      std::string GetObjectFilenames ();\r
 +      \r
 +      std::string GetPreconditionDependenciesName () const;\r
 +      std::string GetCFlagsMacro () const;\r
 +      static std::string GetObjectsMacro ( const Module& );\r
 +      std::string GetLinkingDependenciesMacro () const;\r
 +      std::string GetLibsMacro () const;\r
 +      std::string GetLinkerMacro () const;\r
 +      void GenerateCleanObjectsAsYouGoCode () const;\r
 +      void GenerateLinkerCommand ( const std::string& dependencies,\r
 +                                   const std::string& linker,\r
 +                                   const std::string& linkerParameters,\r
 +                                   const std::string& objectsMacro,\r
 +                                   const std::string& libsMacro );\r
 +      void GeneratePhonyTarget() const;\r
 +      void GenerateRules ();\r
 +      void GenerateImportLibraryTargetIfNeeded ();\r
 +      void GetDefinitionDependencies ( string_list& dependencies ) const;\r
 +      std::string GetLinkingDependencies () const;\r
 +      static MingwBackend* backend;\r
 +      static FILE* fMakefile;\r
 +      static bool use_pch;\r
 +private:\r
 +      std::string ConcatenatePaths ( const std::string& path1,\r
 +                                     const std::string& path2 ) const;\r
 +      std::string GenerateGccDefineParametersFromVector ( const std::vector<Define*>& defines ) const;\r
 +      std::string GenerateGccDefineParameters () const;\r
 +      std::string GenerateGccIncludeParametersFromVector ( const std::vector<Include*>& includes ) const;\r
 +      std::string GenerateCompilerParametersFromVector ( const std::vector<CompilerFlag*>& compilerFlags ) const;\r
 +      std::string GenerateLinkerParametersFromVector ( const std::vector<LinkerFlag*>& linkerFlags ) const;\r
 +      std::string GenerateImportLibraryDependenciesFromVector ( const std::vector<Library*>& libraries );\r
 +      std::string GenerateLinkerParameters () const;\r
 +      void GenerateMacro ( const char* assignmentOperation,\r
 +                           const std::string& macro,\r
 +                           const IfableData& data,\r
 +                           const std::vector<CompilerFlag*>* compilerFlags );\r
 +      void GenerateMacros ( const char* op,\r
 +                            const IfableData& data,\r
 +                            const std::vector<CompilerFlag*>* compilerFlags,\r
 +                            const std::vector<LinkerFlag*>* linkerFlags );\r
 +      void GenerateObjectMacros ( const char* assignmentOperation,\r
 +                                  const IfableData& data,\r
 +                                  const std::vector<CompilerFlag*>* compilerFlags,\r
 +                                  const std::vector<LinkerFlag*>* linkerFlags );\r
 +      std::string GenerateGccIncludeParameters () const;\r
 +      std::string GenerateGccParameters () const;\r
 +      std::string GenerateNasmParameters () const;\r
 +      void GenerateGccCommand ( const std::string& sourceFilename,\r
 +                                const std::string& cc,\r
 +                                const std::string& cflagsMacro );\r
 +      void GenerateGccAssemblerCommand ( const std::string& sourceFilename,\r
 +                                         const std::string& cc,\r
 +                                         const std::string& cflagsMacro );\r
 +      void GenerateNasmCommand ( const std::string& sourceFilename,\r
 +                                 const std::string& nasmflagsMacro );\r
 +      void GenerateWindresCommand ( const std::string& sourceFilename,\r
 +                                    const std::string& windresflagsMacro );\r
 +      void GenerateWinebuildCommands ( const std::string& sourceFilename );\r
++      std::string GetWidlFlags ( const File& file );\r
 +      void GenerateWidlCommandsServer (\r
-               const std::string& sourceFilename,\r
++              const File& file,\r
 +              const std::string& widlflagsMacro );\r
 +      void GenerateWidlCommandsClient (\r
-       void GenerateWidlCommands ( const std::string& sourceFilename,\r
++              const File& file,\r
 +              const std::string& widlflagsMacro );\r
-       void GenerateCommands ( const std::string& sourceFilename,\r
++      void GenerateWidlCommands ( const File& file,\r
 +                                  const std::string& widlflagsMacro );\r
++      void GenerateCommands ( const File& file,\r
 +                              const std::string& cc,\r
 +                              const std::string& cppc,\r
 +                              const std::string& cflagsMacro,\r
 +                              const std::string& nasmflagsMacro,\r
 +                              const std::string& windresflagsMacro,\r
 +                              const std::string& widlflagsMacro );\r
 +      void GenerateObjectFileTargets ( const IfableData& data,\r
 +                                       const std::string& cc,\r
 +                                       const std::string& cppc,\r
 +                                       const std::string& cflagsMacro,\r
 +                                       const std::string& nasmflagsMacro,\r
 +                                       const std::string& windresflagsMacro,\r
 +                                       const std::string& widlflagsMacro );\r
 +      void GenerateObjectFileTargets ( const std::string& cc,\r
 +                                       const std::string& cppc,\r
 +                                       const std::string& cflagsMacro,\r
 +                                       const std::string& nasmflagsMacro,\r
 +                                       const std::string& windresflagsMacro,\r
 +                                       const std::string& widlflagsMacro );\r
 +      std::string GenerateArchiveTarget ( const std::string& ar,\r
 +                                          const std::string& objs_macro ) const;\r
 +      void GetSpecObjectDependencies ( string_list& dependencies,\r
 +                                       const std::string& filename ) const;\r
 +      void GetWidlObjectDependencies ( string_list& dependencies,\r
 +                                       const std::string& filename ) const;\r
 +      void GetDefaultDependencies ( string_list& dependencies ) const;\r
 +      void GetInvocationDependencies ( const Module& module, string_list& dependencies );\r
 +      bool IsWineModule () const;\r
 +      std::string GetDefinitionFilename () const;\r
 +      static std::string RemoveVariables ( std::string path);\r
 +      void GenerateBuildMapCode ();\r
 +      void GenerateBuildNonSymbolStrippedCode ();\r
 +public:\r
 +      const Module& module;\r
 +      string_list clean_files;\r
 +      std::string cflagsMacro;\r
 +      std::string nasmflagsMacro;\r
 +      std::string windresflagsMacro;\r
 +      std::string widlflagsMacro;\r
 +      std::string linkerflagsMacro;\r
 +      std::string objectsMacro;\r
 +      std::string libsMacro;\r
 +      std::string linkDepsMacro;\r
 +};\r
 +\r
 +\r
 +class MingwBuildToolModuleHandler : public MingwModuleHandler\r
 +{\r
 +public:\r
 +      MingwBuildToolModuleHandler ( const Module& module );\r
 +      virtual HostType DefaultHost() { return HostTrue; }\r
 +      virtual void Process ();\r
 +private:\r
 +      void GenerateBuildToolModuleTarget ();\r
 +};\r
 +\r
 +\r
 +class MingwKernelModuleHandler : public MingwModuleHandler\r
 +{\r
 +public:\r
 +      MingwKernelModuleHandler ( const Module& module );\r
 +      virtual HostType DefaultHost() { return HostFalse; }\r
 +      virtual void Process ();\r
 +      std::string TypeSpecificCFlags() { return "-D_SEH_NO_NATIVE_NLG"; }\r
 +private:\r
 +      void GenerateKernelModuleTarget ();\r
 +};\r
 +\r
 +\r
 +class MingwStaticLibraryModuleHandler : public MingwModuleHandler\r
 +{\r
 +public:\r
 +      MingwStaticLibraryModuleHandler ( const Module& module );\r
 +      virtual HostType DefaultHost() { return HostFalse; }\r
 +      virtual void Process ();\r
 +private:\r
 +      void GenerateStaticLibraryModuleTarget ();\r
 +};\r
 +\r
 +\r
 +class MingwObjectLibraryModuleHandler : public MingwModuleHandler\r
 +{\r
 +public:\r
 +      MingwObjectLibraryModuleHandler ( const Module& module );\r
 +      virtual HostType DefaultHost() { return HostFalse; }\r
 +      virtual void Process ();\r
 +private:\r
 +      void GenerateObjectLibraryModuleTarget ();\r
 +};\r
 +\r
 +\r
 +class MingwKernelModeDLLModuleHandler : public MingwModuleHandler\r
 +{\r
 +public:\r
 +      MingwKernelModeDLLModuleHandler ( const Module& module );\r
 +      virtual HostType DefaultHost() { return HostFalse; }\r
 +      virtual void Process ();\r
 +      std::string TypeSpecificCFlags() { return "-D_SEH_NO_NATIVE_NLG"; }\r
 +      std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; }\r
 +private:\r
 +      void GenerateKernelModeDLLModuleTarget ();\r
 +};\r
 +\r
 +\r
 +class MingwKernelModeDriverModuleHandler : public MingwModuleHandler\r
 +{\r
 +public:\r
 +      MingwKernelModeDriverModuleHandler ( const Module& module );\r
 +      virtual HostType DefaultHost() { return HostFalse; }\r
 +      virtual void Process ();\r
 +      std::string TypeSpecificCFlags() { return "-D__NTDRIVER__ -D_SEH_NO_NATIVE_NLG"; }\r
 +      std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; }\r
 +private:\r
 +      void GenerateKernelModeDriverModuleTarget ();\r
 +};\r
 +\r
 +\r
 +class MingwNativeDLLModuleHandler : public MingwModuleHandler\r
 +{\r
 +public:\r
 +      MingwNativeDLLModuleHandler ( const Module& module );\r
 +      virtual HostType DefaultHost() { return HostFalse; }\r
 +      virtual void Process ();\r
 +      std::string TypeSpecificCFlags() { return "-D_SEH_NO_NATIVE_NLG"; }\r
 +      std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; }\r
 +private:\r
 +      void GenerateNativeDLLModuleTarget ();\r
 +};\r
 +\r
 +\r
 +class MingwNativeCUIModuleHandler : public MingwModuleHandler\r
 +{\r
 +public:\r
 +      MingwNativeCUIModuleHandler ( const Module& module );\r
 +      virtual HostType DefaultHost() { return HostFalse; }\r
 +      virtual void Process ();\r
 +      std::string TypeSpecificCFlags() { return "-D__NTAPP__ -D_SEH_NO_NATIVE_NLG"; }\r
 +      std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; }\r
 +private:\r
 +      void GenerateNativeCUIModuleTarget ();\r
 +};\r
 +\r
 +\r
 +class MingwWin32DLLModuleHandler : public MingwModuleHandler\r
 +{\r
 +public:\r
 +      MingwWin32DLLModuleHandler ( const Module& module );\r
 +      virtual HostType DefaultHost() { return HostFalse; }\r
 +      virtual void Process ();\r
 +private:\r
 +      void GenerateExtractWineDLLResourcesTarget ();\r
 +      void GenerateWin32DLLModuleTarget ();\r
 +};\r
 +\r
 +\r
 +class MingwWin32CUIModuleHandler : public MingwModuleHandler\r
 +{\r
 +public:\r
 +      MingwWin32CUIModuleHandler ( const Module& module );\r
 +      virtual HostType DefaultHost() { return HostFalse; }\r
 +      virtual void Process ();\r
 +private:\r
 +      void GenerateWin32CUIModuleTarget ();\r
 +};\r
 +\r
 +\r
 +class MingwWin32GUIModuleHandler : public MingwModuleHandler\r
 +{\r
 +public:\r
 +      MingwWin32GUIModuleHandler ( const Module& module );\r
 +      virtual HostType DefaultHost() { return HostFalse; }\r
 +      virtual void Process ();\r
 +private:\r
 +      void GenerateWin32GUIModuleTarget ();\r
 +};\r
 +\r
 +\r
 +class MingwBootLoaderModuleHandler : public MingwModuleHandler\r
 +{\r
 +public:\r
 +      MingwBootLoaderModuleHandler ( const Module& module );\r
 +      virtual HostType DefaultHost() { return HostFalse; }\r
 +      virtual void Process ();\r
 +      std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; }\r
 +private:\r
 +      void GenerateBootLoaderModuleTarget ();\r
 +};\r
 +\r
 +\r
 +class MingwBootSectorModuleHandler : public MingwModuleHandler\r
 +{\r
 +public:\r
 +      MingwBootSectorModuleHandler ( const Module& module );\r
 +      virtual HostType DefaultHost() { return HostFalse; }\r
 +      virtual void Process ();\r
 +      std::string TypeSpecificNasmFlags() { return "-f bin"; }\r
 +private:\r
 +      void GenerateBootSectorModuleTarget ();\r
 +};\r
 +\r
 +\r
 +class MingwIsoModuleHandler : public MingwModuleHandler\r
 +{\r
 +public:\r
 +      MingwIsoModuleHandler ( const Module& module );\r
 +      virtual HostType DefaultHost() { return HostFalse; }\r
 +      virtual void Process ();\r
 +private:\r
 +      void GenerateIsoModuleTarget ();\r
 +      std::string GetBootstrapCdDirectories ( const std::string& bootcdDirectory );\r
 +      std::string GetNonModuleCdDirectories ( const std::string& bootcdDirectory );\r
 +      std::string GetCdDirectories ( const std::string& bootcdDirectory );\r
 +      void GetBootstrapCdFiles ( std::vector<std::string>& out ) const;\r
 +      void GetNonModuleCdFiles ( std::vector<std::string>& out ) const;\r
 +      void GetCdFiles ( std::vector<std::string>& out ) const;\r
 +      void OutputBootstrapfileCopyCommands ( const std::string& bootcdDirectory );\r
 +      void OutputCdfileCopyCommands ( const std::string& bootcdDirectory );\r
 +};\r
 +\r
 +\r
 +class MingwLiveIsoModuleHandler : public MingwModuleHandler\r
 +{\r
 +public:\r
 +      MingwLiveIsoModuleHandler ( const Module& module );\r
 +      virtual HostType DefaultHost() { return HostFalse; }\r
 +      virtual void Process ();\r
 +private:\r
 +      void GenerateLiveIsoModuleTarget ();\r
 +      void CreateDirectory ( const std::string& directory );\r
 +      void OutputCopyCommand ( const std::string& sourceFilename,\r
 +                               const std::string& targetFilename,\r
 +                               const std::string& targetDirectory );\r
 +      void OutputModuleCopyCommands ( std::string& livecdDirectory,\r
 +                                      std::string& livecdReactos );\r
 +      void OutputNonModuleCopyCommands ( std::string& livecdDirectory,\r
 +                                         std::string& livecdReactos );\r
 +      void OutputProfilesDirectoryCommands ( std::string& livecdDirectory );\r
 +      void OutputLoaderCommands ( std::string& livecdDirectory );\r
 +      void OutputRegistryCommands ( std::string& livecdDirectory );\r
 +};\r
 +\r
 +\r
 +class MingwTestModuleHandler : public MingwModuleHandler\r
 +{\r
 +public:\r
 +      MingwTestModuleHandler ( const Module& module );\r
 +      virtual HostType DefaultHost() { return HostFalse; }\r
 +      virtual void Process ();\r
 +private:\r
 +      void GenerateTestModuleTarget ();\r
 +};\r
 +\r
 +\r
 +class MingwRpcServerModuleHandler : public MingwModuleHandler\r
 +{\r
 +public:\r
 +      MingwRpcServerModuleHandler ( const Module& module );\r
 +      virtual HostType DefaultHost() { return HostFalse; }\r
 +      virtual void Process ();\r
 +};\r
 +\r
 +\r
 +class MingwRpcClientModuleHandler : public MingwModuleHandler\r
 +{\r
 +public:\r
 +      MingwRpcClientModuleHandler ( const Module& module );\r
 +      virtual HostType DefaultHost() { return HostFalse; }\r
 +      virtual void Process ();\r
 +};\r
 +\r
 +#endif /* MINGW_MODULEHANDLER_H */\r
index 2260fa2,0000000..26422d2
mode 100644,000000..100644
--- /dev/null
@@@ -1,961 -1,0 +1,970 @@@
-               if ( att )\r
 +#include "pch.h"\r
 +#include <assert.h>\r
 +\r
 +#include "rbuild.h"\r
 +\r
 +using std::string;\r
 +using std::vector;\r
 +\r
 +string\r
 +FixSeparator ( const string& s )\r
 +{\r
 +      string s2(s);\r
 +      char* p = strchr ( &s2[0], CBAD_SEP );\r
 +      while ( p )\r
 +      {\r
 +              *p++ = CSEP;\r
 +              p = strchr ( p, CBAD_SEP );\r
 +      }\r
 +      return s2;\r
 +}\r
 +\r
 +string\r
 +ReplaceExtension (\r
 +      const string& filename,\r
 +      const string& newExtension )\r
 +{\r
 +      size_t index = filename.find_last_of ( '/' );\r
 +      if ( index == string::npos )\r
 +              index = 0;\r
 +      size_t index2 = filename.find_last_of ( '\\' );\r
 +      if ( index2 != string::npos && index2 > index )\r
 +              index = index2;\r
 +      string tmp = filename.substr( index /*, filename.size() - index*/ );\r
 +      size_t ext_index = tmp.find_last_of( '.' );\r
 +      if ( ext_index != string::npos )\r
 +              return filename.substr ( 0, index + ext_index ) + newExtension;\r
 +      return filename + newExtension;\r
 +}\r
 +\r
 +string\r
 +GetSubPath (\r
 +      const string& location,\r
 +      const string& path,\r
 +      const string& att_value )\r
 +{\r
 +      if ( !att_value.size() )\r
 +              throw InvalidBuildFileException (\r
 +                      location,\r
 +                      "<directory> tag has empty 'name' attribute" );\r
 +      if ( strpbrk ( att_value.c_str (), "/\\?*:<>|" ) )\r
 +              throw InvalidBuildFileException (\r
 +                      location,\r
 +                      "<directory> tag has invalid characters in 'name' attribute" );\r
 +      if ( !path.size() )\r
 +              return att_value;\r
 +      return FixSeparator(path + CSEP + att_value);\r
 +}\r
 +\r
 +string\r
 +GetExtension ( const string& filename )\r
 +{\r
 +      size_t index = filename.find_last_of ( '/' );\r
 +      if (index == string::npos) index = 0;\r
 +      string tmp = filename.substr( index, filename.size() - index );\r
 +      size_t ext_index = tmp.find_last_of( '.' );\r
 +      if (ext_index != string::npos) \r
 +              return filename.substr ( index + ext_index, filename.size() );\r
 +      return "";\r
 +}\r
 +\r
 +string\r
 +GetDirectory ( const string& filename )\r
 +{\r
 +      size_t index = filename.find_last_of ( CSEP );\r
 +      if ( index == string::npos )\r
 +              return filename;\r
 +      else\r
 +              return filename.substr ( 0, index );\r
 +}\r
 +\r
 +string\r
 +NormalizeFilename ( const string& filename )\r
 +{\r
 +      Path path;\r
 +      string normalizedPath = path.Fixup ( filename, true );\r
 +      string relativeNormalizedPath = path.RelativeFromWorkingDirectory ( normalizedPath );\r
 +      return FixSeparator ( relativeNormalizedPath );\r
 +}\r
 +\r
 +IfableData::~IfableData()\r
 +{\r
 +      size_t i;\r
 +      for ( i = 0; i < files.size(); i++ )\r
 +              delete files[i];\r
 +      for ( i = 0; i < includes.size(); i++ )\r
 +              delete includes[i];\r
 +      for ( i = 0; i < defines.size(); i++ )\r
 +              delete defines[i];\r
 +      for ( i = 0; i < libraries.size(); i++ )\r
 +              delete libraries[i];\r
 +      for ( i = 0; i < properties.size(); i++ )\r
 +              delete properties[i];\r
 +      for ( i = 0; i < ifs.size(); i++ )\r
 +              delete ifs[i];\r
 +}\r
 +\r
 +void IfableData::ProcessXML ()\r
 +{\r
 +      size_t i;\r
 +      for ( i = 0; i < files.size (); i++ )\r
 +              files[i]->ProcessXML ();\r
 +      for ( i = 0; i < includes.size (); i++ )\r
 +              includes[i]->ProcessXML ();\r
 +      for ( i = 0; i < defines.size (); i++ )\r
 +              defines[i]->ProcessXML ();\r
 +      for ( i = 0; i < libraries.size (); i++ )\r
 +              libraries[i]->ProcessXML ();\r
 +      for ( i = 0; i < properties.size(); i++ )\r
 +              properties[i]->ProcessXML ();\r
 +      for ( i = 0; i < ifs.size (); i++ )\r
 +              ifs[i]->ProcessXML ();\r
 +}\r
 +\r
 +Module::Module ( const Project& project,\r
 +                 const XMLElement& moduleNode,\r
 +                 const string& modulePath )\r
 +      : project (project),\r
 +        node (moduleNode),\r
 +        importLibrary (NULL),\r
 +        bootstrap (NULL),\r
 +        pch (NULL),\r
 +        cplusplus (false),\r
 +        host (HostDefault)\r
 +{\r
 +      if ( node.name != "module" )\r
 +              throw InvalidOperationException ( __FILE__,\r
 +                                                __LINE__,\r
 +                                                "Module created with non-<module> node" );\r
 +\r
 +      xmlbuildFile = Path::RelativeFromWorkingDirectory ( moduleNode.xmlFile->filename() );\r
 +\r
 +      path = FixSeparator ( modulePath );\r
 +\r
 +      const XMLAttribute* att = moduleNode.GetAttribute ( "name", true );\r
 +      assert(att);\r
 +      name = att->value;\r
 +\r
 +      att = moduleNode.GetAttribute ( "type", true );\r
 +      assert(att);\r
 +      type = GetModuleType ( node.location, *att );\r
 +\r
 +      att = moduleNode.GetAttribute ( "extension", false );\r
 +      if ( att != NULL )\r
 +              extension = att->value;\r
 +      else\r
 +              extension = GetDefaultModuleExtension ();\r
 +\r
 +      att = moduleNode.GetAttribute ( "entrypoint", false );\r
 +      if ( att != NULL )\r
 +              entrypoint = att->value;\r
 +      else\r
 +              entrypoint = GetDefaultModuleEntrypoint ();\r
 +\r
 +      att = moduleNode.GetAttribute ( "baseaddress", false );\r
 +      if ( att != NULL )\r
 +              baseaddress = att->value;\r
 +      else\r
 +              baseaddress = GetDefaultModuleBaseaddress ();\r
 +\r
 +      att = moduleNode.GetAttribute ( "mangledsymbols", false );\r
 +      if ( att != NULL )\r
 +      {\r
 +              const char* p = att->value.c_str();\r
 +              if ( !stricmp ( p, "true" ) || !stricmp ( p, "yes" ) )\r
 +                      mangledSymbols = true;\r
 +              else if ( !stricmp ( p, "false" ) || !stricmp ( p, "no" ) )\r
 +                      mangledSymbols = false;\r
 +              else\r
 +              {\r
 +                      throw InvalidAttributeValueException (\r
 +                              moduleNode.location,\r
 +                              "mangledsymbols",\r
 +                              att->value );\r
 +              }\r
 +      }\r
 +      else\r
 +              mangledSymbols = false;\r
 +\r
 +      att = moduleNode.GetAttribute ( "host", false );\r
 +      if ( att != NULL )\r
 +      {\r
 +              const char* p = att->value.c_str();\r
 +              if ( !stricmp ( p, "true" ) || !stricmp ( p, "yes" ) )\r
 +                      host = HostTrue;\r
 +              else if ( !stricmp ( p, "false" ) || !stricmp ( p, "no" ) )\r
 +                      host = HostFalse;\r
 +              else\r
 +              {\r
 +                      throw InvalidAttributeValueException (\r
 +                              moduleNode.location,\r
 +                              "host",\r
 +                              att->value );\r
 +              }\r
 +      }\r
 +\r
 +      att = moduleNode.GetAttribute ( "prefix", false );\r
 +      if ( att != NULL )\r
 +              prefix = att->value;\r
 +\r
 +      att = moduleNode.GetAttribute ( "installbase", false );\r
 +      if ( att != NULL )\r
 +              installBase = att->value;\r
 +      else\r
 +              installBase = "";\r
 +\r
 +      att = moduleNode.GetAttribute ( "installname", false );\r
 +      if ( att != NULL )\r
 +              installName = att->value;\r
 +      else\r
 +              installName = "";\r
 +      \r
 +      att = moduleNode.GetAttribute ( "usewrc", false );\r
 +      if ( att != NULL )\r
 +              useWRC = att->value == "true";\r
 +      else\r
 +              useWRC = true;\r
 +\r
 +      att = moduleNode.GetAttribute ( "warnings", false );\r
 +      if ( att != NULL )\r
 +              enableWarnings = att->value == "true";\r
 +      else\r
 +              enableWarnings = false;\r
 +}\r
 +\r
 +Module::~Module ()\r
 +{\r
 +      size_t i;\r
 +      for ( i = 0; i < invocations.size(); i++ )\r
 +              delete invocations[i];\r
 +      for ( i = 0; i < dependencies.size(); i++ )\r
 +              delete dependencies[i];\r
 +      for ( i = 0; i < compilerFlags.size(); i++ )\r
 +              delete compilerFlags[i];\r
 +      for ( i = 0; i < linkerFlags.size(); i++ )\r
 +              delete linkerFlags[i];\r
 +      for ( i = 0; i < stubbedComponents.size(); i++ )\r
 +              delete stubbedComponents[i];\r
 +      if ( pch )\r
 +              delete pch;\r
 +}\r
 +\r
 +void\r
 +Module::ProcessXML()\r
 +{\r
 +      size_t i;\r
 +      for ( i = 0; i < node.subElements.size(); i++ )\r
 +              ProcessXMLSubElement ( *node.subElements[i], path );\r
 +      for ( i = 0; i < invocations.size(); i++ )\r
 +              invocations[i]->ProcessXML ();\r
 +      for ( i = 0; i < dependencies.size(); i++ )\r
 +              dependencies[i]->ProcessXML ();\r
 +      for ( i = 0; i < compilerFlags.size(); i++ )\r
 +              compilerFlags[i]->ProcessXML();\r
 +      for ( i = 0; i < linkerFlags.size(); i++ )\r
 +              linkerFlags[i]->ProcessXML();\r
 +      for ( i = 0; i < stubbedComponents.size(); i++ )\r
 +              stubbedComponents[i]->ProcessXML();\r
 +      non_if_data.ProcessXML();\r
 +      if ( pch )\r
 +              pch->ProcessXML();\r
 +}\r
 +\r
 +void\r
 +Module::ProcessXMLSubElement ( const XMLElement& e,\r
 +                               const string& path,\r
 +                               If* pIf /*= NULL*/ )\r
 +{\r
 +      bool subs_invalid = false;\r
 +      string subpath ( path );\r
 +      if ( e.name == "file" && e.value.size () > 0 )\r
 +      {\r
 +              bool first = false;\r
 +              const XMLAttribute* att = e.GetAttribute ( "first", false );\r
-               File* pFile = new File ( FixSeparator ( path + CSEP + e.value ), first );\r
++              if ( att != NULL )\r
 +              {\r
 +                      if ( !stricmp ( att->value.c_str(), "true" ) )\r
 +                              first = true;\r
 +                      else if ( stricmp ( att->value.c_str(), "false" ) )\r
 +                              throw InvalidBuildFileException (\r
 +                                      e.location,\r
 +                                      "attribute 'first' of <file> element can only be 'true' or 'false'" );\r
 +              }\r
++              string switches = "";\r
++              att = e.GetAttribute ( "switches", false );\r
++              if ( att != NULL )\r
++                      switches = att->value;\r
 +              if ( !cplusplus )\r
 +              {\r
 +                      // check for c++ file\r
 +                      string ext = GetExtension ( e.value );\r
 +                      if ( !stricmp ( ext.c_str(), ".cpp" ) )\r
 +                              cplusplus = true;\r
 +                      else if ( !stricmp ( ext.c_str(), ".cc" ) )\r
 +                              cplusplus = true;\r
 +                      else if ( !stricmp ( ext.c_str(), ".cxx" ) )\r
 +                              cplusplus = true;\r
 +              }\r
- File::File ( const string& _name, bool _first )\r
-       : name(_name), first(_first)\r
++              File* pFile = new File ( FixSeparator ( path + CSEP + e.value ),\r
++                                       first,\r
++                                       switches );\r
 +              if ( pIf )\r
 +                      pIf->data.files.push_back ( pFile );\r
 +              else\r
 +                      non_if_data.files.push_back ( pFile );\r
 +              subs_invalid = true;\r
 +      }\r
 +      else if ( e.name == "library" && e.value.size () )\r
 +      {\r
 +              Library* pLibrary = new Library ( e, *this, e.value );\r
 +              if ( pIf )\r
 +                      pIf->data.libraries.push_back ( pLibrary );\r
 +              else\r
 +                      non_if_data.libraries.push_back ( pLibrary );\r
 +              subs_invalid = true;\r
 +      }\r
 +      else if ( e.name == "directory" )\r
 +      {\r
 +              const XMLAttribute* att = e.GetAttribute ( "name", true );\r
 +              assert(att);\r
 +              subpath = GetSubPath ( e.location, path, att->value );\r
 +      }\r
 +      else if ( e.name == "include" )\r
 +      {\r
 +              Include* include = new Include ( project, this, e );\r
 +              if ( pIf )\r
 +                      pIf->data.includes.push_back ( include );\r
 +              else\r
 +                      non_if_data.includes.push_back ( include );\r
 +              subs_invalid = true;\r
 +      }\r
 +      else if ( e.name == "define" )\r
 +      {\r
 +              Define* pDefine = new Define ( project, this, e );\r
 +              if ( pIf )\r
 +                      pIf->data.defines.push_back ( pDefine );\r
 +              else\r
 +                      non_if_data.defines.push_back ( pDefine );\r
 +              subs_invalid = true;\r
 +      }\r
 +      else if ( e.name == "invoke" )\r
 +      {\r
 +              if ( pIf )\r
 +                      throw InvalidBuildFileException (\r
 +                              e.location,\r
 +                              "<invoke> is not a valid sub-element of <if>" );\r
 +              invocations.push_back ( new Invoke ( e, *this ) );\r
 +              subs_invalid = false;\r
 +      }\r
 +      else if ( e.name == "dependency" )\r
 +      {\r
 +              if ( pIf )\r
 +                      throw InvalidBuildFileException (\r
 +                              e.location,\r
 +                              "<dependency> is not a valid sub-element of <if>" );\r
 +              dependencies.push_back ( new Dependency ( e, *this ) );\r
 +              subs_invalid = true;\r
 +      }\r
 +      else if ( e.name == "importlibrary" )\r
 +      {\r
 +              if ( pIf )\r
 +                      throw InvalidBuildFileException (\r
 +                              e.location,\r
 +                              "<importlibrary> is not a valid sub-element of <if>" );\r
 +              if ( importLibrary )\r
 +                      throw InvalidBuildFileException (\r
 +                              e.location,\r
 +                              "Only one <importlibrary> is valid per module" );\r
 +              importLibrary = new ImportLibrary ( e, *this );\r
 +              subs_invalid = true;\r
 +      }\r
 +      else if ( e.name == "if" )\r
 +      {\r
 +              If* pOldIf = pIf;\r
 +              pIf = new If ( e, project, this );\r
 +              if ( pOldIf )\r
 +                      pOldIf->data.ifs.push_back ( pIf );\r
 +              else\r
 +                      non_if_data.ifs.push_back ( pIf );\r
 +              subs_invalid = false;\r
 +      }\r
 +      else if ( e.name == "compilerflag" )\r
 +      {\r
 +              compilerFlags.push_back ( new CompilerFlag ( project, this, e ) );\r
 +              subs_invalid = true;\r
 +      }\r
 +      else if ( e.name == "linkerflag" )\r
 +      {\r
 +              linkerFlags.push_back ( new LinkerFlag ( project, this, e ) );\r
 +              subs_invalid = true;\r
 +      }\r
 +      else if ( e.name == "component" )\r
 +      {\r
 +              stubbedComponents.push_back ( new StubbedComponent ( this, e ) );\r
 +              subs_invalid = false;\r
 +      }\r
 +      else if ( e.name == "property" )\r
 +      {\r
 +              throw InvalidBuildFileException (\r
 +                      e.location,\r
 +                      "<property> is not a valid sub-element of <module>" );\r
 +      }\r
 +      else if ( e.name == "bootstrap" )\r
 +      {\r
 +              bootstrap = new Bootstrap ( project, this, e );\r
 +              subs_invalid = true;\r
 +      }\r
 +      else if ( e.name == "pch" )\r
 +      {\r
 +              if ( pIf )\r
 +                      throw InvalidBuildFileException (\r
 +                              e.location,\r
 +                              "<pch> is not a valid sub-element of <if>" );\r
 +              if ( pch )\r
 +                      throw InvalidBuildFileException (\r
 +                              e.location,\r
 +                              "Only one <pch> is valid per module" );\r
 +              pch = new PchFile (\r
 +                      e, *this, FixSeparator ( path + CSEP + e.value ) );\r
 +              subs_invalid = true;\r
 +      }\r
 +      if ( subs_invalid && e.subElements.size() > 0 )\r
 +              throw InvalidBuildFileException (\r
 +                      e.location,\r
 +                      "<%s> cannot have sub-elements",\r
 +                      e.name.c_str() );\r
 +      for ( size_t i = 0; i < e.subElements.size (); i++ )\r
 +              ProcessXMLSubElement ( *e.subElements[i], subpath, pIf );\r
 +}\r
 +\r
 +ModuleType\r
 +Module::GetModuleType ( const string& location, const XMLAttribute& attribute )\r
 +{\r
 +      if ( attribute.value == "buildtool" )\r
 +              return BuildTool;\r
 +      if ( attribute.value == "staticlibrary" )\r
 +              return StaticLibrary;\r
 +      if ( attribute.value == "objectlibrary" )\r
 +              return ObjectLibrary;\r
 +      if ( attribute.value == "kernel" )\r
 +              return Kernel;\r
 +      if ( attribute.value == "kernelmodedll" )\r
 +              return KernelModeDLL;\r
 +      if ( attribute.value == "kernelmodedriver" )\r
 +              return KernelModeDriver;\r
 +      if ( attribute.value == "nativedll" )\r
 +              return NativeDLL;\r
 +      if ( attribute.value == "nativecui" )\r
 +              return NativeCUI;\r
 +      if ( attribute.value == "win32dll" )\r
 +              return Win32DLL;\r
 +      if ( attribute.value == "win32cui" )\r
 +              return Win32CUI;\r
 +      if ( attribute.value == "win32gui" )\r
 +              return Win32GUI;\r
 +      if ( attribute.value == "bootloader" )\r
 +              return BootLoader;\r
 +      if ( attribute.value == "bootsector" )\r
 +              return BootSector;\r
 +      if ( attribute.value == "iso" )\r
 +              return Iso;\r
 +      if ( attribute.value == "liveiso" )\r
 +              return LiveIso;\r
 +      if ( attribute.value == "test" )\r
 +              return Test;\r
 +      if ( attribute.value == "rpcserver" )\r
 +              return RpcServer;\r
 +      if ( attribute.value == "rpcclient" )\r
 +              return RpcClient;\r
 +      throw InvalidAttributeValueException ( location,\r
 +                                             attribute.name,\r
 +                                             attribute.value );\r
 +}\r
 +\r
 +string\r
 +Module::GetDefaultModuleExtension () const\r
 +{\r
 +      switch (type)\r
 +      {\r
 +              case BuildTool:\r
 +                      return EXEPOSTFIX;\r
 +              case StaticLibrary:\r
 +                      return ".a";\r
 +              case ObjectLibrary:\r
 +                      return ".o";\r
 +              case Kernel:\r
 +              case NativeCUI:\r
 +              case Win32CUI:\r
 +              case Win32GUI:\r
 +                      return ".exe";\r
 +              case KernelModeDLL:\r
 +              case NativeDLL:\r
 +              case Win32DLL:\r
 +                      return ".dll";\r
 +              case KernelModeDriver:\r
 +              case BootLoader:\r
 +                      return ".sys";\r
 +              case BootSector:\r
 +                      return ".o";\r
 +              case Iso:\r
 +              case LiveIso:\r
 +                      return ".iso";\r
 +              case Test:\r
 +                      return ".exe";\r
 +              case RpcServer:\r
 +                      return ".o";\r
 +              case RpcClient:\r
 +                      return ".o";\r
 +      }\r
 +      throw InvalidOperationException ( __FILE__,\r
 +                                        __LINE__ );\r
 +}\r
 +\r
 +string\r
 +Module::GetDefaultModuleEntrypoint () const\r
 +{\r
 +      switch (type)\r
 +      {\r
 +              case Kernel:\r
 +                      return "_NtProcessStartup";\r
 +              case KernelModeDLL:\r
 +                      return "_DriverEntry@8";\r
 +              case NativeDLL:\r
 +                      return "_DllMainCRTStartup@12";\r
 +              case NativeCUI:\r
 +                      return "_NtProcessStartup@4";\r
 +              case Win32DLL:\r
 +                      return "_DllMain@12";\r
 +              case Win32CUI:\r
 +              case Test:\r
 +                      return "_mainCRTStartup";\r
 +              case Win32GUI:\r
 +                      return "_WinMainCRTStartup";\r
 +              case KernelModeDriver:\r
 +                      return "_DriverEntry@8";\r
 +              case BuildTool:\r
 +              case StaticLibrary:\r
 +              case ObjectLibrary:\r
 +              case BootLoader:\r
 +              case BootSector:\r
 +              case Iso:\r
 +              case LiveIso:\r
 +              case RpcServer:\r
 +              case RpcClient:\r
 +                      return "";\r
 +      }\r
 +      throw InvalidOperationException ( __FILE__,\r
 +                                        __LINE__ );\r
 +}\r
 +\r
 +string\r
 +Module::GetDefaultModuleBaseaddress () const\r
 +{\r
 +      switch (type)\r
 +      {\r
 +              case Kernel:\r
 +                      return "0xc0000000";\r
 +              case KernelModeDLL:\r
 +                      return "0x10000";\r
 +              case NativeDLL:\r
 +                      return "0x10000";\r
 +              case NativeCUI:\r
 +                      return "0x10000";\r
 +              case Win32DLL:\r
 +                      return "0x10000";\r
 +              case Win32CUI:\r
 +              case Test:\r
 +                      return "0x00400000";\r
 +              case Win32GUI:\r
 +                      return "0x00400000";\r
 +              case KernelModeDriver:\r
 +                      return "0x10000";\r
 +              case BuildTool:\r
 +              case StaticLibrary:\r
 +              case ObjectLibrary:\r
 +              case BootLoader:\r
 +              case BootSector:\r
 +              case Iso:\r
 +              case LiveIso:\r
 +              case RpcServer:\r
 +              case RpcClient:\r
 +                      return "";\r
 +      }\r
 +      throw InvalidOperationException ( __FILE__,\r
 +                                        __LINE__ );\r
 +}\r
 +\r
 +bool\r
 +Module::HasImportLibrary () const\r
 +{\r
 +      return importLibrary != NULL;\r
 +}\r
 +\r
 +string\r
 +Module::GetTargetName () const\r
 +{\r
 +      return name + extension;\r
 +}\r
 +\r
 +string\r
 +Module::GetDependencyPath () const\r
 +{\r
 +      if ( HasImportLibrary () )\r
 +      {\r
 +              return ReplaceExtension ( GetPath(), ".a" );\r
 +      }\r
 +      else\r
 +              return GetPath();\r
 +}\r
 +\r
 +string\r
 +Module::GetBasePath () const\r
 +{\r
 +      return path;\r
 +}\r
 +\r
 +string\r
 +Module::GetPath () const\r
 +{\r
 +      if ( path.length() > 0 )\r
 +              return path + CSEP + GetTargetName ();\r
 +      else\r
 +              return GetTargetName ();\r
 +}\r
 +\r
 +string\r
 +Module::GetPathWithPrefix ( const string& prefix ) const\r
 +{\r
 +      return path + CSEP + prefix + GetTargetName ();\r
 +}\r
 +\r
 +string\r
 +Module::GetInvocationTarget ( const int index ) const\r
 +{\r
 +      return ssprintf ( "%s_invoke_%d",\r
 +                        name.c_str (),\r
 +                        index );\r
 +}\r
 +\r
 +bool\r
 +Module::HasFileWithExtension (\r
 +      const IfableData& data,\r
 +      const std::string& extension ) const\r
 +{\r
 +      size_t i;\r
 +      for ( i = 0; i < data.files.size (); i++ )\r
 +      {\r
 +              File& file = *data.files[i];\r
 +              string file_ext = GetExtension ( file.name );\r
 +              if ( !stricmp ( file_ext.c_str (), extension.c_str () ) )\r
 +                      return true;\r
 +      }\r
 +      for ( i = 0; i < data.ifs.size (); i++ )\r
 +      {\r
 +              if ( HasFileWithExtension ( data.ifs[i]->data, extension ) )\r
 +                      return true;\r
 +      }\r
 +      return false;\r
 +}\r
 +\r
 +void\r
 +Module::InvokeModule () const\r
 +{\r
 +      for ( size_t i = 0; i < invocations.size (); i++ )\r
 +      {\r
 +              Invoke& invoke = *invocations[i];\r
 +              string command = invoke.invokeModule->GetPath () + " " + invoke.GetParameters ();\r
 +              printf ( "Executing '%s'\n\n", command.c_str () );\r
 +              int exitcode = system ( command.c_str () );\r
 +              if ( exitcode != 0 )\r
 +                      throw InvocationFailedException ( command,\r
 +                                                        exitcode );\r
 +      }\r
 +}\r
 +\r
 +\r
++File::File ( const string& _name, bool _first,\r
++             std::string _switches )\r
++      : name(_name),\r
++        first(_first),\r
++        switches(_switches)\r
 +{\r
 +}\r
 +\r
 +void\r
 +File::ProcessXML()\r
 +{\r
 +}\r
 +\r
 +\r
 +Library::Library ( const XMLElement& _node,\r
 +                   const Module& _module,\r
 +                   const string& _name )\r
 +      : node(_node),\r
 +        module(_module),\r
 +        name(_name),\r
 +        imported_module(_module.project.LocateModule(_name))\r
 +{\r
 +      if ( module.name == name )\r
 +              throw InvalidBuildFileException (\r
 +                      node.location,\r
 +                      "module '%s' cannot link against itself",\r
 +                      name.c_str() );\r
 +      if ( !imported_module )\r
 +              throw InvalidBuildFileException (\r
 +                      node.location,\r
 +                      "module '%s' trying to import non-existant module '%s'",\r
 +                      module.name.c_str(),\r
 +                      name.c_str() );\r
 +}\r
 +\r
 +void\r
 +Library::ProcessXML()\r
 +{\r
 +      if ( !module.project.LocateModule ( name ) )\r
 +              throw InvalidBuildFileException (\r
 +                      node.location,\r
 +                      "module '%s' is trying to link against non-existant module '%s'",\r
 +                      module.name.c_str(),\r
 +                      name.c_str() );\r
 +}\r
 +\r
 +\r
 +Invoke::Invoke ( const XMLElement& _node,\r
 +                 const Module& _module )\r
 +      : node (_node),\r
 +        module (_module)\r
 +{\r
 +}\r
 +\r
 +void\r
 +Invoke::ProcessXML()\r
 +{\r
 +      const XMLAttribute* att = node.GetAttribute ( "module", false );\r
 +      if (att == NULL)\r
 +              invokeModule = &module;\r
 +      else\r
 +      {\r
 +              invokeModule = module.project.LocateModule ( att->value );\r
 +              if ( invokeModule == NULL )\r
 +                      throw InvalidBuildFileException (\r
 +                              node.location,\r
 +                              "module '%s' is trying to invoke non-existant module '%s'",\r
 +                              module.name.c_str(),\r
 +                              att->value.c_str() );\r
 +      }\r
 +\r
 +      for ( size_t i = 0; i < node.subElements.size (); i++ )\r
 +              ProcessXMLSubElement ( *node.subElements[i] );\r
 +}\r
 +\r
 +void\r
 +Invoke::ProcessXMLSubElement ( const XMLElement& e )\r
 +{\r
 +      bool subs_invalid = false;\r
 +      if ( e.name == "input" )\r
 +      {\r
 +              for ( size_t i = 0; i < e.subElements.size (); i++ )\r
 +                      ProcessXMLSubElementInput ( *e.subElements[i] );\r
 +      }\r
 +      else if ( e.name == "output" )\r
 +      {\r
 +              for ( size_t i = 0; i < e.subElements.size (); i++ )\r
 +                      ProcessXMLSubElementOutput ( *e.subElements[i] );\r
 +      }\r
 +      if ( subs_invalid && e.subElements.size() > 0 )\r
 +              throw InvalidBuildFileException ( e.location,\r
 +                                                "<%s> cannot have sub-elements",\r
 +                                                e.name.c_str() );\r
 +}\r
 +\r
 +void\r
 +Invoke::ProcessXMLSubElementInput ( const XMLElement& e )\r
 +{\r
 +      bool subs_invalid = false;\r
 +      if ( e.name == "inputfile" && e.value.size () > 0 )\r
 +      {\r
 +              input.push_back ( new InvokeFile ( e, FixSeparator ( module.path + CSEP + e.value ) ) );\r
 +              subs_invalid = true;\r
 +      }\r
 +      if ( subs_invalid && e.subElements.size() > 0 )\r
 +              throw InvalidBuildFileException ( e.location,\r
 +                                                "<%s> cannot have sub-elements",\r
 +                                                e.name.c_str() );\r
 +}\r
 +\r
 +void\r
 +Invoke::ProcessXMLSubElementOutput ( const XMLElement& e )\r
 +{\r
 +      bool subs_invalid = false;\r
 +      if ( e.name == "outputfile" && e.value.size () > 0 )\r
 +      {\r
 +              output.push_back ( new InvokeFile ( e, FixSeparator ( module.path + CSEP + e.value ) ) );\r
 +              subs_invalid = true;\r
 +      }\r
 +      if ( subs_invalid && e.subElements.size() > 0 )\r
 +              throw InvalidBuildFileException (\r
 +                      e.location,\r
 +                      "<%s> cannot have sub-elements",\r
 +                      e.name.c_str() );\r
 +}\r
 +\r
 +void\r
 +Invoke::GetTargets ( string_list& targets ) const\r
 +{\r
 +      for ( size_t i = 0; i < output.size (); i++ )\r
 +      {\r
 +              InvokeFile& file = *output[i];\r
 +              targets.push_back ( NormalizeFilename ( file.name ) );\r
 +      }\r
 +}\r
 +\r
 +string\r
 +Invoke::GetParameters () const\r
 +{\r
 +      string parameters ( "" );\r
 +      size_t i;\r
 +      for ( i = 0; i < output.size (); i++ )\r
 +      {\r
 +              if ( parameters.length () > 0)\r
 +                      parameters += " ";\r
 +              InvokeFile& invokeFile = *output[i];\r
 +              if ( invokeFile.switches.length () > 0 )\r
 +              {\r
 +                      parameters += invokeFile.switches + " ";\r
 +              }\r
 +              parameters += invokeFile.name;\r
 +      }\r
 +\r
 +      for ( i = 0; i < input.size (); i++ )\r
 +      {\r
 +              if ( parameters.length () > 0 )\r
 +                      parameters += " ";\r
 +              InvokeFile& invokeFile = *input[i];\r
 +              if ( invokeFile.switches.length () > 0 )\r
 +              {\r
 +                      parameters += invokeFile.switches;\r
 +                      parameters += " ";\r
 +              }\r
 +              parameters += invokeFile.name ;\r
 +      }\r
 +\r
 +      return parameters;\r
 +}\r
 +\r
 +\r
 +InvokeFile::InvokeFile ( const XMLElement& _node,\r
 +                         const string& _name )\r
 +      : node (_node),\r
 +      name (_name)\r
 +{\r
 +      const XMLAttribute* att = _node.GetAttribute ( "switches", false );\r
 +      if (att != NULL)\r
 +              switches = att->value;\r
 +      else\r
 +              switches = "";\r
 +}\r
 +\r
 +void\r
 +InvokeFile::ProcessXML()\r
 +{\r
 +}\r
 +\r
 +\r
 +Dependency::Dependency ( const XMLElement& _node,\r
 +                         const Module& _module )\r
 +      : node (_node),\r
 +        module (_module),\r
 +        dependencyModule (NULL)\r
 +{\r
 +}\r
 +\r
 +void\r
 +Dependency::ProcessXML()\r
 +{\r
 +      dependencyModule = module.project.LocateModule ( node.value );\r
 +      if ( dependencyModule == NULL )\r
 +              throw InvalidBuildFileException ( node.location,\r
 +                                                "module '%s' depend on non-existant module '%s'",\r
 +                                                module.name.c_str(),\r
 +                                                node.value.c_str() );\r
 +}\r
 +\r
 +\r
 +ImportLibrary::ImportLibrary ( const XMLElement& _node,\r
 +                               const Module& _module )\r
 +      : node (_node),\r
 +        module (_module)\r
 +{\r
 +      const XMLAttribute* att = _node.GetAttribute ( "basename", false );\r
 +      if (att != NULL)\r
 +              basename = att->value;\r
 +      else\r
 +              basename = module.name;\r
 +\r
 +      att = _node.GetAttribute ( "definition", true );\r
 +      assert (att);\r
 +      definition = FixSeparator(att->value);\r
 +}\r
 +\r
 +\r
 +If::If ( const XMLElement& node_,\r
 +         const Project& project_,\r
 +         const Module* module_ )\r
 +      : node(node_), project(project_), module(module_)\r
 +{\r
 +      const XMLAttribute* att;\r
 +\r
 +      att = node.GetAttribute ( "property", true );\r
 +      assert(att);\r
 +      property = att->value;\r
 +\r
 +      att = node.GetAttribute ( "value", true );\r
 +      assert(att);\r
 +      value = att->value;\r
 +}\r
 +\r
 +If::~If ()\r
 +{\r
 +}\r
 +\r
 +void\r
 +If::ProcessXML()\r
 +{\r
 +}\r
 +\r
 +\r
 +Property::Property ( const XMLElement& node_,\r
 +                     const Project& project_,\r
 +                     const Module* module_ )\r
 +      : node(node_), project(project_), module(module_)\r
 +{\r
 +      const XMLAttribute* att;\r
 +\r
 +      att = node.GetAttribute ( "name", true );\r
 +      assert(att);\r
 +      name = att->value;\r
 +\r
 +      att = node.GetAttribute ( "value", true );\r
 +      assert(att);\r
 +      value = att->value;\r
 +}\r
 +\r
 +void\r
 +Property::ProcessXML()\r
 +{\r
 +}\r
 +\r
 +\r
 +PchFile::PchFile (\r
 +      const XMLElement& node_,\r
 +      const Module& module_,\r
 +      const string& header_ )\r
 +      : node(node_), module(module_), header(header_)\r
 +{\r
 +}\r
 +\r
 +void\r
 +PchFile::ProcessXML()\r
 +{\r
 +}\r
index f14cc2d,0000000..88d8838
mode 100644,000000..100644
--- /dev/null
@@@ -1,616 -1,0 +1,619 @@@
-       File ( const std::string& _name, bool _first );\r
 +#ifndef __RBUILD_H\r
 +#define __RBUILD_H\r
 +\r
 +#include "pch.h"\r
 +\r
 +#ifdef WIN32\r
 +#include <direct.h>\r
 +#include <io.h>\r
 +#endif/*WIN32*/\r
 +#include <sys/stat.h>\r
 +#include <time.h>\r
 +#ifdef _MSC_VER\r
 +#include <sys/utime.h>\r
 +#else/*_MSC_VER*/\r
 +#include <utime.h>\r
 +#ifdef WIN32\r
 +#include <process.h>\r
 +#endif/*WIN32*/\r
 +#endif/*_MSC_VER*/\r
 +\r
 +#include "ssprintf.h"\r
 +#include "exception.h"\r
 +#include "XML.h"\r
 +\r
 +typedef std::vector<std::string> string_list;\r
 +\r
 +#ifdef WIN32\r
 +#define EXEPREFIX ""\r
 +#define EXEPOSTFIX ".exe"\r
 +#define CSEP '\\'\r
 +#define CBAD_SEP '/'\r
 +#define SSEP "\\"\r
 +#define SBAD_SEP "/"\r
 +#else\r
 +#define EXEPREFIX "./"\r
 +#define EXEPOSTFIX ""\r
 +#define CSEP '/'\r
 +#define CBAD_SEP '\\'\r
 +#define SSEP "/"\r
 +#define SBAD_SEP "\\"\r
 +#endif\r
 +\r
 +class Project;\r
 +class IfableData;\r
 +class Module;\r
 +class Include;\r
 +class Define;\r
 +class File;\r
 +class Library;\r
 +class Invoke;\r
 +class InvokeFile;\r
 +class Dependency;\r
 +class ImportLibrary;\r
 +class If;\r
 +class CompilerFlag;\r
 +class LinkerFlag;\r
 +class Property;\r
 +class AutomaticDependency;\r
 +class Bootstrap;\r
 +class CDFile;\r
 +class InstallFile;\r
 +class PchFile;\r
 +class StubbedComponent;\r
 +class StubbedSymbol;\r
 +\r
 +class SourceFileTest;\r
 +\r
 +class IfableData\r
 +{\r
 +public:\r
 +      std::vector<File*> files;\r
 +      std::vector<Include*> includes;\r
 +      std::vector<Define*> defines;\r
 +      std::vector<Library*> libraries;\r
 +      std::vector<Property*> properties;\r
 +      std::vector<If*> ifs;\r
 +\r
 +      ~IfableData();\r
 +      void ProcessXML();\r
 +};\r
 +\r
 +class Project\r
 +{\r
 +      std::string xmlfile;\r
 +      XMLElement *node, *head;\r
 +public:\r
 +      std::string name;\r
 +      std::string makefile;\r
 +      XMLIncludes xmlbuildfiles;\r
 +      std::vector<Module*> modules;\r
 +      std::vector<LinkerFlag*> linkerFlags;\r
 +      std::vector<CDFile*> cdfiles;\r
 +      std::vector<InstallFile*> installfiles;\r
 +      IfableData non_if_data;\r
 +\r
 +      Project ( const std::string& filename );\r
 +      ~Project ();\r
 +      void WriteConfigurationFile ();\r
 +      void ExecuteInvocations ();\r
 +      void ProcessXML ( const std::string& path );\r
 +      Module* LocateModule ( const std::string& name );\r
 +      const Module* LocateModule ( const std::string& name ) const;\r
 +      std::string GetProjectFilename () const;\r
 +private:\r
 +      const Property* LookupProperty ( const std::string& name ) const;\r
 +      void SetConfigurationOption ( char* s,\r
 +                                    std::string name,\r
 +                                    std::string* alternativeName );\r
 +      void SetConfigurationOption ( char* s,\r
 +                                    std::string name );\r
 +      void WriteIfChanged ( char* outbuf,\r
 +                            std::string filename );\r
 +      void ReadXml ();\r
 +      void ProcessXMLSubElement ( const XMLElement& e,\r
 +                                  const std::string& path,\r
 +                                  If* pIf = NULL );\r
 +\r
 +      // disable copy semantics\r
 +      Project ( const Project& );\r
 +      Project& operator = ( const Project& );\r
 +};\r
 +\r
 +\r
 +enum ModuleType\r
 +{\r
 +      BuildTool,\r
 +      StaticLibrary,\r
 +      ObjectLibrary,\r
 +      Kernel,\r
 +      KernelModeDLL,\r
 +      KernelModeDriver,\r
 +      NativeDLL,\r
 +      NativeCUI,\r
 +      Win32DLL,\r
 +      Win32CUI,\r
 +      Win32GUI,\r
 +      BootLoader,\r
 +      BootSector,\r
 +      Iso,\r
 +      LiveIso,\r
 +      Test,\r
 +      RpcServer,\r
 +      RpcClient\r
 +};\r
 +\r
 +enum HostType\r
 +{\r
 +      HostFalse,\r
 +      HostDefault,\r
 +      HostTrue\r
 +};\r
 +\r
 +class Module\r
 +{\r
 +public:\r
 +      const Project& project;\r
 +      const XMLElement& node;\r
 +      std::string xmlbuildFile;\r
 +      std::string name;\r
 +      std::string extension;\r
 +      std::string entrypoint;\r
 +      std::string baseaddress;\r
 +      std::string path;\r
 +      ModuleType type;\r
 +      ImportLibrary* importLibrary;\r
 +      bool mangledSymbols;\r
 +      Bootstrap* bootstrap;\r
 +      IfableData non_if_data;\r
 +      std::vector<Invoke*> invocations;\r
 +      std::vector<Dependency*> dependencies;\r
 +      std::vector<CompilerFlag*> compilerFlags;\r
 +      std::vector<LinkerFlag*> linkerFlags;\r
 +      std::vector<StubbedComponent*> stubbedComponents;\r
 +      PchFile* pch;\r
 +      bool cplusplus;\r
 +      std::string prefix;\r
 +      HostType host;\r
 +      std::string installBase;\r
 +      std::string installName;\r
 +      bool useWRC;\r
 +      bool enableWarnings;\r
 +\r
 +      Module ( const Project& project,\r
 +               const XMLElement& moduleNode,\r
 +               const std::string& modulePath );\r
 +      ~Module ();\r
 +      ModuleType GetModuleType ( const std::string& location,\r
 +                                 const XMLAttribute& attribute );\r
 +      bool HasImportLibrary () const;\r
 +      std::string GetTargetName () const;\r
 +      std::string GetDependencyPath () const;\r
 +      std::string GetBasePath () const;\r
 +      std::string GetPath () const;\r
 +      std::string GetPathWithPrefix ( const std::string& prefix ) const;\r
 +      void GetTargets ( string_list& ) const;\r
 +      std::string GetInvocationTarget ( const int index ) const;\r
 +      bool HasFileWithExtension ( const IfableData&, const std::string& extension ) const;\r
 +      void InvokeModule () const;\r
 +      void ProcessXML ();\r
 +private:\r
 +      std::string GetDefaultModuleExtension () const;\r
 +      std::string GetDefaultModuleEntrypoint () const;\r
 +      std::string GetDefaultModuleBaseaddress () const;\r
 +      void ProcessXMLSubElement ( const XMLElement& e,\r
 +                                  const std::string& path,\r
 +                                  If* pIf = NULL );\r
 +};\r
 +\r
 +\r
 +class Include\r
 +{\r
 +public:\r
 +      const Project& project;\r
 +      const Module* module;\r
 +      const XMLElement& node;\r
 +      std::string directory;\r
 +      std::string basePath;\r
 +\r
 +      Include ( const Project& project,\r
 +                const XMLElement& includeNode );\r
 +      Include ( const Project& project,\r
 +                const Module* module,\r
 +                const XMLElement& includeNode );\r
 +      ~Include ();\r
 +      void ProcessXML();\r
 +private:\r
 +      void Initialize();\r
 +};\r
 +\r
 +\r
 +class Define\r
 +{\r
 +public:\r
 +      const Project& project;\r
 +      const Module* module;\r
 +      const XMLElement& node;\r
 +      std::string name;\r
 +      std::string value;\r
 +\r
 +      Define ( const Project& project,\r
 +               const XMLElement& defineNode );\r
 +      Define ( const Project& project,\r
 +               const Module* module,\r
 +               const XMLElement& defineNode );\r
 +      ~Define();\r
 +      void ProcessXML();\r
 +private:\r
 +      void Initialize();\r
 +};\r
 +\r
 +\r
 +class File\r
 +{\r
 +public:\r
 +      std::string name;\r
 +      bool first;\r
++      std::string switches;\r
 +\r
++      File ( const std::string& _name,\r
++             bool _first,\r
++             std::string _switches );\r
 +\r
 +      void ProcessXML();\r
 +};\r
 +\r
 +\r
 +class Library\r
 +{\r
 +public:\r
 +      const XMLElement& node;\r
 +      const Module& module;\r
 +      std::string name;\r
 +      const Module* imported_module;\r
 +\r
 +      Library ( const XMLElement& _node,\r
 +                const Module& _module,\r
 +                const std::string& _name );\r
 +\r
 +      void ProcessXML();\r
 +};\r
 +\r
 +\r
 +class Invoke\r
 +{\r
 +public:\r
 +      const XMLElement& node;\r
 +      const Module& module;\r
 +      const Module* invokeModule;\r
 +      std::vector<InvokeFile*> input;\r
 +      std::vector<InvokeFile*> output;\r
 +\r
 +      Invoke ( const XMLElement& _node,\r
 +               const Module& _module );\r
 +\r
 +      void ProcessXML();\r
 +      void GetTargets ( string_list& targets ) const;\r
 +      std::string GetParameters () const;\r
 +private:\r
 +      void ProcessXMLSubElement ( const XMLElement& e );\r
 +      void ProcessXMLSubElementInput ( const XMLElement& e );\r
 +      void ProcessXMLSubElementOutput ( const XMLElement& e );\r
 +};\r
 +\r
 +\r
 +class InvokeFile\r
 +{\r
 +public:\r
 +      const XMLElement& node;\r
 +      std::string name;\r
 +      std::string switches;\r
 +\r
 +      InvokeFile ( const XMLElement& _node,\r
 +                   const std::string& _name );\r
 +\r
 +      void ProcessXML ();\r
 +};\r
 +\r
 +\r
 +class Dependency\r
 +{\r
 +public:\r
 +      const XMLElement& node;\r
 +      const Module& module;\r
 +      const Module* dependencyModule;\r
 +\r
 +      Dependency ( const XMLElement& _node,\r
 +                   const Module& _module );\r
 +\r
 +      void ProcessXML();\r
 +};\r
 +\r
 +\r
 +class ImportLibrary\r
 +{\r
 +public:\r
 +      const XMLElement& node;\r
 +      const Module& module;\r
 +      std::string basename;\r
 +      std::string definition;\r
 +\r
 +      ImportLibrary ( const XMLElement& _node,\r
 +                      const Module& module );\r
 +\r
 +      void ProcessXML ();\r
 +};\r
 +