Applied patch by maruel:

- Fixed taking the address of begin() on an empty std::vector.
- Fixed nsis makefile to use %ProgramFiles% environment variable.
- Fixed nsis makefile to pass the output directory and file to makensis.
- Fixed synergy.nsi to get the files from the output directory. That
  enables a debug build of the installer.
- Fixes to compile under VS2005.

I did not apply VS2005 project files, instead adding nmake files.
nmake is pretty weak but the makefiles can be modified without having
visual studio.  Also modified the .rc files to not use winres.h.
This plus nmake means synergy can now be built using the freely
downloadable Microsoft Windows SDK for Vista, available from
microsoft's web site.  This change removes all of the old VC++6
project files in favor of the nmake files.  It also removes the
XCode project in favor of ./configure and make.

All of the nmake files are named nmake.mak.  Only the top level
makefile is directly useful (the rest are included by it) so all
builds are from the top level directory.  nmake knows the following
targets:

  all:  build synergy.exe, synergyc.exe and synergys.exe
  clean:  remove all intermediate files, keep programs
  clobber:  clean and remove programs
  installer:  build programs and an installer
  debug:  build a debug version of 'all'
  release:  build a release version of 'all'
  debug-installer:  build an installer of the debug build
  release-installer:  build an installer of the release build

The default build version is release so 'all' and 'installer' will
build a release version.  The installer itself never has debug
symbols, just the stuff it installs.  The default target is 'all'.
To build use:

  nmake /nologo /f nmake.mak <target>

VC++ and VisualStudio users may need to manually run vcvars.bat in a
command.exe or cmd.exe window before invoking nmake.  The Window 98/Me
command.exe may not handle potentially long command lines;  I haven't
tried to verify if that works.
This commit is contained in:
crs23
2007-09-06 05:01:44 +00:00
parent 0ed17ccca2
commit 5c29ae9967
66 changed files with 1623 additions and 6064 deletions

View File

@@ -15,6 +15,20 @@
#include "CSynergyHook.h"
#include "ProtocolTypes.h"
#include <zmouse.h>
#include <tchar.h>
#if _MSC_VER >= 1400
// VS2005 hack - we don't use assert here because we don't want to link with the CRT.
#undef assert
#if _DEBUG
#define assert(_X_) if (!(_X_)) __debugbreak()
#else
#define assert(_X_) __noop()
#endif
// VS2005 is a bit more smart than VC6 and optimize simple copy loop to
// intrinsic memcpy.
#pragma function(memcpy)
#endif
//
// debugging compile flag. when not zero the server doesn't grab
@@ -766,6 +780,79 @@ DllMain(HINSTANCE instance, DWORD reason, LPVOID)
extern "C" {
// VS2005 hack to not link with the CRT
#if _MSC_VER >= 1400
BOOL WINAPI _DllMainCRTStartup(
HINSTANCE instance, DWORD reason, LPVOID lpreserved)
{
return DllMain(instance, reason, lpreserved);
}
// VS2005 is a bit more bright than VC6 and optimize simple copy loop to
// intrinsic memcpy.
void * __cdecl memcpy(void * _Dst, const void * _Src, size_t _MaxCount)
{
void * _DstBackup = _Dst;
switch (_MaxCount & 3) {
case 3:
((char*)_Dst)[0] = ((char*)_Src)[0];
++(char*&)_Dst;
++(char*&)_Src;
--_MaxCount;
case 2:
((char*)_Dst)[0] = ((char*)_Src)[0];
++(char*&)_Dst;
++(char*&)_Src;
--_MaxCount;
case 1:
((char*)_Dst)[0] = ((char*)_Src)[0];
++(char*&)_Dst;
++(char*&)_Src;
--_MaxCount;
break;
case 0:
break;
default:
__assume(0);
break;
}
// I think it's faster on intel to deference than modify the pointer.
const size_t max = _MaxCount / sizeof(UINT_PTR);
for (size_t i = 0; i < max; ++i) {
((UINT_PTR*)_Dst)[i] = ((UINT_PTR*)_Src)[i];
}
(UINT_PTR*&)_Dst += max;
(UINT_PTR*&)_Src += max;
switch (_MaxCount & 3) {
case 3:
((char*)_Dst)[0] = ((char*)_Src)[0];
++(char*&)_Dst;
++(char*&)_Src;
case 2:
((char*)_Dst)[0] = ((char*)_Src)[0];
++(char*&)_Dst;
++(char*&)_Src;
case 1:
((char*)_Dst)[0] = ((char*)_Src)[0];
++(char*&)_Dst;
++(char*&)_Src;
break;
case 0:
break;
default:
__assume(0);
break;
}
return _DstBackup;
}
#endif
int
init(DWORD threadID)
{
@@ -786,7 +873,7 @@ init(DWORD threadID)
// clean up after old process. the system should've already
// removed the hooks so we just need to reset our state.
g_hinstance = GetModuleHandle("synrgyhk");
g_hinstance = GetModuleHandle(_T("synrgyhk"));
g_processID = GetCurrentProcessId();
g_wheelSupport = kWheelNone;
g_threadID = 0;