Skip to content
Browse files

[mr2025] some code corrections for possibility utils compile in in MI…

…NGW32/MINGW64 environment. add bash script for automation compile (required in MINGW32/MINGW64 installed and also some libs compiled under this environment).
  • Loading branch information...
1 parent 001d1df commit 4fbd9ef4a8b3a39a38cabbd60d54e88bd58acdfa @rsa rsa committed Jun 13, 2012
View
19 cmake/mingw32-i686.cmake
@@ -0,0 +1,19 @@
+# the name of the target operating system
+SET(CMAKE_SYSTEM_NAME Windows)
+SET(CMAKE_SYSTEM_PROCESSOR i686)
+SET(COMPILER_PREFIX ${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32)
+
+# which compilers to use for C and C++ and ASM-ATT
+find_program(CMAKE_RC_COMPILER NAMES ${COMPILER_PREFIX}-windres)
+find_program(CMAKE_C_COMPILER NAMES ${COMPILER_PREFIX}-gcc)
+find_program(CMAKE_CXX_COMPILER NAMES ${COMPILER_PREFIX}-g++)
+find_program(CMAKE_CXX_COMPILER NAMES ${COMPILER_PREFIX}-as)
+
+SET(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX} ${USER_ROOT_PATH})
+
+# adjust the default behaviour of the FIND_XXX() commands:
+# search headers and libraries in the target environment, search
+# programs in the host environment
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
View
19 cmake/mingw32-x86_64.cmake
@@ -0,0 +1,19 @@
+# the name of the target operating system
+SET(CMAKE_SYSTEM_NAME Windows)
+SET(CMAKE_SYSTEM_PROCESSOR x86_64)
+SET(COMPILER_PREFIX ${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32)
+
+# which compilers to use for C and C++
+find_program(CMAKE_RC_COMPILER NAMES ${COMPILER_PREFIX}-windres)
+find_program(CMAKE_C_COMPILER NAMES ${COMPILER_PREFIX}-gcc)
+find_program(CMAKE_CXX_COMPILER NAMES ${COMPILER_PREFIX}-g++)
+find_program(CMAKE_CXX_COMPILER NAMES ${COMPILER_PREFIX}-as)
+
+SET(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX} ${USER_ROOT_PATH})
+
+# adjust the default behaviour of the FIND_XXX() commands:
+# search headers and libraries in the target environment, search
+# programs in the host environment
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
View
16 contrib/extractor/System.cpp
@@ -18,13 +18,15 @@
#include "loadlib/wdt.h"
#include <fcntl.h>
-#if defined( __GNUC__ )
- #define _open open
- #define _close close
+#if defined( __GNUC__ ) && !defined(WIN32)
+ #define _open fopen
+ #define _close fclose
#ifndef O_BINARY
#define O_BINARY 0
#endif
+ #define _FILE FILE*
#else
+ #define _FILE int
#include <io.h>
#endif
@@ -98,8 +100,12 @@ void CreateDir( const std::string& Path )
bool FileExists( const char* FileName )
{
- int fp = _open(FileName, OPEN_FLAGS);
- if(fp != -1)
+ _FILE fp = _open(FileName, OPEN_FLAGS);
+#if !defined(WIN32)
+ if (fp)
+#else
+ if (fp != -1)
+#endif
{
_close(fp);
return true;
View
8 contrib/extractor/libmpq/huffman.h
@@ -27,9 +27,9 @@
#ifndef _HUFFMAN_H
#define _HUFFMAN_H
-#define PTR_NOT(ptr) (struct huffman_tree_item *)(~(unsigned long)(ptr))
+#define PTR_NOT(ptr) (struct huffman_tree_item *)(~(size_t)(ptr))
#define PTR_PTR(ptr) ((struct huffman_tree_item *)(ptr))
-#define PTR_INT(ptr) (long)(ptr)
+#define PTR_INT(ptr) (size_t)(ptr)
#define INSERT_ITEM 1
#define SWITCH_ITEMS 2 /* Switch the item1 and item2 */
@@ -49,8 +49,8 @@ struct huffman_input_stream {
struct huffman_tree_item {
struct huffman_tree_item *next; /* 00 - Pointer to next huffman_tree_item */
struct huffman_tree_item *prev; /* 04 - Pointer to prev huffman_tree_item (< 0 if none) */
- unsigned long dcmp_byte; /* 08 - Index of this item in item pointer array, decompressed byte value */
- unsigned long byte_value; /* 0C - Some byte value */
+ size_t dcmp_byte; /* 08 - Index of this item in item pointer array, decompressed byte value */
+ size_t byte_value; /* 0C - Some byte value */
struct huffman_tree_item *parent; /* 10 - Pointer to parent huffman_tree_item (NULL if none) */
struct huffman_tree_item *child; /* 14 - Pointer to child huffman_tree_item */
};
View
10 contrib/extractor/loadlib/loadlib.h
@@ -1,7 +1,7 @@
#ifndef LOAD_LIB_H
#define LOAD_LIB_H
-#ifdef WIN32
+#if defined (WIN32) && !defined (__MINGW32__)
typedef __int64 int64;
typedef __int32 int32;
typedef __int16 int16;
@@ -12,10 +12,10 @@ typedef unsigned __int16 uint16;
typedef unsigned __int8 uint8;
#else
#include <stdint.h>
-#ifndef uint64_t
-#ifdef __linux__
-#include <linux/types.h>
-#endif
+#if defined (__MINGW32__)
+ #include <sys/types.h>
+#elif defined(__linux__)
+ #include <linux/types.h>
#endif
typedef int64_t int64;
typedef int32_t int32;
View
2 contrib/mmap/CMakeLists.txt
@@ -27,8 +27,6 @@ include_directories(
../../src/game/vmap
../../dep/include/g3dlite
../../src/framework
- ../../dep/ACE_wrappers
- ../../objdir/dep/ACE_wrappers
../../dep/recastnavigation/Detour/Include
../../dep/recastnavigation/Recast/Include
../../dep/src/zlib
View
2 contrib/vmap_extractor_v3/CMakeLists.txt
@@ -20,6 +20,4 @@ ADD_DEFINITIONS("-Wall")
ADD_DEFINITIONS("-ggdb")
ADD_DEFINITIONS("-O3")
-include_directories(../../dep/libmpq)
-
add_subdirectory(vmapextract)
View
5 contrib/vmap_extractor_v3/vmapextract/CMakeLists.txt
@@ -11,6 +11,5 @@
cmake_minimum_required (VERSION 2.6)
project (MANGOS_IOMAP_EXTRACTOR)
-LINK_DIRECTORIES( ${LINK_DIRECTORIES} ../../../dep/libmpq/libmpq/.libs/ )
-add_executable(vmapextractor adtfile.cpp dbcfile.cpp model.cpp mpq_libmpq.cpp vmapexport.cpp wdtfile.cpp wmo.cpp)
-target_link_libraries(vmapextractor libmpq.a bz2 z)
+add_executable(vmapExtractor3 adtfile.cpp dbcfile.cpp model.cpp mpq_libmpq.cpp vmapexport.cpp wdtfile.cpp wmo.cpp gameobject_extract.cpp)
+target_link_libraries(vmapExtractor3 libmpq.a bz2 z)
View
10 contrib/vmap_extractor_v3/vmapextract/loadlib/loadlib.h
@@ -19,7 +19,7 @@
#ifndef LOAD_LIB_H
#define LOAD_LIB_H
-#ifdef WIN32
+#if defined (WIN32) && !defined (__MINGW32__)
typedef __int64 int64;
typedef __int32 int32;
typedef __int16 int16;
@@ -30,10 +30,10 @@ typedef unsigned __int16 uint16;
typedef unsigned __int8 uint8;
#else
#include <stdint.h>
-#ifndef uint64_t
-#ifdef __linux__
-#include <linux/types.h>
-#endif
+#if defined (__MINGW32__)
+ #include <sys/types.h>
+#elif defined(__linux__)
+ #include <linux/types.h>
#endif
typedef int64_t int64;
typedef int32_t int32;
View
15 contrib/vmap_extractor_v3/vmapextract/vmapexport.cpp
@@ -23,11 +23,16 @@
#include <list>
#include <errno.h>
-#ifdef WIN32
- #include <Windows.h>
- #include <sys/stat.h>
- #include <direct.h>
- #define mkdir _mkdir
+#if defined (WIN32)
+ #if defined (__MINGW32__)
+ #include <windows.h>
+ #include <sys/stat.h>
+ #else
+ #include <Windows.h>
+ #include <sys/stat.h>
+ #include <direct.h>
+ #define mkdir _mkdir
+ #endif
#else
#include <sys/stat.h>
#endif
View
12 dep/include/g3dlite/G3D/platform.h
@@ -37,13 +37,13 @@
# define G3D_DEBUG
#endif
-#ifndef _MSC_VER
+#if !defined (_MSC_VER) && !defined(__MINGW32__)
/// Fast call is a register-based optimized calling convention supported only by Visual C++
#define __fastcall
#endif
-#ifdef _MSC_VER
+#if defined (_MSC_VER) || defined(__MINGW32__)
#define G3D_WIN32
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
#define G3D_FREEBSD
@@ -225,12 +225,16 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) {\
return G3D_WinMain(hInst, hPrev, szCmdLine, sw);\
}
-#else
+//#else
/** @def G3D_START_AT_MAIN()
Defines necessary wrapper around WinMain on Windows to allow transfer of execution to main(). */
-# define G3D_START_AT_MAIN()
+// # define G3D_START_AT_MAIN()
+#elif defined(__MINGW32__)
+# include <windows.h>
+# undef WIN32_LEAN_AND_MEAN
+# undef NOMINMAX
#endif // win32
#ifdef __GNUC__
View
6 dep/recastnavigation/Detour/Include/DetourNavMesh.h
@@ -21,7 +21,11 @@
#include "DetourAlloc.h"
-#ifdef WIN32
+#if defined (_MSC_VER)
+ typedef unsigned __int64 uint64;
+#elif defined(__MINGW32__)
+# include <stdint.h>
+# include <sys/types.h>
typedef unsigned __int64 uint64;
#else
#include <stdint.h>
View
2 dep/src/g3dlite/Any.cpp
@@ -1066,7 +1066,7 @@ void Any::deserializeBody(TextInput& ti, Token& token) {
}
// Pointer the value being read
- Any a = NULL;
+ Any a = Any(int(NULL));
std::string key;
if (m_type == TABLE) {
View
15 dep/src/g3dlite/System.cpp
@@ -196,9 +196,12 @@ void System::init() {
// Get the operating system name (also happens to read some other information)
# ifdef G3D_WIN32
// Note that this overrides some of the values computed above
- bool success = RegistryUtil::readInt32
+ bool success = true;
+ #ifndef __MINGW32__
+ success = RegistryUtil::readInt32
("HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0",
"~MHz", m_cpuSpeed);
+ #endif
SYSTEM_INFO systemInfo;
GetSystemInfo(&systemInfo);
@@ -225,7 +228,7 @@ void System::init() {
}
m_numCores = systemInfo.dwNumberOfProcessors;
- uint32 maxAddr = (uint32)systemInfo.lpMaximumApplicationAddress;
+ uint64 maxAddr = (uint64)systemInfo.lpMaximumApplicationAddress;
{
char c[1024];
sprintf(c, "%d x %d-bit %s processor",
@@ -560,7 +563,7 @@ void System::getStandardProcessorExtensions() {
#endif
}
-#if defined(G3D_WIN32) && !defined(G3D_64BIT)
+#if defined(G3D_WIN32) && !defined(G3D_64BIT) && !defined(__MINGW32__)
#pragma message("Port System::memcpy SIMD to all platforms")
/** Michael Herf's fast memcpy */
void memcpyMMX(void* dst, const void* src, int nbytes) {
@@ -611,7 +614,7 @@ void memcpyMMX(void* dst, const void* src, int nbytes) {
#endif
void System::memcpy(void* dst, const void* src, size_t numBytes) {
-#if defined(G3D_WIN32) && !defined(G3D_64BIT)
+#if defined(G3D_WIN32) && !defined(G3D_64BIT) && !defined(__MINGW32__)
memcpyMMX(dst, src, numBytes);
#else
::memcpy(dst, src, numBytes);
@@ -621,7 +624,7 @@ void System::memcpy(void* dst, const void* src, size_t numBytes) {
/** Michael Herf's fastest memset. n32 must be filled with the same
character repeated. */
-#if defined(G3D_WIN32) && !defined(G3D_64BIT)
+#if defined(G3D_WIN32) && !defined(G3D_64BIT) && !defined(__MINGW32__)
#pragma message("Port System::memfill SIMD to all platforms")
// On x86 processors, use MMX
@@ -660,7 +663,7 @@ void memfill(void *dst, int n32, unsigned long i) {
void System::memset(void* dst, uint8 value, size_t numBytes) {
-#if defined(G3D_WIN32) && !defined(G3D_64BIT)
+#if defined(G3D_WIN32) && !defined(G3D_64BIT) && !defined(__MINGW32__)
uint32 v = value;
v = v + (v << 8) + (v << 16) + (v << 24);
G3D::memfill(dst, v, numBytes);
View
157 project_utils_cross-complile.sh
@@ -0,0 +1,157 @@
+#!/bin/bash
+################################################################################################
+# bash script for compilation mangosR2 utility in MINGW32/MINGW64 environment. by /dev/rsa
+################################################################################################
+#check path of running
+if [ ! -d ./.git ]; then
+ echo $"Please, run this script in mangos root folder!"
+ exit 2
+fi;
+
+case "$1" in
+ win32|32)
+ PLATFORM=i686
+ ;;
+ win64|64)
+ PLATFORM=x86_64
+ ;;
+ plain|none)
+ PLATFORM=build
+ ;;
+ *)
+ echo $"Usage: $0 {win32|win64|plain}"
+ exit 2
+esac
+################################################################################################
+#make binary storage
+BINARY_PATH=bin
+if [ ! -d ./$BINARY_PATH ]; then
+ mkdir $BINARY_PATH
+fi;
+
+if [ ! -d ./$BINARY_PATH/$PLATFORM ]; then
+ mkdir $BINARY_PATH/$PLATFORM
+fi;
+################################################################################################
+# Make extractor
+cd contrib/extractor
+make clean
+if [ ! -d ./$PLATFORM ]; then
+ mkdir $PLATFORM
+fi;
+cd $PLATFORM
+if [ "$PLATFORM" != "build" ]; then
+ cmake -DCMAKE_TOOLCHAIN_FILE=../../../cmake/mingw32-$PLATFORM.cmake ..
+else
+ cmake ..
+fi
+
+make
+
+if [ "$PLATFORM" != "build" ]; then
+ cp ./ad.exe ../../../$BINARY_PATH/$PLATFORM/
+ cp /usr/$PLATFORM-w64-mingw32/sys-root/mingw/bin/zlib1.dll ../../../$BINARY_PATH/$PLATFORM/
+ cp /usr/$PLATFORM-w64-mingw32/sys-root/mingw/bin/libgcc_s_sjlj-1.dll ../../../$BINARY_PATH/$PLATFORM/
+ cp /usr/$PLATFORM-w64-mingw32/sys-root/mingw/bin/libstdc++-6.dll ../../../$BINARY_PATH/$PLATFORM/
+else
+ cp ./ad ../../../$BINARY_PATH/$PLATFORM
+fi
+cd ../../..
+################################################################################################
+# Make libmpq
+cd dep/libmpq
+make clean
+. ./autogen.sh
+if [ "$PLATFORM" != "build" ]; then
+ if [ "$PLATFORM" == "i686" ]; then
+ mingw32-configure --host=$PLATFORM-w64-mingw32
+ else
+ mingw64-configure --host=$PLATFORM-w64-mingw32
+ fi
+else
+ ./configure
+fi
+make
+make install
+cd ../..
+################################################################################################
+# Make extractor
+cd contrib/vmap_extractor_v3
+make clean
+if [ ! -d ./$PLATFORM ]; then
+ mkdir $PLATFORM
+fi;
+cd $PLATFORM
+
+if [ "$PLATFORM" != "build" ]; then
+ cmake -DCMAKE_TOOLCHAIN_FILE=../../../cmake/mingw32-$PLATFORM.cmake ..
+else
+ cmake ..
+fi
+
+make
+
+if [ "$PLATFORM" != "build" ]; then
+ cp ./vmapextract/vmapExtractor3.exe ../../../$BINARY_PATH/$PLATFORM/
+ cp /usr/$PLATFORM-w64-mingw32/sys-root/mingw/bin/libbz2-1.dll ../../../$BINARY_PATH/$PLATFORM/
+else
+ cp ./vmapextract/vmapExtractor3 ../../../$BINARY_PATH/$PLATFORM/
+fi
+cd ../../..
+################################################################################################
+# Make external ACE (need run only after ACE version on build server change)
+#if [ "$PLATFORM" != "build" ]; then
+# build_prefix="/usr/local/src"
+# ACE_ROOT=$build_prefix/ACE_wrappers; export ACE_ROOT
+# MINGW_BASE=/usr/$PLATFORM-w64-mingw32; export MINGW_BASE
+# export PATH=$MINGW_BASE/bin:$PATH
+# CROSS_COMPILE=$PLATFORM-; export CROSS_COMPILE
+#fi
+#cd $ACE_ROOT
+#echo '#include "ace/config-win32.h"' > $ACE_ROOT/ace/config.h
+#echo 'include $(ACE_ROOT)/include/makeinclude/platform_mingw32.GNU' > $ACE_ROOT/include/makeinclude/platform_macros.GNU
+#mingw32-make ACE TP_Reactor
+#mingw32-make install ACE TP_Reactor
+################################################################################################
+# Make vmap assembler
+cd contrib/vmap_assembler
+if [ ! -d ./$PLATFORM ]; then
+ mkdir $PLATFORM
+fi;
+cd $PLATFORM
+if [ "$PLATFORM" != "build" ]; then
+ cmake -DCMAKE_TOOLCHAIN_FILE=../../../cmake/mingw32-$PLATFORM.cmake ..
+else
+ cmake ..
+fi
+
+make
+
+if [ "$PLATFORM" != "build" ]; then
+ cp ./vmap_assembler.exe ../../../$BINARY_PATH/$PLATFORM/
+ cp /usr/$PLATFORM-w64-mingw32/sys-root/mingw/lib/libACE.dll ../../../$BINARY_PATH/$PLATFORM/
+else
+ cp ./vmap_assembler ../../../$BINARY_PATH/$PLATFORM/
+fi
+cd ../../..
+################################################################################################
+# Make mmap extractor
+cd contrib/mmap
+if [ ! -d ./$PLATFORM ]; then
+ mkdir $PLATFORM
+fi;
+cd $PLATFORM
+if [ "$PLATFORM" != "build" ]; then
+ cmake -DCMAKE_TOOLCHAIN_FILE=../../../cmake/mingw32-$PLATFORM.cmake ..
+else
+ cmake ..
+fi
+
+make
+
+if [ "$PLATFORM" != "build" ]; then
+ cp ./MoveMapGen.exe ../../../$BINARY_PATH/$PLATFORM/
+else
+ cp ./MoveMapGen ../../../$BINARY_PATH/$PLATFORM/
+fi
+################################################################################################
View
2 src/framework/Platform/Define.h
@@ -114,7 +114,7 @@ typedef ACE_UINT32 uint32;
typedef ACE_UINT16 uint16;
typedef ACE_UINT8 uint8;
-#if COMPILER != COMPILER_MICROSOFT
+#if COMPILER != COMPILER_MICROSOFT && !defined(__MINGW32__)
typedef uint16 WORD;
typedef uint32 DWORD;
#endif //COMPILER
View
2 src/game/MoveMapSharedDefines.h
@@ -20,7 +20,7 @@
#define _MOVE_MAP_SHARED_DEFINES_H
#include "Platform/Define.h"
-#include "../recastnavigation/Detour/Include/DetourNavMesh.h"
+#include "../../dep/recastnavigation/Detour/Include/DetourNavMesh.h"
#define MMAP_MAGIC 0x4d4d4150 // 'MMAP'
#define MMAP_VERSION 3

0 comments on commit 4fbd9ef

Please sign in to comment.
Something went wrong with that request. Please try again.