Browse Source

Patches for compiling Panda3D with MinGW

Kamran Ghanaat 11 years ago
parent
commit
a7b83869bb
39 changed files with 127 additions and 79 deletions
  1. 1 1
      direct/src/dcparse/Sources.pp
  2. 1 1
      direct/src/directbase/Sources.pp
  3. 1 1
      direct/src/directd/Sources.pp
  4. 1 1
      direct/src/directdServer/Sources.pp
  5. 1 1
      direct/src/http/baseincomingset.i
  6. 5 5
      direct/src/plugin/Sources.pp
  7. 1 1
      direct/src/plugin_npapi/Sources.pp
  8. 4 4
      direct/src/plugin_standalone/Sources.pp
  9. 1 1
      direct/src/showbase/Sources.pp
  10. 26 0
      dtool/pptempl/Global.unix.pp
  11. 14 7
      dtool/pptempl/Template.unix.pp
  12. 8 8
      dtool/src/dtoolbase/atomicAdjustI386Impl.I
  13. 7 7
      dtool/src/dtoolbase/cmath.I
  14. 1 1
      dtool/src/dtoolutil/Sources.pp
  15. 6 6
      dtool/src/dtoolutil/filename.cxx
  16. 1 1
      dtool/src/dtoolutil/win32ArgParser.cxx
  17. 2 3
      panda/metalibs/pandadx9/Sources.pp
  18. 1 1
      panda/metalibs/pandaexpress/Sources.pp
  19. 1 1
      panda/metalibs/pandagl/Sources.pp
  20. 3 3
      panda/src/audiotraits/Sources.pp
  21. 1 1
      panda/src/display/Sources.pp
  22. 1 1
      panda/src/display/graphicsEngine.cxx
  23. 2 2
      panda/src/dxgsg9/dxGraphicsStateGuardian9.I
  24. 3 1
      panda/src/dxgsg9/wdxGraphicsWindow9.cxx
  25. 2 2
      panda/src/express/Sources.pp
  26. 1 1
      panda/src/gobj/geom.h
  27. 1 1
      panda/src/movies/Sources.pp
  28. 2 2
      panda/src/nativenet/socket_portable.h
  29. 1 1
      panda/src/net/Sources.pp
  30. 1 1
      panda/src/net/connectionManager.cxx
  31. 1 1
      panda/src/pstatclient/pStatClientImpl.cxx
  32. 1 1
      panda/src/putil/factoryBase.h
  33. 2 2
      panda/src/windisplay/Sources.pp
  34. 17 3
      panda/src/windisplay/winGraphicsPipe.cxx
  35. 1 1
      panda/src/windisplay/winGraphicsWindow.h
  36. 1 1
      pandatool/src/dxfprogs/Sources.pp
  37. 1 1
      pandatool/src/mayaprogs/Sources.pp
  38. 1 1
      pandatool/src/vrmlprogs/Sources.pp
  39. 1 1
      pandatool/src/win-stats/Sources.pp

+ 1 - 1
direct/src/dcparse/Sources.pp

@@ -18,6 +18,6 @@
 
   #define SOURCES \
     dcparse.cxx
-  #define WIN_SYS_LIBS shell32.lib
+  #define WIN_SYS_LIBS shell32
 #end bin_target
 

+ 1 - 1
direct/src/directbase/Sources.pp

@@ -14,7 +14,7 @@
   #if $[ne $[PLATFORM], FreeBSD]
     #define UNIX_SYS_LIBS dl
   #endif
-  #define WIN_SYS_LIBS shell32.lib
+  #define WIN_SYS_LIBS shell32
   #define OSX_SYS_FRAMEWORKS Foundation $[if $[not $[BUILD_IPHONE]],AppKit]
 
 #end lib_target

+ 1 - 1
direct/src/directd/Sources.pp

@@ -7,7 +7,7 @@
     p3directbase
 #define OTHER_LIBS \
     $[if $[HAVE_NET],p3net:c] p3linmath:c p3putil:c p3express:c panda:m pandaexpress:m p3dtoolconfig p3dtool
-#define WIN_SYS_LIBS $[WIN_SYS_LIBS] user32.lib //advapi32.lib
+#define WIN_SYS_LIBS $[WIN_SYS_LIBS] user32 //advapi32
 
 #begin lib_target
   #define TARGET p3directd

+ 1 - 1
direct/src/directdServer/Sources.pp

@@ -7,7 +7,7 @@
 //    p3directbase
 #define OTHER_LIBS \
     $[if $[HAVE_NET],p3net:c] p3linmath:c p3putil:c p3express:c panda:m pandaexpress:m p3dtoolconfig p3dtool
-#define WIN_SYS_LIBS $[WIN_SYS_LIBS] user32.lib //advapi32.lib
+#define WIN_SYS_LIBS $[WIN_SYS_LIBS] user32 //advapi32
 
 #begin bin_target
   #define TARGET p3directdServer

+ 1 - 1
direct/src/http/baseincomingset.i

@@ -70,7 +70,7 @@ inline int BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READE
 template <class _INCLASS1,class _IN_LISTEN,typename  MESSAGE_READER_BUF, typename  MESSAGE_READER_UPPASS>
 inline void BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::AddAConection(_INCLASS1 * newt)
 {
-    push_back(newt);
+    this->push_back(newt);
 }
 ////////////////////////////////////////////////////////////////////
 // Function name    : BaseIncomingSet<_INCLASS1,_IN_LISTEN,MESSAGE_READER_BUF,MESSAGE_READER_UPPASS>::BaseIncomingSet

+ 5 - 5
direct/src/plugin/Sources.pp

@@ -131,7 +131,7 @@
   #define INSTALL_HEADERS \
     p3d_plugin.h
 
-  #define WIN_SYS_LIBS user32.lib gdi32.lib shell32.lib comctl32.lib msimg32.lib ole32.lib
+  #define WIN_SYS_LIBS user32 gdi32 shell32 comctl32 msimg32 ole32
 
 #end lib_target
 
@@ -153,7 +153,7 @@
   #define SOURCES $[COREAPI_SOURCES]
   #define INCLUDED_SOURCES $[COREAPI_INCLUDED_SOURCES]
 
-  #define WIN_SYS_LIBS user32.lib gdi32.lib shell32.lib comctl32.lib msimg32.lib ole32.lib
+  #define WIN_SYS_LIBS user32 gdi32 shell32 comctl32 msimg32 ole32
 
 #end static_lib_target
 
@@ -274,7 +274,7 @@
   #define EXTRA_LIBS $[EXTRA_P3DPYTHON_LIBS]
   #define OSX_SYS_FRAMEWORKS Carbon
 
-  #define WIN_SYS_LIBS user32.lib
+  #define WIN_SYS_LIBS user32
 #end bin_target
 
 #begin bin_target
@@ -324,7 +324,7 @@
   #define EXTRA_LIBS $[EXTRA_P3DPYTHON_LIBS]
   #define OSX_SYS_FRAMEWORKS Carbon
 
-  #define WIN_SYS_LIBS user32.lib
+  #define WIN_SYS_LIBS user32
 #end bin_target
 
 #begin lib_target
@@ -363,7 +363,7 @@
     p3dPythonRun.cxx p3dPythonRun.h p3dPythonRun.I \
     run_p3dpython.h run_p3dpython.cxx
 
-  #define WIN_SYS_LIBS user32.lib
+  #define WIN_SYS_LIBS user32
 #end lib_target
 
 

+ 1 - 1
direct/src/plugin_npapi/Sources.pp

@@ -45,7 +45,7 @@
   #if $[WINDOWS_PLATFORM]
     #define WIN_RESOURCE_FILE nppanda3d.rc
     #define LINKER_DEF_FILE nppanda3d.def
-    #define WIN_SYS_LIBS user32.lib shell32.lib ole32.lib
+    #define WIN_SYS_LIBS user32 shell32 ole32
   #endif
 
   // Mac-specific options.

+ 4 - 4
direct/src/plugin_standalone/Sources.pp

@@ -24,7 +24,7 @@
     panda3dMain.cxx
 
   #define WIN_RESOURCE_FILE panda3d.rc
-  #define WIN_SYS_LIBS user32.lib gdi32.lib shell32.lib ole32.lib
+  #define WIN_SYS_LIBS user32 gdi32 shell32 ole32
 
 #end bin_target
 
@@ -52,7 +52,7 @@
     panda3dWinMain.cxx
 
   #define WIN_RESOURCE_FILE panda3d.rc
-  #define WIN_SYS_LIBS user32.lib gdi32.lib shell32.lib ole32.lib
+  #define WIN_SYS_LIBS user32 gdi32 shell32 ole32
 
 #end bin_target
 
@@ -107,7 +107,7 @@
     p3dEmbed.cxx p3dEmbedMain.cxx
 
   #define WIN_RESOURCE_FILE panda3d.rc
-  #define WIN_SYS_LIBS user32.lib gdi32.lib shell32.lib comctl32.lib msimg32.lib ole32.lib
+  #define WIN_SYS_LIBS user32 gdi32 shell32 comctl32 msimg32 ole32
 
 #end bin_target
 
@@ -136,7 +136,7 @@
     p3dEmbed.cxx p3dEmbedMain.cxx
 
   #define WIN_RESOURCE_FILE panda3d.rc
-  #define WIN_SYS_LIBS user32.lib gdi32.lib shell32.lib comctl32.lib msimg32.lib ole32.lib
+  #define WIN_SYS_LIBS user32 gdi32 shell32 comctl32 msimg32 ole32
 
 #end bin_target
 

+ 1 - 1
direct/src/showbase/Sources.pp

@@ -13,7 +13,7 @@
     p3dtoolutil:c p3dtoolbase:c p3dtool:m
 
   #define WIN_SYS_LIBS \
-    User32.lib
+    user32
 
   #define SOURCES \
     showBase.cxx showBase.h \

+ 26 - 0
dtool/pptempl/Global.unix.pp

@@ -5,3 +5,29 @@
 // are read.  It defines a few global variables to assist
 // Template.unix.pp.
 //
+
+#defun get_metalibs target,complete_libs
+  // In Windows, we need to know the complete set of metalibs that
+  // encapsulates each of the libraries we'd be linking with normally.
+  // In the case where a particular library is not part of a metalib,
+  // we include the library itself.
+
+  #define actual_libs
+  #foreach lib $[complete_libs]
+    // Only consider libraries that we're actually building.
+    #if $[all_libs $[and $[build_directory],$[build_target]],$[lib]]
+      #define modmeta $[module $[TARGET],$[lib]]
+      #if $[ne $[modmeta],]
+        #if $[ne $[modmeta],$[target]]  // We don't link with ourselves.
+          #set actual_libs $[actual_libs] $[modmeta]
+        #endif
+      #else
+        #set actual_libs $[actual_libs] $[lib]
+      #endif
+    #endif
+  #end lib
+  #set actual_libs $[unique $[actual_libs]] $[patsubst %:m,%,$[filter %:m,$[OTHER_LIBS]]]
+  $[actual_libs]
+#end get_metalibs
+
+#defer actual_local_libs $[get_metalibs $[TARGET],$[complete_local_libs]]

+ 14 - 7
dtool/pptempl/Template.unix.pp

@@ -79,13 +79,13 @@
 
 #endif  // $[build_directory]
 
-#defer actual_local_libs $[complete_local_libs]
+#defer actual_local_libs $[get_metalibs $[TARGET],$[complete_local_libs]]
 
 // $[static_lib_dependencies] is the set of libraries we will link
 // with that happen to be static libs.  We will introduce dependency
 // rules for these.  (We don't need dependency rules for dynamic libs,
 // since these don't get burned in at build time.)
-#defer static_lib_dependencies $[all_libs $[if $[lib_is_static],$[RELDIR:%=%/$[ODIR]/$[lib_prefix]$[TARGET]$[dllext]$[lib_ext]]],$[complete_local_libs]]
+#defer static_lib_dependencies $[all_libs $[if $[and $[lib_is_static],$[build_lib]],$[RELDIR:%=%/$[ODIR]/$[lib_prefix]$[TARGET]$[dllext]$[lib_ext]]],$[complete_local_libs]]
 
 // $[target_ipath] is the proper ipath to put on the command line,
 // from the context of a particular target.
@@ -106,7 +106,7 @@
 #defer lpath $[sort $[complete_lpath]] $[other_trees_lib] $[install_lib_dir] $[get_lpath]
 
 // And $[libs] is the set of libraries we will link with.
-#defer nonunique_libs $[nonunique_complete_local_libs:%=%$[dllext]] $[patsubst %:m,,%:c %,%$[dllext],$[OTHER_LIBS]] $[get_libs]
+#defer nonunique_libs $[unique $[actual_local_libs:%=%$[dllext]] $[patsubst %:c,,%:m %,%$[dllext],$[OTHER_LIBS]] $[get_libs]]
 
 // Don't use $[unique] here, since some libraries actually do need to be
 // named multiple times (when linking static).
@@ -310,7 +310,7 @@ igate : $[get_igatedb(metalib_target lib_target ss_lib_target)]
 #define build_it 1
 
 // We don't need a BUILDING_ symbol for Unix; that's a Windows thing.
-#define building_var
+#define building_var $[or $[BUILDING_DLL],$[module $[BUILDING_DLL],$[TARGET]]]
 
 // $[igatescan] is the set of C++ headers and source files that we
 // need to scan for interrogate.  $[igateoutput] is the name of the
@@ -342,6 +342,11 @@ igate : $[get_igatedb(metalib_target lib_target ss_lib_target)]
 
   #define sources \
    $[patsubst %,$[%_obj],$[c_sources] $[mm_sources] $[cxx_sources]]
+  #if $[not $[BUILD_COMPONENTS]]
+    // Also link in all of the component files directly into the metalib.
+    #define sources $[sources] \
+      $[components $[patsubst %,$[RELDIR]/$[%_obj],$[c_sources] $[mm_sources] $[cxx_sources]],$[active_component_libs]]
+  #endif
   #define interrogate_sources \
    $[patsubst %,$[%_obj],$[cxx_interrogate_sources]]
   #define cc_ld $[or $[get_ld],$[CC]]
@@ -353,11 +358,13 @@ $[varname] = $[sources] $[if $[not $[link_extra_bundle]],$[interrogate_sources]]
   #define sources $($[varname])
 
 $[target] : $[sources] $[static_lib_dependencies]
+#if $[build_lib]
   #if $[filter %.mm %.cxx %.yxx %.lxx,$[get_sources]]
 $[TAB] $[link_lib_c++]
   #else  
 $[TAB] $[link_lib_c]
   #endif
+#endif  // BUILD_LIB
 
   #if $[link_extra_bundle]
     // Also generate the bundles (on OSX only).
@@ -371,7 +378,7 @@ $[TAB] $[BUNDLE_LIB_C++]
 // Here are the rules to install and uninstall the library and
 // everything that goes along with it.
 #define installed_files \
-    $[install_lib_dir]/$[lib_prefix]$[TARGET]$[lib_ext] \
+   $[if $[build_lib],$[install_lib_dir]/$[lib_prefix]$[TARGET]$[lib_ext]] \
     $[if $[link_extra_bundle],$[install_lib_dir]/$[lib_prefix]$[TARGET]$[bundle_ext]] \
     $[INSTALL_SCRIPTS:%=$[install_bin_dir]/%] \
     $[INSTALL_MODULES:%=$[install_lib_dir]/%] \
@@ -683,7 +690,7 @@ $[TAB] $[compile_c++]
 #define target $[$[file]_obj]
 #define source $[file]
 #define ipath $[target_ipath]
-#define flags $[cflags] $[CFLAGS_SHARED]
+#define flags $[cflags] $[CFLAGS_SHARED] $[building_var:%=-D%]
 #if $[ne $[file], $[notdir $file]]
   // If the source file is not in the current directory, tack on "."
   // to front of the ipath.
@@ -701,7 +708,7 @@ $[TAB] $[compile_c]
 #define target $[$[file]_obj]
 #define source $[file]
 #define ipath $[target_ipath]
-#define flags $[c++flags] $[CFLAGS_SHARED]
+#define flags $[c++flags] $[CFLAGS_SHARED] $[building_var:%=-D%]
 #if $[ne $[file], $[notdir $file]]
   // If the source file is not in the current directory, tack on "."
   // to front of the ipath.

+ 8 - 8
dtool/src/dtoolbase/atomicAdjustI386Impl.I

@@ -21,8 +21,8 @@
 INLINE void AtomicAdjustI386Impl::
 inc(TVOLATILE AtomicAdjustI386Impl::Integer &var) {
   assert((((size_t)&var) & (sizeof(Integer) - 1)) == 0);
-#ifdef _M_IX86
-  // Windows case
+#if defined(_M_IX86) && !defined(__GNUC__)
+  // MSVC Windows case
   TVOLATILE Integer *var_ptr = &var;
   __asm {
     mov edx, var_ptr;
@@ -47,8 +47,8 @@ INLINE bool AtomicAdjustI386Impl::
 dec(TVOLATILE AtomicAdjustI386Impl::Integer &var) {
   assert((((size_t)&var) & (sizeof(Integer) - 1)) == 0);
   unsigned char c;
-#ifdef _M_IX86
-  // Windows case
+#if defined(_M_IX86) && !defined(__GNUC__)
+  // MSVC Windows case
   TVOLATILE Integer *var_ptr = &var;
   __asm {
     mov edx, var_ptr;
@@ -164,8 +164,8 @@ compare_and_exchange(TVOLATILE AtomicAdjustI386Impl::Integer &mem,
                      AtomicAdjustI386Impl::Integer new_value) {
   assert((((size_t)&mem) & (sizeof(Integer) - 1)) == 0);
   Integer prev;
-#ifdef _M_IX86
-  // Windows case
+#if defined(_M_IX86) && !defined(__GNUC__)
+  // MSVC Windows case
   TVOLATILE Integer *mem_ptr = &mem;
   __asm {
     mov edx, mem_ptr;
@@ -197,8 +197,8 @@ compare_and_exchange_ptr(TVOLATILE AtomicAdjustI386Impl::Pointer &mem,
                          AtomicAdjustI386Impl::Pointer new_value) {
   assert((((size_t)&mem) & (sizeof(Pointer) - 1)) == 0);
   Pointer prev;
-#ifdef _M_IX86
-  // Windows case
+#if defined(_M_IX86) && !defined(__GNUC__)
+  // MSVC Windows case
   TVOLATILE Pointer *mem_ptr = &mem;
   __asm {
     mov edx, mem_ptr;

+ 7 - 7
dtool/src/dtoolbase/cmath.I

@@ -59,8 +59,8 @@ INLINE float ctan(float v) {
 ////////////////////////////////////////////////////////////////////
 INLINE void
 csincos(float v, float *sin_result, float *cos_result) {
-  // MS VC defines _M_IX86 for x86.  gcc should define _X86_
-#if defined(_M_IX86) || defined(_X86_)
+  // MS VC defines _M_IX86 for x86. GCC uses different ASM notation.
+#if defined(_M_IX86) && !defined(__GNUC__)
   //#define fsincos_opcode __asm _emit 0xd9 __asm _emit 0xfb
   __asm {
     mov eax, sin_result
@@ -70,10 +70,10 @@ csincos(float v, float *sin_result, float *cos_result) {
       fstp DWORD ptr [edx]
       fstp DWORD ptr [eax]
       }
-#else //!_X86_
+#else //__GNUC__
   *sin_result = sinf(v);
   *cos_result = cosf(v);
-#endif //!_X86_
+#endif //__GNUC__
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -242,7 +242,7 @@ ctan(double v) {
 ////////////////////////////////////////////////////////////////////
 INLINE void
 csincos(double v, double *sin_result, double *cos_result) {
-#if defined(_M_IX86) || defined(_X86_)
+#if defined(_M_IX86) && !defined(__GNUC__)
   //#define fsincos_opcode __asm _emit 0xd9 __asm _emit 0xfb
   __asm {
     mov eax, sin_result
@@ -252,10 +252,10 @@ csincos(double v, double *sin_result, double *cos_result) {
       fstp QWORD ptr [edx]
       fstp QWORD ptr [eax]
       }
-#else //!_X86_
+#else //__GNUC__
   *sin_result = sin(v);
   *cos_result = cos(v);
-#endif //!_X86_
+#endif //__GNUC__
 }
 
 ////////////////////////////////////////////////////////////////////

+ 1 - 1
dtool/src/dtoolutil/Sources.pp

@@ -4,7 +4,7 @@
   #if $[ne $[PLATFORM], FreeBSD]
     #define UNIX_SYS_LIBS dl
   #endif
-  #define WIN_SYS_LIBS shell32.lib
+  #define WIN_SYS_LIBS shell32
   #define OSX_SYS_FRAMEWORKS Foundation $[if $[not $[BUILD_IPHONE]],AppKit]
   
   #define COMBINED_SOURCES $[TARGET]_composite1.cxx  $[TARGET]_composite2.cxx

+ 6 - 6
dtool/src/dtoolutil/filename.cxx

@@ -1687,7 +1687,7 @@ get_access_timestamp() const {
 ////////////////////////////////////////////////////////////////////
 streamsize Filename::
 get_file_size() const {
-#ifdef WIN32_VC
+#if defined(WIN32_VC) && !defined(__GNUC__)
   wstring os_specific = get_filename_index(0).to_os_specific_w();
 
   struct _stat64 this_buf;
@@ -2075,7 +2075,7 @@ open_read(ifstream &stream) const {
 #endif
 
   stream.clear();
-#ifdef WIN32_VC
+#if defined(WIN32_VC) && !defined(__GNUC__)
   wstring os_specific = to_os_specific_w();
   stream.open(os_specific.c_str(), open_mode);
 #else
@@ -2131,7 +2131,7 @@ open_write(ofstream &stream, bool truncate) const {
 #endif
 
   stream.clear();
-#ifdef WIN32_VC
+#if defined(WIN32_VC) && !defined(__GNUC__)
   wstring os_specific = to_os_specific_w();
   stream.open(os_specific.c_str(), open_mode);
 #else
@@ -2173,7 +2173,7 @@ open_append(ofstream &stream) const {
 #endif
 
   stream.clear();
-#ifdef WIN32_VC
+#if defined(WIN32_VC) && !defined(__GNUC__)
   wstring os_specific = to_os_specific_w();
   stream.open(os_specific.c_str(), open_mode);
 #else
@@ -2225,7 +2225,7 @@ open_read_write(fstream &stream, bool truncate) const {
 #endif
 
   stream.clear();
-#ifdef WIN32_VC
+#if defined(WIN32_VC) && !defined(__GNUC__)
   wstring os_specific = to_os_specific_w();
   stream.open(os_specific.c_str(), open_mode);
 #else
@@ -2268,7 +2268,7 @@ open_read_append(fstream &stream) const {
 #endif
 
   stream.clear();
-#ifdef WIN32_VC
+#if defined(WIN32_VC) && !defined(__GNUC__)
   wstring os_specific = to_os_specific_w();
   stream.open(os_specific.c_str(), open_mode);
 #else

+ 1 - 1
dtool/src/dtoolutil/win32ArgParser.cxx

@@ -23,7 +23,7 @@
 #include "executionEnvironment.h"
 
 #include <windows.h>
-#include <Tlhelp32.h>
+#include <tlhelp32.h>
 
 ////////////////////////////////////////////////////////////////////
 //     Function: Win32ArgParser::Constructor

+ 2 - 3
panda/metalibs/pandadx9/Sources.pp

@@ -18,7 +18,6 @@
   #define TARGET pandadx9
   #define SOURCES pandadx9.cxx
   #define WIN_SYS_LIBS \
-     ddraw.lib dxguid.lib winmm.lib \
-     kernel32.lib gdi32.lib user32.lib advapi32.lib $[WIN_SYS_LIBS]  
+     ddraw dxguid winmm \
+     kernel32 gdi32 user32 advapi32 $[WIN_SYS_LIBS]
 #end metalib_target
-

+ 1 - 1
panda/metalibs/pandaexpress/Sources.pp

@@ -16,6 +16,6 @@
 
   #define SOURCES pandaexpress.cxx
   #define WIN_SYS_LIBS \
-     advapi32.lib ws2_32.lib $[WIN_SYS_LIBS]
+     advapi32 ws2_32 $[WIN_SYS_LIBS]
 
 #end metalib_target

+ 1 - 1
panda/metalibs/pandagl/Sources.pp

@@ -20,5 +20,5 @@
   #define TARGET pandagl
   #define SOURCES pandagl.cxx pandagl.h
   #define INSTALL_HEADERS pandagl.h
-  #define WIN_SYS_LIBS opengl32.lib winmm.lib kernel32.lib oldnames.lib user32.lib gdi32.lib
+  #define WIN_SYS_LIBS opengl32 winmm kernel32 user32 gdi32
 #end metalib_target

+ 3 - 3
panda/src/audiotraits/Sources.pp

@@ -9,7 +9,7 @@
   #define USE_PACKAGES rad_mss
   #define BUILDING_DLL BUILDING_MILES_AUDIO
   #define LOCAL_LIBS p3audio p3event p3pipeline
-  #define WIN_SYS_LIBS $[WIN_SYS_LIBS] user32.lib advapi32.lib winmm.lib
+  #define WIN_SYS_LIBS $[WIN_SYS_LIBS] user32 advapi32 winmm
 
   #define COMBINED_SOURCES $[TARGET]_composite1.cxx
 
@@ -35,7 +35,7 @@
   #define USE_PACKAGES fmodex
   #define BUILDING_DLL BUILDING_FMOD_AUDIO
   #define LOCAL_LIBS p3audio p3event
-  #define WIN_SYS_LIBS $[WIN_SYS_LIBS] user32.lib advapi32.lib winmm.lib
+  #define WIN_SYS_LIBS $[WIN_SYS_LIBS] user32 advapi32 winmm
 
   #define COMBINED_SOURCES fmod_audio_composite1.cxx
 
@@ -55,7 +55,7 @@
   #define USE_PACKAGES openal
   #define BUILDING_DLL BUILDING_OPENAL_AUDIO
   #define LOCAL_LIBS p3audio p3event
-  #define WIN_SYS_LIBS $[WIN_SYS_LIBS] user32.lib advapi32.lib winmm.lib
+  #define WIN_SYS_LIBS $[WIN_SYS_LIBS] user32 advapi32 winmm
 
   #define COMBINED_SOURCES openal_audio_composite1.cxx
 

+ 1 - 1
panda/src/display/Sources.pp

@@ -1,6 +1,6 @@
 #define OTHER_LIBS p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \
                    p3dtoolutil:c p3dtoolbase:c p3dtool:m p3prc:c
-#define WIN_SYS_LIBS $[WIN_SYS_LIBS] ws2_32.lib
+#define WIN_SYS_LIBS $[WIN_SYS_LIBS] ws2_32
                    
 #begin lib_target
   #define TARGET p3display

+ 1 - 1
panda/src/display/graphicsEngine.cxx

@@ -52,7 +52,7 @@
 
 #if defined(WIN32)
   #define WINDOWS_LEAN_AND_MEAN
-  #include <WinSock2.h>
+  #include <winsock2.h>
   #include <wtypes.h>
   #undef WINDOWS_LEAN_AND_MEAN
 #else

+ 2 - 2
panda/src/dxgsg9/dxGraphicsStateGuardian9.I

@@ -21,8 +21,8 @@
 ////////////////////////////////////////////////////////////////////
 INLINE DWORD DXGraphicsStateGuardian9::
 LColor_to_D3DCOLOR(const LColor &cLColor) {
-// MS VC defines _M_IX86 for x86.  gcc should define _X86_
-#if (defined(_M_IX86) || defined(_X86_)) && !defined(STDFLOAT_DOUBLE)
+// MS VC defines _M_IX86 for x86. GCC  should define _X86_. GCC (MinGW) uses different ASM notation.
+#if (defined(_M_IX86) || defined(_X86_)) && !defined(STDFLOAT_DOUBLE) && !defined(__GNUC__)
   DWORD d3dcolor, tempcolorval=255;
 
   // note the default FPU rounding mode will give 255*0.5f=0x80, not 0x7F as VC would force it to by resetting rounding mode

+ 3 - 1
panda/src/dxgsg9/wdxGraphicsWindow9.cxx

@@ -552,6 +552,8 @@ create_screen_buffers_and_device(DXScreenData &display, bool force_16bpp_zbuffer
   adapter = display._card_id;
   device_type = D3DDEVTYPE_HAL;
 
+  int supported_multisamples = 0;
+
   // NVIDIA NVPerfHUD
   if (dx_use_nvperfhud) {
     UINT adapter_id;
@@ -634,7 +636,7 @@ create_screen_buffers_and_device(DXScreenData &display, bool force_16bpp_zbuffer
 
   presentation_params->Windowed = !is_fullscreen();
 
-  int supported_multisamples = 0;
+  supported_multisamples = 0;
   if (framebuffer_multisample.get_value()){
     supported_multisamples = multisamples.get_value();
   }

+ 2 - 2
panda/src/express/Sources.pp

@@ -210,14 +210,14 @@
 
   #define IGATESCAN all
   #define WIN_SYS_LIBS \
-     advapi32.lib ws2_32.lib $[WIN_SYS_LIBS]
+     advapi32 ws2_32 $[WIN_SYS_LIBS]
 
   // These libraries and frameworks are used by dtoolutil; we redefine
   // them here so they get into the panda build system.
   #if $[ne $[PLATFORM], FreeBSD]
     #define UNIX_SYS_LIBS dl
   #endif
-  #define WIN_SYS_LIBS shell32.lib $[WIN_SYS_LIBS]
+  #define WIN_SYS_LIBS shell32 $[WIN_SYS_LIBS]
   #define OSX_SYS_FRAMEWORKS Foundation $[if $[not $[BUILD_IPHONE]],AppKit]
 
 #end lib_target

+ 1 - 1
panda/src/gobj/geom.h

@@ -251,7 +251,7 @@ public:
     CPT(GeomMunger) _modifier;
   };
   // It is not clear why MSVC7 needs this class to be public.
-  class CacheEntry : public GeomCacheEntry {
+  class EXPCL_PANDA_GOBJ CacheEntry : public GeomCacheEntry {
   public:
     INLINE CacheEntry(Geom *source, 
                       const GeomVertexData *source_data,

+ 1 - 1
panda/src/movies/Sources.pp

@@ -7,7 +7,7 @@
   #define LOCAL_LIBS p3gobj
 
   #define USE_PACKAGES dx9 vorbis
-  #define WIN_SYS_LIBS $[WIN_SYS_LIBS] strmiids.lib winmm.lib
+  #define WIN_SYS_LIBS $[WIN_SYS_LIBS] strmiids winmm
 
   #define COMBINED_SOURCES \
     $[TARGET]_composite1.cxx

+ 2 - 2
panda/src/nativenet/socket_portable.h

@@ -45,7 +45,7 @@ typedef unsigned long SOCKET;
 ************************************************************************/
 #elif defined(WIN32) || defined(WIN32_VC) || defined(WIN64_VC)
 #include <winsock2.h>
-#include <Ws2tcpip.h>
+#include <ws2tcpip.h>
 
 
 inline int DO_SELECT(SOCKET n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,struct timeval *timeout)
@@ -116,7 +116,7 @@ inline int init_network()
     int answer = WSAStartup(0x0101, &mydata);
     if (answer != 0)
         return BASIC_ERROR;
-    
+
     return ALL_OK;
 }
 

+ 1 - 1
panda/src/net/Sources.pp

@@ -1,7 +1,7 @@
 #define OTHER_LIBS \
    p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \
    p3dtoolutil:c p3dtoolbase:c p3prc:c p3dtool:m
-#define WIN_SYS_LIBS Iphlpapi.lib
+#define WIN_SYS_LIBS iphlpapi
 
 #define BUILD_DIRECTORY $[and $[HAVE_NET],$[WANT_NATIVE_NET]]
 #define USE_PACKAGES net

+ 1 - 1
panda/src/net/connectionManager.cxx

@@ -25,7 +25,7 @@
 
 #if defined(WIN32_VC) || defined(WIN64_VC)
 #include <winsock2.h>  // For gethostname()
-#include <Iphlpapi.h> // For GetAdaptersAddresses()
+#include <iphlpapi.h> // For GetAdaptersAddresses()
 #elif defined(ANDROID)
 #include <net/if.h>
 #else

+ 1 - 1
panda/src/pstatclient/pStatClientImpl.cxx

@@ -29,7 +29,7 @@
 #include <algorithm>
 
 #if defined(WIN32_VC) || defined(WIN64_VC)
-#include <Winsock2.h>
+#include <winsock2.h>
 #include <windows.h>
 #endif
 

+ 1 - 1
panda/src/putil/factoryBase.h

@@ -88,7 +88,7 @@ private:
 private:
   // internal mechanics and bookkeeping
 
-#if (defined(WIN32_VC) || defined(WIN64_VC)) && !defined(__ICL)    //__ICL is Intel C++
+#if (defined(WIN32_VC) || defined(WIN64_VC)) && !defined(__ICL) && !defined(__GNUC__)    //__ICL is Intel C++, __GNUC__ for MinGW
   // Visual C++ seems to have a problem with building a map based on
   // BaseCreateFunc.  We'll have to typecast it on the way out.
   typedef pmap<TypeHandle, void *> Creators;

+ 2 - 2
panda/src/windisplay/Sources.pp

@@ -2,7 +2,7 @@
 
 #define OTHER_LIBS p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \
                    p3dtoolutil:c p3dtoolbase:c p3dtool:m
-#define WIN_SYS_LIBS Imm32.lib
+#define WIN_SYS_LIBS imm32
 
 #define BUILDING_DLL BUILDING_PANDAWIN
 
@@ -32,6 +32,6 @@
      winGraphicsWindow.cxx \
      winDetectDx9.cxx
 
-  #define WIN_SYS_LIBS Imm32.lib winmm.lib kernel32.lib oldnames.lib user32.lib gdi32.lib
+  #define WIN_SYS_LIBS imm32 winmm kernel32 user32 gdi32
 
 #end lib_target

+ 17 - 3
panda/src/windisplay/winGraphicsPipe.cxx

@@ -126,6 +126,7 @@ typedef union
 LONG_INTEGER;
 
 PN_uint64 cpu_time_function (void) {
+#ifndef __GNUC__  // for MinGW, MSVC only
 #ifdef _WIN64
   return __rdtsc();
 #else
@@ -144,6 +145,7 @@ PN_uint64 cpu_time_function (void) {
 
   return long_integer.long_integer;
 #endif
+#endif  // !__GNUC__
 }
 
 typedef union
@@ -166,6 +168,7 @@ typedef union
 }
 CPU_ID_REGISTERS;
 
+#ifndef __GNUC__  // for MinGW, MSVC only
 typedef struct
 {
   union
@@ -431,6 +434,7 @@ typedef struct
   unsigned int log_base_2_cache_line_size;
 }
 CPU_ID;
+#endif  // !__GNUC__
 
 typedef struct
 {
@@ -459,8 +463,8 @@ typedef struct
 }
 CPU_ID_BINARY_DATA_ARRAY;
 
+#ifndef __GNUC__  // for MinGW, MSVC only
 void cpu_id_to_cpu_id_binary_data (CPU_ID *cpu_id, CPU_ID_BINARY_DATA *cpu_id_binary_data) {
-
   cpu_id_binary_data -> cpu_id_registers_0 = cpu_id -> cpu_id_registers_0;
   cpu_id_binary_data -> cpu_id_registers_1 = cpu_id -> cpu_id_registers_1;
   cpu_id_binary_data -> cpu_id_registers_0x80000000 = cpu_id -> cpu_id_registers_0x80000000;
@@ -471,9 +475,10 @@ void cpu_id_to_cpu_id_binary_data (CPU_ID *cpu_id, CPU_ID_BINARY_DATA *cpu_id_bi
   cpu_id_binary_data -> cpu_id_registers_0x80000006 = cpu_id -> cpu_id_registers_0x80000006;
   cpu_id_binary_data -> cpu_id_registers_0x80000008 = cpu_id -> cpu_id_registers_0x80000008;
 }
+#endif  // !__GNUC__
 
+#ifndef __GNUC__  // for MinGW, MSVC only
 void cpu_id_binary_data_to_cpu_id (CPU_ID_BINARY_DATA *cpu_id_binary_data, CPU_ID *cpu_id) {
-
   memset (cpu_id, 0, sizeof (CPU_ID));
 
   cpu_id -> cpu_id_registers_0 = cpu_id_binary_data -> cpu_id_registers_0;
@@ -486,11 +491,13 @@ void cpu_id_binary_data_to_cpu_id (CPU_ID_BINARY_DATA *cpu_id_binary_data, CPU_I
   cpu_id -> cpu_id_registers_0x80000006 = cpu_id_binary_data -> cpu_id_registers_0x80000006;
   cpu_id -> cpu_id_registers_0x80000008 = cpu_id_binary_data -> cpu_id_registers_0x80000008;
 }
+#endif  // !__GNUC__
 
 int cpuid (int input_eax, CPU_ID_REGISTERS *cpu_id_registers) {
   int state;
 
-  state = false;   
+  state = false;
+#ifndef __GNUC__  // for MinGW, MSVC only
   __try
   {
     if (input_eax == 0) {
@@ -540,10 +547,12 @@ int cpuid (int input_eax, CPU_ID_REGISTERS *cpu_id_registers) {
   {
     state = false;
   }
+#endif  // !__GNUC__
 
   return state;
 }
 
+#ifndef __GNUC__  // for MinGW, MSVC only
 void parse_cpu_id (CPU_ID *cpu_id) {
 
   printf ("CPUID\n");
@@ -593,7 +602,9 @@ void parse_cpu_id (CPU_ID *cpu_id) {
     printf ("  l2_cache_size %dK \n", cpu_id -> l2_cache_size);       
   }
 }
+#endif // !__GNUC__
 
+#ifndef __GNUC__  // for MinGW, MSVC only
 int initialize_cpu_id (CPU_ID *cpu_id) {
 
   int state;
@@ -674,6 +685,7 @@ int initialize_cpu_id (CPU_ID *cpu_id) {
   
   return state;
 }
+#endif  // !_GNUC__
 
 int update_cpu_frequency_function (int processor_number, DisplayInformation *display_information)
 {
@@ -932,6 +944,7 @@ lookup_cpu_data() {
   windisplay_cat.info() << string;
 
 
+#ifndef __GNUC__  // for MinGW, MSVC only
   // CPUID
   CPU_ID cpu_id;
 
@@ -979,6 +992,7 @@ lookup_cpu_data() {
   }
 
   windisplay_cat.info() << "end CPU ID\n";
+#endif  // !__GNUC__
 
   // Number of CPU's
   count_number_of_cpus(_display_information);

+ 1 - 1
panda/src/windisplay/winGraphicsWindow.h

@@ -247,7 +247,7 @@ private:
   // represent this particular window.  We use it to add hooks for
   // communicating with the parent window, in particular to receive
   // keyboard events from the parent window when necessary.
-  class WinWindowHandle : public WindowHandle {
+  class EXPCL_PANDAWIN WinWindowHandle : public WindowHandle {
   public:
     WinWindowHandle(WinGraphicsWindow *window,
                     const WindowHandle &copy);

+ 1 - 1
pandatool/src/dxfprogs/Sources.pp

@@ -24,7 +24,7 @@
 
 #begin bin_target
   #define TARGET dxf2egg
-  #define LOCAL_LIBS p3dxf p3dxfegg p3eggbase p3progbase
+  #define LOCAL_LIBS p3dxfegg p3dxf p3eggbase p3progbase
 
   #define SOURCES \
     dxfToEgg.cxx dxfToEgg.h

+ 1 - 1
pandatool/src/mayaprogs/Sources.pp

@@ -1,6 +1,6 @@
 #define BUILD_DIRECTORY $[HAVE_MAYA]
 
-#define WIN_SYS_LIBS shell32.lib advapi32.lib ws2_32.lib
+#define WIN_SYS_LIBS shell32 advapi32 ws2_32
 
 #begin bin_target
   #define TARGET maya2egg

+ 1 - 1
pandatool/src/vrmlprogs/Sources.pp

@@ -11,7 +11,7 @@
 
 #begin bin_target
   #define TARGET vrml2egg
-  #define LOCAL_LIBS p3vrml p3vrmlegg p3eggbase p3progbase
+  #define LOCAL_LIBS p3vrmlegg p3vrml p3eggbase p3progbase
 
   #define SOURCES \
     vrmlToEgg.cxx vrmlToEgg.h

+ 1 - 1
pandatool/src/win-stats/Sources.pp

@@ -27,7 +27,7 @@
   #endif
   #define EXTRA_CDEFS $[EXTRA_CDEFS] WIN32_LEAN_AND_MEAN
 
-  #define WIN_SYS_LIBS Imm32.lib winmm.lib kernel32.lib oldnames.lib user32.lib gdi32.lib
+  #define WIN_SYS_LIBS imm32 winmm kernel32 user32 gdi32
 
 #end bin_target